1 /*!\file netinet/in_pcb.h
2 * Internal IP structures.
6 * Copyright (c) 1982, 1986, 1990, 1993
7 * The Regents of the University of California. All rights reserved.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the University of
20 * California, Berkeley and its contributors.
21 * 4. Neither the name of the University nor the names of its contributors
22 * may be used to endorse or promote products derived from this software
23 * without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
38 * $Id: in_pcb.h,v 1.14.2.2 1997/03/03 09:24:37 davidg Exp $
41 #ifndef __NETINET_IN_PCB_H
42 #define __NETINET_IN_PCB_H
44 #include <sys/queue.h>
47 * Common structure pcb for internet protocol implementation.
48 * Here are stored pointers to local and foreign host table
49 * entries, local and foreign socket numbers, and pointers
50 * up (to a socket structure) and down (to a protocol-specific)
53 LIST_HEAD(inpcbhead, inpcb);
56 LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */
57 LIST_ENTRY(inpcb) inp_hash; /* hash list */
58 struct inpcbinfo *inp_pcbinfo;
59 struct in_addr inp_faddr; /* foreign host table entry */
60 u_short inp_fport; /* foreign port */
61 struct in_addr inp_laddr; /* local host table entry */
62 u_short inp_lport; /* local port */
63 struct socket *inp_socket; /* back pointer to socket */
64 caddr_t inp_ppcb; /* pointer to per-protocol pcb */
65 struct route inp_route; /* placeholder for routing entry */
66 int inp_flags; /* generic IP/datagram flags */
67 struct ip inp_ip; /* header prototype; should have more */
68 struct mbuf *inp_options; /* IP options */
69 struct ip_moptions *inp_moptions; /* IP multicast options */
73 struct inpcbhead *listhead;
74 struct inpcbhead *hashbase;
75 unsigned long hashmask;
76 unsigned short lastport;
77 unsigned short lastlow;
78 unsigned short lasthi;
81 #define INP_PCBHASH(faddr, lport, fport, mask) \
82 (((faddr) ^ ((faddr) >> 16) ^ (lport) ^ (fport)) & (mask))
84 /* flags in inp_flags: */
85 #define INP_RECVOPTS 0x01 /* receive incoming IP options */
86 #define INP_RECVRETOPTS 0x02 /* receive IP options for reply */
87 #define INP_RECVDSTADDR 0x04 /* receive IP dst address */
88 #define INP_HDRINCL 0x08 /* user supplies entire IP header */
89 #define INP_HIGHPORT 0x10 /* user wants "high" port binding */
90 #define INP_LOWPORT 0x20 /* user wants "low" port binding */
91 #define INP_ANONPORT 0x40 /* port chosen for user */
92 #define INP_RECVIF 0x80 /* receive incoming interface */
93 #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
96 #define INPLOOKUP_WILDCARD 1
98 #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)