| 1 | /* $NetBSD: in_pcb.h,v 1.60 2016/04/26 08:44:44 ozaki-r Exp $ */ |
| 2 | |
| 3 | /* |
| 4 | * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. |
| 5 | * All rights reserved. |
| 6 | * |
| 7 | * Redistribution and use in source and binary forms, with or without |
| 8 | * modification, are permitted provided that the following conditions |
| 9 | * are met: |
| 10 | * 1. Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * 2. Redistributions in binary form must reproduce the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer in the |
| 14 | * documentation and/or other materials provided with the distribution. |
| 15 | * 3. Neither the name of the project nor the names of its contributors |
| 16 | * may be used to endorse or promote products derived from this software |
| 17 | * without specific prior written permission. |
| 18 | * |
| 19 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND |
| 20 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 21 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 22 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE |
| 23 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 24 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 25 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 26 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 27 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 28 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 29 | * SUCH DAMAGE. |
| 30 | */ |
| 31 | |
| 32 | /* |
| 33 | * Copyright (c) 1982, 1986, 1990, 1993 |
| 34 | * The Regents of the University of California. All rights reserved. |
| 35 | * |
| 36 | * Redistribution and use in source and binary forms, with or without |
| 37 | * modification, are permitted provided that the following conditions |
| 38 | * are met: |
| 39 | * 1. Redistributions of source code must retain the above copyright |
| 40 | * notice, this list of conditions and the following disclaimer. |
| 41 | * 2. Redistributions in binary form must reproduce the above copyright |
| 42 | * notice, this list of conditions and the following disclaimer in the |
| 43 | * documentation and/or other materials provided with the distribution. |
| 44 | * 3. Neither the name of the University nor the names of its contributors |
| 45 | * may be used to endorse or promote products derived from this software |
| 46 | * without specific prior written permission. |
| 47 | * |
| 48 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 49 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 50 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 51 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 52 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 53 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 54 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 55 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 56 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 57 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 58 | * SUCH DAMAGE. |
| 59 | * |
| 60 | * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 |
| 61 | */ |
| 62 | |
| 63 | #ifndef _NETINET_IN_PCB_H_ |
| 64 | #define _NETINET_IN_PCB_H_ |
| 65 | |
| 66 | #include <sys/queue.h> |
| 67 | #include <net/route.h> |
| 68 | #include <netinet/in_pcb_hdr.h> |
| 69 | |
| 70 | /* |
| 71 | * Common structure pcb for internet protocol implementation. |
| 72 | * Here are stored pointers to local and foreign host table |
| 73 | * entries, local and foreign socket numbers, and pointers |
| 74 | * up (to a socket structure) and down (to a protocol-specific) |
| 75 | * control block. |
| 76 | */ |
| 77 | struct inpcb { |
| 78 | struct inpcb_hdr inp_head; |
| 79 | #define inp_hash inp_head.inph_hash |
| 80 | #define inp_queue inp_head.inph_queue |
| 81 | #define inp_af inp_head.inph_af |
| 82 | #define inp_ppcb inp_head.inph_ppcb |
| 83 | #define inp_state inp_head.inph_state |
| 84 | #define inp_portalgo inp_head.inph_portalgo |
| 85 | #define inp_socket inp_head.inph_socket |
| 86 | #define inp_table inp_head.inph_table |
| 87 | #define inp_sp inp_head.inph_sp |
| 88 | struct route inp_route; /* placeholder for routing entry */ |
| 89 | u_int16_t inp_fport; /* foreign port */ |
| 90 | u_int16_t inp_lport; /* local port */ |
| 91 | int inp_flags; /* generic IP/datagram flags */ |
| 92 | struct ip inp_ip; /* header prototype; should have more */ |
| 93 | struct mbuf *inp_options; /* IP options */ |
| 94 | struct ip_moptions *inp_moptions; /* IP multicast options */ |
| 95 | int inp_errormtu; /* MTU of last xmit status = EMSGSIZE */ |
| 96 | uint8_t inp_ip_minttl; |
| 97 | bool inp_bindportonsend; |
| 98 | }; |
| 99 | |
| 100 | #define inp_faddr inp_ip.ip_dst |
| 101 | #define inp_laddr inp_ip.ip_src |
| 102 | |
| 103 | /* flags in inp_flags: */ |
| 104 | #define INP_RECVOPTS 0x0001 /* receive incoming IP options */ |
| 105 | #define INP_RECVRETOPTS 0x0002 /* receive IP options for reply */ |
| 106 | #define INP_RECVDSTADDR 0x0004 /* receive IP dst address */ |
| 107 | #define INP_HDRINCL 0x0008 /* user supplies entire IP header */ |
| 108 | #define INP_HIGHPORT 0x0010 /* (unused; FreeBSD compat) */ |
| 109 | #define INP_LOWPORT 0x0020 /* user wants "low" port binding */ |
| 110 | #define INP_ANONPORT 0x0040 /* port chosen for user */ |
| 111 | #define INP_RECVIF 0x0080 /* receive incoming interface */ |
| 112 | /* XXX should move to an UDP control block */ |
| 113 | #define INP_ESPINUDP 0x0100 /* ESP over UDP for NAT-T */ |
| 114 | #define INP_ESPINUDP_NON_IKE 0x0200 /* ESP over UDP for NAT-T */ |
| 115 | #define INP_ESPINUDP_ALL (INP_ESPINUDP|INP_ESPINUDP_NON_IKE) |
| 116 | #define 0x0400 /* Kernel removes IP header |
| 117 | * before feeding a packet |
| 118 | * to the raw socket user. |
| 119 | * The socket user will |
| 120 | * not supply an IP header. |
| 121 | * Cancels INP_HDRINCL. |
| 122 | */ |
| 123 | #define INP_RECVTTL 0x0800 /* receive incoming IP TTL */ |
| 124 | #define INP_PKTINFO 0x1000 /* receive dst packet info */ |
| 125 | #define INP_RECVPKTINFO 0x2000 /* receive dst packet info */ |
| 126 | #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\ |
| 127 | INP_RECVIF|INP_RECVTTL|INP_RECVPKTINFO|\ |
| 128 | INP_PKTINFO) |
| 129 | |
| 130 | #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) |
| 131 | |
| 132 | #ifdef _KERNEL |
| 133 | void in_losing(struct inpcb *); |
| 134 | int in_pcballoc(struct socket *, void *); |
| 135 | int in_pcbbind(void *, struct sockaddr_in *, struct lwp *); |
| 136 | int in_pcbconnect(void *, struct sockaddr_in *, struct lwp *); |
| 137 | void in_pcbdetach(void *); |
| 138 | void in_pcbdisconnect(void *); |
| 139 | void in_pcbinit(struct inpcbtable *, int, int); |
| 140 | struct inpcb * |
| 141 | in_pcblookup_port(struct inpcbtable *, |
| 142 | struct in_addr, u_int, int, struct vestigial_inpcb *); |
| 143 | struct inpcb * |
| 144 | in_pcblookup_bind(struct inpcbtable *, |
| 145 | struct in_addr, u_int); |
| 146 | struct inpcb * |
| 147 | in_pcblookup_connect(struct inpcbtable *, |
| 148 | struct in_addr, u_int, struct in_addr, u_int, |
| 149 | struct vestigial_inpcb *); |
| 150 | int in_pcbnotify(struct inpcbtable *, struct in_addr, u_int, |
| 151 | struct in_addr, u_int, int, void (*)(struct inpcb *, int)); |
| 152 | void in_pcbnotifyall(struct inpcbtable *, struct in_addr, int, |
| 153 | void (*)(struct inpcb *, int)); |
| 154 | void in_pcbpurgeif0(struct inpcbtable *, struct ifnet *); |
| 155 | void in_pcbpurgeif(struct inpcbtable *, struct ifnet *); |
| 156 | void in_purgeifmcast(struct ip_moptions *, struct ifnet *); |
| 157 | void in_pcbstate(struct inpcb *, int); |
| 158 | void in_rtchange(struct inpcb *, int); |
| 159 | void in_setpeeraddr(struct inpcb *, struct sockaddr_in *); |
| 160 | void in_setsockaddr(struct inpcb *, struct sockaddr_in *); |
| 161 | struct rtentry * |
| 162 | in_pcbrtentry(struct inpcb *); |
| 163 | #endif |
| 164 | |
| 165 | #endif /* !_NETINET_IN_PCB_H_ */ |
| 166 | |