home *** CD-ROM | disk | FTP | other *** search
/ Otherware / Otherware_1_SB_Development.iso / amiga / os / bsdss4.tz / bsdss4 / bsdss / server / netinet / ip.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-04-22  |  6.6 KB  |  201 lines

  1. /* 
  2.  * Mach Operating System
  3.  * Copyright (c) 1992 Carnegie Mellon University
  4.  * All Rights Reserved.
  5.  * 
  6.  * Permission to use, copy, modify and distribute this software and its
  7.  * documentation is hereby granted, provided that both the copyright
  8.  * notice and this permission notice appear in all copies of the
  9.  * software, derivative works or modified versions, and any portions
  10.  * thereof, and that both notices appear in supporting documentation.
  11.  * 
  12.  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
  13.  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
  14.  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  15.  * 
  16.  * Carnegie Mellon requests users of this software to return to
  17.  * 
  18.  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
  19.  *  School of Computer Science
  20.  *  Carnegie Mellon University
  21.  *  Pittsburgh PA 15213-3890
  22.  * 
  23.  * any improvements or extensions that they make and grant Carnegie Mellon 
  24.  * the rights to redistribute these changes.
  25.  */
  26. /*
  27.  * HISTORY
  28.  * $Log:    ip.h,v $
  29.  * Revision 2.1  92/04/21  17:14:45  rwd
  30.  * BSDSS
  31.  * 
  32.  *
  33.  */
  34.  
  35. /*
  36.  * Copyright (c) 1982, 1986 Regents of the University of California.
  37.  * All rights reserved.
  38.  *
  39.  * Redistribution and use in source and binary forms, with or without
  40.  * modification, are permitted provided that the following conditions
  41.  * are met:
  42.  * 1. Redistributions of source code must retain the above copyright
  43.  *    notice, this list of conditions and the following disclaimer.
  44.  * 2. Redistributions in binary form must reproduce the above copyright
  45.  *    notice, this list of conditions and the following disclaimer in the
  46.  *    documentation and/or other materials provided with the distribution.
  47.  * 3. All advertising materials mentioning features or use of this software
  48.  *    must display the following acknowledgement:
  49.  *    This product includes software developed by the University of
  50.  *    California, Berkeley and its contributors.
  51.  * 4. Neither the name of the University nor the names of its contributors
  52.  *    may be used to endorse or promote products derived from this software
  53.  *    without specific prior written permission.
  54.  *
  55.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  56.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  57.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  58.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  59.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  60.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  61.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  62.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  63.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  64.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  65.  * SUCH DAMAGE.
  66.  *
  67.  *    @(#)ip.h    7.10 (Berkeley) 6/28/90
  68.  */
  69.  
  70. /*
  71.  * Definitions for internet protocol version 4.
  72.  * Per RFC 791, September 1981.
  73.  */
  74. #define    IPVERSION    4
  75.  
  76. /*
  77.  * Structure of an internet header, naked of options.
  78.  *
  79.  * We declare ip_len and ip_off to be short, rather than u_short
  80.  * pragmatically since otherwise unsigned comparisons can result
  81.  * against negative integers quite easily, and fail in subtle ways.
  82.  */
  83. struct ip {
  84. #if BYTE_ORDER == LITTLE_ENDIAN 
  85.     u_char    ip_hl:4,        /* header length */
  86.         ip_v:4;            /* version */
  87. #endif
  88. #if BYTE_ORDER == BIG_ENDIAN 
  89.     u_char    ip_v:4,            /* version */
  90.         ip_hl:4;        /* header length */
  91. #endif
  92.     u_char    ip_tos;            /* type of service */
  93.     short    ip_len;            /* total length */
  94.     u_short    ip_id;            /* identification */
  95.     short    ip_off;            /* fragment offset field */
  96. #define    IP_DF 0x4000            /* dont fragment flag */
  97. #define    IP_MF 0x2000            /* more fragments flag */
  98.     u_char    ip_ttl;            /* time to live */
  99.     u_char    ip_p;            /* protocol */
  100.     u_short    ip_sum;            /* checksum */
  101.     struct    in_addr ip_src,ip_dst;    /* source and dest address */
  102. };
  103.  
  104. #define    IP_MAXPACKET    65535        /* maximum packet size */
  105.  
  106. /*
  107.  * Definitions for IP type of service (ip_tos)
  108.  */
  109. #define    IPTOS_LOWDELAY        0x10
  110. #define    IPTOS_THROUGHPUT    0x08
  111. #define    IPTOS_RELIABILITY    0x04
  112.  
  113. /*
  114.  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
  115.  */
  116. #define    IPTOS_PREC_NETCONTROL        0xe0
  117. #define    IPTOS_PREC_INTERNETCONTROL    0xc0
  118. #define    IPTOS_PREC_CRITIC_ECP        0xa0
  119. #define    IPTOS_PREC_FLASHOVERRIDE    0x80
  120. #define    IPTOS_PREC_FLASH        0x60
  121. #define    IPTOS_PREC_IMMEDIATE        0x40
  122. #define    IPTOS_PREC_PRIORITY        0x20
  123. #define    IPTOS_PREC_ROUTINE        0x10
  124.  
  125. /*
  126.  * Definitions for options.
  127.  */
  128. #define    IPOPT_COPIED(o)        ((o)&0x80)
  129. #define    IPOPT_CLASS(o)        ((o)&0x60)
  130. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  131.  
  132. #define    IPOPT_CONTROL        0x00
  133. #define    IPOPT_RESERVED1        0x20
  134. #define    IPOPT_DEBMEAS        0x40
  135. #define    IPOPT_RESERVED2        0x60
  136.  
  137. #define    IPOPT_EOL        0        /* end of option list */
  138. #define    IPOPT_NOP        1        /* no operation */
  139.  
  140. #define    IPOPT_RR        7        /* record packet route */
  141. #define    IPOPT_TS        68        /* timestamp */
  142. #define    IPOPT_SECURITY        130        /* provide s,c,h,tcc */
  143. #define    IPOPT_LSRR        131        /* loose source route */
  144. #define    IPOPT_SATID        136        /* satnet id */
  145. #define    IPOPT_SSRR        137        /* strict source route */
  146.  
  147. /*
  148.  * Offsets to fields in options other than EOL and NOP.
  149.  */
  150. #define    IPOPT_OPTVAL        0        /* option ID */
  151. #define    IPOPT_OLEN        1        /* option length */
  152. #define IPOPT_OFFSET        2        /* offset within option */
  153. #define    IPOPT_MINOFF        4        /* min value of above */
  154.  
  155. /*
  156.  * Time stamp option structure.
  157.  */
  158. struct    ip_timestamp {
  159.     u_char    ipt_code;        /* IPOPT_TS */
  160.     u_char    ipt_len;        /* size of structure (variable) */
  161.     u_char    ipt_ptr;        /* index of current entry */
  162. #if BYTE_ORDER == LITTLE_ENDIAN 
  163.     u_char    ipt_flg:4,        /* flags, see below */
  164.         ipt_oflw:4;        /* overflow counter */
  165. #endif
  166. #if BYTE_ORDER == BIG_ENDIAN 
  167.     u_char    ipt_oflw:4,        /* overflow counter */
  168.         ipt_flg:4;        /* flags, see below */
  169. #endif
  170.     union ipt_timestamp {
  171.         n_long    ipt_time[1];
  172.         struct    ipt_ta {
  173.             struct in_addr ipt_addr;
  174.             n_long ipt_time;
  175.         } ipt_ta[1];
  176.     } ipt_timestamp;
  177. };
  178.  
  179. /* flag bits for ipt_flg */
  180. #define    IPOPT_TS_TSONLY        0        /* timestamps only */
  181. #define    IPOPT_TS_TSANDADDR    1        /* timestamps and addresses */
  182. #define    IPOPT_TS_PRESPEC    3        /* specified modules only */
  183.  
  184. /* bits for security (not byte swapped) */
  185. #define    IPOPT_SECUR_UNCLASS    0x0000
  186. #define    IPOPT_SECUR_CONFID    0xf135
  187. #define    IPOPT_SECUR_EFTO    0x789a
  188. #define    IPOPT_SECUR_MMMM    0xbc4d
  189. #define    IPOPT_SECUR_RESTR    0xaf13
  190. #define    IPOPT_SECUR_SECRET    0xd788
  191. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  192.  
  193. /*
  194.  * Internet implementation parameters.
  195.  */
  196. #define    MAXTTL        255        /* maximum time to live (seconds) */
  197. #define    IPFRAGTTL    60        /* time to live for frags, slowhz */
  198. #define    IPTTLDEC    1        /* subtracted when forwarding */
  199.  
  200. #define    IP_MSS        576        /* default maximum segment size */
  201.