home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / header45.zip / stack16 / netinet / ip.h < prev    next >
Text File  |  1999-05-11  |  8KB  |  183 lines

  1. #ifndef __IP_32H
  2. #define __IP_32H
  3.  
  4. /*
  5.  * Copyright (c) 1982, 1986 Regents of the University of California.
  6.  * All rights reserved.
  7.  *
  8.  * Redistribution and use in source and binary forms are permitted
  9.  * provided that this notice is preserved and that due credit is given
  10.  * to the University of California at Berkeley. The name of the University
  11.  * may not be used to endorse or promote products derived from this
  12.  * software without specific prior written permission. This software
  13.  * is provided ``as is'' without express or implied warranty.
  14.  *
  15.  *      @(#)ip.h        7.6.1.1 (Berkeley) 3/15/88
  16.  */
  17. #define LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
  18. #define BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
  19. #define PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
  20.  
  21. #ifdef OS2
  22. #define BYTE_ORDER      LITTLE_ENDIAN
  23. #else
  24. #ifndef BYTE_ORDER
  25. /*
  26.  * Definitions for byte order,
  27.  * according to byte significance from low address to high.
  28.  */
  29.  
  30. #ifdef vax
  31. #define BYTE_ORDER      LITTLE_ENDIAN
  32. #else
  33. #define BYTE_ORDER      BIG_ENDIAN      /* mc68000, tahoe, most others */
  34. #endif
  35. #endif
  36. #endif
  37.  
  38. /*
  39.  * Definitions for internet protocol version 4.
  40.  * Per RFC 791, September 1981.
  41.  */
  42. #define IPVERSION       4
  43.  
  44. /*
  45.  * Structure of an internet header, naked of options.
  46.  *
  47.  * We declare ip_len and ip_off to be short, rather than u_short
  48.  * pragmatically since otherwise unsigned comparisons can result
  49.  * against negative integers quite easily, and fail in subtle ways.
  50.  */
  51. struct ip {
  52. #if BYTE_ORDER == LITTLE_ENDIAN
  53.         int     ip_hl:4,                /* header length */
  54.                 ip_v:4;                 /* version */
  55. #endif
  56. #if BYTE_ORDER == BIG_ENDIAN
  57.         u_char  ip_v:4,                 /* version */
  58.                 ip_hl:4;                /* header length */
  59. #endif
  60.         u_char  ip_tos;                 /* type of service */
  61.         short   ip_len;                 /* total length */
  62.         u_short ip_id;                  /* identification */
  63.         short   ip_off;                 /* fragment offset field */
  64. #define IP_DF 0x4000                    /* dont fragment flag */
  65. #define IP_MF 0x2000                    /* more fragments flag */
  66.         u_char  ip_ttl;                 /* time to live */
  67.         u_char  ip_p;                   /* protocol */
  68.         u_short ip_sum;                 /* checksum */
  69.         struct  in_addr ip_src,ip_dst;  /* source and dest address */
  70. };
  71. #ifndef OS2
  72. #define IP_MAXPACKET    65535           /* maximum packet size */
  73. #else
  74. #define IP_MAXPACKET    32767           /* maximum packet size */
  75. #endif
  76.  
  77. /*
  78.  * Definitions for options.
  79.  */
  80. #define IPOPT_COPIED(o)         ((o)&0x80)
  81. #define IPOPT_CLASS(o)          ((o)&0x60)
  82. #define IPOPT_NUMBER(o)         ((o)&0x1f)
  83.  
  84. #define IPOPT_CONTROL           0x00
  85. #define IPOPT_RESERVED1         0x20
  86. #define IPOPT_DEBMEAS           0x40
  87. #define IPOPT_RESERVED2         0x60
  88.  
  89. #define IPOPT_EOL               0               /* end of option list */
  90. #define IPOPT_NOP               1               /* no operation */
  91.  
  92. #define IPOPT_RR                7               /* record packet route */
  93. #define IPOPT_TS                68              /* timestamp */
  94. #define IPOPT_SECURITY          130             /* provide s,c,h,tcc */
  95. #define IPOPT_LSRR              131             /* loose source route */
  96. #define IPOPT_SATID             136             /* satnet id */
  97. #define IPOPT_SSRR              137             /* strict source route */
  98.  
  99. /*
  100.  * Offsets to fields in options other than EOL and NOP.
  101.  */
  102. #define IPOPT_OPTVAL            0               /* option ID */
  103. #define IPOPT_OLEN              1               /* option length */
  104. #define IPOPT_OFFSET            2               /* offset within option */
  105. #define IPOPT_MINOFF            4               /* min value of above */
  106.  
  107. /*
  108.  * Time stamp option structure.
  109.  */
  110. struct  ip_timestamp {
  111.         u_char  ipt_code;               /* IPOPT_TS */
  112.         u_char  ipt_len;                /* size of structure (variable) */
  113.         u_char  ipt_ptr;                /* index of current entry */
  114. #if BYTE_ORDER == LITTLE_ENDIAN
  115.         int     ipt_flg:4,              /* flags, see below */
  116.                 ipt_oflw:4;             /* overflow counter */
  117. #endif
  118. #if BYTE_ORDER == BIG_ENDIAN
  119.         u_char  ipt_oflw:4,             /* overflow counter */
  120.                 ipt_flg:4;              /* flags, see below */
  121. #endif
  122.         union ipt_timestamp {
  123.                 n_long  ipt_time[1];
  124.                 struct  ipt_ta {
  125.                         struct in_addr ipt_addr;
  126.                         n_long ipt_time;
  127.                 } ipt_ta[1];
  128.         } ipt_timestamp;
  129. };
  130.  
  131. /* flag bits for ipt_flg */
  132. #define IPOPT_TS_TSONLY         0               /* timestamps only */
  133. #define IPOPT_TS_TSANDADDR      1               /* timestamps and addresses */
  134. #define IPOPT_TS_PRESPEC        2               /* specified modules only */
  135.  
  136. /* bits for security (not byte swapped) */
  137. #define IPOPT_SECUR_UNCLASS     0x0000
  138. #define IPOPT_SECUR_CONFID      0xf135
  139. #define IPOPT_SECUR_EFTO        0x789a
  140. #define IPOPT_SECUR_MMMM        0xbc4d
  141. #define IPOPT_SECUR_RESTR       0xaf13
  142. #define IPOPT_SECUR_SECRET      0xd788
  143. #define IPOPT_SECUR_TOPSECRET   0x6bc5
  144.  
  145. /*
  146.  * Internet implementation parameters.
  147.  */
  148. #define MAXTTL          255             /* maximum time to live (seconds) */
  149. #define IPFRAGTTL       60              /* time to live for frags, slowhz */
  150. #define IPTTLDEC        1               /* subtracted when forwarding */
  151.  
  152. #define IP_MSS          576             /* default maximum segment size */
  153.  
  154. #pragma pack(1)
  155. struct  ipstat {
  156.         long    ips_total;              /* total packets received */
  157.         long    ips_badsum;             /* checksum bad */
  158.         long    ips_tooshort;           /* packet too short */
  159.         long    ips_toosmall;           /* not enough data */
  160.         long    ips_badhlen;            /* ip header length < data size */
  161.         long    ips_badlen;             /* ip length < ip header length */
  162.         long    ips_fragments;          /* fragments received */
  163.         long    ips_fragdropped;        /* frags dropped (dups, out of space) */
  164.         long    ips_fragtimeout;        /* fragments timed out */
  165.         long    ips_forward;            /* packets forwarded */
  166.         long    ips_cantforward;        /* packets rcvd for unreachable dest */
  167.         long    ips_redirectsent;       /* packets forwarded on same net */
  168.         long    ips_ipOutRequests;      /* requested for transmission */
  169.         long    ips_ipOutNoRoutes;      /* discarded - no route */
  170.         long    ips_ipFragFails;        /* had to fragment but could not */
  171.         long    ips_ipFragOKs;          /* successfully fragmented datagrams */
  172.         long    ips_ipFragCreates;      /* number of fragments created */
  173.         long    ips_ipReasmOKs;         /* datagrams successfully assembled */
  174.         long    ips_ipOutDiscards;      /* discarded due to lack of space */
  175.         long    ips_ipInDiscards;       /* discarded due to lack of space 0 */
  176.         long    ips_ipInAddrErrors;     /* discarded due to lack of space 0 */
  177.         long    ips_ipInDelivers;       /* datagrams successfully delivered */
  178.         long    ips_ipInUnknownProtos;  /* datagrams with unknown protocol  */
  179. };
  180. #pragma pack()
  181.  
  182. #endif /* __IP_32H */
  183.