Thread: how to access structures of...

  1. #1
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214

    how to access structures of...

    structures, is my question.

    well i wanted to print out eveything that an icmp packet holds, like checksum, mtu and the id for example.

    i included </linux/icmp.h>

    Code:
    struct icmphdr *icmp;
    
    ...
    ...
    
    printf("checksum is: %d\n", icmp->checksum);
    that works fine.
    but in the /linux/icmp.h header file there is more than one structure like:
    Code:
    struct icmphdr {
      __u8 checksum;
    
       union {
            struct {
              __u16 id;
              } echo;
                  } frag;
    how would i print out the id of the icmp packet now?
    the id code is included in the union frag and the struct echo as seen above.


    thank you

  2. #2
    template<typename T> threahdead's Avatar
    Join Date
    Sep 2002
    Posts
    214
    didnt thought it would be that easy.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. accessing an array of structures
    By creative in forum C Programming
    Replies: 4
    Last Post: 12-27-2007, 12:52 PM
  2. Structures within Structures
    By Misko82 in forum C Programming
    Replies: 2
    Last Post: 08-27-2007, 12:25 AM
  3. Using pointers to access variables in structures
    By Desolation in forum C++ Programming
    Replies: 5
    Last Post: 07-27-2006, 12:10 PM
  4. Random access files and structures
    By DLR in forum C Programming
    Replies: 8
    Last Post: 04-21-2006, 03:24 PM
  5. Methods for Sorting Structures by Element...
    By Sebastiani in forum C Programming
    Replies: 9
    Last Post: 09-14-2001, 12:59 PM