]>
Commit | Line | Data |
---|---|---|
1c79356b A |
1 | /* |
2 | * Copyright (c) 2000 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
d7e50217 | 6 | * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved. |
1c79356b | 7 | * |
d7e50217 A |
8 | * This file contains Original Code and/or Modifications of Original Code |
9 | * as defined in and that are subject to the Apple Public Source License | |
10 | * Version 2.0 (the 'License'). You may not use this file except in | |
11 | * compliance with the License. Please obtain a copy of the License at | |
12 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
13 | * file. | |
14 | * | |
15 | * The Original Code and all software distributed under the License are | |
16 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
1c79356b A |
17 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
18 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
d7e50217 A |
19 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
20 | * Please see the License for the specific language governing rights and | |
21 | * limitations under the License. | |
1c79356b A |
22 | * |
23 | * @APPLE_LICENSE_HEADER_END@ | |
24 | */ | |
25 | /* | |
26 | * Copyright (c) 1982, 1986, 1993 | |
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 | * @(#)ip_var.h 8.2 (Berkeley) 1/9/95 | |
58 | */ | |
59 | ||
60 | #ifndef _NETINET_IP_VAR_H_ | |
61 | #define _NETINET_IP_VAR_H_ | |
9bccf70c | 62 | #include <sys/appleapiopts.h> |
1c79356b | 63 | |
9bccf70c | 64 | #ifdef __APPLE_API_PRIVATE |
1c79356b A |
65 | /* |
66 | * Overlay for ip header used by other protocols (tcp, udp). | |
67 | */ | |
68 | struct ipovly { | |
69 | u_char ih_x1[9]; /* (unused) */ | |
70 | u_char ih_pr; /* protocol */ | |
71 | u_short ih_len; /* protocol length */ | |
72 | struct in_addr ih_src; /* source internet address */ | |
73 | struct in_addr ih_dst; /* destination internet address */ | |
74 | }; | |
75 | ||
76 | /* | |
77 | * Ip reassembly queue structure. Each fragment | |
78 | * being reassembled is attached to one of these structures. | |
79 | * They are timed out after ipq_ttl drops to 0, and may also | |
80 | * be reclaimed if memory becomes tight. | |
81 | */ | |
82 | struct ipq { | |
83 | struct ipq *next,*prev; /* to other reass headers */ | |
84 | u_char ipq_ttl; /* time for reass q to live */ | |
85 | u_char ipq_p; /* protocol of this fragment */ | |
86 | u_short ipq_id; /* sequence id for reassembly */ | |
87 | struct mbuf *ipq_frags; /* to ip headers of fragments */ | |
88 | struct in_addr ipq_src,ipq_dst; | |
0b4e3aa0 | 89 | u_long reserved[4]; /* for future use */ |
1c79356b | 90 | #if IPDIVERT |
9bccf70c A |
91 | #ifdef IPDIVERT_44 |
92 | u_int32_t ipq_div_info; /* ipfw divert port & flags */ | |
93 | #else | |
94 | u_int16_t ipq_divert; /* ipfw divert port (Maintain backward compat.) */ | |
95 | #endif | |
96 | u_int16_t ipq_div_cookie; /* ipfw divert cookie */ | |
1c79356b A |
97 | #endif |
98 | }; | |
99 | ||
100 | /* | |
101 | * Structure stored in mbuf in inpcb.ip_options | |
102 | * and passed to ip_output when ip options are in use. | |
103 | * The actual length of the options (including ipopt_dst) | |
104 | * is in m_len. | |
105 | */ | |
106 | #define MAX_IPOPTLEN 40 | |
107 | ||
108 | struct ipoption { | |
109 | struct in_addr ipopt_dst; /* first-hop dst if source routed */ | |
110 | char ipopt_list[MAX_IPOPTLEN]; /* options proper */ | |
111 | }; | |
112 | ||
113 | /* | |
114 | * Structure attached to inpcb.ip_moptions and | |
115 | * passed to ip_output when IP multicast options are in use. | |
116 | */ | |
117 | struct ip_moptions { | |
118 | struct ifnet *imo_multicast_ifp; /* ifp for outgoing multicasts */ | |
119 | u_char imo_multicast_ttl; /* TTL for outgoing multicasts */ | |
120 | u_char imo_multicast_loop; /* 1 => hear sends if a member */ | |
121 | u_short imo_num_memberships; /* no. memberships this socket */ | |
122 | struct in_multi *imo_membership[IP_MAX_MEMBERSHIPS]; | |
123 | u_long imo_multicast_vif; /* vif num outgoing multicasts */ | |
9bccf70c | 124 | struct in_addr imo_multicast_addr; /* ifindex/addr on MULTICAST_IF */ |
1c79356b | 125 | }; |
9bccf70c | 126 | #endif /* __APPLE_API_PRIVATE */ |
1c79356b | 127 | |
9bccf70c | 128 | #ifdef __APPLE_API_UNSTABLE |
1c79356b A |
129 | struct ipstat { |
130 | u_long ips_total; /* total packets received */ | |
131 | u_long ips_badsum; /* checksum bad */ | |
132 | u_long ips_tooshort; /* packet too short */ | |
133 | u_long ips_toosmall; /* not enough data */ | |
134 | u_long ips_badhlen; /* ip header length < data size */ | |
135 | u_long ips_badlen; /* ip length < ip header length */ | |
136 | u_long ips_fragments; /* fragments received */ | |
137 | u_long ips_fragdropped; /* frags dropped (dups, out of space) */ | |
138 | u_long ips_fragtimeout; /* fragments timed out */ | |
139 | u_long ips_forward; /* packets forwarded */ | |
140 | u_long ips_fastforward; /* packets fast forwarded */ | |
141 | u_long ips_cantforward; /* packets rcvd for unreachable dest */ | |
142 | u_long ips_redirectsent; /* packets forwarded on same net */ | |
143 | u_long ips_noproto; /* unknown or unsupported protocol */ | |
144 | u_long ips_delivered; /* datagrams delivered to upper level*/ | |
145 | u_long ips_localout; /* total ip packets generated here */ | |
146 | u_long ips_odropped; /* lost packets due to nobufs, etc. */ | |
147 | u_long ips_reassembled; /* total packets reassembled ok */ | |
148 | u_long ips_fragmented; /* datagrams successfully fragmented */ | |
149 | u_long ips_ofragments; /* output fragments created */ | |
150 | u_long ips_cantfrag; /* don't fragment flag was set, etc. */ | |
151 | u_long ips_badoptions; /* error in option processing */ | |
152 | u_long ips_noroute; /* packets discarded due to no route */ | |
153 | u_long ips_badvers; /* ip version != 4 */ | |
154 | u_long ips_rawout; /* total raw ip packets generated */ | |
155 | u_long ips_toolong; /* ip length > max ip packet size */ | |
156 | u_long ips_notmember; /* multicasts for unregistered grps */ | |
157 | u_long ips_nogif; /* no match gif found */ | |
9bccf70c | 158 | u_long ips_badaddr; /* invalid address on header */ |
1c79356b | 159 | }; |
9bccf70c A |
160 | #endif /* __APPLE_API_UNSTABLE */ |
161 | ||
162 | #ifdef __APPLE_API_PRIVATE | |
163 | #ifdef KERNEL | |
1c79356b | 164 | |
9bccf70c A |
165 | struct ip_linklocal_stat { |
166 | u_long iplls_in_total; | |
167 | u_long iplls_in_badttl; | |
168 | u_long iplls_out_total; | |
169 | u_long iplls_out_badttl; | |
170 | }; | |
1c79356b A |
171 | |
172 | /* flags passed to ip_output as last parameter */ | |
173 | #define IP_FORWARDING 0x1 /* most of ip header exists */ | |
174 | #define IP_RAWOUTPUT 0x2 /* raw ip header exists */ | |
175 | #define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */ | |
176 | #define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */ | |
177 | ||
178 | struct ip; | |
179 | struct inpcb; | |
180 | struct route; | |
181 | struct sockopt; | |
182 | ||
183 | extern struct ipstat ipstat; | |
9bccf70c | 184 | #if !defined(RANDOM_IP_ID) || RANDOM_IP_ID == 0 |
1c79356b | 185 | extern u_short ip_id; /* ip packet ctr, for ids */ |
9bccf70c | 186 | #endif |
1c79356b A |
187 | extern int ip_defttl; /* default IP ttl */ |
188 | extern int ipforwarding; /* ip forwarding */ | |
189 | extern struct protosw *ip_protox[]; | |
190 | extern struct socket *ip_rsvpd; /* reservation protocol daemon */ | |
191 | extern struct socket *ip_mrouter; /* multicast routing daemon */ | |
192 | extern int (*legal_vif_num) __P((int)); | |
193 | extern u_long (*ip_mcast_src) __P((int)); | |
194 | extern int rsvp_on; | |
195 | extern struct pr_usrreqs rip_usrreqs; | |
196 | ||
197 | int ip_ctloutput __P((struct socket *, struct sockopt *sopt)); | |
198 | void ip_drain __P((void)); | |
199 | void ip_freemoptions __P((struct ip_moptions *)); | |
200 | void ip_init __P((void)); | |
201 | extern int (*ip_mforward) __P((struct ip *, struct ifnet *, struct mbuf *, | |
202 | struct ip_moptions *)); | |
203 | int ip_output __P((struct mbuf *, | |
204 | struct mbuf *, struct route *, int, struct ip_moptions *)); | |
205 | void ip_savecontrol __P((struct inpcb *, struct mbuf **, struct ip *, | |
206 | struct mbuf *)); | |
207 | void ip_slowtimo __P((void)); | |
208 | struct mbuf * | |
209 | ip_srcroute __P((void)); | |
210 | void ip_stripoptions __P((struct mbuf *, struct mbuf *)); | |
9bccf70c A |
211 | #if RANDOM_IP_ID |
212 | u_int16_t | |
213 | ip_randomid __P((void)); | |
214 | #endif | |
1c79356b A |
215 | int rip_ctloutput __P((struct socket *, struct sockopt *)); |
216 | void rip_ctlinput __P((int, struct sockaddr *, void *)); | |
217 | void rip_init __P((void)); | |
218 | void rip_input __P((struct mbuf *, int)); | |
219 | int rip_output __P((struct mbuf *, struct socket *, u_long)); | |
220 | void ipip_input __P((struct mbuf *, int)); | |
221 | void rsvp_input __P((struct mbuf *, int)); | |
222 | int ip_rsvp_init __P((struct socket *)); | |
223 | int ip_rsvp_done __P((void)); | |
224 | int ip_rsvp_vif_init __P((struct socket *, struct sockopt *)); | |
225 | int ip_rsvp_vif_done __P((struct socket *, struct sockopt *)); | |
226 | void ip_rsvp_force_done __P((struct socket *)); | |
227 | ||
228 | #if IPDIVERT | |
229 | void div_init __P((void)); | |
230 | void div_input __P((struct mbuf *, int)); | |
9bccf70c | 231 | void divert_packet __P((struct mbuf *, int, int)); |
1c79356b | 232 | extern struct pr_usrreqs div_usrreqs; |
9bccf70c | 233 | extern u_int16_t ip_divert_cookie; |
1c79356b A |
234 | #endif |
235 | ||
236 | extern struct sockaddr_in *ip_fw_fwd_addr; | |
237 | ||
9bccf70c A |
238 | void in_delayed_cksum(struct mbuf *m); |
239 | ||
240 | #endif /* _KERNEL */ | |
241 | #endif /* __APPLE_API_PRIVATE */ | |
1c79356b A |
242 | |
243 | #endif /* !_NETINET_IP_VAR_H_ */ |