Chameleon

Chameleon Svn Source Tree

Root/branches/JrCs/i386/include/netinet/in_pcb.h

1/*
2 * Copyright (c) 2000-2008 Apple Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28/*
29 * Copyright (c) 1982, 1986, 1990, 1993
30 *The Regents of the University of California. All rights reserved.
31 *
32 * Redistribution and use in source and binary forms, with or without
33 * modification, are permitted provided that the following conditions
34 * are met:
35 * 1. Redistributions of source code must retain the above copyright
36 * notice, this list of conditions and the following disclaimer.
37 * 2. Redistributions in binary form must reproduce the above copyright
38 * notice, this list of conditions and the following disclaimer in the
39 * documentation and/or other materials provided with the distribution.
40 * 3. All advertising materials mentioning features or use of this software
41 * must display the following acknowledgement:
42 *This product includes software developed by the University of
43 *California, Berkeley and its contributors.
44 * 4. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
47 *
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
58 * SUCH DAMAGE.
59 *
60 *@(#)in_pcb.h8.1 (Berkeley) 6/10/93
61 * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.32.2.4 2001/08/13 16:26:17 ume Exp $
62 */
63/*
64 * NOTICE: This file was modified by SPARTA, Inc. in 2007 to introduce
65 * support for mandatory and extensible security protections. This notice
66 * is included in support of clause 2.2 (b) of the Apple Public License,
67 * Version 2.0.
68 */
69
70#ifndef _NETINET_IN_PCB_H_
71#define _NETINET_IN_PCB_H_
72#include <sys/appleapiopts.h>
73
74#include <sys/types.h>
75#include <sys/queue.h>
76
77#include <netinet6/ipsec.h> /* for IPSEC */
78
79typedefu_quad_tinp_gen_t;
80
81/*
82 * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet.
83 * So, AF_INET6 null laddr is also used as AF_INET null laddr,
84 * by utilize following structure. (At last, same as INRIA)
85 */
86struct in_addr_4in6 {
87u_int32_tia46_pad32[3];
88structin_addria46_addr4;
89};
90
91
92/*
93 * The range of the generation count, as used in this implementation,
94 * is 9e19. We would have to create 300 billion connections per
95 * second for this number to roll over in a year. This seems sufficiently
96 * unlikely that we simply don't concern ourselves with that possibility.
97 */
98
99/*
100 * Interface exported to userland by various protocols which use
101 * inpcbs. Hack alert -- only define if struct xsocket is in scope.
102 */
103
104/*
105 * This is a copy of the inpcb as it shipped in Panther. This structure
106 * is filled out in a copy function. This allows the inpcb to change
107 * without breaking userland tools.
108 *
109 * CAUTION: Many fields may not be filled out. Fewer may be filled out
110 * in the future. Code defensively.
111 */
112
113#pragma pack(4)
114
115#if defined(__LP64__)
116struct _inpcb_list_entry {
117 u_int32_tle_next;
118 u_int32_tle_prev;
119};
120#define _INPCB_PTR(x)u_int32_t
121#define _INPCB_LIST_ENTRY(x)struct _inpcb_list_entry
122#else
123#define _INPCB_PTR(x)x
124#define _INPCB_LIST_ENTRY(x)LIST_ENTRY(x)
125#endif
126
127struct inpcbinfo;
128struct inpcbport;
129struct mbuf;
130struct ip6_pktopts;
131struct ip6_moptions;
132struct icmp6_filter;
133struct inpcbpolicy;
134
135struct inpcb {
136_INPCB_LIST_ENTRY(inpcb) inp_hash;/* hash list */
137structin_addr reserved1;/* APPLE reserved: inp_faddr defined in protcol indep. part */
138structin_addr reserved2; /* APPLE reserved */
139u_shortinp_fport;/* foreign port */
140u_shortinp_lport;/* local port */
141_INPCB_LIST_ENTRY(inpcb) inp_list;/* list for all PCBs of this proto */
142_INPCB_PTR(caddr_t)inp_ppcb;/* pointer to per-protocol pcb */
143_INPCB_PTR(struct inpcbinfo *)inp_pcbinfo;/* PCB list info */
144_INPCB_PTR(void *)inp_socket;/* back pointer to socket */
145u_charnat_owner;/* Used to NAT TCP/UDP traffic */
146u_int32_t nat_cookie;/* Cookie stored and returned to NAT */
147_INPCB_LIST_ENTRY(inpcb) inp_portlist;/* list for this PCB's local port */
148_INPCB_PTR(struct inpcbport *)inp_phd;/* head of this list */
149inp_gen_t inp_gencnt;/* generation count of this instance */
150intinp_flags;/* generic IP/datagram flags */
151u_int32_t inp_flow;
152
153u_charinp_vflag;
154
155u_char inp_ip_ttl;/* time to live proto */
156u_char inp_ip_p;/* protocol proto */
157/* protocol dependent part */
158union {
159/* foreign host table entry */
160structin_addr_4in6 inp46_foreign;
161structin6_addr inp6_foreign;
162} inp_dependfaddr;
163union {
164/* local host table entry */
165structin_addr_4in6 inp46_local;
166structin6_addr inp6_local;
167} inp_dependladdr;
168union {
169/* placeholder for routing entry */
170u_charinp4_route[20];
171u_charinp6_route[32];
172} inp_dependroute;
173struct {
174/* type of service proto */
175u_char inp4_ip_tos;
176/* IP options */
177_INPCB_PTR(struct mbuf *) inp4_options;
178/* IP multicast options */
179_INPCB_PTR(struct ip_moptions *) inp4_moptions;
180} inp_depend4;
181
182struct {
183/* IP options */
184_INPCB_PTR(struct mbuf *)inp6_options;
185u_int8_tinp6_hlim;
186u_int8_tunused_uint8_1;
187ushortunused_uint16_1;
188/* IP6 options for outgoing packets */
189_INPCB_PTR(struct ip6_pktopts *)inp6_outputopts;
190/* IP multicast options */
191_INPCB_PTR(struct ip6_moptions *)inp6_moptions;
192/* ICMPv6 code type filter */
193_INPCB_PTR(struct icmp6_filter *)inp6_icmp6filt;
194/* IPV6_CHECKSUM setsockopt */
195intinp6_cksum;
196u_shortinp6_ifindex;
197shortinp6_hops;
198} inp_depend6;
199
200inthash_element; /* Array index of pcb's hash list */
201_INPCB_PTR(caddr_t)inp_saved_ppcb;/* place to save pointer while cached */
202_INPCB_PTR(struct inpcbpolicy *)inp_sp;
203u_int32_treserved[3];/* For future use */
204};
205
206structxinpcb {
207u_int32_txi_len;/* length of this structure */
208structinpcb xi_inp;
209structxsocket xi_socket;
210u_quad_txi_alignment_hack;
211};
212
213#if !CONFIG_EMBEDDED
214
215struct inpcb64_list_entry {
216 u_int64_t le_next;
217 u_int64_t le_prev;
218};
219
220structxinpcb64 {
221u_int64_txi_len;/* length of this structure */
222u_int64_txi_inpp;
223u_short inp_fport;/* foreign port */
224u_shortinp_lport;/* local port */
225struct inpcb64_list_entry
226inp_list;/* list for all PCBs of this proto */
227u_int64_tinp_ppcb;/* pointer to per-protocol pcb */
228u_int64_tinp_pcbinfo;/* PCB list info */
229struct inpcb64_list_entry
230inp_portlist;/* list for this PCB's local port */
231u_int64_tinp_phd;/* head of this list */
232inp_gen_tinp_gencnt;/* generation count of this instance */
233intinp_flags;/* generic IP/datagram flags */
234u_int32_tinp_flow;
235u_charinp_vflag;
236u_charinp_ip_ttl;/* time to live */
237u_charinp_ip_p;/* protocol */
238 union {/* foreign host table entry */
239 struct in_addr_4in6inp46_foreign;
240 struct in6_addrinp6_foreign;
241 }inp_dependfaddr;
242 union {/* local host table entry */
243 struct in_addr_4in6inp46_local;
244 struct in6_addrinp6_local;
245 }inp_dependladdr;
246 struct {
247 u_charinp4_ip_tos;/* type of service */
248 }inp_depend4;
249 struct {
250 u_int8_t inp6_hlim;
251intinp6_cksum;
252 u_shortinp6_ifindex;
253 short inp6_hops;
254 }inp_depend6;
255 struct xsocket64 xi_socket;
256u_quad_txi_alignment_hack;
257};
258
259#endif /* !CONFIG_EMBEDDED */
260
261structxinpgen {
262u_int32_t xig_len;/* length of this structure */
263u_intxig_count;/* number of PCBs at this time */
264inp_gen_t xig_gen;/* generation count at this time */
265so_gen_t xig_sogen;/* socket generation count at this time */
266};
267
268#pragma pack()
269
270/*
271 * These defines are for use with the inpcb.
272 */
273#define INP_IPV40x1
274#define INP_IPV60x2
275#defineinp_faddrinp_dependfaddr.inp46_foreign.ia46_addr4
276#defineinp_laddrinp_dependladdr.inp46_local.ia46_addr4
277#defineinp_routeinp_dependroute.inp4_route
278#defineinp_ip_tosinp_depend4.inp4_ip_tos
279#defineinp_optionsinp_depend4.inp4_options
280#defineinp_moptionsinp_depend4.inp4_moptions
281#definein6p_faddrinp_dependfaddr.inp6_foreign
282#definein6p_laddrinp_dependladdr.inp6_local
283#definein6p_routeinp_dependroute.inp6_route
284#definein6p_ip6_hliminp_depend6.inp6_hlim
285#definein6p_hopsinp_depend6.inp6_hops/* default hop limit */
286#definein6p_ip6_nxtinp_ip_p
287#definein6p_flowinfoinp_flow
288#definein6p_vflaginp_vflag
289#definein6p_optionsinp_depend6.inp6_options
290#definein6p_outputoptsinp_depend6.inp6_outputopts
291#definein6p_moptionsinp_depend6.inp6_moptions
292#definein6p_icmp6filtinp_depend6.inp6_icmp6filt
293#definein6p_cksuminp_depend6.inp6_cksum
294#definein6p_ifindexinp_depend6.inp6_ifindex
295#definein6p_flagsinp_flags /* for KAME src sync over BSD*'s */
296#definein6p_socketinp_socket /* for KAME src sync over BSD*'s */
297#definein6p_lportinp_lport /* for KAME src sync over BSD*'s */
298#definein6p_fportinp_fport /* for KAME src sync over BSD*'s */
299#definein6p_ppcbinp_ppcb /* for KAME src sync over BSD*'s */
300#definein6p_stateinp_state
301#definein6p_wantcntinp_wantcnt
302
303
304/* flags in inp_flags: */
305#defineINP_RECVOPTS0x01/* receive incoming IP options */
306#defineINP_RECVRETOPTS0x02/* receive IP options for reply */
307#defineINP_RECVDSTADDR0x04/* receive IP dst address */
308#defineINP_HDRINCL0x08/* user supplies entire IP header */
309#defineINP_HIGHPORT0x10/* user wants "high" port binding */
310#defineINP_LOWPORT0x20/* user wants "low" port binding */
311#defineINP_ANONPORT0x40/* port chosen for user */
312#defineINP_RECVIF0x80/* receive incoming interface */
313#defineINP_MTUDISC0x100/* user can do MTU discovery */
314#ifdef __APPLE__
315#define INP_STRIPHDR0x200/* Strip headers in raw_ip, for OT support */
316#endif
317#define INP_FAITH0x400 /* accept FAITH'ed connections */
318#define INP_INADDR_ANY 0x800 /* local address wasn't specified */
319
320#define INP_RECVTTL0x1000
321#defineINP_UDP_NOCKSUM0x2000/* Turn off outbound UDP checksum */
322#defineINP_BOUND_IF0x4000/* bind socket to an ifindex */
323
324#define IN6P_IPV6_V6ONLY0x008000 /* restrict AF_INET6 socket for v6 */
325
326#defineIN6P_PKTINFO0x010000 /* receive IP6 dst and I/F */
327#defineIN6P_HOPLIMIT0x020000 /* receive hoplimit */
328#defineIN6P_HOPOPTS0x040000 /* receive hop-by-hop options */
329#defineIN6P_DSTOPTS0x080000 /* receive dst options after rthdr */
330#defineIN6P_RTHDR0x100000 /* receive routing header */
331#defineIN6P_RTHDRDSTOPTS0x200000 /* receive dstoptions before rthdr */
332#defineIN6P_TCLASS0x400000 /* receive traffic class value */
333#defineIN6P_AUTOFLOWLABEL0x800000 /* attach flowlabel automatically */
334#defineIN6P_BINDV6ONLY0x10000000 /* do not grab IPv4 traffic */
335
336
337#endif /* !_NETINET_IN_PCB_H_ */
338

Archive Download this file

Revision: 1466