PageRenderTime 58ms CodeModel.GetById 28ms RepoModel.GetById 0ms app.codeStats 0ms

/bsd/sys/netinet/in_pcb.h

https://gitlab.com/jforge/osv
C Header | 559 lines | 328 code | 57 blank | 174 comment | 4 complexity | 4fbfeff866e193f5c291e4e94258a895 MD5 | raw file
Possible License(s): BSD-3-Clause, 0BSD, MPL-2.0-no-copyleft-exception
  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$
  36. */
  37. #ifndef _NETINET_IN_PCB_H_
  38. #define _NETINET_IN_PCB_H_
  39. #include <sys/cdefs.h>
  40. #include <stddef.h>
  41. #include <bsd/porting/netport.h>
  42. #include <bsd/porting/rwlock.h>
  43. #include <bsd/sys/netinet/in.h>
  44. #include <bsd/sys/netinet6/in6.h>
  45. #include <bsd/sys/sys/queue.h>
  46. #include <bsd/sys/net/vnet.h>
  47. #include <bsd/porting/uma_stub.h>
  48. __BEGIN_DECLS
  49. void ipport_tick_init(const void *unused);
  50. #define in6pcb inpcb /* for KAME src sync over BSD*'s */
  51. #define in6p_sp inp_sp /* for KAME src sync over BSD*'s */
  52. struct inpcbpolicy;
  53. /*
  54. * struct inpcb is the common protocol control block structure used in most
  55. * IP transport protocols.
  56. *
  57. * Pointers to local and foreign host table entries, local and foreign socket
  58. * numbers, and pointers up (to a socket structure) and down (to a
  59. * protocol-specific control block) are stored here.
  60. */
  61. LIST_HEAD(inpcbhead, inpcb);
  62. LIST_HEAD(inpcbporthead, inpcbport);
  63. typedef u_quad_t inp_gen_t;
  64. /*
  65. * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet.
  66. * So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing
  67. * the following structure.
  68. */
  69. struct in_addr_4in6 {
  70. u_int32_t ia46_pad32[3];
  71. struct in_addr ia46_addr4;
  72. };
  73. /*
  74. * NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553. in_conninfo has
  75. * some extra padding to accomplish this.
  76. */
  77. struct in_endpoints {
  78. u_int16_t ie_fport; /* foreign port */
  79. u_int16_t ie_lport; /* local port */
  80. /* protocol dependent part, local and foreign addr */
  81. union {
  82. /* foreign host table entry */
  83. struct in_addr_4in6 ie46_foreign;
  84. struct in6_addr ie6_foreign;
  85. } ie_dependfaddr;
  86. union {
  87. /* local host table entry */
  88. struct in_addr_4in6 ie46_local;
  89. struct in6_addr ie6_local;
  90. } ie_dependladdr;
  91. };
  92. #define ie_faddr ie_dependfaddr.ie46_foreign.ia46_addr4
  93. #define ie_laddr ie_dependladdr.ie46_local.ia46_addr4
  94. #define ie6_faddr ie_dependfaddr.ie6_foreign
  95. #define ie6_laddr ie_dependladdr.ie6_local
  96. /*
  97. * XXX The defines for inc_* are hacks and should be changed to direct
  98. * references.
  99. */
  100. struct in_conninfo {
  101. u_int8_t inc_flags;
  102. u_int8_t inc_len;
  103. u_int16_t inc_fibnum; /* XXX was pad, 16 bits is plenty */
  104. /* protocol dependent part */
  105. struct in_endpoints inc_ie;
  106. };
  107. /*
  108. * Flags for inc_flags.
  109. */
  110. #define INC_ISIPV6 0x01
  111. #define inc_isipv6 inc_flags /* temp compatability */
  112. #define inc_fport inc_ie.ie_fport
  113. #define inc_lport inc_ie.ie_lport
  114. #define inc_faddr inc_ie.ie_faddr
  115. #define inc_laddr inc_ie.ie_laddr
  116. #define inc6_faddr inc_ie.ie6_faddr
  117. #define inc6_laddr inc_ie.ie6_laddr
  118. struct icmp6_filter;
  119. /*-
  120. * struct inpcb captures the network layer state for TCP, UDP, and raw IPv4
  121. * and IPv6 sockets. In the case of TCP, further per-connection state is
  122. * hung off of inp_ppcb most of the time. Almost all fields of struct inpcb
  123. * are static after creation or protected by a per-inpcb rwlock, inp_lock. A
  124. * few fields also require the global pcbinfo lock for the inpcb to be held,
  125. * when modified, such as the global connection lists and hashes, as well as
  126. * binding information (which affects which hash a connection is on). This
  127. * model means that connections can be looked up without holding the
  128. * per-connection lock, which is important for performance when attempting to
  129. * find the connection for a packet given its IP and port tuple. Writing to
  130. * these fields that write locks be held on both the inpcb and global locks.
  131. *
  132. * Key:
  133. * (c) - Constant after initialization
  134. * (i) - Protected by the inpcb lock
  135. * (p) - Protected by the pcbinfo lock for the inpcb
  136. * (s) - Protected by another subsystem's locks
  137. * (x) - Undefined locking
  138. *
  139. * A few other notes:
  140. *
  141. * When a read lock is held, stability of the field is guaranteed; to write
  142. * to a field, a write lock must generally be held.
  143. *
  144. * netinet/netinet6-layer code should not assume that the inp_socket pointer
  145. * is safe to dereference without inp_lock being held, even for protocols
  146. * other than TCP (where the inpcb persists during TIMEWAIT even after the
  147. * socket has been freed), or there may be close(2)-related races.
  148. *
  149. * The inp_vflag field is overloaded, and would otherwise ideally be (c).
  150. */
  151. struct inpcb {
  152. inpcb(struct socket* so, struct inpcbinfo* pcbinfo);
  153. LIST_ENTRY(inpcb) inp_hash = {};/* (i/p) hash list */
  154. LIST_ENTRY(inpcb) inp_list = {};/* (i/p) list for all PCBs for proto */
  155. void *inp_ppcb = {}; /* (i) pointer to per-protocol pcb */
  156. struct inpcbinfo *inp_pcbinfo = {}; /* (c) PCB list info */
  157. struct socket *inp_socket = {}; /* (i) back pointer to socket */
  158. u_int32_t inp_flow = {}; /* (i) IPv6 flow information */
  159. int inp_flags = {}; /* (i) generic IP/datagram flags */
  160. int inp_flags2 = {}; /* (i) generic IP/datagram flags #2*/
  161. u_char inp_vflag = {}; /* (i) IP version flag (v4/v6) */
  162. u_char inp_ip_ttl = {}; /* (i) time to live proto */
  163. u_char inp_ip_p = {}; /* (c) protocol proto */
  164. u_char inp_ip_minttl = {}; /* (i) minimum TTL or drop */
  165. uint32_t inp_flowid = {}; /* (x) flow id / queue id */
  166. u_int inp_refcount = {}; /* (i) refcount */
  167. /* Local and foreign ports, local and foreign addr. */
  168. struct in_conninfo inp_inc = {}; /* (i/p) list for PCB's local port */
  169. /* Protocol-dependent part; options. */
  170. struct {
  171. u_char inp4_ip_tos; /* (i) type of service proto */
  172. struct mbuf *inp4_options; /* (i) IP options */
  173. struct ip_moptions *inp4_moptions; /* (i) IP mcast options */
  174. } inp_depend4 = {};
  175. struct {
  176. /* (i) IP options */
  177. struct mbuf *inp6_options;
  178. /* (i) IP6 options for outgoing packets */
  179. struct ip6_pktopts *inp6_outputopts;
  180. /* (i) IP multicast options */
  181. struct ip6_moptions *inp6_moptions;
  182. /* (i) ICMPv6 code type filter */
  183. struct icmp6_filter *inp6_icmp6filt;
  184. /* (i) IPV6_CHECKSUM setsockopt */
  185. int inp6_cksum;
  186. short inp6_hops;
  187. } inp_depend6 = {};
  188. LIST_ENTRY(inpcb) inp_portlist = {}; /* (i/p) */
  189. struct inpcbport *inp_phd = {}; /* (i/p) head of this list */
  190. inp_gen_t inp_gencnt; /* (c) generation count */
  191. struct llentry *inp_lle; /* cached L2 information */
  192. struct rtentry *inp_rt; /* cached L3 information */
  193. mutex inp_lock;
  194. };
  195. #define inp_fport inp_inc.inc_fport
  196. #define inp_lport inp_inc.inc_lport
  197. #define inp_faddr inp_inc.inc_faddr
  198. #define inp_laddr inp_inc.inc_laddr
  199. #define inp_ip_tos inp_depend4.inp4_ip_tos
  200. #define inp_options inp_depend4.inp4_options
  201. #define inp_moptions inp_depend4.inp4_moptions
  202. #define in6p_faddr inp_inc.inc6_faddr
  203. #define in6p_laddr inp_inc.inc6_laddr
  204. #define in6p_hops inp_depend6.inp6_hops /* default hop limit */
  205. #define in6p_flowinfo inp_flow
  206. #define in6p_options inp_depend6.inp6_options
  207. #define in6p_outputopts inp_depend6.inp6_outputopts
  208. #define in6p_moptions inp_depend6.inp6_moptions
  209. #define in6p_icmp6filt inp_depend6.inp6_icmp6filt
  210. #define in6p_cksum inp_depend6.inp6_cksum
  211. #define inp_vnet inp_pcbinfo->ipi_vnet
  212. /*
  213. * The range of the generation count, as used in this implementation, is 9e19.
  214. * We would have to create 300 billion connections per second for this number
  215. * to roll over in a year. This seems sufficiently unlikely that we simply
  216. * don't concern ourselves with that possibility.
  217. */
  218. /*
  219. * Interface exported to userland by various protocols which use inpcbs. Hack
  220. * alert -- only define if struct xsocket is in scope.
  221. */
  222. #ifdef _SYS_SOCKETVAR_H_
  223. struct xinpcb {
  224. size_t xi_len; /* length of this structure */
  225. struct inpcb xi_inp;
  226. struct xsocket xi_socket;
  227. u_quad_t xi_alignment_hack;
  228. };
  229. struct xinpgen {
  230. size_t xig_len; /* length of this structure */
  231. u_int xig_count; /* number of PCBs at this time */
  232. inp_gen_t xig_gen; /* generation count at this time */
  233. so_gen_t xig_sogen; /* socket generation count at this time */
  234. };
  235. #endif /* _SYS_SOCKETVAR_H_ */
  236. struct inpcbport {
  237. LIST_ENTRY(inpcbport) phd_hash;
  238. struct inpcbhead phd_pcblist;
  239. u_short phd_port;
  240. };
  241. /*-
  242. * Global data structure for each high-level protocol (UDP, TCP, ...) in both
  243. * IPv4 and IPv6. Holds inpcb lists and information for managing them.
  244. *
  245. * Each pcbinfo is protected by two locks: ipi_lock and ipi_hash_lock,
  246. * the former covering mutable global fields (such as the global pcb list),
  247. * and the latter covering the hashed lookup tables. The lock order is:
  248. *
  249. * ipi_lock (before) inpcb locks (before) ipi_hash_lock}
  250. *
  251. * Locking key:
  252. *
  253. * (c) Constant or nearly constant after initialisation
  254. * (g) Locked by ipi_lock
  255. * (h) Read using either ipi_hash_lock or inpcb lock; write requires both
  256. * (x) Synchronisation properties poorly defined
  257. */
  258. struct inpcbinfo {
  259. /*
  260. * Global lock protecting global inpcb list, inpcb count, etc.
  261. */
  262. mutex ipi_lock;
  263. /*
  264. * Global list of inpcbs on the protocol.
  265. */
  266. struct inpcbhead *ipi_listhead; /* (g) */
  267. u_int ipi_count; /* (g) */
  268. /*
  269. * Generation count -- incremented each time a connection is allocated
  270. * or freed.
  271. */
  272. u_quad_t ipi_gencnt; /* (g) */
  273. /*
  274. * Fields associated with port lookup and allocation.
  275. */
  276. u_short ipi_lastport; /* (x) */
  277. u_short ipi_lastlow; /* (x) */
  278. u_short ipi_lasthi; /* (x) */
  279. /*
  280. * Global lock protecting hash lookup tables.
  281. */
  282. struct rwlock ipi_hash_lock;
  283. /*
  284. * Global hash of inpcbs, hashed by local and foreign addresses and
  285. * port numbers.
  286. */
  287. struct inpcbhead *ipi_hashbase; /* (h) */
  288. u_long ipi_hashmask; /* (h) */
  289. /*
  290. * Global hash of inpcbs, hashed by only local port number.
  291. */
  292. struct inpcbporthead *ipi_porthashbase; /* (h) */
  293. u_long ipi_porthashmask; /* (h) */
  294. /*
  295. * Pointer to network stack instance
  296. */
  297. struct vnet *ipi_vnet; /* (c) */
  298. /*
  299. * general use 2
  300. */
  301. void *ipi_pspare[2];
  302. };
  303. #ifdef _KERNEL
  304. #define INP_LOCK_INIT(inp, d, t) \
  305. mutex_init(&(inp)->inp_lock)
  306. #define INP_LOCK_DESTROY(inp) mutex_destroy(&(inp)->inp_lock)
  307. #define INP_LOCK(inp) mutex_lock(&(inp)->inp_lock)
  308. #define INP_TRY_LOCK(inp) mutex_try_lock(&(inp)->inp_lock)
  309. #define INP_UNLOCK(inp) mutex_unlock(&(inp)->inp_lock)
  310. #define INP_LOCKED(inp) mutex_owned(&(inp)->inp_lock)
  311. #define INP_LOCK_ASSERT(inp) assert(mutex_owned(&(inp)->inp_lock))
  312. #define INP_UNLOCK_ASSERT(inp) assert(!mutex_owned(&(inp)->inp_lock))
  313. #ifdef INVARIANTS
  314. void inp_lock_assert(struct inpcb *);
  315. void inp_unlock_assert(struct inpcb *);
  316. #else
  317. static __inline void
  318. inp_lock_assert(struct inpcb *inp)
  319. {
  320. }
  321. static __inline void
  322. inp_unlock_assert(struct inpcb *inp)
  323. {
  324. }
  325. #endif
  326. void inp_apply_all(void (*func)(struct inpcb *, void *), void *arg);
  327. int inp_ip_tos_get(const struct inpcb *inp);
  328. void inp_ip_tos_set(struct inpcb *inp, int val);
  329. struct socket *
  330. inp_inpcbtosocket(struct inpcb *inp);
  331. struct tcpcb *
  332. inp_inpcbtotcpcb(struct inpcb *inp);
  333. void inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp,
  334. uint32_t *faddr, uint16_t *fp);
  335. #endif /* _KERNEL */
  336. #define INP_INFO_LOCK_INIT(ipi, d) \
  337. mutex_init(&(ipi)->ipi_lock)
  338. #define INP_INFO_LOCK_DESTROY(ipi) mutex_destroy(&(ipi)->ipi_lock)
  339. #define INP_INFO_WLOCK(ipi) mutex_lock(&(ipi)->ipi_lock)
  340. #define INP_INFO_TRY_WLOCK(ipi) mutex_trylock(&(ipi)->ipi_lock)
  341. #define INP_INFO_WUNLOCK(ipi) mutex_unlock(&(ipi)->ipi_lock)
  342. #define INP_INFO_LOCK_ASSERT(ipi) do {} while (0)
  343. #define INP_INFO_WLOCK_ASSERT(ipi) do {} while (0)
  344. #define INP_INFO_UNLOCK_ASSERT(ipi) do {} while (0)
  345. #define INP_HASH_LOCK_INIT(ipi, d) \
  346. rw_init_flags(&(ipi)->ipi_hash_lock, (d), 0)
  347. #define INP_HASH_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_hash_lock)
  348. #define INP_HASH_RLOCK(ipi) rw_rlock(&(ipi)->ipi_hash_lock)
  349. #define INP_HASH_WLOCK(ipi) rw_wlock(&(ipi)->ipi_hash_lock)
  350. #define INP_HASH_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_hash_lock)
  351. #define INP_HASH_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_hash_lock)
  352. #define INP_HASH_LOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_hash_lock, \
  353. RA_LOCKED)
  354. #define INP_HASH_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_hash_lock, \
  355. RA_WLOCKED)
  356. #define INP_PCBHASH(faddr, lport, fport, mask) \
  357. (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask))
  358. #define INP_PCBPORTHASH(lport, mask) \
  359. (ntohs((lport)) & (mask))
  360. /*
  361. * Flags for inp_vflags -- historically version flags only
  362. */
  363. #define INP_IPV4 0x1
  364. #define INP_IPV6 0x2
  365. #define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */
  366. /*
  367. * Flags for inp_flags.
  368. */
  369. #define INP_RECVOPTS 0x00000001 /* receive incoming IP options */
  370. #define INP_RECVRETOPTS 0x00000002 /* receive IP options for reply */
  371. #define INP_RECVDSTADDR 0x00000004 /* receive IP dst address */
  372. #define INP_HDRINCL 0x00000008 /* user supplies entire IP header */
  373. #define INP_HIGHPORT 0x00000010 /* user wants "high" port binding */
  374. #define INP_LOWPORT 0x00000020 /* user wants "low" port binding */
  375. #define INP_ANONPORT 0x00000040 /* port chosen for user */
  376. #define INP_RECVIF 0x00000080 /* receive incoming interface */
  377. #define INP_MTUDISC 0x00000100 /* user can do MTU discovery */
  378. #define INP_FAITH 0x00000200 /* accept FAITH'ed connections */
  379. #define INP_RECVTTL 0x00000400 /* receive incoming IP TTL */
  380. #define INP_DONTFRAG 0x00000800 /* don't fragment packet */
  381. #define INP_BINDANY 0x00001000 /* allow bind to any address */
  382. #define INP_INHASHLIST 0x00002000 /* in_pcbinshash() has been called */
  383. #define INP_RECVTOS 0x00004000 /* receive incoming IP TOS */
  384. #define IN6P_IPV6_V6ONLY 0x00008000 /* restrict AF_INET6 socket for v6 */
  385. #define IN6P_PKTINFO 0x00010000 /* receive IP6 dst and I/F */
  386. #define IN6P_HOPLIMIT 0x00020000 /* receive hoplimit */
  387. #define IN6P_HOPOPTS 0x00040000 /* receive hop-by-hop options */
  388. #define IN6P_DSTOPTS 0x00080000 /* receive dst options after rthdr */
  389. #define IN6P_RTHDR 0x00100000 /* receive routing header */
  390. #define IN6P_RTHDRDSTOPTS 0x00200000 /* receive dstoptions before rthdr */
  391. #define IN6P_TCLASS 0x00400000 /* receive traffic class value */
  392. #define IN6P_AUTOFLOWLABEL 0x00800000 /* attach flowlabel automatically */
  393. #define INP_TIMEWAIT 0x01000000 /* in TIMEWAIT, ppcb is tcptw */
  394. #define INP_ONESBCAST 0x02000000 /* send all-ones broadcast */
  395. #define INP_DROPPED 0x04000000 /* protocol drop flag */
  396. #define INP_SOCKREF 0x08000000 /* strong socket reference */
  397. #define INP_SW_FLOWID 0x10000000 /* software generated flow id */
  398. #define INP_HW_FLOWID 0x20000000 /* hardware generated flow id */
  399. #define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */
  400. #define IN6P_MTU 0x80000000 /* receive path MTU */
  401. #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
  402. INP_RECVIF|INP_RECVTTL|INP_RECVTOS|\
  403. IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\
  404. IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\
  405. IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\
  406. IN6P_MTU)
  407. /*
  408. * Flags for inp_flags2.
  409. */
  410. #define INP_LLE_VALID 0x00000001 /* cached lle is valid */
  411. #define INP_RT_VALID 0x00000002 /* cached rtentry is valid */
  412. #define INP_REUSEPORT 0x00000008 /* SO_REUSEPORT option is set */
  413. #define INP_FREED 0x00000010 /* inp itself is not valid */
  414. /*
  415. * Flags passed to in_pcblookup*() functions.
  416. */
  417. #define INPLOOKUP_WILDCARD 0x00000001 /* Allow wildcard sockets. */
  418. #define INPLOOKUP_LOCKPCB 0x00000002 /* Return read-locked. */
  419. #define INPLOOKUP_MASK (INPLOOKUP_WILDCARD | INPLOOKUP_LOCKPCB)
  420. #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
  421. #define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */
  422. #define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family
  423. #define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af)
  424. /*
  425. * Constants for pcbinfo.ipi_hashfields.
  426. */
  427. #define IPI_HASHFIELDS_NONE 0
  428. #define IPI_HASHFIELDS_2TUPLE 1
  429. #define IPI_HASHFIELDS_4TUPLE 2
  430. #ifdef _KERNEL
  431. VNET_DECLARE(int, ipport_reservedhigh);
  432. VNET_DECLARE(int, ipport_reservedlow);
  433. VNET_DECLARE(int, ipport_lowfirstauto);
  434. VNET_DECLARE(int, ipport_lowlastauto);
  435. VNET_DECLARE(int, ipport_firstauto);
  436. VNET_DECLARE(int, ipport_lastauto);
  437. VNET_DECLARE(int, ipport_hifirstauto);
  438. VNET_DECLARE(int, ipport_hilastauto);
  439. VNET_DECLARE(int, ipport_randomized);
  440. VNET_DECLARE(int, ipport_randomcps);
  441. VNET_DECLARE(int, ipport_randomtime);
  442. VNET_DECLARE(int, ipport_stoprandom);
  443. VNET_DECLARE(int, ipport_tcpallocs);
  444. #define V_ipport_reservedhigh VNET(ipport_reservedhigh)
  445. #define V_ipport_reservedlow VNET(ipport_reservedlow)
  446. #define V_ipport_lowfirstauto VNET(ipport_lowfirstauto)
  447. #define V_ipport_lowlastauto VNET(ipport_lowlastauto)
  448. #define V_ipport_firstauto VNET(ipport_firstauto)
  449. #define V_ipport_lastauto VNET(ipport_lastauto)
  450. #define V_ipport_hifirstauto VNET(ipport_hifirstauto)
  451. #define V_ipport_hilastauto VNET(ipport_hilastauto)
  452. #define V_ipport_randomized VNET(ipport_randomized)
  453. #define V_ipport_randomcps VNET(ipport_randomcps)
  454. #define V_ipport_randomtime VNET(ipport_randomtime)
  455. #define V_ipport_stoprandom VNET(ipport_stoprandom)
  456. #define V_ipport_tcpallocs VNET(ipport_tcpallocs)
  457. void in_pcbinfo_destroy(struct inpcbinfo *);
  458. void in_pcbinfo_init(struct inpcbinfo *, const char *, struct inpcbhead *,
  459. int, int, u_int);
  460. void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *);
  461. int in_pcbbind(struct inpcb *, struct bsd_sockaddr *, struct ucred *);
  462. int in_pcb_lport(struct inpcb *, struct in_addr *, u_short *,
  463. struct ucred *, int);
  464. int in_pcbbind_setup(struct inpcb *, struct bsd_sockaddr *, in_addr_t *,
  465. u_short *, struct ucred *);
  466. int in_pcbconnect(struct inpcb *, struct bsd_sockaddr *, struct ucred *);
  467. int in_pcbconnect_mbuf(struct inpcb *, struct bsd_sockaddr *, struct ucred *,
  468. struct mbuf *);
  469. int in_pcbconnect_setup(struct inpcb *, struct bsd_sockaddr *, in_addr_t *,
  470. u_short *, in_addr_t *, u_short *, struct inpcb **,
  471. struct ucred *);
  472. void in_pcbdetach(struct inpcb *);
  473. void in_pcbdisconnect(struct inpcb *);
  474. void in_pcbdrop(struct inpcb *);
  475. void in_pcbfree(struct inpcb *);
  476. int in_pcbinshash(struct inpcb *);
  477. struct inpcb *
  478. in_pcblookup_local(struct inpcbinfo *,
  479. struct in_addr, u_short, int, struct ucred *);
  480. struct inpcb *
  481. in_pcblookup(struct inpcbinfo *, struct in_addr, u_int,
  482. struct in_addr, u_int, int, struct ifnet *);
  483. struct inpcb *
  484. in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int,
  485. struct in_addr, u_int, int, struct ifnet *, struct mbuf *);
  486. void
  487. in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr faddr, int errval,
  488. struct inpcb *(*notify)(struct inpcb *, int));
  489. void in_pcbref(struct inpcb *);
  490. void in_pcbrehash(struct inpcb *);
  491. void in_pcbrehash_mbuf(struct inpcb *, struct mbuf *);
  492. int in_pcbrele(struct inpcb *);
  493. int in_pcbrele_locked(struct inpcb *);
  494. void in_pcbsetsolabel(struct socket *so);
  495. int in_getpeeraddr(struct socket *so, struct bsd_sockaddr **nam);
  496. int in_getsockaddr(struct socket *so, struct bsd_sockaddr **nam);
  497. struct bsd_sockaddr *
  498. in_sockaddr(in_port_t port, struct in_addr *addr);
  499. void in_pcbsosetlabel(struct socket *so);
  500. #endif /* _KERNEL */
  501. __END_DECLS
  502. #endif /* !_NETINET_IN_PCB_H_ */