IP Data Structures

Source: Internet
Author: User

This digest is from Linux kernel ip.h, thanks to the open source GNU

struct IP
  {
#if __byte_order = = __little_endian
    unsigned int ip_hl:4;/* header length */
    unsigned int ip_v:4;/* version */
#endif
#if __byte_order = = __big_endian
    unsigned int ip_v:4;/* version */
    unsigned int ip_hl:4;/* header length */
#endif
    u_int8_t ip_tos;/* Type of service */
    U_short ip_len;/* Total length */
    U_short ip_id;/* Identification * *
    U_short ip_off;/* Fragment Offset field */
#defineIP_RF 0x8000/* Reserved Fragment flag * *
#defineIP_DF 0x4000/* dont fragment flag * *
#defineIP_MF 0x2000/* MORE Fragments flag * *
#defineIP_OFFMASK 0x1fff/* mask for fragmenting bits */
    u_int8_t ip_ttl;/* Time to live */
    u_int8_t ip_p;/* Protocol * *
    U_short ip_sum;/* Checksum * *
    struct in_addr ip_src, ip_dst;/* source and dest address */
  };
struct TIMESTAMP
  {
    u_int8_t Len;
    u_int8_t ptr;
#if __byte_order = = __little_endian
    unsigned int flags:4;
    unsigned int overflow:4;
#elif __byte_order = = __big_endian
    unsigned int overflow:4;
    unsigned int flags:4;
#else
# error "Please fix <bits/endian.h>"
#endif
    u_int32_t Data[9];
  };
struct IPHDR
  {
#if __byte_order = = __little_endian
    unsigned int ihl:4;
    unsigned int version:4;
#elif __byte_order = = __big_endian
    unsigned int version:4;
    unsigned int ihl:4;
#else
# error "Please fix <bits/endian.h>"
#endif
    u_int8_t tos;
    u_int16_t Tot_len;
    u_int16_t ID;
    u_int16_t Frag_off;
    u_int8_t TTL;
    u_int8_t Protocol;
    u_int16_t check;
    u_int32_t saddr;
    u_int32_t daddr;
    /*the options start here. */
  };
/*
* Time stamp option structure.
*/
struct IP_TIMESTAMP
  {
    u_int8_t ipt_code;/* ipopt_ts * *
    u_int8_t ipt_len;/* size of structure (variable) */
    u_int8_t ipt_ptr;/* Index of current entry */
#if __byte_order = = __little_endian
    unsigned int ipt_flg:4;/* flags, see below */
    unsigned int ipt_oflw:4;/* overflow counter */
#endif
#if __byte_order = = __big_endian
    unsigned int ipt_oflw:4;/* overflow counter */
    unsigned int ipt_flg:4;/* flags, see below */
#endif
    u_int32_t Data[9];
  };

IP Data Structures

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.