ip.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:7k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* ip.h - internet protocol header file */
  2. /* Copyright 1984-1996 Wind River Systems, Inc. */
  3. /*
  4.  * Copyright (c) 1982, 1986, 1993
  5.  * The Regents of the University of California.  All rights reserved.
  6.  *
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Redistributions in binary form must reproduce the above copyright
  13.  *    notice, this list of conditions and the following disclaimer in the
  14.  *    documentation and/or other materials provided with the distribution.
  15.  * 3. All advertising materials mentioning features or use of this software
  16.  *    must display the following acknowledgement:
  17.  * This product includes software developed by the University of
  18.  * California, Berkeley and its contributors.
  19.  * 4. Neither the name of the University nor the names of its contributors
  20.  *    may be used to endorse or promote products derived from this software
  21.  *    without specific prior written permission.
  22.  *
  23.  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  24.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  27.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33.  * SUCH DAMAGE.
  34.  *
  35.  * @(#)ip.h 8.2 (Berkeley) 6/1/94
  36.  */
  37. /*
  38. modification history
  39. --------------------
  40. 02o,31aug00,rae  added Router Alert Option (IPOPT_RA)
  41. 02n,15jul97,spm  made IP checksum calculation configurable (SPR #7836)
  42. 02m,24feb97,bjl  moved struct ipt_ta declatation outside of union 
  43.  ipt_timestamp to make struct ipt_ta globally visible for c++
  44. 01b,11apr97,rjc  added min cost tos.
  45. 01a,03mar96,vin  created from BSD4.4 stuff,integrated with 02l.
  46.  Corrected bitfields according to the ansi spec.
  47. */
  48. #ifndef __INCiph
  49. #define __INCiph
  50. #ifdef __cplusplus
  51. extern "C" {
  52. #endif
  53. #include "vxWorks.h"
  54. /* Definitions for selecting IP checksum calculations (also see netLib.h). */
  55. #define IP_CKSUM_SEND_MASK      0x1
  56. #define IP_CKSUM_RECV_MASK      0x2
  57. #ifndef _BYTE_ORDER
  58. /*
  59.  * Definitions for byte order,
  60.  * according to byte significance from low address to high.
  61.  */
  62. #define _LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
  63. #define _BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
  64. #define _PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
  65. #ifdef vax
  66. #define _BYTE_ORDER      _LITTLE_ENDIAN
  67. #else
  68. #define _BYTE_ORDER      _BIG_ENDIAN      /* mc68000, tahoe, most others */
  69. #endif
  70. #endif /* _BYTE_ORDER */
  71. /*
  72.  * Definitions for internet protocol version 4.
  73.  * Per RFC 791, September 1981.
  74.  */
  75. #define IPVERSION 4
  76. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  77. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  78. #endif  /* CPU_FAMILY==I960 */
  79. /*
  80.  * Structure of an internet header, naked of options.
  81.  *
  82.  * We declare ip_len and ip_off to be short, rather than u_short
  83.  * pragmatically since otherwise unsigned comparisons can result
  84.  * against negative integers quite easily, and fail in subtle ways.
  85.  */
  86. struct ip {
  87. #if _BYTE_ORDER == _LITTLE_ENDIAN
  88. u_int ip_hl:4, /* header length */
  89. ip_v:4, /* version */
  90. #endif
  91. #if _BYTE_ORDER == _BIG_ENDIAN
  92. u_int ip_v:4, /* version */
  93. ip_hl:4, /* header length */
  94. #endif
  95. ip_tos:8, /* type of service */
  96. ip_len:16; /* total length */
  97. u_short ip_id; /* identification */
  98. short ip_off; /* fragment offset field */
  99. #define IP_DF 0x4000 /* dont fragment flag */
  100. #define IP_MF 0x2000 /* more fragments flag */
  101. #define IP_OFFMASK 0x1fff /* mask for fragmenting bits */
  102. u_char ip_ttl; /* time to live */
  103. u_char ip_p; /* protocol */
  104. u_short ip_sum; /* checksum */
  105. struct in_addr ip_src,ip_dst; /* source and dest address */
  106. };
  107. #define IP_MAXPACKET 65535 /* maximum packet size */
  108. /*
  109.  * Definitions for IP type of service (ip_tos)
  110.  */
  111. #define IPTOS_LOWDELAY 0x10
  112. #define IPTOS_THROUGHPUT 0x08
  113. #define IPTOS_RELIABILITY 0x04
  114. #define IPTOS_MINCOST 0x02
  115. /*
  116.  * Definitions for IP precedence (also in ip_tos) (hopefully unused)
  117.  */
  118. #define IPTOS_PREC_NETCONTROL 0xe0
  119. #define IPTOS_PREC_INTERNETCONTROL 0xc0
  120. #define IPTOS_PREC_CRITIC_ECP 0xa0
  121. #define IPTOS_PREC_FLASHOVERRIDE 0x80
  122. #define IPTOS_PREC_FLASH 0x60
  123. #define IPTOS_PREC_IMMEDIATE 0x40
  124. #define IPTOS_PREC_PRIORITY 0x20
  125. #define IPTOS_PREC_ROUTINE 0x00
  126. /*
  127.  * Definitions for options.
  128.  */
  129. #define IPOPT_COPIED(o) ((o)&0x80)
  130. #define IPOPT_CLASS(o) ((o)&0x60)
  131. #define IPOPT_NUMBER(o) ((o)&0x1f)
  132. #define IPOPT_CONTROL 0x00
  133. #define IPOPT_RESERVED1 0x20
  134. #define IPOPT_DEBMEAS 0x40
  135. #define IPOPT_RESERVED2 0x60
  136. #define IPOPT_EOL 0 /* end of option list */
  137. #define IPOPT_NOP 1 /* no operation */
  138. #define IPOPT_RR 7 /* record packet route */
  139. #define IPOPT_TS 68 /* timestamp */
  140. #define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
  141. #define IPOPT_LSRR 131 /* loose source route */
  142. #define IPOPT_SATID 136 /* satnet id */
  143. #define IPOPT_SSRR 137 /* strict source route */
  144. #define IPOPT_RA 148 /* router alert */
  145. /*
  146.  * Offsets to fields in options other than EOL and NOP.
  147.  */
  148. #define IPOPT_OPTVAL 0 /* option ID */
  149. #define IPOPT_OLEN 1 /* option length */
  150. #define IPOPT_OFFSET 2 /* offset within option */
  151. #define IPOPT_MINOFF 4 /* min value of above */
  152. struct ipt_ta {
  153. struct in_addr ipt_addr;
  154. u_long ipt_time;
  155. };
  156. /*
  157.  * Time stamp option structure.
  158.  */
  159. struct ip_timestamp {
  160.         u_int ipt_code:8, /* IPOPT_TS */
  161. ipt_len:8, /* size of structure (variable) */
  162. ipt_ptr:8, /* index of current entry */
  163. #if _BYTE_ORDER == _LITTLE_ENDIAN
  164. ipt_flg:4, /* flags, see below */
  165. ipt_oflw:4; /* overflow counter */
  166. #endif
  167. #if _BYTE_ORDER == _BIG_ENDIAN
  168. ipt_oflw:4, /* overflow counter */
  169. ipt_flg:4; /* flags, see below */
  170. #endif
  171. union ipt_timestamp {
  172. u_long ipt_time[1];
  173. struct ipt_ta ipt_ta[1];
  174. } ipt_timestamp;
  175. };
  176. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  177. #pragma align 0                 /* turn off alignment requirement */
  178. #endif  /* CPU_FAMILY==I960 */
  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. /* bits for security (not byte swapped) */
  184. #define IPOPT_SECUR_UNCLASS 0x0000
  185. #define IPOPT_SECUR_CONFID 0xf135
  186. #define IPOPT_SECUR_EFTO 0x789a
  187. #define IPOPT_SECUR_MMMM 0xbc4d
  188. #define IPOPT_SECUR_RESTR 0xaf13
  189. #define IPOPT_SECUR_SECRET 0xd788
  190. #define IPOPT_SECUR_TOPSECRET 0x6bc5
  191. /*
  192.  * Internet implementation parameters.
  193.  */
  194. #define MAXTTL 255 /* maximum time to live (seconds) */
  195. #define IPDEFTTL 64 /* default ttl, from RFC 1340 */
  196. #define IPFRAGTTL 60 /* time to live for frags, slowhz */
  197. #define IPTTLDEC 1 /* subtracted when forwarding */
  198. #define IP_MSS 576 /* default maximum segment size */
  199. #define IPFORWARDING    1 /* Set IP to always forward */
  200. #ifdef __cplusplus
  201. }
  202. #endif
  203. #endif /* __INCiph */