home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / update701 / root.18 / usr / include / netinet / ip.h / ip.h
Encoding:
C/C++ Source or Header  |  1998-08-18  |  6.9 KB  |  203 lines

  1. /*
  2.  * Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  3.  *                                                                         
  4.  *        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  5.  *                   SANTA CRUZ OPERATION INC.                             
  6.  *                                                                         
  7.  *   The copyright notice above does not evidence any actual or intended   
  8.  *   publication of such source code.                                      
  9.  */
  10.  
  11. /*
  12.  * Copyrighted as an unpublished work.
  13.  * (c) Copyright 1987-1995 Computer Associates International, Inc.
  14.  * All rights reserved.
  15.  *
  16.  * RESTRICTED RIGHTS
  17.  *
  18.  * These programs are supplied under a license.  They may be used,
  19.  * disclosed, and/or copied only as permitted under such license
  20.  * agreement.  Any copy must contain the above copyright notice and
  21.  * this restricted rights notice.  Use, copying, and/or disclosure
  22.  * of the programs is strictly prohibited unless otherwise provided
  23.  * in the license agreement.
  24.  */
  25. /*
  26.  * Copyright (c) 1982-1995
  27.  *      The Regents of the University of California.  All rights reserved.
  28.  *
  29.  * Redistribution and use in source and binary forms, with or without
  30.  * modification, are permitted provided that the following conditions
  31.  * are met:
  32.  * 1. Redistributions of source code must retain the above copyright
  33.  *    notice, this list of conditions and the following disclaimer.
  34.  * 2. Redistributions in binary form must reproduce the above copyright
  35.  *    notice, this list of conditions and the following disclaimer in the
  36.  *    documentation and/or other materials provided with the distribution.
  37.  * 3. All advertising materials mentioning features or use of this software
  38.  *    must display the following acknowledgement:
  39.  *      This product includes software developed by the University of
  40.  *      California, Berkeley and its contributors.
  41.  * 4. Neither the name of the University nor the names of its contributors
  42.  *    may be used to endorse or promote products derived from this software
  43.  *    without specific prior written permission.
  44.  *
  45.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  46.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  47.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  48.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  49.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  50.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  51.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  52.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  53.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  54.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  55.  * SUCH DAMAGE.
  56.  */
  57. #ident "@(#)ip.h    1.5"
  58. #ident "$Header$"
  59.  
  60. #ifndef __netinet_ip_h
  61. #define __netinet_ip_h
  62.  
  63. #ifdef _KERNEL_HEADERS
  64. #include <net/inet/ip_f.h>
  65. #else /* !_KERNEL_HEADERS */
  66. #include <netinet/ip_f.h>
  67. #endif /* _KERNEL_HEADERS */
  68.  
  69. /*
  70.  * Definitions for internet protocol version 4. Per RFC 791, September 1981. 
  71.  */
  72. #define    IPVERSION    4
  73.  
  74. /*
  75.  * Definitions for IP type of service (ip_tos)
  76.  */
  77. #define IPTOS_LOWDELAY        0x10
  78. #define IPTOS_THROUGHPUT    0x08
  79. #define IPTOS_RELIABILITY    0x04
  80. #define IPTOS_MONETARY        0x02
  81. #define IPTOS_RESERVED2        0x01
  82. #define IPTOS_NONE        0x00
  83.  
  84. /*
  85.  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
  86.  */
  87. #define IPTOS_PREC_NETCONTROL        0xe0
  88. #define IPTOS_PREC_INTERNETCONTROL    0xc0
  89. #define IPTOS_PREC_CRITIC_ECP        0xa0
  90. #define IPTOS_PREC_FLASHOVERRIDE    0x80
  91. #define IPTOS_PREC_FLASH        0x60
  92. #define IPTOS_PREC_IMMEDIATE        0x40
  93. #define IPTOS_PREC_PRIORITY        0x20
  94. #define IPTOS_PREC_ROUTINE        0x00
  95.  
  96. #define IPPREC(x)        ((u_char) (x) & 0xe0)
  97. #define IPTOS(x)        ((u_char) (x) & 0x1c)
  98.  
  99. #if defined(TOSNAMES)
  100. struct ip_tosval {
  101.     char *tv_name;
  102.     u_char tv_val;
  103. } ip_tosvals[] = {
  104.     "none",     IPTOS_NONE,
  105.     "delay",     IPTOS_LOWDELAY,
  106.     "throughput",     IPTOS_THROUGHPUT,
  107.     "reliability",     IPTOS_RELIABILITY,
  108.     "monetary",     IPTOS_MONETARY,
  109.     "reserved2",     IPTOS_RESERVED2
  110. };
  111.  
  112. int n_iptosvals = (sizeof(ip_tosvals) / sizeof(struct ip_tosval));
  113. struct ip_tosval ip_precvals[] = {
  114.     "netcontrol",        IPTOS_PREC_NETCONTROL,
  115.     "internetcontrol",    IPTOS_PREC_INTERNETCONTROL,
  116.     "crtic/ecp",        IPTOS_PREC_CRITIC_ECP,
  117.     "flashoverride",     IPTOS_PREC_FLASHOVERRIDE,
  118.     "flash",         IPTOS_PREC_FLASH,
  119.     "immediate",         IPTOS_PREC_IMMEDIATE,
  120.     "priority",         IPTOS_PREC_PRIORITY,
  121.     "routine",         IPTOS_PREC_ROUTINE,
  122. };
  123. int n_ipprecvals = (sizeof(ip_precvals) / sizeof(struct ip_tosval));
  124. #endif    /* TOSNAMES */
  125.  
  126. #define IP_MAXPACKET 65535        /* maximum packet size */
  127. /*
  128.  * Definitions for options. 
  129.  */
  130. #define    IPOPT_COPIED(o)        ((o)&0x80)
  131. #define    IPOPT_CLASS(o)        ((o)&0x60)
  132. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  133.  
  134. #define    IPOPT_CONTROL        0x00
  135. #define    IPOPT_RESERVED1        0x20
  136. #define    IPOPT_DEBMEAS        0x40
  137. #define    IPOPT_RESERVED2        0x60
  138.  
  139. #define    IPOPT_EOL        0    /* end of option list */
  140. #define    IPOPT_NOP        1    /* no operation */
  141.  
  142. #define    IPOPT_RR        7    /* record packet route */
  143. #define    IPOPT_TS        68    /* timestamp */
  144. #define    IPOPT_SECURITY        130    /* provide s,c,h,tcc */
  145. #define    IPOPT_LSRR        131    /* loose source route */
  146. #define    IPOPT_SATID        136    /* satnet id */
  147. #define    IPOPT_SSRR        137    /* strict source route */
  148. #define IPOPT_RA        148    /* router alert */
  149.  
  150. /*
  151.  * Offsets to fields in options other than EOL and NOP. 
  152.  */
  153. #define    IPOPT_OPTVAL        0    /* option ID */
  154. #define    IPOPT_OLEN        1    /* option length */
  155. #define IPOPT_OFFSET        2    /* offset within option */
  156. #define    IPOPT_MINOFF        4    /* min value of above */
  157.  
  158. /* flag bits for ipt_flg */
  159. #define    IPOPT_TS_TSONLY        0    /* timestamps only */
  160. #define    IPOPT_TS_TSANDADDR    1    /* timestamps and addresses */
  161. #define    IPOPT_TS_PRESPEC    2    /* specified modules only */
  162.  
  163. /* bits for security (not byte swapped) */
  164. #define    IPOPT_SECUR_UNCLASS    0x0000
  165. #define    IPOPT_SECUR_CONFID    0xf135
  166. #define    IPOPT_SECUR_EFTO    0x789a
  167. #define    IPOPT_SECUR_MMMM    0xbc4d
  168. #define    IPOPT_SECUR_RESTR    0xaf13
  169. #define    IPOPT_SECUR_SECRET    0xd788
  170. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  171.  
  172. /*
  173.  * Maximum size of any reasonable combination of IP options (RFC791).
  174.  */
  175. #define IP_OPTIONS_OPT_MAXSZ \
  176.  ( 1 + 1    /* end of opt list, no operation */ \
  177.  + 11        /* basic security */ \
  178.  + 255*3    /* loose source routing, ext security, record route */ \
  179.  + 4        /* stream id */ \
  180.  + 255*2    /* strict source routing, timestamp */ \
  181.  + 4*8 )    /* reasonable value to align each option to 4 octet boundary */
  182.  
  183. /*
  184.  * Internet implementation parameters. 
  185.  */
  186. #define    MAXTTL        255    /* maximum time to live (seconds) */
  187. #define    IPFRAGTTL    60    /* time to live for frags, slowhz */
  188. #define    IPTTLDEC    1    /* subtracted when forwarding */
  189.  
  190. #define IP_MINMTU    68    /* RFC 791 minimum MTU */
  191. #define    IP_MSS        576    /* default maximum segment size */
  192.  
  193. #if !defined(GBITS)
  194. #define    GBITS(x,p,n)    (((x)>>(p+1-n)) &~(~0<<n))
  195. #endif
  196.  
  197. #if !defined(SBITS)
  198. #define SBITS(x,p,n,v)        (x)=((((v)&~(~0<<n))<<(p+1-n))|\
  199.                     ((x)&~((~(~0<<n))<<(p+1-n))));
  200. #endif
  201.  
  202. #endif    /* __netinet_ip_h */
  203.