1 |
/*!\file netinet/ip_var.h
|
1 |
/*!\file netinet/ip_var.h
|
2 |
* Internal IP definitions and statistics.
|
2 |
* Internal IP definitions and statistics.
|
3 |
*/
|
3 |
*/
|
4 |
|
4 |
|
5 |
/*
|
5 |
/*
|
6 |
* Copyright (c) 1982, 1986, 1993
|
6 |
* Copyright (c) 1982, 1986, 1993
|
7 |
* The Regents of the University of California. All rights reserved.
|
7 |
* The Regents of the University of California. All rights reserved.
|
8 |
*
|
8 |
*
|
9 |
* Redistribution and use in source and binary forms, with or without
|
9 |
* Redistribution and use in source and binary forms, with or without
|
10 |
* modification, are permitted provided that the following conditions
|
10 |
* modification, are permitted provided that the following conditions
|
11 |
* are met:
|
11 |
* are met:
|
12 |
* 1. Redistributions of source code must retain the above copyright
|
12 |
* 1. Redistributions of source code must retain the above copyright
|
13 |
* notice, this list of conditions and the following disclaimer.
|
13 |
* notice, this list of conditions and the following disclaimer.
|
14 |
* 2. Redistributions in binary form must reproduce the above copyright
|
14 |
* 2. Redistributions in binary form must reproduce the above copyright
|
15 |
* notice, this list of conditions and the following disclaimer in the
|
15 |
* notice, this list of conditions and the following disclaimer in the
|
16 |
* documentation and/or other materials provided with the distribution.
|
16 |
* documentation and/or other materials provided with the distribution.
|
17 |
* 3. All advertising materials mentioning features or use of this software
|
17 |
* 3. All advertising materials mentioning features or use of this software
|
18 |
* must display the following acknowledgement:
|
18 |
* must display the following acknowledgement:
|
19 |
* This product includes software developed by the University of
|
19 |
* This product includes software developed by the University of
|
20 |
* California, Berkeley and its contributors.
|
20 |
* California, Berkeley and its contributors.
|
21 |
* 4. Neither the name of the University nor the names of its contributors
|
21 |
* 4. Neither the name of the University nor the names of its contributors
|
22 |
* may be used to endorse or promote products derived from this software
|
22 |
* may be used to endorse or promote products derived from this software
|
23 |
* without specific prior written permission.
|
23 |
* without specific prior written permission.
|
24 |
*
|
24 |
*
|
25 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
25 |
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
26 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26 |
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
27 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
27 |
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
28 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
28 |
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
|
29 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
29 |
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
30 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
30 |
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
31 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
31 |
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
32 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
32 |
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
33 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
33 |
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
34 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
34 |
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
35 |
* SUCH DAMAGE.
|
35 |
* SUCH DAMAGE.
|
36 |
*
|
36 |
*
|
37 |
* @(#)ip_var.h 8.2 (Berkeley) 1/9/95
|
37 |
* @(#)ip_var.h 8.2 (Berkeley) 1/9/95
|
38 |
* $Id: ip_var.h,v 1.24.2.2 1996/11/12 11:28:59 phk Exp $
|
38 |
* $Id: ip_var.h,v 1.24.2.2 1996/11/12 11:28:59 phk Exp $
|
39 |
*/
|
39 |
*/
|
40 |
|
40 |
|
41 |
#ifndef __NETINET_IP_VAR_H
|
41 |
#ifndef __NETINET_IP_VAR_H
|
42 |
#define __NETINET_IP_VAR_H
|
42 |
#define __NETINET_IP_VAR_H
|
43 |
|
43 |
|
44 |
#include <sys/packon.h>
|
44 |
#include <sys/packon.h>
|
45 |
|
45 |
|
46 |
#if defined(__TURBOC__) || defined(__BORLANDC__)
|
46 |
#if defined(__TURBOC__) || defined(__BORLANDC__)
|
47 |
#pragma warn -bbf- /* "Bitfields must be signed or unsigned int" warning */
|
47 |
#pragma warn -bbf- /* "Bitfields must be signed or unsigned int" warning */
|
48 |
#endif
|
48 |
#endif
|
49 |
|
49 |
|
50 |
/*
|
50 |
/*
|
51 |
* Overlay for ip header used by other protocols (tcp, udp).
|
51 |
* Overlay for ip header used by other protocols (tcp, udp).
|
52 |
*/
|
52 |
*/
|
53 |
struct ipovly {
|
53 |
struct ipovly {
|
54 |
caddr_t ih_next, ih_prev; /* for protocol sequence q's */
|
54 |
caddr_t ih_next, ih_prev; /* for protocol sequence q's */
|
55 |
u_char ih_x1; /* (unused) */
|
55 |
u_char ih_x1; /* (unused) */
|
56 |
u_char ih_pr; /* protocol */
|
56 |
u_char ih_pr; /* protocol */
|
57 |
u_short ih_len; /* protocol length */
|
57 |
u_short ih_len; /* protocol length */
|
58 |
struct in_addr ih_src; /* source internet address */
|
58 |
struct in_addr ih_src; /* source internet address */
|
59 |
struct in_addr ih_dst; /* destination internet address */
|
59 |
struct in_addr ih_dst; /* destination internet address */
|
60 |
};
|
60 |
};
|
61 |
|
61 |
|
62 |
|
62 |
|
63 |
/*
|
63 |
/*
|
64 |
* Ip header, when holding a fragment.
|
64 |
* Ip header, when holding a fragment.
|
65 |
*
|
65 |
*
|
66 |
* Note: ipf_next must be at same offset as ipq_next above
|
66 |
* Note: ipf_next must be at same offset as ipq_next above
|
67 |
*/
|
67 |
*/
|
68 |
struct ipasfrag {
|
68 |
struct ipasfrag {
|
69 |
u_char ip_hl:4;
|
69 |
u_char ip_hl:4;
|
70 |
u_char ip_v:4;
|
70 |
u_char ip_v:4;
|
71 |
u_char ipf_mff; /* XXX overlays ip_tos: use low bit
|
71 |
u_char ipf_mff; /* XXX overlays ip_tos: use low bit
|
72 |
* to avoid destroying tos;
|
72 |
* to avoid destroying tos;
|
73 |
* copied from (ip_off&IP_MF) */
|
73 |
* copied from (ip_off&IP_MF) */
|
74 |
u_short ip_len;
|
74 |
u_short ip_len;
|
75 |
u_short ip_id;
|
75 |
u_short ip_id;
|
76 |
u_short ip_off;
|
76 |
u_short ip_off;
|
77 |
u_char ip_ttl;
|
77 |
u_char ip_ttl;
|
78 |
u_char ip_p;
|
78 |
u_char ip_p;
|
79 |
u_short ip_sum;
|
79 |
u_short ip_sum;
|
80 |
struct ipasfrag *ipf_next; /* next fragment */
|
80 |
struct ipasfrag *ipf_next; /* next fragment */
|
81 |
struct ipasfrag *ipf_prev; /* previous fragment */
|
81 |
struct ipasfrag *ipf_prev; /* previous fragment */
|
82 |
};
|
82 |
};
|
83 |
|
83 |
|
84 |
#include <sys/packoff.h>
|
84 |
#include <sys/packoff.h>
|
85 |
|
85 |
|
86 |
/*
|
86 |
/*
|
87 |
* Ip reassembly queue structure. Each fragment
|
87 |
* Ip reassembly queue structure. Each fragment
|
88 |
* being reassembled is attached to one of these structures.
|
88 |
* being reassembled is attached to one of these structures.
|
89 |
* They are timed out after ipq_ttl drops to 0, and may also
|
89 |
* They are timed out after ipq_ttl drops to 0, and may also
|
90 |
* be reclaimed if memory becomes tight.
|
90 |
* be reclaimed if memory becomes tight.
|
91 |
*/
|
91 |
*/
|
92 |
struct ipq {
|
92 |
struct ipq {
|
93 |
struct ipq *next,*prev; /* to other reass headers */
|
93 |
struct ipq *next,*prev; /* to other reass headers */
|
94 |
u_char ipq_ttl; /* time for reass q to live */
|
94 |
u_char ipq_ttl; /* time for reass q to live */
|
95 |
u_char ipq_p; /* protocol of this fragment */
|
95 |
u_char ipq_p; /* protocol of this fragment */
|
96 |
u_short ipq_id; /* sequence id for reassembly */
|
96 |
u_short ipq_id; /* sequence id for reassembly */
|
97 |
struct ipasfrag *ipq_next,*ipq_prev;
|
97 |
struct ipasfrag *ipq_next,*ipq_prev;
|
98 |
/* to ip headers of fragments */
|
98 |
/* to ip headers of fragments */
|
99 |
struct in_addr ipq_src,ipq_dst;
|
99 |
struct in_addr ipq_src,ipq_dst;
|
100 |
#ifdef IPDIVERT
|
100 |
#ifdef IPDIVERT
|
101 |
u_short ipq_divert; /* divert protocol port */
|
101 |
u_short ipq_divert; /* divert protocol port */
|
102 |
#endif
|
102 |
#endif
|
103 |
};
|
103 |
};
|
104 |
|
104 |
|
105 |
/*
|
105 |
/*
|
106 |
* Structure stored in mbuf in inpcb.ip_options
|
106 |
* Structure stored in mbuf in inpcb.ip_options
|
107 |
* and passed to ip_output when ip options are in use.
|
107 |
* and passed to ip_output when ip options are in use.
|
108 |
* The actual length of the options (including ipopt_dst)
|
108 |
* The actual length of the options (including ipopt_dst)
|
109 |
* is in m_len.
|
109 |
* is in m_len.
|
110 |
*/
|
110 |
*/
|
111 |
#define MAX_IPOPTLEN 40
|
111 |
#define MAX_IPOPTLEN 40
|
112 |
|
112 |
|
113 |
struct ipoption {
|
113 |
struct ipoption {
|
114 |
struct in_addr ipopt_dst; /* first-hop dst if source routed */
|
114 |
struct in_addr ipopt_dst; /* first-hop dst if source routed */
|
115 |
char ipopt_list[MAX_IPOPTLEN]; /* options proper */
|
115 |
char ipopt_list[MAX_IPOPTLEN]; /* options proper */
|
116 |
};
|
116 |
};
|
117 |
|
117 |
|
118 |
/*
|
118 |
/*
|
119 |
* Structure attached to inpcb.ip_moptions and
|
119 |
* Structure attached to inpcb.ip_moptions and
|
120 |
* passed to ip_output when IP multicast options are in use.
|
120 |
* passed to ip_output when IP multicast options are in use.
|
121 |
*/
|
121 |
*/
|
122 |
struct ip_moptions {
|
122 |
struct ip_moptions {
|
123 |
struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
|
123 |
struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */
|
124 |
u_char imo_multicast_ttl; /* TTL for outgoing multicasts */
|
124 |
u_char imo_multicast_ttl; /* TTL for outgoing multicasts */
|
125 |
u_char imo_multicast_loop; /* 1 => hear sends if a member */
|
125 |
u_char imo_multicast_loop; /* 1 => hear sends if a member */
|
126 |
u_short imo_num_memberships; /* no. memberships this socket */
|
126 |
u_short imo_num_memberships; /* no. memberships this socket */
|
127 |
struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
|
127 |
struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS];
|
128 |
u_long imo_multicast_vif; /* vif num outgoing multicasts */
|
128 |
u_long imo_multicast_vif; /* vif num outgoing multicasts */
|
129 |
};
|
129 |
};
|
130 |
|
130 |
|
131 |
struct ipstat {
|
131 |
struct ipstat {
|
132 |
u_long ips_total; /* total packets received */
|
132 |
u_long ips_total; /* total packets received */
|
133 |
u_long ips_badsum; /* checksum bad */
|
133 |
u_long ips_badsum; /* checksum bad */
|
134 |
u_long ips_tooshort; /* packet too short */
|
134 |
u_long ips_tooshort; /* packet too short */
|
135 |
u_long ips_toosmall; /* not enough data */
|
135 |
u_long ips_toosmall; /* not enough data */
|
136 |
u_long ips_badhlen; /* ip header length < data size */
|
136 |
u_long ips_badhlen; /* ip header length < data size */
|
137 |
u_long ips_badlen; /* ip length < ip header length */
|
137 |
u_long ips_badlen; /* ip length < ip header length */
|
138 |
u_long ips_fragments; /* fragments received */
|
138 |
u_long ips_fragments; /* fragments received */
|
139 |
u_long ips_fragdropped; /* frags dropped (dups, out of space) */
|
139 |
u_long ips_fragdropped; /* frags dropped (dups, out of space) */
|
140 |
u_long ips_fragtimeout; /* fragments timed out */
|
140 |
u_long ips_fragtimeout; /* fragments timed out */
|
141 |
u_long ips_forward; /* packets forwarded */
|
141 |
u_long ips_forward; /* packets forwarded */
|
142 |
u_long ips_cantforward; /* packets rcvd for unreachable dest */
|
142 |
u_long ips_cantforward; /* packets rcvd for unreachable dest */
|
143 |
u_long ips_redirectsent; /* packets forwarded on same net */
|
143 |
u_long ips_redirectsent; /* packets forwarded on same net */
|
144 |
u_long ips_noproto; /* unknown or unsupported protocol */
|
144 |
u_long ips_noproto; /* unknown or unsupported protocol */
|
145 |
u_long ips_delivered; /* datagrams delivered to upper level*/
|
145 |
u_long ips_delivered; /* datagrams delivered to upper level*/
|
146 |
u_long ips_localout; /* total ip packets generated here */
|
146 |
u_long ips_localout; /* total ip packets generated here */
|
147 |
u_long ips_odropped; /* lost out packets due to nobufs, etc. */
|
147 |
u_long ips_odropped; /* lost out packets due to nobufs, etc. */
|
148 |
u_long ips_idropped; /*!! new, lost in packets due to nobufs, etc. */
|
148 |
u_long ips_idropped; /*!! new, lost in packets due to nobufs, etc. */
|
149 |
u_long ips_reassembled; /* total packets reassembled ok */
|
149 |
u_long ips_reassembled; /* total packets reassembled ok */
|
150 |
u_long ips_fragmented; /* datagrams successfully fragmented */
|
150 |
u_long ips_fragmented; /* datagrams successfully fragmented */
|
151 |
u_long ips_ofragments; /* output fragments created */
|
151 |
u_long ips_ofragments; /* output fragments created */
|
152 |
u_long ips_cantfrag; /* don't fragment flag was set, etc. */
|
152 |
u_long ips_cantfrag; /* don't fragment flag was set, etc. */
|
153 |
u_long ips_badoptions; /* error in option processing */
|
153 |
u_long ips_badoptions; /* error in option processing */
|
154 |
u_long ips_noroute; /* packets discarded due to no route */
|
154 |
u_long ips_noroute; /* packets discarded due to no route */
|
155 |
u_long ips_badvers; /* ip version != 4 */
|
155 |
u_long ips_badvers; /* ip version != 4 */
|
156 |
u_long ips_rawout; /* total raw ip packets generated */
|
156 |
u_long ips_rawout; /* total raw ip packets generated */
|
157 |
u_long ips_toolong; /* ip length > max ip packet size */
|
157 |
u_long ips_toolong; /* ip length > max ip packet size */
|
158 |
};
|
158 |
};
|
159 |
|
159 |
|
160 |
#if defined(__TURBOC__) || defined(__BORLANDC__)
|
160 |
#if defined(__TURBOC__) || defined(__BORLANDC__)
|
161 |
#pragma warn -bbf.
|
161 |
#pragma warn -bbf.
|
162 |
#endif
|
162 |
#endif
|
163 |
|
163 |
|
164 |
#endif
|
164 |
#endif
|
165 |
|
165 |
|