Appendix E. Programming Structures for Data Formats

The following syntax descriptions provide sample C or C++ data structures that represent various protocol message formats. To implement Internet Protocol (IP), you can use the following data structure:

struct ipdtgrm 
    { 
    unsigned char ipver; 
    unsigned char tos; 
    short iplen; 
    short id; 
    short fragofst; 
    unsigned char ttl; 
    unsigned char protoc; 
    short checksm; 
    char *srcaddrs; 
    char *destaddrs; 
    unsigned char data; 
    }; 

The Internet Control Message Protocol messages can be represented as data structures, displayed in the following syntax:

struct icmpmsg 
    { 
    char type; 
    char code; 
    short checksum; 
    short msgid; 
    short sqncenum; 
    char *gtwaddr; 
    char *param; 
    char *padlen; 
    int rsv=0; 
    char *data; 
    }; 

The following ...

Get Special Edition Using TCP/IP, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.