]> git.saurik.com Git - apple/xnu.git/blame - bsd/netinet/ip_var.h
xnu-344.49.tar.gz
[apple/xnu.git] / bsd / netinet / ip_var.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
43866e37 6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
1c79356b 7 *
43866e37
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,
43866e37
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 */
68struct 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 */
82struct 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
108struct 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 */
117struct 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
129struct 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
165struct 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
178struct ip;
179struct inpcb;
180struct route;
181struct sockopt;
182
183extern struct ipstat ipstat;
9bccf70c 184#if !defined(RANDOM_IP_ID) || RANDOM_IP_ID == 0
1c79356b 185extern u_short ip_id; /* ip packet ctr, for ids */
9bccf70c 186#endif
1c79356b
A
187extern int ip_defttl; /* default IP ttl */
188extern int ipforwarding; /* ip forwarding */
189extern struct protosw *ip_protox[];
190extern struct socket *ip_rsvpd; /* reservation protocol daemon */
191extern struct socket *ip_mrouter; /* multicast routing daemon */
192extern int (*legal_vif_num) __P((int));
193extern u_long (*ip_mcast_src) __P((int));
194extern int rsvp_on;
195extern struct pr_usrreqs rip_usrreqs;
196
197int ip_ctloutput __P((struct socket *, struct sockopt *sopt));
198void ip_drain __P((void));
199void ip_freemoptions __P((struct ip_moptions *));
200void ip_init __P((void));
201extern int (*ip_mforward) __P((struct ip *, struct ifnet *, struct mbuf *,
202 struct ip_moptions *));
203int ip_output __P((struct mbuf *,
204 struct mbuf *, struct route *, int, struct ip_moptions *));
205void ip_savecontrol __P((struct inpcb *, struct mbuf **, struct ip *,
206 struct mbuf *));
207void ip_slowtimo __P((void));
208struct mbuf *
209 ip_srcroute __P((void));
210void ip_stripoptions __P((struct mbuf *, struct mbuf *));
9bccf70c
A
211#if RANDOM_IP_ID
212u_int16_t
213 ip_randomid __P((void));
214#endif
1c79356b
A
215int rip_ctloutput __P((struct socket *, struct sockopt *));
216void rip_ctlinput __P((int, struct sockaddr *, void *));
217void rip_init __P((void));
218void rip_input __P((struct mbuf *, int));
219int rip_output __P((struct mbuf *, struct socket *, u_long));
220void ipip_input __P((struct mbuf *, int));
221void rsvp_input __P((struct mbuf *, int));
222int ip_rsvp_init __P((struct socket *));
223int ip_rsvp_done __P((void));
224int ip_rsvp_vif_init __P((struct socket *, struct sockopt *));
225int ip_rsvp_vif_done __P((struct socket *, struct sockopt *));
226void ip_rsvp_force_done __P((struct socket *));
227
228#if IPDIVERT
229void div_init __P((void));
230void div_input __P((struct mbuf *, int));
9bccf70c 231void divert_packet __P((struct mbuf *, int, int));
1c79356b 232extern struct pr_usrreqs div_usrreqs;
9bccf70c 233extern u_int16_t ip_divert_cookie;
1c79356b
A
234#endif
235
236extern struct sockaddr_in *ip_fw_fwd_addr;
237
9bccf70c
A
238void in_delayed_cksum(struct mbuf *m);
239
240#endif /* _KERNEL */
241#endif /* __APPLE_API_PRIVATE */
1c79356b
A
242
243#endif /* !_NETINET_IP_VAR_H_ */