Remove wrong getvfsbytype.3 MLINK. The manpage doesn't document it.
[dragonfly.git] / sys / netinet / in_pcb.h
CommitLineData
984263bc 1/*
66d6c637
JH
2 * Copyright (c) 2004 Jeffrey M. Hsu. All rights reserved.
3 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
f23061d4 4 *
66d6c637
JH
5 * This code is derived from software contributed to The DragonFly Project
6 * by Jeffrey M. Hsu.
f23061d4 7 *
66d6c637
JH
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. Neither the name of The DragonFly Project nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific, prior written permission.
f23061d4 19 *
66d6c637
JH
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 */
33
66d6c637 34/*
984263bc
MD
35 * Copyright (c) 1982, 1986, 1990, 1993
36 * The Regents of the University of California. All rights reserved.
37 *
38 * Redistribution and use in source and binary forms, with or without
39 * modification, are permitted provided that the following conditions
40 * are met:
41 * 1. Redistributions of source code must retain the above copyright
42 * notice, this list of conditions and the following disclaimer.
43 * 2. Redistributions in binary form must reproduce the above copyright
44 * notice, this list of conditions and the following disclaimer in the
45 * documentation and/or other materials provided with the distribution.
2c64e990 46 * 3. Neither the name of the University nor the names of its contributors
984263bc
MD
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
63 * $FreeBSD: src/sys/netinet/in_pcb.h,v 1.32.2.7 2003/01/24 05:11:34 sam Exp $
64 */
65
66#ifndef _NETINET_IN_PCB_H_
67#define _NETINET_IN_PCB_H_
68
1bd40720 69#ifndef _SYS_QUEUE_H_
984263bc 70#include <sys/queue.h>
1bd40720
MD
71#endif
72#ifndef _SYS_SYSCTL_H_
48a2763f 73#include <sys/sysctl.h>
1bd40720
MD
74#endif
75#ifndef _NETINET_IN_H_
76#include <netinet/in.h>
77#endif
78#ifndef _NET_ROUTE_H_
984263bc 79#include <net/route.h>
1bd40720 80#endif
984263bc
MD
81
82#define in6pcb inpcb /* for KAME src sync over BSD*'s */
984263bc
MD
83
84/*
85 * Common structure pcb for internet protocol implementation.
86 * Here are stored pointers to local and foreign host table
87 * entries, local and foreign socket numbers, and pointers
88 * up (to a socket structure) and down (to a protocol-specific)
89 * control block.
90 */
91LIST_HEAD(inpcbhead, inpcb);
92LIST_HEAD(inpcbporthead, inpcbport);
93typedef u_quad_t inp_gen_t;
94
ef962575
JH
95struct inpcontainer {
96 struct inpcb *ic_inp;
97 LIST_ENTRY(inpcontainer) ic_list;
98};
99LIST_HEAD(inpcontainerhead, inpcontainer);
100
984263bc
MD
101/*
102 * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet.
103 * So, AF_INET6 null laddr is also used as AF_INET null laddr,
104 * by utilize following structure. (At last, same as INRIA)
105 */
106struct in_addr_4in6 {
107 u_int32_t ia46_pad32[3];
108 struct in_addr ia46_addr4;
109};
110
740d1d9f
SZ
111union in_dependaddr {
112 struct in_addr_4in6 id46_addr;
113 struct in6_addr id6_addr;
114};
115
984263bc
MD
116/*
117 * NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553.
118 * in_conninfo has some extra padding to accomplish this.
119 */
120struct in_endpoints {
121 u_int16_t ie_fport; /* foreign port */
122 u_int16_t ie_lport; /* local port */
123 /* protocol dependent part, local and foreign addr */
740d1d9f
SZ
124 union in_dependaddr ie_dependfaddr; /* foreign host table entry */
125 union in_dependaddr ie_dependladdr; /* local host table entry */
126#define ie_faddr ie_dependfaddr.id46_addr.ia46_addr4
127#define ie_laddr ie_dependladdr.id46_addr.ia46_addr4
128#define ie6_faddr ie_dependfaddr.id6_addr
129#define ie6_laddr ie_dependladdr.id6_addr
984263bc
MD
130};
131
740d1d9f
SZ
132struct inp_localgroup {
133 LIST_ENTRY(inp_localgroup) il_list;
134 uint16_t il_lport;
727ccde8 135 u_char il_af; /* AF_INET or AF_INET6 */
740d1d9f 136 u_char il_pad;
2f035eef 137 uint32_t il_pad2;
740d1d9f
SZ
138 union in_dependaddr il_dependladdr;
139#define il_laddr il_dependladdr.id46_addr.ia46_addr4
140#define il6_laddr il_dependladdr.id6_addr
141 int il_inpsiz; /* size of il_inp[] */
142 int il_inpcnt; /* # of elem in il_inp[] */
143 struct inpcb *il_inp[];
144};
145LIST_HEAD(inp_localgrphead, inp_localgroup);
146
984263bc
MD
147/*
148 * XXX
149 * At some point struct route should possibly change to:
150 * struct rtentry *rt
f23061d4 151 * struct in_endpoints *ie;
984263bc
MD
152 */
153struct in_conninfo {
154 u_int8_t inc_flags;
155 u_int8_t inc_len;
156 u_int16_t inc_pad; /* XXX alignment for in_endpoints */
157 /* protocol dependent part; cached route */
158 struct in_endpoints inc_ie;
159 union {
160 /* placeholder for routing entry */
161 struct route inc4_route;
162 struct route_in6 inc6_route;
163 } inc_dependroute;
164};
9a7c6212 165#define inc_isipv6 inc_flags /* temp compatibility */
984263bc
MD
166#define inc_fport inc_ie.ie_fport
167#define inc_lport inc_ie.ie_lport
168#define inc_faddr inc_ie.ie_faddr
169#define inc_laddr inc_ie.ie_laddr
170#define inc_route inc_dependroute.inc4_route
171#define inc6_faddr inc_ie.ie6_faddr
172#define inc6_laddr inc_ie.ie6_laddr
173#define inc6_route inc_dependroute.inc6_route
174
175/*
176 * NB: the zone allocator is type-stable EXCEPT FOR THE FIRST TWO LONGS
177 * of the structure. Therefore, it is important that the members in
178 * that position not contain any information which is required to be
179 * stable.
180 */
181struct icmp6_filter;
6b048a7c 182struct inpcbportinfo;
984263bc
MD
183
184struct inpcb {
185 LIST_ENTRY(inpcb) inp_hash; /* hash list */
186 LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */
187 u_int32_t inp_flow;
d31e8230 188 int inp_lgrpindex; /* local group index */
984263bc
MD
189
190 /* local and foreign ports, local and foreign addr */
191 struct in_conninfo inp_inc;
192
f23061d4 193 void *inp_ppcb; /* pointer to per-protocol pcb */
984263bc
MD
194 struct inpcbinfo *inp_pcbinfo; /* PCB list info */
195 struct socket *inp_socket; /* back pointer to socket */
196 /* list for this PCB's local port */
76a9ffca
SZ
197 int inp_flags; /* generic IP/datagram flags */
198 uint16_t inp_hashval; /* valid iff INP_HASH */
199 uint16_t inp_pad; /* explicit padding */
984263bc 200
755d70b8 201 void *inp_unused1; /* was: for IPSEC */
727ccde8 202 u_char inp_af; /* AF_INET or AF_INET6 */
984263bc
MD
203 u_char inp_ip_ttl; /* time to live proto */
204 u_char inp_ip_p; /* protocol proto */
95926362 205 u_char inp_ip_minttl; /* minimum TTL or drop */
984263bc
MD
206
207 /* protocol dependent part; options */
208 struct {
209 u_char inp4_ip_tos; /* type of service proto */
210 struct mbuf *inp4_options; /* IP options */
211 struct ip_moptions *inp4_moptions; /* IP multicast options */
212 } inp_depend4;
213#define inp_fport inp_inc.inc_fport
214#define inp_lport inp_inc.inc_lport
215#define inp_faddr inp_inc.inc_faddr
216#define inp_laddr inp_inc.inc_laddr
217#define inp_route inp_inc.inc_route
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 struct {
222 /* IP options */
223 struct mbuf *inp6_options;
224 /* IP6 options for outgoing packets */
225 struct ip6_pktopts *inp6_outputopts;
226 /* IP multicast options */
227 struct ip6_moptions *inp6_moptions;
228 /* ICMPv6 code type filter */
229 struct icmp6_filter *inp6_icmp6filt;
230 /* IPV6_CHECKSUM setsockopt */
231 int inp6_cksum;
232 u_short inp6_ifindex;
233 short inp6_hops;
234 u_int8_t inp6_hlim;
235 } inp_depend6;
236 LIST_ENTRY(inpcb) inp_portlist;
0723a285 237 struct inpcbporthead *inp_porthash;
984263bc
MD
238 struct inpcbport *inp_phd; /* head of this list */
239 inp_gen_t inp_gencnt; /* generation count of this instance */
240#define in6p_faddr inp_inc.inc6_faddr
241#define in6p_laddr inp_inc.inc6_laddr
242#define in6p_route inp_inc.inc6_route
243#define in6p_ip6_hlim inp_depend6.inp6_hlim
244#define in6p_hops inp_depend6.inp6_hops /* default hop limit */
245#define in6p_ip6_nxt inp_ip_p
246#define in6p_flowinfo inp_flow
727ccde8 247#define in6p_af inp_af
984263bc
MD
248#define in6p_options inp_depend6.inp6_options
249#define in6p_outputopts inp_depend6.inp6_outputopts
250#define in6p_moptions inp_depend6.inp6_moptions
251#define in6p_icmp6filt inp_depend6.inp6_icmp6filt
252#define in6p_cksum inp_depend6.inp6_cksum
253#define inp6_ifindex inp_depend6.inp6_ifindex
254#define in6p_flags inp_flags /* for KAME src sync over BSD*'s */
255#define in6p_socket inp_socket /* for KAME src sync over BSD*'s */
256#define in6p_lport inp_lport /* for KAME src sync over BSD*'s */
257#define in6p_fport inp_fport /* for KAME src sync over BSD*'s */
258#define in6p_ppcb inp_ppcb /* for KAME src sync over BSD*'s */
ed1f0be2
JL
259
260 void *inp_pf_sk;
984263bc
MD
261};
262/*
263 * The range of the generation count, as used in this implementation,
264 * is 9e19. We would have to create 300 billion connections per
265 * second for this number to roll over in a year. This seems sufficiently
266 * unlikely that we simply don't concern ourselves with that possibility.
267 */
268
269/*
270 * Interface exported to userland by various protocols which use
271 * inpcbs. Hack alert -- only define if struct xsocket is in scope.
272 */
273#ifdef _SYS_SOCKETVAR_H_
274struct xinpcb {
275 size_t xi_len; /* length of this structure */
276 struct inpcb xi_inp;
277 struct xsocket xi_socket;
278 u_quad_t xi_alignment_hack;
279};
984263bc
MD
280#endif /* _SYS_SOCKETVAR_H_ */
281
282struct inpcbport {
283 LIST_ENTRY(inpcbport) phd_hash;
284 struct inpcbhead phd_pcblist;
285 u_short phd_port;
286};
287
0ce0603e
MD
288struct lwkt_token;
289
6b048a7c 290struct inpcbportinfo {
6b048a7c 291 struct inpcbporthead *porthashbase;
8aaef6e5 292 u_long porthashcnt;
2524c225 293 u_short offset;
6b048a7c
SZ
294} __cachealign;
295
984263bc 296struct inpcbinfo { /* XXX documentation, prefixes */
be4519a2 297 struct lwkt_token *infotoken; /* if this inpcbinfo is shared */
984263bc
MD
298 struct inpcbhead *hashbase;
299 u_long hashmask;
16db446e 300 int portinfo_cnt;
6b048a7c 301 struct inpcbportinfo *portinfo;
0ce0603e 302 struct inpcbport *portsave; /* port allocation cache */
ef962575 303 struct inpcontainerhead *wildcardhashbase;
2322f6ca 304 u_long wildcardhashmask;
740d1d9f
SZ
305 struct inp_localgrphead *localgrphashbase;
306 u_long localgrphashmask;
d2e9e54c 307 struct inpcbhead pcblisthead; /* head of queue of active pcb's */
9f42c129 308 size_t ipi_size; /* allocation size for pcbs */
984263bc 309 u_int ipi_count; /* number of pcbs in this list */
be4519a2 310 int cpu; /* related protocol thread cpu */
984263bc 311 u_quad_t ipi_gencnt; /* current generation count */
07310e1a 312} __cachealign;
984263bc 313
13d8907a 314
2322f6ca 315#define INP_PCBCONNHASH(faddr, fport, laddr, lport, mask) \
13d8907a
JH
316 (((faddr) ^ ((faddr) >> 16) ^ (laddr) ^ ntohs((lport) ^ (fport))) & (mask))
317
8aaef6e5 318#define INP_PCBPORTHASH(lport, cnt) (ntohs(lport) % (cnt))
13d8907a 319
2322f6ca 320#define INP_PCBWILDCARDHASH(lport, mask) (ntohs(lport) & (mask))
984263bc 321
740d1d9f
SZ
322#define INP_PCBLOCALGRPHASH(lport, mask) (ntohs(lport) & (mask))
323
984263bc
MD
324/* flags in inp_flags: */
325#define INP_RECVOPTS 0x01 /* receive incoming IP options */
326#define INP_RECVRETOPTS 0x02 /* receive IP options for reply */
327#define INP_RECVDSTADDR 0x04 /* receive IP dst address */
328#define INP_HDRINCL 0x08 /* user supplies entire IP header */
329#define INP_HIGHPORT 0x10 /* user wants "high" port binding */
330#define INP_LOWPORT 0x20 /* user wants "low" port binding */
331#define INP_ANONPORT 0x40 /* port chosen for user */
332#define INP_RECVIF 0x80 /* receive incoming interface */
333#define INP_MTUDISC 0x100 /* user can do MTU discovery */
2322f6ca 334#define INP_WILDCARD 0x400 /* wildcard match */
684247a4 335#define INP_FLAG_PROTO2 0x800 /* protocol specific */
1e019813 336#define INP_CONNECTED 0x1000 /* exact match */
26641eb6 337#define INP_FLAG_PROTO1 0x2000 /* protocol specific */
d2e9e54c 338#define INP_PLACEMARKER 0x4000 /* skip this pcb, its a placemarker */
76a9ffca 339#define INP_HASH 0x8000 /* inp_hashval is valid */
984263bc
MD
340
341#define IN6P_PKTINFO 0x010000 /* receive IP6 dst and I/F */
342#define IN6P_HOPLIMIT 0x020000 /* receive hoplimit */
343#define IN6P_HOPOPTS 0x040000 /* receive hop-by-hop options */
344#define IN6P_DSTOPTS 0x080000 /* receive dst options after rthdr */
345#define IN6P_RTHDR 0x100000 /* receive routing header */
346#define IN6P_RTHDRDSTOPTS 0x200000 /* receive dstoptions before rthdr */
347#define IN6P_AUTOFLOWLABEL 0x800000 /* attach flowlabel automatically */
5aa41e7c
HT
348/*
349 * RFC3542 Definition
350 */
351#define IN6P_TCLASS 0x400000 /* receive traffic class value */
352#define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */
353#define IN6P_MTU 0x80000000 /* receive path MTU */
984263bc 354
86976ce4 355/* 0x10000000 unused */
be4519a2 356#define INP_ONLIST 0x20000000 /* on pcblist */
95926362
MD
357#define INP_RECVTTL 0x80000000 /* receive incoming IP TTL */
358
984263bc 359#define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
5aa41e7c 360 INP_RECVIF|INP_RECVTTL|\
984263bc
MD
361 IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
362 IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
5aa41e7c
HT
363 IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\
364 IN6P_MTU)
365
984263bc 366#define INP_UNMAPPABLEOPTS (IN6P_HOPOPTS|IN6P_DSTOPTS|IN6P_RTHDR|\
5aa41e7c 367 IN6P_TCLASS|IN6P_AUTOFLOWLABEL)
984263bc
MD
368
369 /* for KAME src sync over BSD*'s */
370#define IN6P_HIGHPORT INP_HIGHPORT
371#define IN6P_LOWPORT INP_LOWPORT
372#define IN6P_ANONPORT INP_ANONPORT
373#define IN6P_RECVIF INP_RECVIF
374#define IN6P_MTUDISC INP_MTUDISC
984263bc
MD
375#define IN6P_CONTROLOPTS INP_CONTROLOPTS
376 /*
377 * socket AF version is {newer than,or include}
378 * actual datagram AF version
379 */
380
381#define INPLOOKUP_WILDCARD 1
382#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
383#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
384
ed1f0be2
JL
385/* macros for handling bitmap of ports not to allocate dynamically */
386#define DP_MAPBITS (sizeof(u_int32_t) * NBBY)
387#define DP_MAPSIZE (howmany(65536, DP_MAPBITS))
388#define DP_SET(m, p) ((m)[(p) / DP_MAPBITS] |= (1 << ((p) % DP_MAPBITS)))
389#define DP_CLR(m, p) ((m)[(p) / DP_MAPBITS] &= ~(1 << ((p) % DP_MAPBITS)))
390#define DP_ISSET(m, p) ((m)[(p) / DP_MAPBITS] & (1 << ((p) % DP_MAPBITS)))
391
392/* default values for baddynamicports [see ip_init()] */
393#define DEFBADDYNAMICPORTS_TCP { \
394 587, 749, 750, 751, 871, 2049, \
395 6000, 6001, 6002, 6003, 6004, 6005, 6006, 6007, 6008, 6009, 6010, \
396 0 }
397#define DEFBADDYNAMICPORTS_UDP { 623, 664, 749, 750, 751, 2049, 0 }
398
399struct baddynamicports {
400 u_int32_t tcp[DP_MAPSIZE];
401 u_int32_t udp[DP_MAPSIZE];
402};
403
404
984263bc 405#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
f23061d4 406#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
984263bc 407
727ccde8
SZ
408#define INP_ISIPV6(inp) ((inp)->inp_af == AF_INET6)
409#define INP_ISIPV4(inp) ((inp)->inp_af == AF_INET)
410
984263bc 411#ifdef _KERNEL
5588b5cd 412
0723a285
SZ
413static __inline struct inpcbporthead *
414in_pcbporthash_head(struct inpcbportinfo *portinfo, u_short lport)
415{
416 return &portinfo->porthashbase[
8aaef6e5 417 INP_PCBPORTHASH(lport, portinfo->porthashcnt)];
0723a285
SZ
418}
419
420#define GET_PORTHASH_TOKEN(porthashhead) \
5588b5cd 421do { \
0723a285 422 lwkt_getpooltoken((porthashhead)); \
5588b5cd
SZ
423} while (0)
424
0723a285 425#define REL_PORTHASH_TOKEN(porthashhead) \
5588b5cd 426do { \
0723a285 427 lwkt_relpooltoken((porthashhead)); \
5588b5cd
SZ
428} while (0)
429
430#ifdef INVARIANTS
0723a285
SZ
431#define ASSERT_PORTHASH_TOKEN_HELD(pcbhashhead) \
432 ASSERT_LWKT_TOKEN_HELD(lwkt_token_pool_lookup((pcbhashhead)))
433#else
434#define ASSERT_PORTHASH_TOKEN_HELD(pcbhashhead)
435#endif
5588b5cd 436
be4519a2
SZ
437#define GET_PCBINFO_TOKEN(pcbinfo) \
438do { \
439 if ((pcbinfo)->infotoken) \
440 lwkt_gettoken((pcbinfo)->infotoken); \
441} while (0)
442
443#define REL_PCBINFO_TOKEN(pcbinfo) \
444do { \
445 if ((pcbinfo)->infotoken) \
446 lwkt_reltoken((pcbinfo)->infotoken); \
447} while (0)
448
449#ifdef INVARIANTS
450#define ASSERT_PCBINFO_TOKEN_HELD(pcbinfo) \
451do { \
452 if ((pcbinfo)->infotoken) \
453 ASSERT_LWKT_TOKEN_HELD((pcbinfo)->infotoken); \
454} while (0)
455#else /* !INVARIANTS */
456#define ASSERT_PCBINFO_TOKEN_HELD(pcbinfo)
457#endif /* INVARIANTS */
458
aac7374f
SZ
459#ifdef INVARIANTS
460#define ASSERT_INP_NOTINHASH(inp) \
461do { \
462 KASSERT(!((inp)->inp_flags & INP_CONNECTED), \
463 ("already on connhash")); \
464 KASSERT(!((inp)->inp_flags & INP_WILDCARD), \
465 ("already on wildcardhash")); \
466} while (0)
467#else /* !INVARIANTS */
468#define ASSERT_INP_NOTINHASH(inp)
469#endif /* INVARIANTS */
470
984263bc
MD
471extern int ipport_lowfirstauto;
472extern int ipport_lowlastauto;
473extern int ipport_firstauto;
474extern int ipport_lastauto;
475extern int ipport_hifirstauto;
476extern int ipport_hilastauto;
477
002c1265 478union netmsg;
db190d5c 479struct xinpcb;
002c1265 480
7195d381
SZ
481typedef void (*inp_notify_t)(struct inpcb *, int);
482
2524c225 483void in_pcbportrange(u_short *, u_short *, u_short, u_short);
be4519a2 484void in_pcbpurgeif0 (struct inpcbinfo *, struct ifnet *);
42a7fc75
RG
485void in_losing (struct inpcb *);
486void in_rtchange (struct inpcb *, int);
be4519a2 487void in_pcbinfo_init (struct inpcbinfo *, int, boolean_t);
0723a285 488void in_pcbportinfo_init (struct inpcbportinfo *, int, u_short);
aa35ea43 489void in_pcbportinfo_set(struct inpcbinfo *, struct inpcbportinfo *, int);
e4700d00 490int in_pcballoc (struct socket *, struct inpcbinfo *);
0ce0603e 491void in_pcbunlink (struct inpcb *, struct inpcbinfo *);
b55ecf7e 492void in_pcbunlink_flags (struct inpcb *, struct inpcbinfo *, int);
0ce0603e 493void in_pcblink (struct inpcb *, struct inpcbinfo *);
b55ecf7e 494void in_pcblink_flags (struct inpcb *, struct inpcbinfo *, int);
be4519a2
SZ
495void in_pcbonlist (struct inpcb *);
496void in_pcbofflist (struct inpcb *);
42a7fc75 497int in_pcbbind (struct inpcb *, struct sockaddr *, struct thread *);
3b0238a0 498int in_pcbbind_remote(struct inpcb *, const struct sockaddr *,
db26865d 499 struct thread *);
42a7fc75
RG
500int in_pcbconnect (struct inpcb *, struct sockaddr *, struct thread *);
501void in_pcbdetach (struct inpcb *);
502void in_pcbdisconnect (struct inpcb *);
2322f6ca 503void in_pcbinswildcardhash(struct inpcb *inp);
8affadf8 504void in_pcbinswildcardhash_oncpu(struct inpcb *, struct inpcbinfo *);
13d8907a 505void in_pcbinsconnhash(struct inpcb *inp);
0723a285 506void in_pcbinsporthash(struct inpcbporthead *, struct inpcb *);
dc9229d4 507void in_pcbinsporthash_lport (struct inpcb *);
296c350d 508void in_pcbremporthash (struct inpcb *);
42a7fc75 509int in_pcbladdr (struct inpcb *, struct sockaddr *,
3e4150ef 510 struct sockaddr_in **, struct thread *);
834fa505
SZ
511int in_pcbladdr_find (struct inpcb *, struct sockaddr *,
512 struct sockaddr_in **, struct thread *, int);
984263bc 513struct inpcb *
42a7fc75 514 in_pcblookup_hash (struct inpcbinfo *,
984263bc 515 struct in_addr, u_int, struct in_addr, u_int,
99ebfb7c 516 boolean_t, struct ifnet *);
740d1d9f
SZ
517struct inpcb *
518 in_pcblookup_pkthash (struct inpcbinfo *,
519 struct in_addr, u_int, struct in_addr, u_int,
99ebfb7c 520 boolean_t, struct ifnet *, const struct mbuf *);
be4519a2 521void in_pcbnotifyall (struct inpcbinfo *, struct in_addr,
7195d381 522 int, inp_notify_t);
42a7fc75 523int in_setpeeraddr (struct socket *so, struct sockaddr **nam);
002c1265 524void in_setpeeraddr_dispatch(union netmsg *);
002c1265 525void in_setsockaddr_dispatch(netmsg_t msg);
ed1f0be2 526int in_baddynamic(u_int16_t, u_int16_t);
2322f6ca 527void in_pcbremwildcardhash(struct inpcb *inp);
8affadf8 528void in_pcbremwildcardhash_oncpu(struct inpcb *, struct inpcbinfo *);
13d8907a 529void in_pcbremconnhash(struct inpcb *inp);
42a7fc75
RG
530void in_pcbremlists (struct inpcb *inp);
531int prison_xinpcb (struct thread *p, struct inpcb *inp);
88da6203 532void in_savefaddr (struct socket *so, const struct sockaddr *faddr);
02ad2f0b
SZ
533struct inpcb *
534 in_pcblocalgroup_last(const struct inpcbinfo *, const struct inpcb *);
be4519a2 535void in_pcbglobalinit(void);
cbc3e519 536void in_pcbresetroute(struct inpcb *);
48a2763f 537
d930a2f2
SZ
538int in_pcblist_range(SYSCTL_HANDLER_ARGS);
539int in_pcblist_ncpus(SYSCTL_HANDLER_ARGS);
be4519a2
SZ
540
541struct inpcb *
729f22bc 542 in_pcbmarker(void);
be4519a2 543struct inpcontainer *
729f22bc 544 in_pcbcontainer_marker(void);
5588b5cd 545
984263bc
MD
546#endif /* _KERNEL */
547
548#endif /* !_NETINET_IN_PCB_H_ */