1df8bae1dSRodney W. Grimes /* 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 * 3. All advertising materials mentioning features or use of this software 14df8bae1dSRodney W. Grimes * must display the following acknowledgement: 15df8bae1dSRodney W. Grimes * This product includes software developed by the University of 16df8bae1dSRodney W. Grimes * California, Berkeley and its contributors. 17df8bae1dSRodney W. Grimes * 4. Neither the name of the University nor the names of its contributors 18df8bae1dSRodney W. Grimes * may be used to endorse or promote products derived from this software 19df8bae1dSRodney W. Grimes * without specific prior written permission. 20df8bae1dSRodney W. Grimes * 21df8bae1dSRodney W. Grimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 22df8bae1dSRodney W. Grimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 23df8bae1dSRodney W. Grimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24df8bae1dSRodney W. Grimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 25df8bae1dSRodney W. Grimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 26df8bae1dSRodney W. Grimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27df8bae1dSRodney W. Grimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28df8bae1dSRodney W. Grimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29df8bae1dSRodney W. Grimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30df8bae1dSRodney W. Grimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31df8bae1dSRodney W. Grimes * SUCH DAMAGE. 32df8bae1dSRodney W. Grimes * 33df8bae1dSRodney W. Grimes * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 34f1844d4cSBruce Evans * $Id: in_pcb.h,v 1.9 1995/11/14 20:34:03 phk Exp $ 35df8bae1dSRodney W. Grimes */ 36df8bae1dSRodney W. Grimes 37707f139eSPaul Richards #ifndef _NETINET_IN_PCB_H_ 38707f139eSPaul Richards #define _NETINET_IN_PCB_H_ 39707f139eSPaul Richards 40f1844d4cSBruce Evans #include <sys/queue.h> 41f1844d4cSBruce Evans 42df8bae1dSRodney W. Grimes /* 43df8bae1dSRodney W. Grimes * Common structure pcb for internet protocol implementation. 44df8bae1dSRodney W. Grimes * Here are stored pointers to local and foreign host table 45df8bae1dSRodney W. Grimes * entries, local and foreign socket numbers, and pointers 46df8bae1dSRodney W. Grimes * up (to a socket structure) and down (to a protocol-specific) 47df8bae1dSRodney W. Grimes * control block. 48df8bae1dSRodney W. Grimes */ 4915bd2b43SDavid Greenman LIST_HEAD(inpcbhead, inpcb); 5015bd2b43SDavid Greenman 51df8bae1dSRodney W. Grimes struct inpcb { 5215bd2b43SDavid Greenman LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ 5315bd2b43SDavid Greenman LIST_ENTRY(inpcb) inp_hash; /* hash list */ 5415bd2b43SDavid Greenman struct inpcbinfo *inp_pcbinfo; 55df8bae1dSRodney W. Grimes struct in_addr inp_faddr; /* foreign host table entry */ 56df8bae1dSRodney W. Grimes u_short inp_fport; /* foreign port */ 57df8bae1dSRodney W. Grimes struct in_addr inp_laddr; /* local host table entry */ 58df8bae1dSRodney W. Grimes u_short inp_lport; /* local port */ 59df8bae1dSRodney W. Grimes struct socket *inp_socket; /* back pointer to socket */ 60df8bae1dSRodney W. Grimes caddr_t inp_ppcb; /* pointer to per-protocol pcb */ 61df8bae1dSRodney W. Grimes struct route inp_route; /* placeholder for routing entry */ 62df8bae1dSRodney W. Grimes int inp_flags; /* generic IP/datagram flags */ 63df8bae1dSRodney W. Grimes struct ip inp_ip; /* header prototype; should have more */ 64df8bae1dSRodney W. Grimes struct mbuf *inp_options; /* IP options */ 65df8bae1dSRodney W. Grimes struct ip_moptions *inp_moptions; /* IP multicast options */ 66df8bae1dSRodney W. Grimes }; 67df8bae1dSRodney W. Grimes 6815bd2b43SDavid Greenman struct inpcbinfo { 6915bd2b43SDavid Greenman struct inpcbhead *listhead; 7015bd2b43SDavid Greenman struct inpcbhead *hashbase; 7115bd2b43SDavid Greenman unsigned long hashsize; 7215bd2b43SDavid Greenman unsigned short lastport; 7315bd2b43SDavid Greenman }; 7415bd2b43SDavid Greenman 75df8bae1dSRodney W. Grimes /* flags in inp_flags: */ 76df8bae1dSRodney W. Grimes #define INP_RECVOPTS 0x01 /* receive incoming IP options */ 77df8bae1dSRodney W. Grimes #define INP_RECVRETOPTS 0x02 /* receive IP options for reply */ 78df8bae1dSRodney W. Grimes #define INP_RECVDSTADDR 0x04 /* receive IP dst address */ 79df8bae1dSRodney W. Grimes #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR) 80df8bae1dSRodney W. Grimes #define INP_HDRINCL 0x08 /* user supplies entire IP header */ 81df8bae1dSRodney W. Grimes 82df8bae1dSRodney W. Grimes #define INPLOOKUP_WILDCARD 1 83df8bae1dSRodney W. Grimes 84df8bae1dSRodney W. Grimes #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb) 85df8bae1dSRodney W. Grimes 86df8bae1dSRodney W. Grimes #ifdef KERNEL 8726f9a767SRodney W. Grimes void in_losing __P((struct inpcb *)); 8815bd2b43SDavid Greenman int in_pcballoc __P((struct socket *, struct inpcbinfo *)); 89df8bae1dSRodney W. Grimes int in_pcbbind __P((struct inpcb *, struct mbuf *)); 90df8bae1dSRodney W. Grimes int in_pcbconnect __P((struct inpcb *, struct mbuf *)); 9126f9a767SRodney W. Grimes void in_pcbdetach __P((struct inpcb *)); 9226f9a767SRodney W. Grimes void in_pcbdisconnect __P((struct inpcb *)); 93b5e8ce9fSBruce Evans int in_pcbladdr __P((struct inpcb *, struct mbuf *, 94b5e8ce9fSBruce Evans struct sockaddr_in **)); 95df8bae1dSRodney W. Grimes struct inpcb * 9615bd2b43SDavid Greenman in_pcblookup __P((struct inpcbhead *, 97df8bae1dSRodney W. Grimes struct in_addr, u_int, struct in_addr, u_int, int)); 9815bd2b43SDavid Greenman struct inpcb * 9915bd2b43SDavid Greenman in_pcblookuphash __P((struct inpcbinfo *, 10015bd2b43SDavid Greenman struct in_addr, u_int, struct in_addr, u_int)); 10115bd2b43SDavid Greenman void in_pcbnotify __P((struct inpcbhead *, struct sockaddr *, 102df8bae1dSRodney W. Grimes u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int))); 10315bd2b43SDavid Greenman void in_pcbrehash __P((struct inpcb *)); 10426f9a767SRodney W. Grimes void in_setpeeraddr __P((struct inpcb *, struct mbuf *)); 10526f9a767SRodney W. Grimes void in_setsockaddr __P((struct inpcb *, struct mbuf *)); 106df8bae1dSRodney W. Grimes #endif 107707f139eSPaul Richards 108707f139eSPaul Richards #endif 109