1139823Simp/*- 21541Srgrimes * Copyright (c) 1982, 1986, 1990, 1993 3185791Srwatson * The Regents of the University of California. 4222213Srwatson * Copyright (c) 2010-2011 Juniper Networks, Inc. 5185791Srwatson * All rights reserved. 61541Srgrimes * 7222213Srwatson * Portions of this software were developed by Robert N. M. Watson under 8222213Srwatson * contract to Juniper Networks, Inc. 9222213Srwatson * 101541Srgrimes * Redistribution and use in source and binary forms, with or without 111541Srgrimes * modification, are permitted provided that the following conditions 121541Srgrimes * are met: 131541Srgrimes * 1. Redistributions of source code must retain the above copyright 141541Srgrimes * notice, this list of conditions and the following disclaimer. 151541Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 161541Srgrimes * notice, this list of conditions and the following disclaimer in the 171541Srgrimes * documentation and/or other materials provided with the distribution. 181541Srgrimes * 4. Neither the name of the University nor the names of its contributors 191541Srgrimes * may be used to endorse or promote products derived from this software 201541Srgrimes * without specific prior written permission. 211541Srgrimes * 221541Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 231541Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 241541Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 251541Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 261541Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271541Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281541Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291541Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301541Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311541Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321541Srgrimes * SUCH DAMAGE. 331541Srgrimes * 341541Srgrimes * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 3550477Speter * $FreeBSD: stable/11/sys/netinet/in_pcb.h 343432 2019-01-25 15:25:53Z tuexen $ 361541Srgrimes */ 371541Srgrimes 382169Spaul#ifndef _NETINET_IN_PCB_H_ 392169Spaul#define _NETINET_IN_PCB_H_ 402169Spaul 4112644Sbde#include <sys/queue.h> 42102981Sbde#include <sys/_lock.h> 43102981Sbde#include <sys/_mutex.h> 44178285Srwatson#include <sys/_rwlock.h> 45297225Sgnn#include <net/route.h> 4612644Sbde 47178285Srwatson#ifdef _KERNEL 48222787Sbz#include <sys/lock.h> 49178285Srwatson#include <sys/rwlock.h> 50195699Srwatson#include <net/vnet.h> 51205157Srwatson#include <vm/uma.h> 52178285Srwatson#endif 53178285Srwatson 5453541Sshin#define in6pcb inpcb /* for KAME src sync over BSD*'s */ 5553541Sshin#define in6p_sp inp_sp /* for KAME src sync over BSD*'s */ 56105199Ssamstruct inpcbpolicy; 5753541Sshin 581541Srgrimes/* 59183460Srwatson * struct inpcb is the common protocol control block structure used in most 60183460Srwatson * IP transport protocols. 61169154Srwatson * 62169154Srwatson * Pointers to local and foreign host table entries, local and foreign socket 63169154Srwatson * numbers, and pointers up (to a socket structure) and down (to a 64169154Srwatson * protocol-specific control block) are stored here. 651541Srgrimes */ 6660938SjakeLIST_HEAD(inpcbhead, inpcb); 6760938SjakeLIST_HEAD(inpcbporthead, inpcbport); 6836079Swollmantypedef u_quad_t inp_gen_t; 697684Sdg 7034881Swollman/* 7153541Sshin * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. 72169154Srwatson * So, AF_INET6 null laddr is also used as AF_INET null laddr, by utilizing 73169154Srwatson * the following structure. 7453541Sshin */ 7553541Sshinstruct in_addr_4in6 { 7653541Sshin u_int32_t ia46_pad32[3]; 7753541Sshin struct in_addr ia46_addr4; 7853541Sshin}; 7953541Sshin 8053541Sshin/* 81169154Srwatson * NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553. in_conninfo has 82169154Srwatson * some extra padding to accomplish this. 83287481Sglebius * NOTE 2: tcp_syncache.c uses first 5 32-bit words, which identify fport, 84287481Sglebius * lport, faddr to generate hash, so these fields shouldn't be moved. 8586764Sjlemon */ 8686764Sjlemonstruct in_endpoints { 8786764Sjlemon u_int16_t ie_fport; /* foreign port */ 8886764Sjlemon u_int16_t ie_lport; /* local port */ 8986764Sjlemon /* protocol dependent part, local and foreign addr */ 9086764Sjlemon union { 9186764Sjlemon /* foreign host table entry */ 9286764Sjlemon struct in_addr_4in6 ie46_foreign; 9386764Sjlemon struct in6_addr ie6_foreign; 9486764Sjlemon } ie_dependfaddr; 9586764Sjlemon union { 9686764Sjlemon /* local host table entry */ 9786764Sjlemon struct in_addr_4in6 ie46_local; 9886764Sjlemon struct in6_addr ie6_local; 9986764Sjlemon } ie_dependladdr; 100271400Sae u_int32_t ie6_zoneid; /* scope zone id */ 101185791Srwatson}; 10286764Sjlemon#define ie_faddr ie_dependfaddr.ie46_foreign.ia46_addr4 10386764Sjlemon#define ie_laddr ie_dependladdr.ie46_local.ia46_addr4 10486764Sjlemon#define ie6_faddr ie_dependfaddr.ie6_foreign 10586764Sjlemon#define ie6_laddr ie_dependladdr.ie6_local 10686764Sjlemon 10786764Sjlemon/* 108169154Srwatson * XXX The defines for inc_* are hacks and should be changed to direct 109169154Srwatson * references. 11086764Sjlemon */ 11186764Sjlemonstruct in_conninfo { 11286764Sjlemon u_int8_t inc_flags; 11386764Sjlemon u_int8_t inc_len; 114178888Sjulian u_int16_t inc_fibnum; /* XXX was pad, 16 bits is plenty */ 115122922Sandre /* protocol dependent part */ 11686764Sjlemon struct in_endpoints inc_ie; 11786764Sjlemon}; 118186222Sbz 119186222Sbz/* 120186222Sbz * Flags for inc_flags. 121186222Sbz */ 122186222Sbz#define INC_ISIPV6 0x01 123343432Stuexen#define INC_IPV6MINMTU 0x02 124186222Sbz 125298995Spfg#define inc_isipv6 inc_flags /* temp compatibility */ 12686764Sjlemon#define inc_fport inc_ie.ie_fport 12786764Sjlemon#define inc_lport inc_ie.ie_lport 12886764Sjlemon#define inc_faddr inc_ie.ie_faddr 12986764Sjlemon#define inc_laddr inc_ie.ie_laddr 13086764Sjlemon#define inc6_faddr inc_ie.ie6_faddr 13186764Sjlemon#define inc6_laddr inc_ie.ie6_laddr 132271400Sae#define inc6_zoneid inc_ie.ie6_zoneid 13386764Sjlemon 13453541Sshinstruct icmp6_filter; 13553541Sshin 136180368Srwatson/*- 137286227Sjch * struct inpcb captures the network layer state for TCP, UDP, and raw IPv4 and 138286227Sjch * IPv6 sockets. In the case of TCP and UDP, further per-connection state is 139180368Srwatson * hung off of inp_ppcb most of the time. Almost all fields of struct inpcb 140180368Srwatson * are static after creation or protected by a per-inpcb rwlock, inp_lock. A 141286227Sjch * few fields are protected by multiple locks as indicated in the locking notes 142286227Sjch * below. For these fields, all of the listed locks must be write-locked for 143286227Sjch * any modifications. However, these fields can be safely read while any one of 144286227Sjch * the listed locks are read-locked. This model can permit greater concurrency 145286227Sjch * for read operations. For example, connections can be looked up while only 146286227Sjch * holding a read lock on the global pcblist lock. This is important for 147286227Sjch * performance when attempting to find the connection for a packet given its IP 148286227Sjch * and port tuple. 149180368Srwatson * 150286227Sjch * One noteworthy exception is that the global pcbinfo lock follows a different 151286227Sjch * set of rules in relation to the inp_list field. Rather than being 152286227Sjch * write-locked for modifications and read-locked for list iterations, it must 153286227Sjch * be read-locked during modifications and write-locked during list iterations. 154286227Sjch * This ensures that the relatively rare global list iterations safely walk a 155286227Sjch * stable snapshot of connections while allowing more common list modifications 156286227Sjch * to safely grab the pcblist lock just while adding or removing a connection 157286227Sjch * from the global list. 158286227Sjch * 159180368Srwatson * Key: 160180368Srwatson * (c) - Constant after initialization 161222748Srwatson * (g) - Protected by the pcbgroup lock 162180368Srwatson * (i) - Protected by the inpcb lock 163180368Srwatson * (p) - Protected by the pcbinfo lock for the inpcb 164286227Sjch * (l) - Protected by the pcblist lock for the inpcb 165286227Sjch * (h) - Protected by the pcbhash lock for the inpcb 166180368Srwatson * (s) - Protected by another subsystem's locks 167180368Srwatson * (x) - Undefined locking 168180368Srwatson * 169180368Srwatson * A few other notes: 170180368Srwatson * 171180368Srwatson * When a read lock is held, stability of the field is guaranteed; to write 172180368Srwatson * to a field, a write lock must generally be held. 173180368Srwatson * 174180368Srwatson * netinet/netinet6-layer code should not assume that the inp_socket pointer 175180368Srwatson * is safe to dereference without inp_lock being held, even for protocols 176180368Srwatson * other than TCP (where the inpcb persists during TIMEWAIT even after the 177180368Srwatson * socket has been freed), or there may be close(2)-related races. 178180368Srwatson * 179180368Srwatson * The inp_vflag field is overloaded, and would otherwise ideally be (c). 180286227Sjch * 181286227Sjch * TODO: Currently only the TCP stack is leveraging the global pcbinfo lock 182286227Sjch * read-lock usage during modification, this model can be applied to other 183286227Sjch * protocols (especially SCTP). 184180368Srwatson */ 1851541Srgrimesstruct inpcb { 186286227Sjch LIST_ENTRY(inpcb) inp_hash; /* (h/i) hash list */ 187222748Srwatson LIST_ENTRY(inpcb) inp_pcbgrouphash; /* (g/i) hash list */ 188286227Sjch LIST_ENTRY(inpcb) inp_list; /* (p/l) list for all PCBs for proto */ 189286227Sjch /* (p[w]) for list iteration */ 190286227Sjch /* (p[r]/l) for addition/removal */ 191180368Srwatson void *inp_ppcb; /* (i) pointer to per-protocol pcb */ 192180368Srwatson struct inpcbinfo *inp_pcbinfo; /* (c) PCB list info */ 193222748Srwatson struct inpcbgroup *inp_pcbgroup; /* (g/i) PCB group list */ 194286227Sjch LIST_ENTRY(inpcb) inp_pcbgroup_wild; /* (g/i/h) group wildcard entry */ 195185791Srwatson struct socket *inp_socket; /* (i) back pointer to socket */ 196183606Sbz struct ucred *inp_cred; /* (c) cache of socket cred */ 197185791Srwatson u_int32_t inp_flow; /* (i) IPv6 flow information */ 198180368Srwatson int inp_flags; /* (i) generic IP/datagram flags */ 199191126Skmacy int inp_flags2; /* (i) generic IP/datagram flags #2*/ 200180368Srwatson u_char inp_vflag; /* (i) IP version flag (v4/v6) */ 201180368Srwatson u_char inp_ip_ttl; /* (i) time to live proto */ 202180368Srwatson u_char inp_ip_p; /* (c) protocol proto */ 203180368Srwatson u_char inp_ip_minttl; /* (i) minimum TTL or drop */ 204190880Skmacy uint32_t inp_flowid; /* (x) flow id / queue id */ 205185773Srwatson u_int inp_refcount; /* (i) refcount */ 206302153Snp void *inp_pspare[5]; /* (x) packet pacing / general use */ 207266418Sadrian uint32_t inp_flowtype; /* (x) M_HASHTYPE value */ 208268479Sadrian uint32_t inp_rss_listen_bucket; /* (x) overridden RSS listen bucket */ 209302153Snp u_int inp_ispare[4]; /* (x) packet pacing / user cookie / 210224151Sbz * general use */ 21153541Sshin 212174388Skmacy /* Local and foreign ports, local and foreign addr. */ 213286227Sjch struct in_conninfo inp_inc; /* (i) list for PCB's local port */ 214174388Skmacy 215185791Srwatson /* MAC and IPSEC policy information. */ 216180368Srwatson struct label *inp_label; /* (i) MAC label */ 217180368Srwatson struct inpcbpolicy *inp_sp; /* (s) for IPSEC */ 218174388Skmacy 219169154Srwatson /* Protocol-dependent part; options. */ 22053541Sshin struct { 221180368Srwatson u_char inp4_ip_tos; /* (i) type of service proto */ 222180368Srwatson struct mbuf *inp4_options; /* (i) IP options */ 223185791Srwatson struct ip_moptions *inp4_moptions; /* (i) IP mcast options */ 22453541Sshin } inp_depend4; 22553541Sshin struct { 226180368Srwatson /* (i) IP options */ 22753541Sshin struct mbuf *inp6_options; 228180368Srwatson /* (i) IP6 options for outgoing packets */ 22953541Sshin struct ip6_pktopts *inp6_outputopts; 230180368Srwatson /* (i) IP multicast options */ 23153541Sshin struct ip6_moptions *inp6_moptions; 232180368Srwatson /* (i) ICMPv6 code type filter */ 23353541Sshin struct icmp6_filter *inp6_icmp6filt; 234180368Srwatson /* (i) IPV6_CHECKSUM setsockopt */ 23553541Sshin int inp6_cksum; 23653541Sshin short inp6_hops; 23753541Sshin } inp_depend6; 238286227Sjch LIST_ENTRY(inpcb) inp_portlist; /* (i/h) */ 239286227Sjch struct inpcbport *inp_phd; /* (i/h) head of this list */ 240160491Sups#define inp_zero_size offsetof(struct inpcb, inp_gencnt) 241185791Srwatson inp_gen_t inp_gencnt; /* (c) generation count */ 242191158Skmacy struct llentry *inp_lle; /* cached L2 information */ 243178285Srwatson struct rwlock inp_lock; 244297225Sgnn rt_gen_t inp_rt_cookie; /* generation for route entry */ 245297225Sgnn union { /* cached L3 information */ 246297225Sgnn struct route inpu_route; 247297225Sgnn struct route_in6 inpu_route6; 248297225Sgnn } inp_rtu; 249297225Sgnn#define inp_route inp_rtu.inpu_route 250297225Sgnn#define inp_route6 inp_rtu.inpu_route6 251185791Srwatson}; 252185791Srwatson#define inp_fport inp_inc.inc_fport 253185791Srwatson#define inp_lport inp_inc.inc_lport 254185791Srwatson#define inp_faddr inp_inc.inc_faddr 255185791Srwatson#define inp_laddr inp_inc.inc_laddr 256185791Srwatson#define inp_ip_tos inp_depend4.inp4_ip_tos 257185791Srwatson#define inp_options inp_depend4.inp4_options 258185791Srwatson#define inp_moptions inp_depend4.inp4_moptions 25998102Shsu 26086764Sjlemon#define in6p_faddr inp_inc.inc6_faddr 26186764Sjlemon#define in6p_laddr inp_inc.inc6_laddr 262271400Sae#define in6p_zoneid inp_inc.inc6_zoneid 26353541Sshin#define in6p_hops inp_depend6.inp6_hops /* default hop limit */ 26453541Sshin#define in6p_flowinfo inp_flow 26553541Sshin#define in6p_options inp_depend6.inp6_options 26653541Sshin#define in6p_outputopts inp_depend6.inp6_outputopts 26753541Sshin#define in6p_moptions inp_depend6.inp6_moptions 26853541Sshin#define in6p_icmp6filt inp_depend6.inp6_icmp6filt 26953541Sshin#define in6p_cksum inp_depend6.inp6_cksum 270185791Srwatson 271191688Szec#define inp_vnet inp_pcbinfo->ipi_vnet 272191688Szec 27334881Swollman/* 274169154Srwatson * The range of the generation count, as used in this implementation, is 9e19. 275169154Srwatson * We would have to create 300 billion connections per second for this number 276169154Srwatson * to roll over in a year. This seems sufficiently unlikely that we simply 277169154Srwatson * don't concern ourselves with that possibility. 27834881Swollman */ 2791541Srgrimes 28036079Swollman/* 281169154Srwatson * Interface exported to userland by various protocols which use inpcbs. Hack 282169154Srwatson * alert -- only define if struct xsocket is in scope. 28336079Swollman */ 28436079Swollman#ifdef _SYS_SOCKETVAR_H_ 28536079Swollmanstruct xinpcb { 28636079Swollman size_t xi_len; /* length of this structure */ 28736079Swollman struct inpcb xi_inp; 28836079Swollman struct xsocket xi_socket; 28936079Swollman u_quad_t xi_alignment_hack; 29036079Swollman}; 29136079Swollman 29236079Swollmanstruct xinpgen { 29336079Swollman size_t xig_len; /* length of this structure */ 29436079Swollman u_int xig_count; /* number of PCBs at this time */ 29536079Swollman inp_gen_t xig_gen; /* generation count at this time */ 29636079Swollman so_gen_t xig_sogen; /* socket generation count at this time */ 29736079Swollman}; 29836079Swollman#endif /* _SYS_SOCKETVAR_H_ */ 29936079Swollman 30032821Sdgstruct inpcbport { 30160938Sjake LIST_ENTRY(inpcbport) phd_hash; 30232821Sdg struct inpcbhead phd_pcblist; 30332821Sdg u_short phd_port; 30432821Sdg}; 30532821Sdg 306222213Srwatson/*- 307169154Srwatson * Global data structure for each high-level protocol (UDP, TCP, ...) in both 308169154Srwatson * IPv4 and IPv6. Holds inpcb lists and information for managing them. 309222213Srwatson * 310286227Sjch * Each pcbinfo is protected by three locks: ipi_lock, ipi_hash_lock and 311286227Sjch * ipi_list_lock: 312286227Sjch * - ipi_lock covering the global pcb list stability during loop iteration, 313286227Sjch * - ipi_hash_lock covering the hashed lookup tables, 314286227Sjch * - ipi_list_lock covering mutable global fields (such as the global 315286227Sjch * pcb list) 316222213Srwatson * 317286227Sjch * The lock order is: 318222213Srwatson * 319286227Sjch * ipi_lock (before) 320286227Sjch * inpcb locks (before) 321286227Sjch * ipi_list locks (before) 322286227Sjch * {ipi_hash_lock, pcbgroup locks} 323286227Sjch * 324222213Srwatson * Locking key: 325222213Srwatson * 326222213Srwatson * (c) Constant or nearly constant after initialisation 327222213Srwatson * (g) Locked by ipi_lock 328286227Sjch * (l) Locked by ipi_list_lock 329222748Srwatson * (h) Read using either ipi_hash_lock or inpcb lock; write requires both 330222748Srwatson * (p) Protected by one or more pcbgroup locks 331222213Srwatson * (x) Synchronisation properties poorly defined 332169154Srwatson */ 333169154Srwatsonstruct inpcbinfo { 334169154Srwatson /* 335286227Sjch * Global lock protecting full inpcb list traversal 336169154Srwatson */ 337222213Srwatson struct rwlock ipi_lock; 338169154Srwatson 339169154Srwatson /* 340222213Srwatson * Global list of inpcbs on the protocol. 341169154Srwatson */ 342286227Sjch struct inpcbhead *ipi_listhead; /* (g/l) */ 343286227Sjch u_int ipi_count; /* (l) */ 344169154Srwatson 345169154Srwatson /* 346222213Srwatson * Generation count -- incremented each time a connection is allocated 347222213Srwatson * or freed. 348169154Srwatson */ 349286227Sjch u_quad_t ipi_gencnt; /* (l) */ 350169154Srwatson 351169154Srwatson /* 352169154Srwatson * Fields associated with port lookup and allocation. 353169154Srwatson */ 354222213Srwatson u_short ipi_lastport; /* (x) */ 355222213Srwatson u_short ipi_lastlow; /* (x) */ 356222213Srwatson u_short ipi_lasthi; /* (x) */ 357169154Srwatson 358169154Srwatson /* 359169154Srwatson * UMA zone from which inpcbs are allocated for this protocol. 360169154Srwatson */ 361222213Srwatson struct uma_zone *ipi_zone; /* (c) */ 362169154Srwatson 363169154Srwatson /* 364222748Srwatson * Connection groups associated with this protocol. These fields are 365222748Srwatson * constant, but pcbgroup structures themselves are protected by 366222748Srwatson * per-pcbgroup locks. 367222488Srwatson */ 368222748Srwatson struct inpcbgroup *ipi_pcbgroups; /* (c) */ 369222748Srwatson u_int ipi_npcbgroups; /* (c) */ 370222748Srwatson u_int ipi_hashfields; /* (c) */ 371222748Srwatson 372222748Srwatson /* 373222748Srwatson * Global lock protecting non-pcbgroup hash lookup tables. 374222748Srwatson */ 375250300Sandre struct rwlock ipi_hash_lock; 376222488Srwatson 377222488Srwatson /* 378222213Srwatson * Global hash of inpcbs, hashed by local and foreign addresses and 379222213Srwatson * port numbers. 380169154Srwatson */ 381222488Srwatson struct inpcbhead *ipi_hashbase; /* (h) */ 382222488Srwatson u_long ipi_hashmask; /* (h) */ 383174388Skmacy 384174388Skmacy /* 385222213Srwatson * Global hash of inpcbs, hashed by only local port number. 386222213Srwatson */ 387222488Srwatson struct inpcbporthead *ipi_porthashbase; /* (h) */ 388222488Srwatson u_long ipi_porthashmask; /* (h) */ 389222213Srwatson 390222213Srwatson /* 391222748Srwatson * List of wildcard inpcbs for use with pcbgroups. In the past, was 392222748Srwatson * per-pcbgroup but is now global. All pcbgroup locks must be held 393222748Srwatson * to modify the list, so any is sufficient to read it. 394222748Srwatson */ 395222748Srwatson struct inpcbhead *ipi_wildbase; /* (p) */ 396222748Srwatson u_long ipi_wildmask; /* (p) */ 397222748Srwatson 398222748Srwatson /* 399191688Szec * Pointer to network stack instance 400174388Skmacy */ 401222213Srwatson struct vnet *ipi_vnet; /* (c) */ 402191688Szec 403191688Szec /* 404191688Szec * general use 2 405191688Szec */ 406181365Srwatson void *ipi_pspare[2]; 407286227Sjch 408286227Sjch /* 409286227Sjch * Global lock protecting global inpcb list, inpcb count, etc. 410286227Sjch */ 411286227Sjch struct rwlock ipi_list_lock; 4127684Sdg}; 4137684Sdg 414233096Srmh#ifdef _KERNEL 415222748Srwatson/* 416222748Srwatson * Connection groups hold sets of connections that have similar CPU/thread 417222748Srwatson * affinity. Each connection belongs to exactly one connection group. 418222748Srwatson */ 419222748Srwatsonstruct inpcbgroup { 420222748Srwatson /* 421222748Srwatson * Per-connection group hash of inpcbs, hashed by local and foreign 422222748Srwatson * addresses and port numbers. 423222748Srwatson */ 424222748Srwatson struct inpcbhead *ipg_hashbase; /* (c) */ 425222748Srwatson u_long ipg_hashmask; /* (c) */ 426222748Srwatson 427222748Srwatson /* 428222748Srwatson * Notional affinity of this pcbgroup. 429222748Srwatson */ 430222748Srwatson u_int ipg_cpu; /* (p) */ 431222748Srwatson 432222748Srwatson /* 433222748Srwatson * Per-connection group lock, not to be confused with ipi_lock. 434222748Srwatson * Protects the hash table hung off the group, but also the global 435222748Srwatson * wildcard list in inpcbinfo. 436222748Srwatson */ 437222748Srwatson struct mtx ipg_lock; 438222748Srwatson} __aligned(CACHE_LINE_SIZE); 439222748Srwatson 440122991Ssam#define INP_LOCK_INIT(inp, d, t) \ 441178285Srwatson rw_init_flags(&(inp)->inp_lock, (t), RW_RECURSE | RW_DUPOK) 442178285Srwatson#define INP_LOCK_DESTROY(inp) rw_destroy(&(inp)->inp_lock) 443178285Srwatson#define INP_RLOCK(inp) rw_rlock(&(inp)->inp_lock) 444178285Srwatson#define INP_WLOCK(inp) rw_wlock(&(inp)->inp_lock) 445180536Srwatson#define INP_TRY_RLOCK(inp) rw_try_rlock(&(inp)->inp_lock) 446180536Srwatson#define INP_TRY_WLOCK(inp) rw_try_wlock(&(inp)->inp_lock) 447178285Srwatson#define INP_RUNLOCK(inp) rw_runlock(&(inp)->inp_lock) 448178285Srwatson#define INP_WUNLOCK(inp) rw_wunlock(&(inp)->inp_lock) 449191125Skmacy#define INP_TRY_UPGRADE(inp) rw_try_upgrade(&(inp)->inp_lock) 450191125Skmacy#define INP_DOWNGRADE(inp) rw_downgrade(&(inp)->inp_lock) 451191125Skmacy#define INP_WLOCKED(inp) rw_wowned(&(inp)->inp_lock) 452191125Skmacy#define INP_LOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_LOCKED) 453178285Srwatson#define INP_RLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_RLOCKED) 454178285Srwatson#define INP_WLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_WLOCKED) 455178285Srwatson#define INP_UNLOCK_ASSERT(inp) rw_assert(&(inp)->inp_lock, RA_UNLOCKED) 45698102Shsu 457177530Skmacy/* 458181365Srwatson * These locking functions are for inpcb consumers outside of sys/netinet, 459177530Skmacy * more specifically, they were added for the benefit of TOE drivers. The 460177530Skmacy * macros are reserved for use by the stack. 461177530Skmacy */ 462177530Skmacyvoid inp_wlock(struct inpcb *); 463177530Skmacyvoid inp_wunlock(struct inpcb *); 464177530Skmacyvoid inp_rlock(struct inpcb *); 465177530Skmacyvoid inp_runlock(struct inpcb *); 466177530Skmacy 467177530Skmacy#ifdef INVARIANTS 468177575Skmacyvoid inp_lock_assert(struct inpcb *); 469177575Skmacyvoid inp_unlock_assert(struct inpcb *); 470177530Skmacy#else 471177530Skmacystatic __inline void 472177575Skmacyinp_lock_assert(struct inpcb *inp __unused) 473177530Skmacy{ 474177530Skmacy} 475177530Skmacy 476177530Skmacystatic __inline void 477177575Skmacyinp_unlock_assert(struct inpcb *inp __unused) 478177530Skmacy{ 479177530Skmacy} 480177575Skmacy 481177530Skmacy#endif 482180640Skmacy 483180678Skmacyvoid inp_apply_all(void (*func)(struct inpcb *, void *), void *arg); 484180678Skmacyint inp_ip_tos_get(const struct inpcb *inp); 485180678Skmacyvoid inp_ip_tos_set(struct inpcb *inp, int val); 486180678Skmacystruct socket * 487180678Skmacy inp_inpcbtosocket(struct inpcb *inp); 488180678Skmacystruct tcpcb * 489180678Skmacy inp_inpcbtotcpcb(struct inpcb *inp); 490181365Srwatsonvoid inp_4tuple_get(struct inpcb *inp, uint32_t *laddr, uint16_t *lp, 491180678Skmacy uint32_t *faddr, uint16_t *fp); 492252710Strocinyshort inp_so_options(const struct inpcb *inp); 493180640Skmacy 494177575Skmacy#endif /* _KERNEL */ 495177530Skmacy 49698102Shsu#define INP_INFO_LOCK_INIT(ipi, d) \ 497178285Srwatson rw_init_flags(&(ipi)->ipi_lock, (d), RW_RECURSE) 498178285Srwatson#define INP_INFO_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_lock) 499178285Srwatson#define INP_INFO_RLOCK(ipi) rw_rlock(&(ipi)->ipi_lock) 500178285Srwatson#define INP_INFO_WLOCK(ipi) rw_wlock(&(ipi)->ipi_lock) 501180536Srwatson#define INP_INFO_TRY_RLOCK(ipi) rw_try_rlock(&(ipi)->ipi_lock) 502180536Srwatson#define INP_INFO_TRY_WLOCK(ipi) rw_try_wlock(&(ipi)->ipi_lock) 503204806Srwatson#define INP_INFO_TRY_UPGRADE(ipi) rw_try_upgrade(&(ipi)->ipi_lock) 504286443Sjch#define INP_INFO_WLOCKED(ipi) rw_wowned(&(ipi)->ipi_lock) 505178285Srwatson#define INP_INFO_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_lock) 506178285Srwatson#define INP_INFO_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_lock) 507178285Srwatson#define INP_INFO_LOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_LOCKED) 508178285Srwatson#define INP_INFO_RLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_RLOCKED) 509178285Srwatson#define INP_INFO_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_WLOCKED) 510178285Srwatson#define INP_INFO_UNLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_lock, RA_UNLOCKED) 51198102Shsu 512286227Sjch#define INP_LIST_LOCK_INIT(ipi, d) \ 513286227Sjch rw_init_flags(&(ipi)->ipi_list_lock, (d), 0) 514286227Sjch#define INP_LIST_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_list_lock) 515286227Sjch#define INP_LIST_RLOCK(ipi) rw_rlock(&(ipi)->ipi_list_lock) 516286227Sjch#define INP_LIST_WLOCK(ipi) rw_wlock(&(ipi)->ipi_list_lock) 517286227Sjch#define INP_LIST_TRY_RLOCK(ipi) rw_try_rlock(&(ipi)->ipi_list_lock) 518286227Sjch#define INP_LIST_TRY_WLOCK(ipi) rw_try_wlock(&(ipi)->ipi_list_lock) 519286227Sjch#define INP_LIST_TRY_UPGRADE(ipi) rw_try_upgrade(&(ipi)->ipi_list_lock) 520286227Sjch#define INP_LIST_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_list_lock) 521286227Sjch#define INP_LIST_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_list_lock) 522286227Sjch#define INP_LIST_LOCK_ASSERT(ipi) \ 523286227Sjch rw_assert(&(ipi)->ipi_list_lock, RA_LOCKED) 524286227Sjch#define INP_LIST_RLOCK_ASSERT(ipi) \ 525286227Sjch rw_assert(&(ipi)->ipi_list_lock, RA_RLOCKED) 526286227Sjch#define INP_LIST_WLOCK_ASSERT(ipi) \ 527286227Sjch rw_assert(&(ipi)->ipi_list_lock, RA_WLOCKED) 528286227Sjch#define INP_LIST_UNLOCK_ASSERT(ipi) \ 529286227Sjch rw_assert(&(ipi)->ipi_list_lock, RA_UNLOCKED) 530286227Sjch 531222488Srwatson#define INP_HASH_LOCK_INIT(ipi, d) \ 532222488Srwatson rw_init_flags(&(ipi)->ipi_hash_lock, (d), 0) 533222488Srwatson#define INP_HASH_LOCK_DESTROY(ipi) rw_destroy(&(ipi)->ipi_hash_lock) 534222488Srwatson#define INP_HASH_RLOCK(ipi) rw_rlock(&(ipi)->ipi_hash_lock) 535222488Srwatson#define INP_HASH_WLOCK(ipi) rw_wlock(&(ipi)->ipi_hash_lock) 536222488Srwatson#define INP_HASH_RUNLOCK(ipi) rw_runlock(&(ipi)->ipi_hash_lock) 537222488Srwatson#define INP_HASH_WUNLOCK(ipi) rw_wunlock(&(ipi)->ipi_hash_lock) 538222488Srwatson#define INP_HASH_LOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_hash_lock, \ 539222488Srwatson RA_LOCKED) 540222488Srwatson#define INP_HASH_WLOCK_ASSERT(ipi) rw_assert(&(ipi)->ipi_hash_lock, \ 541222488Srwatson RA_WLOCKED) 542222488Srwatson 543222748Srwatson#define INP_GROUP_LOCK_INIT(ipg, d) mtx_init(&(ipg)->ipg_lock, (d), NULL, \ 544222748Srwatson MTX_DEF | MTX_DUPOK) 545222748Srwatson#define INP_GROUP_LOCK_DESTROY(ipg) mtx_destroy(&(ipg)->ipg_lock) 546222748Srwatson 547222748Srwatson#define INP_GROUP_LOCK(ipg) mtx_lock(&(ipg)->ipg_lock) 548222748Srwatson#define INP_GROUP_LOCK_ASSERT(ipg) mtx_assert(&(ipg)->ipg_lock, MA_OWNED) 549222748Srwatson#define INP_GROUP_UNLOCK(ipg) mtx_unlock(&(ipg)->ipg_lock) 550222748Srwatson 55123324Sdg#define INP_PCBHASH(faddr, lport, fport, mask) \ 55232821Sdg (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) 55332821Sdg#define INP_PCBPORTHASH(lport, mask) \ 55432821Sdg (ntohs((lport)) & (mask)) 555271386Sae#define INP6_PCBHASHKEY(faddr) ((faddr)->s6_addr32[3]) 55623324Sdg 557185791Srwatson/* 558191126Skmacy * Flags for inp_vflags -- historically version flags only 559185791Srwatson */ 560185791Srwatson#define INP_IPV4 0x1 561185791Srwatson#define INP_IPV6 0x2 562185791Srwatson#define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */ 563185791Srwatson 564185791Srwatson/* 565191126Skmacy * Flags for inp_flags. 566185791Srwatson */ 567189848Srwatson#define INP_RECVOPTS 0x00000001 /* receive incoming IP options */ 568189848Srwatson#define INP_RECVRETOPTS 0x00000002 /* receive IP options for reply */ 569189848Srwatson#define INP_RECVDSTADDR 0x00000004 /* receive IP dst address */ 570189848Srwatson#define INP_HDRINCL 0x00000008 /* user supplies entire IP header */ 571189848Srwatson#define INP_HIGHPORT 0x00000010 /* user wants "high" port binding */ 572189848Srwatson#define INP_LOWPORT 0x00000020 /* user wants "low" port binding */ 573189848Srwatson#define INP_ANONPORT 0x00000040 /* port chosen for user */ 574189848Srwatson#define INP_RECVIF 0x00000080 /* receive incoming interface */ 575189848Srwatson#define INP_MTUDISC 0x00000100 /* user can do MTU discovery */ 576274331Smelifaro /* 0x000200 unused: was INP_FAITH */ 577189848Srwatson#define INP_RECVTTL 0x00000400 /* receive incoming IP TTL */ 578189848Srwatson#define INP_DONTFRAG 0x00000800 /* don't fragment packet */ 579193217Spjd#define INP_BINDANY 0x00001000 /* allow bind to any address */ 580189848Srwatson#define INP_INHASHLIST 0x00002000 /* in_pcbinshash() has been called */ 581236959Stuexen#define INP_RECVTOS 0x00004000 /* receive incoming IP TOS */ 582189848Srwatson#define IN6P_IPV6_V6ONLY 0x00008000 /* restrict AF_INET6 socket for v6 */ 583189848Srwatson#define IN6P_PKTINFO 0x00010000 /* receive IP6 dst and I/F */ 584189848Srwatson#define IN6P_HOPLIMIT 0x00020000 /* receive hoplimit */ 585189848Srwatson#define IN6P_HOPOPTS 0x00040000 /* receive hop-by-hop options */ 586189848Srwatson#define IN6P_DSTOPTS 0x00080000 /* receive dst options after rthdr */ 587189848Srwatson#define IN6P_RTHDR 0x00100000 /* receive routing header */ 588189848Srwatson#define IN6P_RTHDRDSTOPTS 0x00200000 /* receive dstoptions before rthdr */ 589189848Srwatson#define IN6P_TCLASS 0x00400000 /* receive traffic class value */ 590189848Srwatson#define IN6P_AUTOFLOWLABEL 0x00800000 /* attach flowlabel automatically */ 591189848Srwatson#define INP_TIMEWAIT 0x01000000 /* in TIMEWAIT, ppcb is tcptw */ 592189848Srwatson#define INP_ONESBCAST 0x02000000 /* send all-ones broadcast */ 593189848Srwatson#define INP_DROPPED 0x04000000 /* protocol drop flag */ 594189848Srwatson#define INP_SOCKREF 0x08000000 /* strong socket reference */ 595275358Shselasky#define INP_RESERVED_0 0x10000000 /* reserved field */ 596275358Shselasky#define INP_RESERVED_1 0x20000000 /* reserved field */ 597121477Sume#define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */ 598121477Sume#define IN6P_MTU 0x80000000 /* receive path MTU */ 59978064Sume 60019622Sfenner#define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\ 601236959Stuexen INP_RECVIF|INP_RECVTTL|INP_RECVTOS|\ 60278064Sume IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\ 60378064Sume IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\ 604121472Sume IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\ 605121472Sume IN6P_MTU) 6061541Srgrimes 607191126Skmacy/* 608191126Skmacy * Flags for inp_flags2. 609191126Skmacy */ 610191129Skmacy#define INP_LLE_VALID 0x00000001 /* cached lle is valid */ 611191129Skmacy#define INP_RT_VALID 0x00000002 /* cached rtentry is valid */ 612222748Srwatson#define INP_PCBGROUPWILD 0x00000004 /* in pcbgroup wildcard list */ 613227207Strociny#define INP_REUSEPORT 0x00000008 /* SO_REUSEPORT option is set */ 614241129Sglebius#define INP_FREED 0x00000010 /* inp itself is not valid */ 615252710Strociny#define INP_REUSEADDR 0x00000020 /* SO_REUSEADDR option is set */ 616268479Sadrian#define INP_BINDMULTI 0x00000040 /* IP_BINDMULTI option is set */ 617268479Sadrian#define INP_RSS_BUCKET_SET 0x00000080 /* IP_RSS_LISTEN_BUCKET is set */ 618271293Sadrian#define INP_RECVFLOWID 0x00000100 /* populate recv datagram with flow info */ 619271293Sadrian#define INP_RECVRSSBUCKETID 0x00000200 /* populate recv datagram with bucket id */ 620191126Skmacy 621222488Srwatson/* 622222488Srwatson * Flags passed to in_pcblookup*() functions. 623222488Srwatson */ 624222488Srwatson#define INPLOOKUP_WILDCARD 0x00000001 /* Allow wildcard sockets. */ 625222488Srwatson#define INPLOOKUP_RLOCKPCB 0x00000002 /* Return inpcb read-locked. */ 626222488Srwatson#define INPLOOKUP_WLOCKPCB 0x00000004 /* Return inpcb write-locked. */ 627222488Srwatson 628222488Srwatson#define INPLOOKUP_MASK (INPLOOKUP_WILDCARD | INPLOOKUP_RLOCKPCB | \ 629222488Srwatson INPLOOKUP_WLOCKPCB) 630222488Srwatson 6311541Srgrimes#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) 63253541Sshin#define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */ 6331541Srgrimes 63453541Sshin#define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family 63553541Sshin 636133874Srwatson#define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af) 63753541Sshin 638222748Srwatson/* 639222748Srwatson * Constants for pcbinfo.ipi_hashfields. 640222748Srwatson */ 641222748Srwatson#define IPI_HASHFIELDS_NONE 0 642222748Srwatson#define IPI_HASHFIELDS_2TUPLE 1 643222748Srwatson#define IPI_HASHFIELDS_4TUPLE 2 644222748Srwatson 64555205Speter#ifdef _KERNEL 646195699SrwatsonVNET_DECLARE(int, ipport_reservedhigh); 647195699SrwatsonVNET_DECLARE(int, ipport_reservedlow); 648195699SrwatsonVNET_DECLARE(int, ipport_lowfirstauto); 649195699SrwatsonVNET_DECLARE(int, ipport_lowlastauto); 650195699SrwatsonVNET_DECLARE(int, ipport_firstauto); 651195699SrwatsonVNET_DECLARE(int, ipport_lastauto); 652195699SrwatsonVNET_DECLARE(int, ipport_hifirstauto); 653195699SrwatsonVNET_DECLARE(int, ipport_hilastauto); 654195699SrwatsonVNET_DECLARE(int, ipport_randomized); 655195699SrwatsonVNET_DECLARE(int, ipport_randomcps); 656195699SrwatsonVNET_DECLARE(int, ipport_randomtime); 657195699SrwatsonVNET_DECLARE(int, ipport_stoprandom); 658195699SrwatsonVNET_DECLARE(int, ipport_tcpallocs); 659195699Srwatson 660195727Srwatson#define V_ipport_reservedhigh VNET(ipport_reservedhigh) 661195727Srwatson#define V_ipport_reservedlow VNET(ipport_reservedlow) 662195727Srwatson#define V_ipport_lowfirstauto VNET(ipport_lowfirstauto) 663195727Srwatson#define V_ipport_lowlastauto VNET(ipport_lowlastauto) 664195727Srwatson#define V_ipport_firstauto VNET(ipport_firstauto) 665195727Srwatson#define V_ipport_lastauto VNET(ipport_lastauto) 666195727Srwatson#define V_ipport_hifirstauto VNET(ipport_hifirstauto) 667195727Srwatson#define V_ipport_hilastauto VNET(ipport_hilastauto) 668195727Srwatson#define V_ipport_randomized VNET(ipport_randomized) 669195727Srwatson#define V_ipport_randomcps VNET(ipport_randomcps) 670195727Srwatson#define V_ipport_randomtime VNET(ipport_randomtime) 671195727Srwatson#define V_ipport_stoprandom VNET(ipport_stoprandom) 672195727Srwatson#define V_ipport_tcpallocs VNET(ipport_tcpallocs) 673195699Srwatson 674205157Srwatsonvoid in_pcbinfo_destroy(struct inpcbinfo *); 675205157Srwatsonvoid in_pcbinfo_init(struct inpcbinfo *, const char *, struct inpcbhead *, 676222748Srwatson int, int, char *, uma_init, uma_fini, uint32_t, u_int); 677205157Srwatson 678268557Sadrianint in_pcbbind_check_bindmulti(const struct inpcb *ni, 679268557Sadrian const struct inpcb *oi); 680268557Sadrian 681222748Srwatsonstruct inpcbgroup * 682222748Srwatson in_pcbgroup_byhash(struct inpcbinfo *, u_int, uint32_t); 683222748Srwatsonstruct inpcbgroup * 684222748Srwatson in_pcbgroup_byinpcb(struct inpcb *); 685222748Srwatsonstruct inpcbgroup * 686222748Srwatson in_pcbgroup_bytuple(struct inpcbinfo *, struct in_addr, u_short, 687222748Srwatson struct in_addr, u_short); 688222748Srwatsonvoid in_pcbgroup_destroy(struct inpcbinfo *); 689222748Srwatsonint in_pcbgroup_enabled(struct inpcbinfo *); 690222748Srwatsonvoid in_pcbgroup_init(struct inpcbinfo *, u_int, int); 691222748Srwatsonvoid in_pcbgroup_remove(struct inpcb *); 692222748Srwatsonvoid in_pcbgroup_update(struct inpcb *); 693222748Srwatsonvoid in_pcbgroup_update_mbuf(struct inpcb *, struct mbuf *); 694222748Srwatson 69598102Shsuvoid in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *); 696160491Supsint in_pcballoc(struct socket *, struct inpcbinfo *); 697127505Spjdint in_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *); 698219579Sbzint in_pcb_lport(struct inpcb *, struct in_addr *, u_short *, 699219579Sbz struct ucred *, int); 700105565Siedowseint in_pcbbind_setup(struct inpcb *, struct sockaddr *, in_addr_t *, 701127505Spjd u_short *, struct ucred *); 702127505Spjdint in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *); 703222691Srwatsonint in_pcbconnect_mbuf(struct inpcb *, struct sockaddr *, struct ucred *, 704222691Srwatson struct mbuf *); 705105629Siedowseint in_pcbconnect_setup(struct inpcb *, struct sockaddr *, in_addr_t *, 706105629Siedowse u_short *, in_addr_t *, u_short *, struct inpcb **, 707127505Spjd struct ucred *); 70892723Salfredvoid in_pcbdetach(struct inpcb *); 70992723Salfredvoid in_pcbdisconnect(struct inpcb *); 710158009Srwatsonvoid in_pcbdrop(struct inpcb *); 711157373Srwatsonvoid in_pcbfree(struct inpcb *); 71292723Salfredint in_pcbinshash(struct inpcb *); 713222748Srwatsonint in_pcbinshash_nopcbgroup(struct inpcb *); 714264879Ssmhint in_pcbladdr(struct inpcb *, struct in_addr *, struct in_addr *, 715264879Ssmh struct ucred *); 7161541Srgrimesstruct inpcb * 71792723Salfred in_pcblookup_local(struct inpcbinfo *, 718180427Sbz struct in_addr, u_short, int, struct ucred *); 7197684Sdgstruct inpcb * 720222488Srwatson in_pcblookup(struct inpcbinfo *, struct in_addr, u_int, 72193085Sbde struct in_addr, u_int, int, struct ifnet *); 722222691Srwatsonstruct inpcb * 723222691Srwatson in_pcblookup_mbuf(struct inpcbinfo *, struct in_addr, u_int, 724222691Srwatson struct in_addr, u_int, int, struct ifnet *, struct mbuf *); 72598102Shsuvoid in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, 72698211Shsu int, struct inpcb *(*)(struct inpcb *, int)); 727185773Srwatsonvoid in_pcbref(struct inpcb *); 72892723Salfredvoid in_pcbrehash(struct inpcb *); 729222691Srwatsonvoid in_pcbrehash_mbuf(struct inpcb *, struct mbuf *); 730185773Srwatsonint in_pcbrele(struct inpcb *); 731222217Srwatsonint in_pcbrele_rlocked(struct inpcb *); 732222217Srwatsonint in_pcbrele_wlocked(struct inpcb *); 733297225Sgnnvoid in_losing(struct inpcb *); 734122875Srwatsonvoid in_pcbsetsolabel(struct socket *so); 735169462Srwatsonint in_getpeeraddr(struct socket *so, struct sockaddr **nam); 736169462Srwatsonint in_getsockaddr(struct socket *so, struct sockaddr **nam); 737102218Struckmanstruct sockaddr * 738102218Struckman in_sockaddr(in_port_t port, struct in_addr *addr); 739122875Srwatsonvoid in_pcbsosetlabel(struct socket *so); 74055205Speter#endif /* _KERNEL */ 74134881Swollman 74234923Sbde#endif /* !_NETINET_IN_PCB_H_ */ 743