added watt32 headers and brought the DOS version up to parity with UNIX
[oftp] / libs / watt32 / netinet / in_pcb.h
1 /*!\file netinet/in_pcb.h
2  * Internal IP structures.
3  */
4
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 #include <sys/queue.h>
45
46 /*
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)
51  * control block.
52  */
53 LIST_HEAD(inpcbhead, inpcb);
54
55 struct 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 */
70 };
71
72 struct inpcbinfo {
73         struct inpcbhead *listhead;
74         struct inpcbhead *hashbase;
75         unsigned long hashmask;
76         unsigned short lastport;
77         unsigned short lastlow;
78         unsigned short lasthi;
79 };
80
81 #define INP_PCBHASH(faddr, lport, fport, mask) \
82         (((faddr) ^ ((faddr) >> 16) ^ (lport) ^ (fport)) & (mask))
83
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|\
94                                         INP_RECVIF)
95
96 #define INPLOOKUP_WILDCARD      1
97
98 #define sotoinpcb(so)   ((struct inpcb *)(so)->so_pcb)
99
100 #endif