home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Headers / bsd / netinet / ip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-04-27  |  4.2 KB  |  141 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.  
  27. #include <bsd/machine/endian.h>
  28.  
  29. /*
  30.  * Definitions for internet protocol version 4.
  31.  * Per RFC 791, September 1981.
  32.  */
  33. #define    IPVERSION    4
  34.  
  35. /*
  36.  * Structure of an internet header, naked of options.
  37.  *
  38.  * We declare ip_len and ip_off to be short, rather than u_short
  39.  * pragmatically since otherwise unsigned comparisons can result
  40.  * against negative integers quite easily, and fail in subtle ways.
  41.  */
  42. struct ip {
  43. #if BYTE_ORDER == LITTLE_ENDIAN 
  44.     u_char    ip_hl:4,        /* header length */
  45.         ip_v:4;            /* version */
  46. #endif
  47. #if BYTE_ORDER == BIG_ENDIAN 
  48.     u_char    ip_v:4,            /* version */
  49.         ip_hl:4;        /* header length */
  50. #endif
  51.     u_char    ip_tos;            /* type of service */
  52.     short    ip_len;            /* total length */
  53.     u_short    ip_id;            /* identification */
  54.     short    ip_off;            /* fragment offset field */
  55. #define    IP_DF 0x4000            /* dont fragment flag */
  56. #define    IP_MF 0x2000            /* more fragments flag */
  57.     u_char    ip_ttl;            /* time to live */
  58.     u_char    ip_p;            /* protocol */
  59.     u_short    ip_sum;            /* checksum */
  60.     struct    in_addr ip_src,ip_dst;    /* source and dest address */
  61. };
  62.  
  63. #define    IP_MAXPACKET    65535        /* maximum packet size */
  64.  
  65. /*
  66.  * Definitions for options.
  67.  */
  68. #define    IPOPT_COPIED(o)        ((o)&0x80)
  69. #define    IPOPT_CLASS(o)        ((o)&0x60)
  70. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  71.  
  72. #define    IPOPT_CONTROL        0x00
  73. #define    IPOPT_RESERVED1        0x20
  74. #define    IPOPT_DEBMEAS        0x40
  75. #define    IPOPT_RESERVED2        0x60
  76.  
  77. #define    IPOPT_EOL        0        /* end of option list */
  78. #define    IPOPT_NOP        1        /* no operation */
  79.  
  80. #define    IPOPT_RR        7        /* record packet route */
  81. #define    IPOPT_TS        68        /* timestamp */
  82. #define    IPOPT_SECURITY        130        /* provide s,c,h,tcc */
  83. #define    IPOPT_LSRR        131        /* loose source route */
  84. #define    IPOPT_SATID        136        /* satnet id */
  85. #define    IPOPT_SSRR        137        /* strict source route */
  86.  
  87. /*
  88.  * Offsets to fields in options other than EOL and NOP.
  89.  */
  90. #define    IPOPT_OPTVAL        0        /* option ID */
  91. #define    IPOPT_OLEN        1        /* option length */
  92. #define IPOPT_OFFSET        2        /* offset within option */
  93. #define    IPOPT_MINOFF        4        /* min value of above */
  94.  
  95. /*
  96.  * Time stamp option structure.
  97.  */
  98. struct    ip_timestamp {
  99.     u_char    ipt_code;        /* IPOPT_TS */
  100.     u_char    ipt_len;        /* size of structure (variable) */
  101.     u_char    ipt_ptr;        /* index of current entry */
  102. #if BYTE_ORDER == LITTLE_ENDIAN 
  103.     u_char    ipt_flg:4,        /* flags, see below */
  104.         ipt_oflw:4;        /* overflow counter */
  105. #endif
  106. #if BYTE_ORDER == BIG_ENDIAN 
  107.     u_char    ipt_oflw:4,        /* overflow counter */
  108.         ipt_flg:4;        /* flags, see below */
  109. #endif
  110.     union ipt_timestamp {
  111.         n_long    ipt_time[1];
  112.         struct    ipt_ta {
  113.             struct in_addr ipt_addr;
  114.             n_long ipt_time;
  115.         } ipt_ta[1];
  116.     } ipt_timestamp;
  117. };
  118.  
  119. /* flag bits for ipt_flg */
  120. #define    IPOPT_TS_TSONLY        0        /* timestamps only */
  121. #define    IPOPT_TS_TSANDADDR    1        /* timestamps and addresses */
  122. #define    IPOPT_TS_PRESPEC    2        /* specified modules only */
  123.  
  124. /* bits for security (not byte swapped) */
  125. #define    IPOPT_SECUR_UNCLASS    0x0000
  126. #define    IPOPT_SECUR_CONFID    0xf135
  127. #define    IPOPT_SECUR_EFTO    0x789a
  128. #define    IPOPT_SECUR_MMMM    0xbc4d
  129. #define    IPOPT_SECUR_RESTR    0xaf13
  130. #define    IPOPT_SECUR_SECRET    0xd788
  131. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  132.  
  133. /*
  134.  * Internet implementation parameters.
  135.  */
  136. #define    MAXTTL        255        /* maximum time to live (seconds) */
  137. #define    IPFRAGTTL    60        /* time to live for frags, slowhz */
  138. #define    IPTTLDEC    1        /* subtracted when forwarding */
  139.  
  140. #define    IP_MSS        576        /* default maximum segment size */
  141.