home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.2 (Developer) / NS_dev_3.2.iso / NextDeveloper / Headers / bsd / netinet / ip.h < prev    next >
C/C++ Source or Header  |  1993-10-19  |  5KB  |  157 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1987 Carnegie-Mellon University
  4.  * All rights reserved.  The CMU software License Agreement specifies
  5.  * the terms and conditions for use and redistribution.
  6.  */
  7. /*
  8.  * Copyright (c) 1982, 1986 Regents of the University of California.
  9.  * All rights reserved.
  10.  *
  11.  * Redistribution and use in source and binary forms are permitted
  12.  * provided that this notice is preserved and that due credit is given
  13.  * to the University of California at Berkeley. The name of the University
  14.  * may not be used to endorse or promote products derived from this
  15.  * software without specific prior written permission. This software
  16.  * is provided ``as is'' without express or implied warranty.
  17.  *
  18.  *    @(#)ip.h    7.6.1.1 (Berkeley) 3/15/88
  19.  *
  20.  * HISTORY
  21.  * 21-Oct-86  David Golub (dbg) at Carnegie-Mellon University
  22.  *    Use different versions of time-stamp option definition
  23.  *    for big-ender and little-enter machines.
  24.  *
  25.  */
  26. #ifndef BYTE_ORDER
  27.  
  28. /*
  29.  * Definitions for byte order,
  30.  * according to byte significance from low address to high.
  31.  */
  32. #define    LITTLE_ENDIAN    1234    /* least-significant byte first (vax) */
  33. #define    BIG_ENDIAN    4321    /* most-significant byte first (IBM, net) */
  34. #define    PDP_ENDIAN    3412    /* LSB first in word, MSW first in long (pdp) */
  35.  
  36. #if    __LITTLE_ENDIAN__
  37. #define    BYTE_ORDER    LITTLE_ENDIAN    /* vax, i386 */
  38. #endif    __LITTLE_ENDIAN__
  39.  
  40. #if    __BIG_ENDIAN__
  41. #define    BYTE_ORDER    BIG_ENDIAN    /* mc68000, tahoe, most others */
  42. #endif    __BIG_ENDIAN__
  43. #endif BYTE_ORDER
  44.  
  45. /*
  46.  * Definitions for internet protocol version 4.
  47.  * Per RFC 791, September 1981.
  48.  */
  49. #define    IPVERSION    4
  50.  
  51. /*
  52.  * Structure of an internet header, naked of options.
  53.  *
  54.  * We declare ip_len and ip_off to be short, rather than u_short
  55.  * pragmatically since otherwise unsigned comparisons can result
  56.  * against negative integers quite easily, and fail in subtle ways.
  57.  */
  58. struct ip {
  59. #if BYTE_ORDER == LITTLE_ENDIAN 
  60.     u_char    ip_hl:4,        /* header length */
  61.         ip_v:4;            /* version */
  62. #endif
  63. #if BYTE_ORDER == BIG_ENDIAN 
  64.     u_char    ip_v:4,            /* version */
  65.         ip_hl:4;        /* header length */
  66. #endif
  67.     u_char    ip_tos;            /* type of service */
  68.     short    ip_len;            /* total length */
  69.     u_short    ip_id;            /* identification */
  70.     short    ip_off;            /* fragment offset field */
  71. #define    IP_DF 0x4000            /* dont fragment flag */
  72. #define    IP_MF 0x2000            /* more fragments flag */
  73.     u_char    ip_ttl;            /* time to live */
  74.     u_char    ip_p;            /* protocol */
  75.     u_short    ip_sum;            /* checksum */
  76.     struct    in_addr ip_src,ip_dst;    /* source and dest address */
  77. };
  78.  
  79. #define    IP_MAXPACKET    65535        /* maximum packet size */
  80.  
  81. /*
  82.  * Definitions for options.
  83.  */
  84. #define    IPOPT_COPIED(o)        ((o)&0x80)
  85. #define    IPOPT_CLASS(o)        ((o)&0x60)
  86. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  87.  
  88. #define    IPOPT_CONTROL        0x00
  89. #define    IPOPT_RESERVED1        0x20
  90. #define    IPOPT_DEBMEAS        0x40
  91. #define    IPOPT_RESERVED2        0x60
  92.  
  93. #define    IPOPT_EOL        0        /* end of option list */
  94. #define    IPOPT_NOP        1        /* no operation */
  95.  
  96. #define    IPOPT_RR        7        /* record packet route */
  97. #define    IPOPT_TS        68        /* timestamp */
  98. #define    IPOPT_SECURITY        130        /* provide s,c,h,tcc */
  99. #define    IPOPT_LSRR        131        /* loose source route */
  100. #define    IPOPT_SATID        136        /* satnet id */
  101. #define    IPOPT_SSRR        137        /* strict source route */
  102.  
  103. /*
  104.  * Offsets to fields in options other than EOL and NOP.
  105.  */
  106. #define    IPOPT_OPTVAL        0        /* option ID */
  107. #define    IPOPT_OLEN        1        /* option length */
  108. #define IPOPT_OFFSET        2        /* offset within option */
  109. #define    IPOPT_MINOFF        4        /* min value of above */
  110.  
  111. /*
  112.  * Time stamp option structure.
  113.  */
  114. struct    ip_timestamp {
  115.     u_char    ipt_code;        /* IPOPT_TS */
  116.     u_char    ipt_len;        /* size of structure (variable) */
  117.     u_char    ipt_ptr;        /* index of current entry */
  118. #if BYTE_ORDER == LITTLE_ENDIAN 
  119.     u_char    ipt_flg:4,        /* flags, see below */
  120.         ipt_oflw:4;        /* overflow counter */
  121. #endif
  122. #if BYTE_ORDER == BIG_ENDIAN 
  123.     u_char    ipt_oflw:4,        /* overflow counter */
  124.         ipt_flg:4;        /* flags, see below */
  125. #endif
  126.     union ipt_timestamp {
  127.         n_long    ipt_time[1];
  128.         struct    ipt_ta {
  129.             struct in_addr ipt_addr;
  130.             n_long ipt_time;
  131.         } ipt_ta[1];
  132.     } ipt_timestamp;
  133. };
  134.  
  135. /* flag bits for ipt_flg */
  136. #define    IPOPT_TS_TSONLY        0        /* timestamps only */
  137. #define    IPOPT_TS_TSANDADDR    1        /* timestamps and addresses */
  138. #define    IPOPT_TS_PRESPEC    2        /* specified modules only */
  139.  
  140. /* bits for security (not byte swapped) */
  141. #define    IPOPT_SECUR_UNCLASS    0x0000
  142. #define    IPOPT_SECUR_CONFID    0xf135
  143. #define    IPOPT_SECUR_EFTO    0x789a
  144. #define    IPOPT_SECUR_MMMM    0xbc4d
  145. #define    IPOPT_SECUR_RESTR    0xaf13
  146. #define    IPOPT_SECUR_SECRET    0xd788
  147. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  148.  
  149. /*
  150.  * Internet implementation parameters.
  151.  */
  152. #define    MAXTTL        255        /* maximum time to live (seconds) */
  153. #define    IPFRAGTTL    60        /* time to live for frags, slowhz */
  154. #define    IPTTLDEC    1        /* subtracted when forwarding */
  155.  
  156. #define    IP_MSS        576        /* default maximum segment size */
  157.