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

VxWorks

开发平台:

C/C++

  1. /* ip_var.h - internet protocol protocol variable header file */
  2. /* Copyright 1984 - 2002 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_var.h 8.2 (Berkeley) 1/9/95
  36.  */
  37. /*
  38. modification history
  39. --------------------
  40. 01h,15apr02,wap  reinstate netJobAdd() removal changes
  41. 01g,29mar02,wap  back out the previous change (needs more investigation)
  42. 01f,22mar02,rae  ipintr mod helps remove extra netJobAdd (SPR #74604)
  43. 01e,10oct01,rae  merge from truestack (ip_mroute update, VIRTUAL)
  44. 01d,05oct97,vin  moved ip_moptions to in_pcb.h for multicast hashing changes.
  45. 01c,31jan97,vin  changed declaration according to prototype decl in protosw.h
  46. 01b,22nov96,vin  modified ipq for new ipReAssembly
  47. 01a,03mar96,vin  created from BSD4.4lite2. corrected bit fields according to
  48.  ansi specfication
  49. */
  50. #ifndef __INCip_varh
  51. #define __INCip_varh
  52. #ifdef __cplusplus
  53. extern "C" {
  54. #endif
  55. #include "net/if.h"
  56. #include "netinet/in.h"
  57. #include "netinet/in_pcb.h"
  58. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  59. #pragma align 1                 /* tell gcc960 not to optimize alignments */
  60. #endif /* CPU_FAMILY==I960 */
  61. /*
  62.  * Overlay for ip header used by other protocols (tcp, udp).
  63.  */
  64. struct ipovly {
  65. caddr_t ih_next, ih_prev; /* for protocol sequence q's */
  66. u_char ih_x1; /* (unused) */
  67. u_char ih_pr; /* protocol */
  68. short ih_len; /* protocol length */
  69. struct in_addr ih_src; /* source internet address */
  70. struct in_addr ih_dst; /* destination internet address */
  71. };
  72. /*
  73.  * Ip reassembly queue structure.  Each fragment
  74.  * being reassembled is attached to one of these structures.
  75.  * They are timed out after ipq_ttl drops to 0, and may also
  76.  * be reclaimed if memory becomes tight.
  77.  */
  78. struct ipq {
  79. struct ipq *next,*prev; /* to other reass headers */
  80. u_char ipq_ttl; /* time for reass q to live */
  81. u_char ipq_p; /* protocol of this fragment */
  82. u_short ipq_id; /* sequence id for reassembly */
  83.      struct  mbuf * pMbufHdr;  /* back pointer to mbuf */
  84.      struct  mbuf * pMbufPkt; /* pointer to mbuf packet */
  85. /* to ip headers of fragments */
  86. struct in_addr ipq_src,ipq_dst;
  87. };
  88. /*
  89.  * Ip header, when holding a fragment.
  90.  *
  91.  * Note: ipf_next must be at same offset as ipq_next above
  92.  */
  93. struct ipasfrag {
  94. #if _BYTE_ORDER == _LITTLE_ENDIAN
  95. u_int ip_hl:4,
  96. ip_v:4,
  97. #endif
  98. #if _BYTE_ORDER == _BIG_ENDIAN
  99. u_int ip_v:4,
  100. ip_hl:4,
  101. #endif
  102. ipf_mff:8, /* XXX overlays ip_tos: use low bit
  103.  * to avoid destroying tos;
  104.  * copied from (ip_off&IP_MF) */
  105. ip_len:16;
  106. u_short ip_id;
  107. short ip_off;
  108. u_char ip_ttl;
  109. u_char ip_p;
  110. u_short ip_sum;
  111. struct in_addr ip_src,ip_dst; /* source and dest address */
  112. };
  113. /*
  114.  * Structure stored in mbuf in inpcb.ip_options
  115.  * and passed to ip_output when ip options are in use.
  116.  * The actual length of the options (including ipopt_dst)
  117.  * is in m_len.
  118.  */
  119. #define MAX_IPOPTLEN 40
  120. struct ipoption {
  121. struct in_addr ipopt_dst; /* first-hop dst if source routed */
  122. char ipopt_list[MAX_IPOPTLEN]; /* options proper */
  123. };
  124. struct ipstat {
  125. u_long ips_total; /* total packets received */
  126. u_long ips_badsum; /* checksum bad */
  127. u_long ips_tooshort; /* packet too short */
  128. u_long ips_toosmall; /* not enough data */
  129. u_long ips_badhlen; /* ip header length < data size */
  130. u_long ips_badlen; /* ip length < ip header length */
  131. u_long ips_fragments; /* fragments received */
  132. u_long ips_fragdropped; /* frags dropped (dups, out of space) */
  133. u_long ips_fragtimeout; /* fragments timed out */
  134. u_long ips_forward; /* packets forwarded */
  135. u_long ips_cantforward; /* packets rcvd for unreachable dest */
  136. u_long ips_redirectsent; /* packets forwarded on same net */
  137. u_long ips_noproto; /* unknown or unsupported protocol */
  138. u_long ips_delivered; /* datagrams delivered to upper level*/
  139. u_long ips_localout; /* total ip packets generated here */
  140. u_long ips_odropped; /* lost packets due to nobufs, etc. */
  141. u_long ips_reassembled; /* total packets reassembled ok */
  142. u_long ips_fragmented; /* datagrams sucessfully fragmented */
  143. u_long ips_ofragments; /* output fragments created */
  144. u_long ips_cantfrag; /* don't fragment flag was set, etc. */
  145. u_long ips_badoptions; /* error in option processing */
  146. u_long ips_noroute; /* packets discarded due to no route */
  147. u_long ips_badvers; /* ip version != 4 */
  148. u_long ips_rawout; /* total raw ip packets generated */
  149. };
  150. #if ((CPU_FAMILY==I960) && (defined __GNUC__))
  151. #pragma align 0                 /* turn off alignment requirement */
  152. #endif /* CPU_FAMILY==I960 */
  153. /* flags passed to ip_output as last parameter */
  154. #define IP_FORWARDING 0x1 /* most of ip header exists */
  155. #define IP_RAWOUTPUT 0x2 /* raw ip header exists */
  156. #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
  157. #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
  158. #define ipTimeToLive ip_defttl /* MIB-II Read Write Variable */
  159. #ifndef VIRTUAL_STACK
  160. extern struct ipstat ipstat;
  161. extern struct ipq ipq; /* ip reass. queue */
  162. extern u_short ip_id; /* ip packet ctr, for ids */
  163. extern int ip_defttl; /* default IP ttl */
  164. #endif /* VIRTUAL_STACK */
  165. extern int  ip_ctloutput (int, struct socket *, int, int, struct mbuf **);
  166. extern void  ip_deq (struct ipasfrag *);
  167. extern int  ip_dooptions (struct mbuf *);
  168. extern void  ip_drain (void);
  169. extern void  ip_enq (struct ipasfrag *, struct ipasfrag *);
  170. extern void  ip_forward (struct mbuf *, int);
  171. extern void  ip_freef (struct ipq *);
  172. extern void  ip_freemoptions (struct ip_moptions *, struct inpcb *);
  173. extern int  ip_getmoptions (int, struct ip_moptions *, struct mbuf **);
  174. extern void  ip_init (void);
  175. extern int  ip_mforward (struct mbuf *, struct ifnet *, struct ip *, struct ip_moptions*);
  176. extern int  ip_optcopy (struct ip *, struct ip *);
  177. extern int  ip_output (struct mbuf *, struct mbuf *, struct route *, 
  178.     int, struct ip_moptions *);
  179. extern int  ip_pcbopts (struct mbuf **, struct mbuf *);
  180. extern struct in_ifaddr * ip_rtaddr (struct in_addr);
  181. extern void  ip_slowtimo (void);
  182. extern struct mbuf * ip_srcroute (void);
  183. extern void  ip_stripoptions (struct mbuf *, struct mbuf *);
  184. extern int  ip_sysctl (int *, u_int, void *, size_t *, void *, size_t);
  185. extern void  ipintr (struct mbuf *m);
  186. extern int  rip_ctloutput (int, struct socket *, int, int, 
  187. struct mbuf **);
  188. extern void  rip_init (void);
  189. extern void  rip_input (struct mbuf *);
  190. extern int  rip_output (struct mbuf *, struct socket *, u_long);
  191. extern int  rip_usrreq (struct socket *, int, struct mbuf *, 
  192.      struct mbuf *, struct mbuf *);
  193. #ifdef __cplusplus
  194. }
  195. #endif
  196. #endif /* __INCip_varh */