in_pcb.h revision 222217
1/*-
2 * Copyright (c) 1982, 1986, 1990, 1993
3 *	The Regents of the University of California.
4 * Copyright (c) 2010-2011 Juniper Networks, Inc.
5 * All rights reserved.
6 *
7 * Portions of this software were developed by Robert N. M. Watson under
8 * contract to Juniper Networks, Inc.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 *    notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 *    notice, this list of conditions and the following disclaimer in the
17 *    documentation and/or other materials provided with the distribution.
18 * 4. Neither the name of the University nor the names of its contributors
19 *    may be used to endorse or promote products derived from this software
20 *    without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 *	@(#)in_pcb.h	8.1 (Berkeley) 6/10/93
35 * $FreeBSD: head/sys/netinet/in_pcb.h 222217 2011-05-23 19:32:02Z rwatson $
36 */
37
38#ifndef _NETINET_IN_PCB_H_
39#define _NETINET_IN_PCB_H_
40
41#include <sys/queue.h>
42#include <sys/_lock.h>
43#include <sys/_mutex.h>
44#include <sys/_rwlock.h>
45
46#ifdef _KERNEL
47#include <sys/rwlock.h>
48#include <net/vnet.h>
49#include <vm/uma.h>
50#endif
51
52#define	in6pcb		inpcb	/* for KAME src sync over BSD*'s */
53#define	in6p_sp		inp_sp	/* for KAME src sync over BSD*'s */
54struct inpcbpolicy;
55
56/*
57 * struct inpcb is the common protocol control block structure used in most
58 * IP transport protocols.
59 *
60 * Pointers to local and foreign host table entries, local and foreign socket
61 * numbers, and pointers up (to a socket structure) and down (to a
62 * protocol-specific control block) are stored here.
63 */
64LIST_HEAD(inpcbhead, inpcb);
65LIST_HEAD(inpcbporthead, inpcbport);
66typedef	u_quad_t	inp_gen_t;
67
68/*
69 * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet.
70 * So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing
71 * the following structure.
72 */
73struct in_addr_4in6 {
74	u_int32_t	ia46_pad32[3];
75	struct	in_addr	ia46_addr4;
76};
77
78/*
79 * NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553.  in_conninfo has
80 * some extra padding to accomplish this.
81 */
82struct in_endpoints {
83	u_int16_t	ie_fport;		/* foreign port */
84	u_int16_t	ie_lport;		/* local port */
85	/* protocol dependent part, local and foreign addr */
86	union {
87		/* foreign host table entry */
88		struct	in_addr_4in6 ie46_foreign;
89		struct	in6_addr ie6_foreign;
90	} ie_dependfaddr;
91	union {
92		/* local host table entry */
93		struct	in_addr_4in6 ie46_local;
94		struct	in6_addr ie6_local;
95	} ie_dependladdr;
96};
97#define	ie_faddr	ie_dependfaddr.ie46_foreign.ia46_addr4
98#define	ie_laddr	ie_dependladdr.ie46_local.ia46_addr4
99#define	ie6_faddr	ie_dependfaddr.ie6_foreign
100#define	ie6_laddr	ie_dependladdr.ie6_local
101
102/*
103 * XXX The defines for inc_* are hacks and should be changed to direct
104 * references.
105 */
106struct in_conninfo {
107	u_int8_t	inc_flags;
108	u_int8_t	inc_len;
109	u_int16_t	inc_fibnum;	/* XXX was pad, 16 bits is plenty */
110	/* protocol dependent part */
111	struct	in_endpoints inc_ie;
112};
113
114/*
115 * Flags for inc_flags.
116 */
117#define	INC_ISIPV6	0x01
118
119#define inc_isipv6	inc_flags	/* temp compatability */
120#define	inc_fport	inc_ie.ie_fport
121#define	inc_lport	inc_ie.ie_lport
122#define	inc_faddr	inc_ie.ie_faddr
123#define	inc_laddr	inc_ie.ie_laddr
124#define	inc6_faddr	inc_ie.ie6_faddr
125#define	inc6_laddr	inc_ie.ie6_laddr
126
127struct	icmp6_filter;
128
129/*-
130 * struct inpcb captures the network layer state for TCP, UDP, and raw IPv4
131 * and IPv6 sockets.  In the case of TCP, further per-connection state is
132 * hung off of inp_ppcb most of the time.  Almost all fields of struct inpcb
133 * are static after creation or protected by a per-inpcb rwlock, inp_lock.  A
134 * few fields also require the global pcbinfo lock for the inpcb to be held,
135 * when modified, such as the global connection lists and hashes, as well as
136 * binding information (which affects which hash a connection is on).  This
137 * model means that connections can be looked up without holding the
138 * per-connection lock, which is important for performance when attempting to
139 * find the connection for a packet given its IP and port tuple.  Writing to
140 * these fields that write locks be held on both the inpcb and global locks.
141 *
142 * Key:
143 * (c) - Constant after initialization
144 * (i) - Protected by the inpcb lock
145 * (p) - Protected by the pcbinfo lock for the inpcb
146 * (s) - Protected by another subsystem's locks
147 * (x) - Undefined locking
148 *
149 * A few other notes:
150 *
151 * When a read lock is held, stability of the field is guaranteed; to write
152 * to a field, a write lock must generally be held.
153 *
154 * netinet/netinet6-layer code should not assume that the inp_socket pointer
155 * is safe to dereference without inp_lock being held, even for protocols
156 * other than TCP (where the inpcb persists during TIMEWAIT even after the
157 * socket has been freed), or there may be close(2)-related races.
158 *
159 * The inp_vflag field is overloaded, and would otherwise ideally be (c).
160 */
161struct inpcb {
162	LIST_ENTRY(inpcb) inp_hash;	/* (i/p) hash list */
163	LIST_ENTRY(inpcb) inp_list;	/* (i/p) list for all PCBs for proto */
164	void	*inp_ppcb;		/* (i) pointer to per-protocol pcb */
165	struct	inpcbinfo *inp_pcbinfo;	/* (c) PCB list info */
166	struct	socket *inp_socket;	/* (i) back pointer to socket */
167	struct	ucred	*inp_cred;	/* (c) cache of socket cred */
168	u_int32_t inp_flow;		/* (i) IPv6 flow information */
169	int	inp_flags;		/* (i) generic IP/datagram flags */
170	int	inp_flags2;		/* (i) generic IP/datagram flags #2*/
171	u_char	inp_vflag;		/* (i) IP version flag (v4/v6) */
172	u_char	inp_ip_ttl;		/* (i) time to live proto */
173	u_char	inp_ip_p;		/* (c) protocol proto */
174	u_char	inp_ip_minttl;		/* (i) minimum TTL or drop */
175	uint32_t inp_flowid;		/* (x) flow id / queue id */
176	u_int	inp_refcount;		/* (i) refcount */
177	void	*inp_pspare[4];		/* (x) rtentry / general use */
178	u_int	inp_ispare[4];		/* general use */
179
180	/* Local and foreign ports, local and foreign addr. */
181	struct	in_conninfo inp_inc;	/* (i/p) list for PCB's local port */
182
183	/* MAC and IPSEC policy information. */
184	struct	label *inp_label;	/* (i) MAC label */
185	struct	inpcbpolicy *inp_sp;    /* (s) for IPSEC */
186
187	/* Protocol-dependent part; options. */
188	struct {
189		u_char	inp4_ip_tos;		/* (i) type of service proto */
190		struct	mbuf *inp4_options;	/* (i) IP options */
191		struct	ip_moptions *inp4_moptions; /* (i) IP mcast options */
192	} inp_depend4;
193	struct {
194		/* (i) IP options */
195		struct	mbuf *inp6_options;
196		/* (i) IP6 options for outgoing packets */
197		struct	ip6_pktopts *inp6_outputopts;
198		/* (i) IP multicast options */
199		struct	ip6_moptions *inp6_moptions;
200		/* (i) ICMPv6 code type filter */
201		struct	icmp6_filter *inp6_icmp6filt;
202		/* (i) IPV6_CHECKSUM setsockopt */
203		int	inp6_cksum;
204		short	inp6_hops;
205	} inp_depend6;
206	LIST_ENTRY(inpcb) inp_portlist;	/* (i/p) */
207	struct	inpcbport *inp_phd;	/* (i/p) head of this list */
208#define inp_zero_size offsetof(struct inpcb, inp_gencnt)
209	inp_gen_t	inp_gencnt;	/* (c) generation count */
210	struct llentry	*inp_lle;	/* cached L2 information */
211	struct rtentry	*inp_rt;	/* cached L3 information */
212	struct rwlock	inp_lock;
213};
214#define	inp_fport	inp_inc.inc_fport
215#define	inp_lport	inp_inc.inc_lport
216#define	inp_faddr	inp_inc.inc_faddr
217#define	inp_laddr	inp_inc.inc_laddr
218#define	inp_ip_tos	inp_depend4.inp4_ip_tos
219#define	inp_options	inp_depend4.inp4_options
220#define	inp_moptions	inp_depend4.inp4_moptions
221
222#define	in6p_faddr	inp_inc.inc6_faddr
223#define	in6p_laddr	inp_inc.inc6_laddr
224#define	in6p_hops	inp_depend6.inp6_hops	/* default hop limit */
225#define	in6p_flowinfo	inp_flow
226#define	in6p_options	inp_depend6.inp6_options
227#define	in6p_outputopts	inp_depend6.inp6_outputopts
228#define	in6p_moptions	inp_depend6.inp6_moptions
229#define	in6p_icmp6filt	inp_depend6.inp6_icmp6filt
230#define	in6p_cksum	inp_depend6.inp6_cksum
231
232#define	inp_vnet	inp_pcbinfo->ipi_vnet
233
234/*
235 * The range of the generation count, as used in this implementation, is 9e19.
236 * We would have to create 300 billion connections per second for this number
237 * to roll over in a year.  This seems sufficiently unlikely that we simply
238 * don't concern ourselves with that possibility.
239 */
240
241/*
242 * Interface exported to userland by various protocols which use inpcbs.  Hack
243 * alert -- only define if struct xsocket is in scope.
244 */
245#ifdef _SYS_SOCKETVAR_H_
246struct	xinpcb {
247	size_t	xi_len;		/* length of this structure */
248	struct	inpcb xi_inp;
249	struct	xsocket xi_socket;
250	u_quad_t	xi_alignment_hack;
251};
252
253struct	xinpgen {
254	size_t	xig_len;	/* length of this structure */
255	u_int	xig_count;	/* number of PCBs at this time */
256	inp_gen_t xig_gen;	/* generation count at this time */
257	so_gen_t xig_sogen;	/* socket generation count at this time */
258};
259#endif /* _SYS_SOCKETVAR_H_ */
260
261struct inpcbport {
262	LIST_ENTRY(inpcbport) phd_hash;
263	struct inpcbhead phd_pcblist;
264	u_short phd_port;
265};
266
267/*-
268 * Global data structure for each high-level protocol (UDP, TCP, ...) in both
269 * IPv4 and IPv6.  Holds inpcb lists and information for managing them.
270 *
271 * Each pcbinfo is protected by ipi_lock, covering mutable global fields (such
272 * as the global pcb list) and hashed lookup tables.  The lock order is:
273 *
274 *    ipi_lock (before) inpcb locks
275 *
276 * Locking key:
277 *
278 * (c) Constant or nearly constant after initialisation
279 * (g) Locked by ipi_lock
280 * (h) Read using either ipi_lock or inpcb lock; write requires both.
281 * (x) Synchronisation properties poorly defined
282 */
283struct inpcbinfo {
284	/*
285	 * Global lock protecting global inpcb list, inpcb count, hash tables,
286	 * etc.
287	 */
288	struct rwlock		 ipi_lock;
289
290	/*
291	 * Global list of inpcbs on the protocol.
292	 */
293	struct inpcbhead	*ipi_listhead;		/* (g) */
294	u_int			 ipi_count;		/* (g) */
295
296	/*
297	 * Generation count -- incremented each time a connection is allocated
298	 * or freed.
299	 */
300	u_quad_t		 ipi_gencnt;		/* (g) */
301
302	/*
303	 * Fields associated with port lookup and allocation.
304	 */
305	u_short			 ipi_lastport;		/* (x) */
306	u_short			 ipi_lastlow;		/* (x) */
307	u_short			 ipi_lasthi;		/* (x) */
308
309	/*
310	 * UMA zone from which inpcbs are allocated for this protocol.
311	 */
312	struct	uma_zone	*ipi_zone;		/* (c) */
313
314	/*
315	 * Global hash of inpcbs, hashed by local and foreign addresses and
316	 * port numbers.
317	 */
318	struct inpcbhead	*ipi_hashbase;		/* (g) */
319	u_long			 ipi_hashmask;		/* (g) */
320
321	/*
322	 * Global hash of inpcbs, hashed by only local port number.
323	 */
324	struct inpcbporthead	*ipi_porthashbase;	/* (g) */
325	u_long			 ipi_porthashmask;	/* (g) */
326
327	/*
328	 * Pointer to network stack instance
329	 */
330	struct vnet		*ipi_vnet;		/* (c) */
331
332	/*
333	 * general use 2
334	 */
335	void 			*ipi_pspare[2];
336};
337
338#define INP_LOCK_INIT(inp, d, t) \
339	rw_init_flags(&(inp)->inp_lock, (t), RW_RECURSE |  RW_DUPOK)
340#define INP_LOCK_DESTROY(inp)	rw_destroy(&(inp)->inp_lock)
341#define INP_RLOCK(inp)		rw_rlock(&(inp)->inp_lock)
342#define INP_WLOCK(inp)		rw_wlock(&(inp)->inp_lock)
343#define INP_TRY_RLOCK(inp)	rw_try_rlock(&(inp)->inp_lock)
344#define INP_TRY_WLOCK(inp)	rw_try_wlock(&(inp)->inp_lock)
345#define INP_RUNLOCK(inp)	rw_runlock(&(inp)->inp_lock)
346#define INP_WUNLOCK(inp)	rw_wunlock(&(inp)->inp_lock)
347#define	INP_TRY_UPGRADE(inp)	rw_try_upgrade(&(inp)->inp_lock)
348#define	INP_DOWNGRADE(inp)	rw_downgrade(&(inp)->inp_lock)
349#define	INP_WLOCKED(inp)	rw_wowned(&(inp)->inp_lock)
350#define	INP_LOCK_ASSERT(inp)	rw_assert(&(inp)->inp_lock, RA_LOCKED)
351#define	INP_RLOCK_ASSERT(inp)	rw_assert(&(inp)->inp_lock, RA_RLOCKED)
352#define	INP_WLOCK_ASSERT(inp)	rw_assert(&(inp)->inp_lock, RA_WLOCKED)
353#define	INP_UNLOCK_ASSERT(inp)	rw_assert(&(inp)->inp_lock, RA_UNLOCKED)
354
355#ifdef _KERNEL
356/*
357 * These locking functions are for inpcb consumers outside of sys/netinet,
358 * more specifically, they were added for the benefit of TOE drivers. The
359 * macros are reserved for use by the stack.
360 */
361void inp_wlock(struct inpcb *);
362void inp_wunlock(struct inpcb *);
363void inp_rlock(struct inpcb *);
364void inp_runlock(struct inpcb *);
365
366#ifdef INVARIANTS
367void inp_lock_assert(struct inpcb *);
368void inp_unlock_assert(struct inpcb *);
369#else
370static __inline void
371inp_lock_assert(struct inpcb *inp __unused)
372{
373}
374
375static __inline void
376inp_unlock_assert(struct inpcb *inp __unused)
377{
378}
379
380#endif
381
382void	inp_apply_all(void (*func)(struct inpcb *, void *), void *arg);
383int 	inp_ip_tos_get(const struct inpcb *inp);
384void 	inp_ip_tos_set(struct inpcb *inp, int val);
385struct socket *
386	inp_inpcbtosocket(struct inpcb *inp);
387struct tcpcb *
388	inp_inpcbtotcpcb(struct inpcb *inp);
389void 	inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
390		uint32_t *faddr, uint16_t *fp);
391
392#endif /* _KERNEL */
393
394#define INP_INFO_LOCK_INIT(ipi, d) \
395	rw_init_flags(&(ipi)->ipi_lock, (d), RW_RECURSE)
396#define INP_INFO_LOCK_DESTROY(ipi)  rw_destroy(&(ipi)->ipi_lock)
397#define INP_INFO_RLOCK(ipi)	rw_rlock(&(ipi)->ipi_lock)
398#define INP_INFO_WLOCK(ipi)	rw_wlock(&(ipi)->ipi_lock)
399#define INP_INFO_TRY_RLOCK(ipi)	rw_try_rlock(&(ipi)->ipi_lock)
400#define INP_INFO_TRY_WLOCK(ipi)	rw_try_wlock(&(ipi)->ipi_lock)
401#define INP_INFO_TRY_UPGRADE(ipi)	rw_try_upgrade(&(ipi)->ipi_lock)
402#define INP_INFO_RUNLOCK(ipi)	rw_runlock(&(ipi)->ipi_lock)
403#define INP_INFO_WUNLOCK(ipi)	rw_wunlock(&(ipi)->ipi_lock)
404#define	INP_INFO_LOCK_ASSERT(ipi)	rw_assert(&(ipi)->ipi_lock, RA_LOCKED)
405#define INP_INFO_RLOCK_ASSERT(ipi)	rw_assert(&(ipi)->ipi_lock, RA_RLOCKED)
406#define INP_INFO_WLOCK_ASSERT(ipi)	rw_assert(&(ipi)->ipi_lock, RA_WLOCKED)
407#define INP_INFO_UNLOCK_ASSERT(ipi)	rw_assert(&(ipi)->ipi_lock, RA_UNLOCKED)
408
409#define INP_PCBHASH(faddr, lport, fport, mask) \
410	(((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
411#define INP_PCBPORTHASH(lport, mask) \
412	(ntohs((lport)) & (mask))
413
414/*
415 * Flags for inp_vflags -- historically version flags only
416 */
417#define	INP_IPV4	0x1
418#define	INP_IPV6	0x2
419#define	INP_IPV6PROTO	0x4		/* opened under IPv6 protocol */
420
421/*
422 * Flags for inp_flags.
423 */
424#define	INP_RECVOPTS		0x00000001 /* receive incoming IP options */
425#define	INP_RECVRETOPTS		0x00000002 /* receive IP options for reply */
426#define	INP_RECVDSTADDR		0x00000004 /* receive IP dst address */
427#define	INP_HDRINCL		0x00000008 /* user supplies entire IP header */
428#define	INP_HIGHPORT		0x00000010 /* user wants "high" port binding */
429#define	INP_LOWPORT		0x00000020 /* user wants "low" port binding */
430#define	INP_ANONPORT		0x00000040 /* port chosen for user */
431#define	INP_RECVIF		0x00000080 /* receive incoming interface */
432#define	INP_MTUDISC		0x00000100 /* user can do MTU discovery */
433#define	INP_FAITH		0x00000200 /* accept FAITH'ed connections */
434#define	INP_RECVTTL		0x00000400 /* receive incoming IP TTL */
435#define	INP_DONTFRAG		0x00000800 /* don't fragment packet */
436#define	INP_BINDANY		0x00001000 /* allow bind to any address */
437#define	INP_INHASHLIST		0x00002000 /* in_pcbinshash() has been called */
438#define	IN6P_IPV6_V6ONLY	0x00008000 /* restrict AF_INET6 socket for v6 */
439#define	IN6P_PKTINFO		0x00010000 /* receive IP6 dst and I/F */
440#define	IN6P_HOPLIMIT		0x00020000 /* receive hoplimit */
441#define	IN6P_HOPOPTS		0x00040000 /* receive hop-by-hop options */
442#define	IN6P_DSTOPTS		0x00080000 /* receive dst options after rthdr */
443#define	IN6P_RTHDR		0x00100000 /* receive routing header */
444#define	IN6P_RTHDRDSTOPTS	0x00200000 /* receive dstoptions before rthdr */
445#define	IN6P_TCLASS		0x00400000 /* receive traffic class value */
446#define	IN6P_AUTOFLOWLABEL	0x00800000 /* attach flowlabel automatically */
447#define	INP_TIMEWAIT		0x01000000 /* in TIMEWAIT, ppcb is tcptw */
448#define	INP_ONESBCAST		0x02000000 /* send all-ones broadcast */
449#define	INP_DROPPED		0x04000000 /* protocol drop flag */
450#define	INP_SOCKREF		0x08000000 /* strong socket reference */
451#define	INP_SW_FLOWID           0x10000000 /* software generated flow id */
452#define	INP_HW_FLOWID           0x20000000 /* hardware generated flow id */
453#define	IN6P_RFC2292		0x40000000 /* used RFC2292 API on the socket */
454#define	IN6P_MTU		0x80000000 /* receive path MTU */
455
456#define	INP_CONTROLOPTS		(INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
457				 INP_RECVIF|INP_RECVTTL|\
458				 IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
459				 IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
460				 IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\
461				 IN6P_MTU)
462
463/*
464 * Flags for inp_flags2.
465 */
466#define	INP_LLE_VALID		0x00000001 /* cached lle is valid */
467#define	INP_RT_VALID		0x00000002 /* cached rtentry is valid */
468
469#define	INPLOOKUP_WILDCARD	1
470#define	sotoinpcb(so)	((struct inpcb *)(so)->so_pcb)
471#define	sotoin6pcb(so)	sotoinpcb(so) /* for KAME src sync over BSD*'s */
472
473#define	INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
474
475#define	INP_CHECK_SOCKAF(so, af)	(INP_SOCKAF(so) == af)
476
477#ifdef _KERNEL
478VNET_DECLARE(int, ipport_reservedhigh);
479VNET_DECLARE(int, ipport_reservedlow);
480VNET_DECLARE(int, ipport_lowfirstauto);
481VNET_DECLARE(int, ipport_lowlastauto);
482VNET_DECLARE(int, ipport_firstauto);
483VNET_DECLARE(int, ipport_lastauto);
484VNET_DECLARE(int, ipport_hifirstauto);
485VNET_DECLARE(int, ipport_hilastauto);
486VNET_DECLARE(int, ipport_randomized);
487VNET_DECLARE(int, ipport_randomcps);
488VNET_DECLARE(int, ipport_randomtime);
489VNET_DECLARE(int, ipport_stoprandom);
490VNET_DECLARE(int, ipport_tcpallocs);
491
492#define	V_ipport_reservedhigh	VNET(ipport_reservedhigh)
493#define	V_ipport_reservedlow	VNET(ipport_reservedlow)
494#define	V_ipport_lowfirstauto	VNET(ipport_lowfirstauto)
495#define	V_ipport_lowlastauto	VNET(ipport_lowlastauto)
496#define	V_ipport_firstauto	VNET(ipport_firstauto)
497#define	V_ipport_lastauto	VNET(ipport_lastauto)
498#define	V_ipport_hifirstauto	VNET(ipport_hifirstauto)
499#define	V_ipport_hilastauto	VNET(ipport_hilastauto)
500#define	V_ipport_randomized	VNET(ipport_randomized)
501#define	V_ipport_randomcps	VNET(ipport_randomcps)
502#define	V_ipport_randomtime	VNET(ipport_randomtime)
503#define	V_ipport_stoprandom	VNET(ipport_stoprandom)
504#define	V_ipport_tcpallocs	VNET(ipport_tcpallocs)
505
506void	in_pcbinfo_destroy(struct inpcbinfo *);
507void	in_pcbinfo_init(struct inpcbinfo *, const char *, struct inpcbhead *,
508	    int, int, char *, uma_init, uma_fini, uint32_t);
509
510void	in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
511int	in_pcballoc(struct socket *, struct inpcbinfo *);
512int	in_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *);
513int	in_pcb_lport(struct inpcb *, struct in_addr *, u_short *,
514	    struct ucred *, int);
515int	in_pcbbind_setup(struct inpcb *, struct sockaddr *, in_addr_t *,
516	    u_short *, struct ucred *);
517int	in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *);
518int	in_pcbconnect_setup(struct inpcb *, struct sockaddr *, in_addr_t *,
519	    u_short *, in_addr_t *, u_short *, struct inpcb **,
520	    struct ucred *);
521void	in_pcbdetach(struct inpcb *);
522void	in_pcbdisconnect(struct inpcb *);
523void	in_pcbdrop(struct inpcb *);
524void	in_pcbfree(struct inpcb *);
525int	in_pcbinshash(struct inpcb *);
526struct inpcb *
527	in_pcblookup_local(struct inpcbinfo *,
528	    struct in_addr, u_short, int, struct ucred *);
529struct inpcb *
530	in_pcblookup_hash(struct inpcbinfo *, struct in_addr, u_int,
531	    struct in_addr, u_int, int, struct ifnet *);
532void	in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr,
533	    int, struct inpcb *(*)(struct inpcb *, int));
534void	in_pcbref(struct inpcb *);
535void	in_pcbrehash(struct inpcb *);
536int	in_pcbrele(struct inpcb *);
537int	in_pcbrele_rlocked(struct inpcb *);
538int	in_pcbrele_wlocked(struct inpcb *);
539void	in_pcbsetsolabel(struct socket *so);
540int	in_getpeeraddr(struct socket *so, struct sockaddr **nam);
541int	in_getsockaddr(struct socket *so, struct sockaddr **nam);
542struct sockaddr *
543	in_sockaddr(in_port_t port, struct in_addr *addr);
544void	in_pcbsosetlabel(struct socket *so);
545#endif /* _KERNEL */
546
547#endif /* !_NETINET_IN_PCB_H_ */
548