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