home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue6 / SDL.ZIP / !gcc / include / unixlib / netinet / h / ip < prev    next >
Encoding:
Text File  |  2006-09-17  |  5.9 KB  |  190 lines

  1. /****************************************************************************
  2.  *
  3.  * $Source: $
  4.  * $Date: $
  5.  * $Revision: $
  6.  * $State: $
  7.  * $Author: $
  8.  *
  9.  ***************************************************************************/
  10.  
  11. /*
  12.  * File taken from glibc 2.2.5.
  13.  * Following changes were made:
  14.  *  - Added __BEGIN_DECLS/__END_DECLS
  15.  *  - Changed "#include <bits/types.h>" into "#include <unixlib/types.h>"
  16.  */
  17.  
  18. /*
  19.  * Copyright (c) 1982, 1986, 1993
  20.  *    The Regents of the University of California.  All rights reserved.
  21.  *
  22.  * Redistribution and use in source and binary forms, with or without
  23.  * modification, are permitted provided that the following conditions
  24.  * are met:
  25.  * 1. Redistributions of source code must retain the above copyright
  26.  *    notice, this list of conditions and the following disclaimer.
  27.  * 2. Redistributions in binary form must reproduce the above copyright
  28.  *    notice, this list of conditions and the following disclaimer in the
  29.  *    documentation and/or other materials provided with the distribution.
  30.  * 4. Neither the name of the University nor the names of its contributors
  31.  *    may be used to endorse or promote products derived from this software
  32.  *    without specific prior written permission.
  33.  *
  34.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  35.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  36.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  37.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  38.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  39.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  40.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  41.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  42.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  43.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  44.  * SUCH DAMAGE.
  45.  *
  46.  *    @(#)ip.h    8.1 (Berkeley) 6/10/93
  47.  */
  48.  
  49. #ifndef _NETINET_IP_H
  50. #define _NETINET_IP_H
  51.  
  52. #include <unixlib/types.h>
  53. #include <endian.h>
  54. #include <netinet/in.h>
  55.  
  56. __BEGIN_DECLS
  57.  
  58. /*
  59.  * Definitions for internet protocol version 4.
  60.  * Per RFC 791, September 1981.
  61.  */
  62. #define    IPVERSION    4
  63.  
  64. /*
  65.  * Structure of an internet header, naked of options.
  66.  */
  67. struct ip {
  68. #if __BYTE_ORDER == __LITTLE_ENDIAN
  69.     __u_char  ip_hl:4,        /* header length */
  70.           ip_v:4;        /* version */
  71. #endif
  72. #if __BYTE_ORDER == __BIG_ENDIAN
  73.     __u_char  ip_v:4,        /* version */
  74.           ip_hl:4;        /* header length */
  75. #endif
  76.     __u_char  ip_tos;        /* type of service */
  77.     __u_short ip_len;        /* total length */
  78.     __u_short ip_id;        /* identification */
  79.     __u_short ip_off;        /* fragment offset field */
  80. #define    IP_RF 0x8000            /* reserved fragment flag */
  81. #define    IP_DF 0x4000            /* dont fragment flag */
  82. #define    IP_MF 0x2000            /* more fragments flag */
  83. #define    IP_OFFMASK 0x1fff        /* mask for fragmenting bits */
  84.     __u_char  ip_ttl;        /* time to live */
  85.     __u_char  ip_p;            /* protocol */
  86.     __u_short ip_sum;        /* checksum */
  87.     struct      in_addr ip_src, ip_dst; /* source and dest address */
  88. };
  89.  
  90. #define    IP_MAXPACKET    65535        /* maximum packet size */
  91.  
  92. /*
  93.  * Definitions for IP type of service (ip_tos)
  94.  */
  95. #define    IPTOS_LOWDELAY        0x10
  96. #define    IPTOS_THROUGHPUT    0x08
  97. #define    IPTOS_RELIABILITY    0x04
  98. #define    IPTOS_LOWCOST        0x02
  99. #define    IPTOS_MINCOST        IPTOS_LOWCOST
  100.  
  101. /*
  102.  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
  103.  */
  104. #define    IPTOS_PREC_NETCONTROL        0xe0
  105. #define    IPTOS_PREC_INTERNETCONTROL    0xc0
  106. #define    IPTOS_PREC_CRITIC_ECP        0xa0
  107. #define    IPTOS_PREC_FLASHOVERRIDE    0x80
  108. #define    IPTOS_PREC_FLASH        0x60
  109. #define    IPTOS_PREC_IMMEDIATE        0x40
  110. #define    IPTOS_PREC_PRIORITY        0x20
  111. #define    IPTOS_PREC_ROUTINE        0x00
  112.  
  113. /*
  114.  * Definitions for options.
  115.  */
  116. #define    IPOPT_COPIED(o)        ((o)&0x80)
  117. #define    IPOPT_CLASS(o)        ((o)&0x60)
  118. #define    IPOPT_NUMBER(o)        ((o)&0x1f)
  119.  
  120. #define    IPOPT_CONTROL        0x00
  121. #define    IPOPT_RESERVED1        0x20
  122. #define    IPOPT_DEBMEAS        0x40
  123. #define    IPOPT_RESERVED2        0x60
  124.  
  125. #define    IPOPT_EOL        0        /* end of option list */
  126. #define    IPOPT_NOP        1        /* no operation */
  127.  
  128. #define    IPOPT_RR        7        /* record packet route */
  129. #define    IPOPT_TS        68        /* timestamp */
  130. #define    IPOPT_SECURITY        130        /* provide s,c,h,tcc */
  131. #define    IPOPT_LSRR        131        /* loose source route */
  132. #define    IPOPT_SATID        136        /* satnet id */
  133. #define    IPOPT_SSRR        137        /* strict source route */
  134.  
  135. /*
  136.  * Offsets to fields in options other than EOL and NOP.
  137.  */
  138. #define    IPOPT_OPTVAL        0        /* option ID */
  139. #define    IPOPT_OLEN        1        /* option length */
  140. #define    IPOPT_OFFSET        2        /* offset within option */
  141. #define    IPOPT_MINOFF        4        /* min value of above */
  142.  
  143. #define    MAX_IPOPTLEN        40
  144.  
  145. /*
  146.  * Time stamp option structure.
  147.  */
  148. struct    ip_timestamp {
  149.     __u_char ipt_code;        /* IPOPT_TS */
  150.     __u_char ipt_len;        /* size of structure (variable) */
  151.     __u_char ipt_ptr;        /* index of current entry */
  152. #if __BYTE_ORDER == __LITTLE_ENDIAN
  153.     __u_char ipt_flg:4,        /* flags, see below */
  154.          ipt_oflw:4;        /* overflow counter */
  155. #endif
  156. #if __BYTE_ORDER == __BIG_ENDIAN
  157.     __u_char ipt_oflw:4,        /* overflow counter */
  158.          ipt_flg:4;        /* flags, see below */
  159. #endif
  160.     __u_long data[9];
  161. };
  162.  
  163. /* flag bits for ipt_flg */
  164. #define    IPOPT_TS_TSONLY        0        /* timestamps only */
  165. #define    IPOPT_TS_TSANDADDR    1        /* timestamps and addresses */
  166. #define    IPOPT_TS_PRESPEC    3        /* specified modules only */
  167.  
  168. /* bits for security (not byte swapped) */
  169. #define    IPOPT_SECUR_UNCLASS    0x0000
  170. #define    IPOPT_SECUR_CONFID    0xf135
  171. #define    IPOPT_SECUR_EFTO    0x789a
  172. #define    IPOPT_SECUR_MMMM    0xbc4d
  173. #define    IPOPT_SECUR_RESTR    0xaf13
  174. #define    IPOPT_SECUR_SECRET    0xd788
  175. #define    IPOPT_SECUR_TOPSECRET    0x6bc5
  176.  
  177. /*
  178.  * Internet implementation parameters.
  179.  */
  180. #define    MAXTTL        255        /* maximum time to live (seconds) */
  181. #define    IPDEFTTL    64        /* default ttl, from RFC 1340 */
  182. #define    IPFRAGTTL    60        /* time to live for frags, slowhz */
  183. #define    IPTTLDEC    1        /* subtracted when forwarding */
  184.  
  185. #define    IP_MSS        576        /* default maximum segment size */
  186.  
  187. __END_DECLS
  188.  
  189. #endif /* netinet/ip.h. */
  190.