1c398230bSWarner Losh /*- 2df8bae1dSRodney W. Grimes * Copyright (c) 1982, 1986, 1990, 1993 3df8bae1dSRodney W. Grimes * The Regents of the University of California. All rights reserved. 4df8bae1dSRodney W. Grimes * 5df8bae1dSRodney W. Grimes * Redistribution and use in source and binary forms, with or without 6df8bae1dSRodney W. Grimes * modification, are permitted provided that the following conditions 7df8bae1dSRodney W. Grimes * are met: 8df8bae1dSRodney W. Grimes * 1. Redistributions of source code must retain the above copyright 9df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer. 10df8bae1dSRodney W. Grimes * 2. Redistributions in binary form must reproduce the above copyright 11df8bae1dSRodney W. Grimes * notice, this list of conditions and the following disclaimer in the 12df8bae1dSRodney W. Grimes * documentation and/or other materials provided with the distribution. 13df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 14df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 15df8bae1dSRodney W. Grimes * without specific prior written permission. 16df8bae1dSRodney W. Grimes * 17df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 18df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 21df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27df8bae1dSRodney W. Grimes * SUCH DAMAGE. 28df8bae1dSRodney W. Grimes * 29df8bae1dSRodney W. Grimes * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 30c3aac50fSPeter Wemm * $FreeBSD$ 31df8bae1dSRodney W. Grimes */ 32df8bae1dSRodney W. Grimes 33707f139eSPaul Richards #ifndef _NETINET_IN_PCB_H_ 34707f139eSPaul Richards #define _NETINET_IN_PCB_H_ 35707f139eSPaul Richards 36f1844d4cSBruce Evans #include <sys/queue.h> 3740545cf5SBruce Evans #include <sys/_lock.h> 3840545cf5SBruce Evans #include <sys/_mutex.h> 39f1844d4cSBruce Evans 4038e04732SRobert Watson #include <net/route.h> 4182cd038dSYoshinobu Inoue 4282cd038dSYoshinobu Inoue #define in6pcb inpcb /* for KAME src sync over BSD*'s */ 4382cd038dSYoshinobu Inoue #define in6p_sp inp_sp /* for KAME src sync over BSD*'s */ 44b9234fafSSam Leffler struct inpcbpolicy; 4582cd038dSYoshinobu Inoue 46df8bae1dSRodney W. Grimes /* 47df8bae1dSRodney W. Grimes * Common structure pcb for internet protocol implementation. 48df8bae1dSRodney W. Grimes * Here are stored pointers to local and foreign host table 49df8bae1dSRodney W. Grimes * entries, local and foreign socket numbers, and pointers 50df8bae1dSRodney W. Grimes * up (to a socket structure) and down (to a protocol-specific) 51df8bae1dSRodney W. Grimes * control block. 52df8bae1dSRodney W. Grimes */ 53e3975643SJake Burkholder LIST_HEAD(inpcbhead, inpcb); 54e3975643SJake Burkholder LIST_HEAD(inpcbporthead, inpcbport); 5598271db4SGarrett Wollman typedef u_quad_t inp_gen_t; 5615bd2b43SDavid Greenman 573d4d47f3SGarrett Wollman /* 5882cd038dSYoshinobu Inoue * PCB with AF_INET6 null bind'ed laddr can receive AF_INET input packet. 5982cd038dSYoshinobu Inoue * So, AF_INET6 null laddr is also used as AF_INET null laddr, 6082cd038dSYoshinobu Inoue * by utilize following structure. (At last, same as INRIA) 6182cd038dSYoshinobu Inoue */ 6282cd038dSYoshinobu Inoue struct in_addr_4in6 { 6382cd038dSYoshinobu Inoue u_int32_t ia46_pad32[3]; 6482cd038dSYoshinobu Inoue struct in_addr ia46_addr4; 6582cd038dSYoshinobu Inoue }; 6682cd038dSYoshinobu Inoue 6782cd038dSYoshinobu Inoue /* 68be2ac88cSJonathan Lemon * NOTE: ipv6 addrs should be 64-bit aligned, per RFC 2553. 69be2ac88cSJonathan Lemon * in_conninfo has some extra padding to accomplish this. 70be2ac88cSJonathan Lemon */ 71be2ac88cSJonathan Lemon struct in_endpoints { 72be2ac88cSJonathan Lemon u_int16_t ie_fport; /* foreign port */ 73be2ac88cSJonathan Lemon u_int16_t ie_lport; /* local port */ 74be2ac88cSJonathan Lemon /* protocol dependent part, local and foreign addr */ 75be2ac88cSJonathan Lemon union { 76be2ac88cSJonathan Lemon /* foreign host table entry */ 77be2ac88cSJonathan Lemon struct in_addr_4in6 ie46_foreign; 78be2ac88cSJonathan Lemon struct in6_addr ie6_foreign; 79be2ac88cSJonathan Lemon } ie_dependfaddr; 80be2ac88cSJonathan Lemon union { 81be2ac88cSJonathan Lemon /* local host table entry */ 82be2ac88cSJonathan Lemon struct in_addr_4in6 ie46_local; 83be2ac88cSJonathan Lemon struct in6_addr ie6_local; 84be2ac88cSJonathan Lemon } ie_dependladdr; 85be2ac88cSJonathan Lemon #define ie_faddr ie_dependfaddr.ie46_foreign.ia46_addr4 86be2ac88cSJonathan Lemon #define ie_laddr ie_dependladdr.ie46_local.ia46_addr4 87be2ac88cSJonathan Lemon #define ie6_faddr ie_dependfaddr.ie6_foreign 88be2ac88cSJonathan Lemon #define ie6_laddr ie_dependladdr.ie6_local 89be2ac88cSJonathan Lemon }; 90be2ac88cSJonathan Lemon 91be2ac88cSJonathan Lemon /* 92be2ac88cSJonathan Lemon * XXX 9397d8d152SAndre Oppermann * the defines for inc_* are hacks and should be changed to direct references 94be2ac88cSJonathan Lemon */ 95be2ac88cSJonathan Lemon struct in_conninfo { 96be2ac88cSJonathan Lemon u_int8_t inc_flags; 97be2ac88cSJonathan Lemon u_int8_t inc_len; 98be2ac88cSJonathan Lemon u_int16_t inc_pad; /* XXX alignment for in_endpoints */ 9997d8d152SAndre Oppermann /* protocol dependent part */ 100be2ac88cSJonathan Lemon struct in_endpoints inc_ie; 101be2ac88cSJonathan Lemon }; 102be2ac88cSJonathan Lemon #define inc_isipv6 inc_flags /* temp compatability */ 103be2ac88cSJonathan Lemon #define inc_fport inc_ie.ie_fport 104be2ac88cSJonathan Lemon #define inc_lport inc_ie.ie_lport 105be2ac88cSJonathan Lemon #define inc_faddr inc_ie.ie_faddr 106be2ac88cSJonathan Lemon #define inc_laddr inc_ie.ie_laddr 107be2ac88cSJonathan Lemon #define inc6_faddr inc_ie.ie6_faddr 108be2ac88cSJonathan Lemon #define inc6_laddr inc_ie.ie6_laddr 109be2ac88cSJonathan Lemon 11082cd038dSYoshinobu Inoue struct icmp6_filter; 11182cd038dSYoshinobu Inoue 112df8bae1dSRodney W. Grimes struct inpcb { 113e3975643SJake Burkholder LIST_ENTRY(inpcb) inp_hash; /* hash list */ 114e3975643SJake Burkholder LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ 11582cd038dSYoshinobu Inoue u_int32_t inp_flow; 11682cd038dSYoshinobu Inoue 117be2ac88cSJonathan Lemon /* local and foreign ports, local and foreign addr */ 118be2ac88cSJonathan Lemon struct in_conninfo inp_inc; 11982cd038dSYoshinobu Inoue 120df8bae1dSRodney W. Grimes caddr_t inp_ppcb; /* pointer to per-protocol pcb */ 121c3229e05SDavid Greenman struct inpcbinfo *inp_pcbinfo; /* PCB list info */ 122ca98b82cSDavid Greenman struct socket *inp_socket; /* back pointer to socket */ 12382cd038dSYoshinobu Inoue /* list for this PCB's local port */ 124a557af22SRobert Watson struct label *inp_label; /* MAC label */ 125df8bae1dSRodney W. Grimes int inp_flags; /* generic IP/datagram flags */ 12682cd038dSYoshinobu Inoue 12782cd038dSYoshinobu Inoue struct inpcbpolicy *inp_sp; /* for IPSEC */ 1286d53e163SAlfred Perlstein u_char inp_vflag; /* IP version flag (v4/v6) */ 12982cd038dSYoshinobu Inoue #define INP_IPV4 0x1 13082cd038dSYoshinobu Inoue #define INP_IPV6 0x2 131340c35deSJonathan Lemon #define INP_IPV6PROTO 0x4 /* opened under IPv6 protocol */ 132340c35deSJonathan Lemon #define INP_TIMEWAIT 0x8 /* .. probably doesn't go here */ 1338afa2304SBruce M Simpson #define INP_ONESBCAST 0x10 /* send all-ones broadcast */ 134ca98b82cSDavid Greenman u_char inp_ip_ttl; /* time to live proto */ 135ca98b82cSDavid Greenman u_char inp_ip_p; /* protocol proto */ 13682cd038dSYoshinobu Inoue 13782cd038dSYoshinobu Inoue /* protocol dependent part; options */ 13882cd038dSYoshinobu Inoue struct { 13982cd038dSYoshinobu Inoue u_char inp4_ip_tos; /* type of service proto */ 14082cd038dSYoshinobu Inoue struct mbuf *inp4_options; /* IP options */ 14182cd038dSYoshinobu Inoue struct ip_moptions *inp4_moptions; /* IP multicast options */ 14282cd038dSYoshinobu Inoue } inp_depend4; 143be2ac88cSJonathan Lemon #define inp_fport inp_inc.inc_fport 144be2ac88cSJonathan Lemon #define inp_lport inp_inc.inc_lport 145be2ac88cSJonathan Lemon #define inp_faddr inp_inc.inc_faddr 146be2ac88cSJonathan Lemon #define inp_laddr inp_inc.inc_laddr 14782cd038dSYoshinobu Inoue #define inp_ip_tos inp_depend4.inp4_ip_tos 14882cd038dSYoshinobu Inoue #define inp_options inp_depend4.inp4_options 14982cd038dSYoshinobu Inoue #define inp_moptions inp_depend4.inp4_moptions 15082cd038dSYoshinobu Inoue struct { 15182cd038dSYoshinobu Inoue /* IP options */ 15282cd038dSYoshinobu Inoue struct mbuf *inp6_options; 15382cd038dSYoshinobu Inoue /* IP6 options for outgoing packets */ 15482cd038dSYoshinobu Inoue struct ip6_pktopts *inp6_outputopts; 15582cd038dSYoshinobu Inoue /* IP multicast options */ 15682cd038dSYoshinobu Inoue struct ip6_moptions *inp6_moptions; 15782cd038dSYoshinobu Inoue /* ICMPv6 code type filter */ 15882cd038dSYoshinobu Inoue struct icmp6_filter *inp6_icmp6filt; 15982cd038dSYoshinobu Inoue /* IPV6_CHECKSUM setsockopt */ 16082cd038dSYoshinobu Inoue int inp6_cksum; 16182cd038dSYoshinobu Inoue u_short inp6_ifindex; 16282cd038dSYoshinobu Inoue short inp6_hops; 16382cd038dSYoshinobu Inoue } inp_depend6; 164e3975643SJake Burkholder LIST_ENTRY(inpcb) inp_portlist; 1658781d8e9SBruce Evans struct inpcbport *inp_phd; /* head of this list */ 16698271db4SGarrett Wollman inp_gen_t inp_gencnt; /* generation count of this instance */ 167f76fcf6dSJeffrey Hsu struct mtx inp_mtx; 168f76fcf6dSJeffrey Hsu 169be2ac88cSJonathan Lemon #define in6p_faddr inp_inc.inc6_faddr 170be2ac88cSJonathan Lemon #define in6p_laddr inp_inc.inc6_laddr 17197d8d152SAndre Oppermann #define in6p_ip6_hlim inp_depend6.inp6_hlim 17282cd038dSYoshinobu Inoue #define in6p_hops inp_depend6.inp6_hops /* default hop limit */ 17382cd038dSYoshinobu Inoue #define in6p_ip6_nxt inp_ip_p 17482cd038dSYoshinobu Inoue #define in6p_flowinfo inp_flow 17582cd038dSYoshinobu Inoue #define in6p_vflag inp_vflag 17682cd038dSYoshinobu Inoue #define in6p_options inp_depend6.inp6_options 17782cd038dSYoshinobu Inoue #define in6p_outputopts inp_depend6.inp6_outputopts 17882cd038dSYoshinobu Inoue #define in6p_moptions inp_depend6.inp6_moptions 17982cd038dSYoshinobu Inoue #define in6p_icmp6filt inp_depend6.inp6_icmp6filt 18082cd038dSYoshinobu Inoue #define in6p_cksum inp_depend6.inp6_cksum 18182cd038dSYoshinobu Inoue #define inp6_ifindex inp_depend6.inp6_ifindex 18282cd038dSYoshinobu Inoue #define in6p_flags inp_flags /* for KAME src sync over BSD*'s */ 18382cd038dSYoshinobu Inoue #define in6p_socket inp_socket /* for KAME src sync over BSD*'s */ 18482cd038dSYoshinobu Inoue #define in6p_lport inp_lport /* for KAME src sync over BSD*'s */ 18582cd038dSYoshinobu Inoue #define in6p_fport inp_fport /* for KAME src sync over BSD*'s */ 18682cd038dSYoshinobu Inoue #define in6p_ppcb inp_ppcb /* for KAME src sync over BSD*'s */ 187c3229e05SDavid Greenman }; 1883d4d47f3SGarrett Wollman /* 1893d4d47f3SGarrett Wollman * The range of the generation count, as used in this implementation, 1903d4d47f3SGarrett Wollman * is 9e19. We would have to create 300 billion connections per 1913d4d47f3SGarrett Wollman * second for this number to roll over in a year. This seems sufficiently 1923d4d47f3SGarrett Wollman * unlikely that we simply don't concern ourselves with that possibility. 1933d4d47f3SGarrett Wollman */ 194c3229e05SDavid Greenman 19598271db4SGarrett Wollman /* 19698271db4SGarrett Wollman * Interface exported to userland by various protocols which use 19798271db4SGarrett Wollman * inpcbs. Hack alert -- only define if struct xsocket is in scope. 19898271db4SGarrett Wollman */ 19998271db4SGarrett Wollman #ifdef _SYS_SOCKETVAR_H_ 20098271db4SGarrett Wollman struct xinpcb { 20198271db4SGarrett Wollman size_t xi_len; /* length of this structure */ 20298271db4SGarrett Wollman struct inpcb xi_inp; 20398271db4SGarrett Wollman struct xsocket xi_socket; 20498271db4SGarrett Wollman u_quad_t xi_alignment_hack; 20598271db4SGarrett Wollman }; 20698271db4SGarrett Wollman 20798271db4SGarrett Wollman struct xinpgen { 20898271db4SGarrett Wollman size_t xig_len; /* length of this structure */ 20998271db4SGarrett Wollman u_int xig_count; /* number of PCBs at this time */ 21098271db4SGarrett Wollman inp_gen_t xig_gen; /* generation count at this time */ 21198271db4SGarrett Wollman so_gen_t xig_sogen; /* socket generation count at this time */ 21298271db4SGarrett Wollman }; 21398271db4SGarrett Wollman #endif /* _SYS_SOCKETVAR_H_ */ 21498271db4SGarrett Wollman 215c3229e05SDavid Greenman struct inpcbport { 216e3975643SJake Burkholder LIST_ENTRY(inpcbport) phd_hash; 217c3229e05SDavid Greenman struct inpcbhead phd_pcblist; 218c3229e05SDavid Greenman u_short phd_port; 219df8bae1dSRodney W. Grimes }; 220df8bae1dSRodney W. Grimes 2213d4d47f3SGarrett Wollman struct inpcbinfo { /* XXX documentation, prefixes */ 22215bd2b43SDavid Greenman struct inpcbhead *hashbase; 2233d4d47f3SGarrett Wollman u_long hashmask; 224c3229e05SDavid Greenman struct inpcbporthead *porthashbase; 2253d4d47f3SGarrett Wollman u_long porthashmask; 226c3229e05SDavid Greenman struct inpcbhead *listhead; 2273d4d47f3SGarrett Wollman u_short lastport; 2283d4d47f3SGarrett Wollman u_short lastlow; 2293d4d47f3SGarrett Wollman u_short lasthi; 23040545cf5SBruce Evans struct uma_zone *ipi_zone; /* zone to allocate pcbs from */ 2313d4d47f3SGarrett Wollman u_int ipi_count; /* number of pcbs in this list */ 2323d4d47f3SGarrett Wollman u_quad_t ipi_gencnt; /* current generation count */ 233f76fcf6dSJeffrey Hsu struct mtx ipi_mtx; 23415bd2b43SDavid Greenman }; 23515bd2b43SDavid Greenman 236e3f268fcSSam Leffler /* 237e3f268fcSSam Leffler * NB: We cannot enable assertions when IPv6 is configured as 238e3f268fcSSam Leffler * this code is shared by both IPv4 and IPv6 and IPv6 is 239e3f268fcSSam Leffler * not properly locked. 240e3f268fcSSam Leffler */ 2415bd311a5SSam Leffler #define INP_LOCK_INIT(inp, d, t) \ 2425bd311a5SSam Leffler mtx_init(&(inp)->inp_mtx, (d), (t), MTX_DEF | MTX_RECURSE | MTX_DUPOK) 243f76fcf6dSJeffrey Hsu #define INP_LOCK_DESTROY(inp) mtx_destroy(&(inp)->inp_mtx) 244f76fcf6dSJeffrey Hsu #define INP_LOCK(inp) mtx_lock(&(inp)->inp_mtx) 245f76fcf6dSJeffrey Hsu #define INP_UNLOCK(inp) mtx_unlock(&(inp)->inp_mtx) 246d67ec3ddSRobert Watson #define INP_LOCK_ASSERT(inp) do { \ 247d67ec3ddSRobert Watson mtx_assert(&(inp)->inp_mtx, MA_OWNED); \ 248d67ec3ddSRobert Watson NET_ASSERT_GIANT(); \ 249d67ec3ddSRobert Watson } while (0) 25092c71ab3SRobert Watson #define INP_UNLOCK_ASSERT(inp) mtx_assert(&(inp)->inp_mtx, MA_NOTOWNED) 251f76fcf6dSJeffrey Hsu 252f76fcf6dSJeffrey Hsu #define INP_INFO_LOCK_INIT(ipi, d) \ 253f76fcf6dSJeffrey Hsu mtx_init(&(ipi)->ipi_mtx, (d), NULL, MTX_DEF | MTX_RECURSE) 2541cf15713SAndre Oppermann #define INP_INFO_LOCK_DESTROY(ipi) mtx_destroy(&(ipi)->ipi_mtx) 255f76fcf6dSJeffrey Hsu #define INP_INFO_RLOCK(ipi) mtx_lock(&(ipi)->ipi_mtx) 256f76fcf6dSJeffrey Hsu #define INP_INFO_WLOCK(ipi) mtx_lock(&(ipi)->ipi_mtx) 257f76fcf6dSJeffrey Hsu #define INP_INFO_RUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx) 258f76fcf6dSJeffrey Hsu #define INP_INFO_WUNLOCK(ipi) mtx_unlock(&(ipi)->ipi_mtx) 259d67ec3ddSRobert Watson #define INP_INFO_RLOCK_ASSERT(ipi) do { \ 260d67ec3ddSRobert Watson mtx_assert(&(ipi)->ipi_mtx, MA_OWNED); \ 261d67ec3ddSRobert Watson NET_ASSERT_GIANT(); \ 262d67ec3ddSRobert Watson } while (0) 263d67ec3ddSRobert Watson #define INP_INFO_WLOCK_ASSERT(ipi) do { \ 264d67ec3ddSRobert Watson mtx_assert(&(ipi)->ipi_mtx, MA_OWNED); \ 265d67ec3ddSRobert Watson NET_ASSERT_GIANT(); \ 266d67ec3ddSRobert Watson } while (0) 267f76fcf6dSJeffrey Hsu 268ddd79a97SDavid Greenman #define INP_PCBHASH(faddr, lport, fport, mask) \ 269c3229e05SDavid Greenman (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) 270c3229e05SDavid Greenman #define INP_PCBPORTHASH(lport, mask) \ 271c3229e05SDavid Greenman (ntohs((lport)) & (mask)) 272ddd79a97SDavid Greenman 273df8bae1dSRodney W. Grimes /* flags in inp_flags: */ 274df8bae1dSRodney W. Grimes #define INP_RECVOPTS 0x01 /* receive incoming IP options */ 275df8bae1dSRodney W. Grimes #define INP_RECVRETOPTS 0x02 /* receive IP options for reply */ 276df8bae1dSRodney W. Grimes #define INP_RECVDSTADDR 0x04 /* receive IP dst address */ 277df8bae1dSRodney W. Grimes #define INP_HDRINCL 0x08 /* user supplies entire IP header */ 27833b3ac06SPeter Wemm #define INP_HIGHPORT 0x10 /* user wants "high" port binding */ 27933b3ac06SPeter Wemm #define INP_LOWPORT 0x20 /* user wants "low" port binding */ 280321a2846SPoul-Henning Kamp #define INP_ANONPORT 0x40 /* port chosen for user */ 28182c23ebaSBill Fenner #define INP_RECVIF 0x80 /* receive incoming interface */ 28257bf258eSGarrett Wollman #define INP_MTUDISC 0x100 /* user can do MTU discovery */ 28382cd038dSYoshinobu Inoue #define INP_FAITH 0x200 /* accept FAITH'ed connections */ 2844957466bSMatthew N. Dodd #define INP_RECVTTL 0x400 /* receive incoming IP TTL */ 28533841545SHajimu UMEMOTO 28633841545SHajimu UMEMOTO #define IN6P_IPV6_V6ONLY 0x008000 /* restrict AF_INET6 socket for v6 */ 28733841545SHajimu UMEMOTO 28833841545SHajimu UMEMOTO #define IN6P_PKTINFO 0x010000 /* receive IP6 dst and I/F */ 28933841545SHajimu UMEMOTO #define IN6P_HOPLIMIT 0x020000 /* receive hoplimit */ 29033841545SHajimu UMEMOTO #define IN6P_HOPOPTS 0x040000 /* receive hop-by-hop options */ 29133841545SHajimu UMEMOTO #define IN6P_DSTOPTS 0x080000 /* receive dst options after rthdr */ 29233841545SHajimu UMEMOTO #define IN6P_RTHDR 0x100000 /* receive routing header */ 29333841545SHajimu UMEMOTO #define IN6P_RTHDRDSTOPTS 0x200000 /* receive dstoptions before rthdr */ 2945434eaa2SHajimu UMEMOTO #define IN6P_TCLASS 0x400000 /* receive traffic class value */ 29533841545SHajimu UMEMOTO #define IN6P_AUTOFLOWLABEL 0x800000 /* attach flowlabel automatically */ 296f95d4633SHajimu UMEMOTO #define IN6P_RFC2292 0x40000000 /* used RFC2292 API on the socket */ 297f95d4633SHajimu UMEMOTO #define IN6P_MTU 0x80000000 /* receive path MTU */ 29833841545SHajimu UMEMOTO 29982c23ebaSBill Fenner #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\ 3004957466bSMatthew N. Dodd INP_RECVIF|INP_RECVTTL|\ 30133841545SHajimu UMEMOTO IN6P_PKTINFO|IN6P_HOPLIMIT|IN6P_HOPOPTS|\ 30233841545SHajimu UMEMOTO IN6P_DSTOPTS|IN6P_RTHDR|IN6P_RTHDRDSTOPTS|\ 303f95d4633SHajimu UMEMOTO IN6P_TCLASS|IN6P_AUTOFLOWLABEL|IN6P_RFC2292|\ 304f95d4633SHajimu UMEMOTO IN6P_MTU) 30533841545SHajimu UMEMOTO #define INP_UNMAPPABLEOPTS (IN6P_HOPOPTS|IN6P_DSTOPTS|IN6P_RTHDR|\ 306f95d4633SHajimu UMEMOTO IN6P_TCLASS|IN6P_AUTOFLOWLABEL) 30782cd038dSYoshinobu Inoue 30882cd038dSYoshinobu Inoue /* for KAME src sync over BSD*'s */ 30982cd038dSYoshinobu Inoue #define IN6P_HIGHPORT INP_HIGHPORT 31082cd038dSYoshinobu Inoue #define IN6P_LOWPORT INP_LOWPORT 31182cd038dSYoshinobu Inoue #define IN6P_ANONPORT INP_ANONPORT 31282cd038dSYoshinobu Inoue #define IN6P_RECVIF INP_RECVIF 31382cd038dSYoshinobu Inoue #define IN6P_MTUDISC INP_MTUDISC 31482cd038dSYoshinobu Inoue #define IN6P_FAITH INP_FAITH 31582cd038dSYoshinobu Inoue #define IN6P_CONTROLOPTS INP_CONTROLOPTS 31682cd038dSYoshinobu Inoue /* 31782cd038dSYoshinobu Inoue * socket AF version is {newer than,or include} 31882cd038dSYoshinobu Inoue * actual datagram AF version 31982cd038dSYoshinobu Inoue */ 320df8bae1dSRodney W. Grimes 321df8bae1dSRodney W. Grimes #define INPLOOKUP_WILDCARD 1 322df8bae1dSRodney W. Grimes #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) 32382cd038dSYoshinobu Inoue #define sotoin6pcb(so) sotoinpcb(so) /* for KAME src sync over BSD*'s */ 32482cd038dSYoshinobu Inoue 32582cd038dSYoshinobu Inoue #define INP_SOCKAF(so) so->so_proto->pr_domain->dom_family 32682cd038dSYoshinobu Inoue 32782cd038dSYoshinobu Inoue #define INP_CHECK_SOCKAF(so, af) (INP_SOCKAF(so) == af) 328df8bae1dSRodney W. Grimes 329664a31e4SPeter Wemm #ifdef _KERNEL 33082cd038dSYoshinobu Inoue extern int ipport_lowfirstauto; 33182cd038dSYoshinobu Inoue extern int ipport_lowlastauto; 33282cd038dSYoshinobu Inoue extern int ipport_firstauto; 33382cd038dSYoshinobu Inoue extern int ipport_lastauto; 33482cd038dSYoshinobu Inoue extern int ipport_hifirstauto; 33582cd038dSYoshinobu Inoue extern int ipport_hilastauto; 3365f311da2SMike Silbersack extern struct callout ipport_tick_callout; 33782cd038dSYoshinobu Inoue 338f76fcf6dSJeffrey Hsu void in_pcbpurgeif0(struct inpcbinfo *, struct ifnet *); 3396823b823SPawel Jakub Dawidek int in_pcballoc(struct socket *, struct inpcbinfo *, const char *); 340b0330ed9SPawel Jakub Dawidek int in_pcbbind(struct inpcb *, struct sockaddr *, struct ucred *); 3414b932371SIan Dowse int in_pcbbind_setup(struct inpcb *, struct sockaddr *, in_addr_t *, 342b0330ed9SPawel Jakub Dawidek u_short *, struct ucred *); 343b0330ed9SPawel Jakub Dawidek int in_pcbconnect(struct inpcb *, struct sockaddr *, struct ucred *); 3445200e00eSIan Dowse int in_pcbconnect_setup(struct inpcb *, struct sockaddr *, in_addr_t *, 3455200e00eSIan Dowse u_short *, in_addr_t *, u_short *, struct inpcb **, 346b0330ed9SPawel Jakub Dawidek struct ucred *); 3474d77a549SAlfred Perlstein void in_pcbdetach(struct inpcb *); 3484d77a549SAlfred Perlstein void in_pcbdisconnect(struct inpcb *); 3494d77a549SAlfred Perlstein int in_pcbinshash(struct inpcb *); 350df8bae1dSRodney W. Grimes struct inpcb * 3514d77a549SAlfred Perlstein in_pcblookup_local(struct inpcbinfo *, 3524d77a549SAlfred Perlstein struct in_addr, u_int, int); 35315bd2b43SDavid Greenman struct inpcb * 354c1cd65baSBruce Evans in_pcblookup_hash(struct inpcbinfo *, struct in_addr, u_int, 355c1cd65baSBruce Evans struct in_addr, u_int, int, struct ifnet *); 356f76fcf6dSJeffrey Hsu void in_pcbnotifyall(struct inpcbinfo *pcbinfo, struct in_addr, 3573ce144eaSJeffrey Hsu int, struct inpcb *(*)(struct inpcb *, int)); 3584d77a549SAlfred Perlstein void in_pcbrehash(struct inpcb *); 359a557af22SRobert Watson void in_pcbsetsolabel(struct socket *so); 360f76fcf6dSJeffrey Hsu int in_setpeeraddr(struct socket *so, struct sockaddr **nam, struct inpcbinfo *pcbinfo); 361439dfb0cSStefan Farfeleder int in_setsockaddr(struct socket *so, struct sockaddr **nam, struct inpcbinfo *pcbinfo); 36226ef6ac4SDon Lewis struct sockaddr * 36326ef6ac4SDon Lewis in_sockaddr(in_port_t port, struct in_addr *addr); 364a557af22SRobert Watson void in_pcbsosetlabel(struct socket *so); 3654d77a549SAlfred Perlstein void in_pcbremlists(struct inpcb *inp); 3665f311da2SMike Silbersack void ipport_tick(void *xtp); 367664a31e4SPeter Wemm #endif /* _KERNEL */ 3683d4d47f3SGarrett Wollman 3698781d8e9SBruce Evans #endif /* !_NETINET_IN_PCB_H_ */ 370