/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the project nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Copyright (c) 1982, 1986, 1990, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
*/
/*
* Common structure pcb for internet protocol implementation.
* Here are stored pointers to local and foreign host table
* entries, local and foreign socket numbers, and pointers
* up (to a socket structure) and down (to a protocol-specific)
* control block.
*/
struct inpcb {
LIST_ENTRY(inpcb) inp_hash;
LIST_ENTRY(inpcb) inp_lhash;
TAILQ_ENTRY(inpcb) inp_queue;
int inp_af; /* address family - AF_INET or AF_INET6 */
void * inp_ppcb; /* pointer to per-protocol pcb */
int inp_state; /* bind/connect state */
#define INP_ATTACHED 0
#define INP_BOUND 1
#define INP_CONNECTED 2
int inp_portalgo;
struct socket *inp_socket; /* back pointer to socket */
struct inpcbtable *inp_table;
struct inpcbpolicy *inp_sp; /* security policy */
struct route inp_route; /* placeholder for routing entry */
in_port_t inp_fport; /* foreign port */
in_port_t inp_lport; /* local port */
int inp_flags; /* generic IP/datagram flags */
struct mbuf *inp_options; /* IP options */
bool inp_bindportonsend;
/* We still need it for IPv6 due to v4-mapped addresses */
struct ip_moptions *inp_moptions; /* IPv4 multicast options */
struct in4pcb {
struct inpcb in4p_pcb;
struct ip in4p_ip;
int in4p_errormtu; /* MTU of last xmit status = EMSGSIZE */
uint8_t in4p_ip_minttl;
struct in_addr in4p_prefsrcip; /* preferred src IP when wild */
};
/* flags in inp_flags: */
#define INP_RECVOPTS 0x0001 /* receive incoming IP options */
#define INP_RECVRETOPTS 0x0002 /* receive IP options for reply */
#define INP_RECVDSTADDR 0x0004 /* receive IP dst address */
#define INP_HDRINCL 0x0008 /* user supplies entire IP header */
#define INP_HIGHPORT 0x0010 /* (unused; FreeBSD compat) */
#define INP_LOWPORT 0x0020 /* user wants "low" port binding */
#define INP_ANONPORT 0x0040 /* port chosen for user */
#define INP_RECVIF 0x0080 /* receive incoming interface */
/* XXX should move to an UDP control block */
#define INP_ESPINUDP 0x0100 /* ESP over UDP for NAT-T */
#define INP_ESPINUDP_NON_IKE 0x0200 /* ESP over UDP for NAT-T */
#define INP_NOHEADER 0x0400 /* Kernel removes IP header
* before feeding a packet
* to the raw socket user.
* The socket user will
* not supply an IP header.
* Cancels INP_HDRINCL.
*/
#define INP_RECVTTL 0x0800 /* receive incoming IP TTL */
#define INP_RECVPKTINFO 0x1000 /* receive IP dst if/addr */
#define INP_BINDANY 0x2000 /* allow bind to any address */
#define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
INP_RECVIF|INP_RECVTTL|INP_RECVPKTINFO)
/*
* Flags for IPv6 in inp_flags
* We define KAME's original flags in higher 16 bits as much as possible
* for compatibility with *bsd*s.
*/
#define IN6P_RECVOPTS 0x00001000 /* receive incoming IP6 options */
#define IN6P_RECVRETOPTS 0x00002000 /* receive IP6 options for reply */
#define IN6P_RECVDSTADDR 0x00004000 /* receive IP6 dst address */
#define IN6P_IPV6_V6ONLY 0x00008000 /* restrict AF_INET6 socket for v6 */
#define IN6P_PKTINFO 0x00010000 /* receive IP6 dst and I/F */
#define IN6P_HOPLIMIT 0x00020000 /* receive hoplimit */
#define IN6P_HOPOPTS 0x00040000 /* receive hop-by-hop options */
#define IN6P_DSTOPTS 0x00080000 /* receive dst options after rthdr */
#define IN6P_RTHDR 0x00100000 /* receive routing header */
#define IN6P_RTHDRDSTOPTS 0x00200000 /* receive dstoptions before rthdr */
#define IN6P_TCLASS 0x00400000 /* traffic class */
#define IN6P_BINDANY 0x00800000 /* allow bind to any address */
#define IN6P_HIGHPORT 0x01000000 /* user wants "high" port binding */
#define IN6P_LOWPORT 0x02000000 /* user wants "low" port binding */
#define IN6P_ANONPORT 0x04000000 /* port chosen for user */
#define IN6P_FAITH 0x08000000 /* accept FAITH'ed connections */
/* XXX should move to an UDP control block */
#define IN6P_ESPINUDP INP_ESPINUDP /* ESP over UDP for NAT-T */
#define IN6P_RFC2292 0x40000000 /* RFC2292 */
#define IN6P_MTU 0x80000000 /* use minimum MTU */