Watt-32 tcp/ip  2.2 dev-rel.10
in_pcb.h
Go to the documentation of this file.
1 
5 /*
6  * Copyright (c) 1982, 1986, 1990, 1993
7  * The Regents of the University of California. All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
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.
24  *
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
35  * SUCH DAMAGE.
36  *
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 $
39  */
40 
41 #ifndef __NETINET_IN_PCB_H
42 #define __NETINET_IN_PCB_H
43 
44 #ifndef __SYS_MBUF_H
45 #include <sys/mbuf.h>
46 #endif
47 
48 #ifndef __SYS_QUEUE_H
49 #include <sys/queue.h>
50 #endif
51 
52 /*
53  * Common structure pcb for internet protocol implementation.
54  * Here are stored pointers to local and foreign host table
55  * entries, local and foreign socket numbers, and pointers
56  * up (to a socket structure) and down (to a protocol-specific)
57  * control block.
58  */
59 LIST_HEAD(inpcbhead, inpcb);
60 
61 struct inpcb {
62  LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */
63  LIST_ENTRY(inpcb) inp_hash; /* hash list */
64  struct inpcbinfo *inp_pcbinfo;
65  struct in_addr inp_faddr; /* foreign host table entry */
66  u_short inp_fport; /* foreign port */
67  struct in_addr inp_laddr; /* local host table entry */
68  u_short inp_lport; /* local port */
69  struct socket *inp_socket; /* back pointer to socket */
70  caddr_t inp_ppcb; /* pointer to per-protocol pcb */
71  struct route inp_route; /* placeholder for routing entry */
72  int inp_flags; /* generic IP/datagram flags */
73  struct ip inp_ip; /* header prototype; should have more */
74  struct mbuf *inp_options; /* IP options */
75  struct ip_moptions *inp_moptions; /* IP multicast options */
76 };
77 
78 struct inpcbinfo {
79  struct inpcbhead *listhead;
80  struct inpcbhead *hashbase;
81  unsigned long hashmask;
82  unsigned short lastport;
83  unsigned short lastlow;
84  unsigned short lasthi;
85 };
86 
87 #define INP_PCBHASH(faddr, lport, fport, mask) \
88  (((faddr) ^ ((faddr) >> 16) ^ (lport) ^ (fport)) & (mask))
89 
90 /* flags in inp_flags: */
91 #define INP_RECVOPTS 0x01 /* receive incoming IP options */
92 #define INP_RECVRETOPTS 0x02 /* receive IP options for reply */
93 #define INP_RECVDSTADDR 0x04 /* receive IP dst address */
94 #define INP_HDRINCL 0x08 /* user supplies entire IP header */
95 #define INP_HIGHPORT 0x10 /* user wants "high" port binding */
96 #define INP_LOWPORT 0x20 /* user wants "low" port binding */
97 #define INP_ANONPORT 0x40 /* port chosen for user */
98 #define INP_RECVIF 0x80 /* receive incoming interface */
99 #define INP_CONTROLOPTS (INP_RECVOPTS|INP_RECVRETOPTS|INP_RECVDSTADDR|\
100  INP_RECVIF)
101 
102 #define INPLOOKUP_WILDCARD 1
103 
104 #define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
105 
106 #endif
Definition: if.h:84
Definition: in_pcb.h:61
Definition: route.h:56
Definition: ip.h:67
Definition: in.h:146
Definition: mbuf.h:6