in_pcb.h (c3229e05a368643ab2e7e7c210b40586d041ba04) | in_pcb.h (3d4d47f39858441d8b8625898e74563f7b60e2b5) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 | 1/* 2 * Copyright (c) 1982, 1986, 1990, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93 |
34 * $Id: in_pcb.h,v 1.22 1997/08/16 19:15:36 wollman Exp $ | 34 * $Id: in_pcb.h,v 1.23 1998/01/27 09:15:04 davidg Exp $ |
35 */ 36 37#ifndef _NETINET_IN_PCB_H_ 38#define _NETINET_IN_PCB_H_ 39 40#include <sys/queue.h> 41 42/* 43 * Common structure pcb for internet protocol implementation. 44 * Here are stored pointers to local and foreign host table 45 * entries, local and foreign socket numbers, and pointers 46 * up (to a socket structure) and down (to a protocol-specific) 47 * control block. 48 */ 49LIST_HEAD(inpcbhead, inpcb); 50LIST_HEAD(inpcbporthead, inpcbport); 51 | 35 */ 36 37#ifndef _NETINET_IN_PCB_H_ 38#define _NETINET_IN_PCB_H_ 39 40#include <sys/queue.h> 41 42/* 43 * Common structure pcb for internet protocol implementation. 44 * Here are stored pointers to local and foreign host table 45 * entries, local and foreign socket numbers, and pointers 46 * up (to a socket structure) and down (to a protocol-specific) 47 * control block. 48 */ 49LIST_HEAD(inpcbhead, inpcb); 50LIST_HEAD(inpcbporthead, inpcbport); 51 |
52/* 53 * NB: the zone allocator is type-stable EXCEPT FOR THE FIRST TWO LONGS 54 * of the structure. Therefore, it is important that the members in 55 * that position not contain any information which is required to be 56 * stable. 57 */ |
|
52struct inpcb { 53 LIST_ENTRY(inpcb) inp_hash; /* hash list */ 54 struct in_addr inp_faddr; /* foreign host table entry */ 55 struct in_addr inp_laddr; /* local host table entry */ 56 u_short inp_fport; /* foreign port */ 57 u_short inp_lport; /* local port */ 58 LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ 59 caddr_t inp_ppcb; /* pointer to per-protocol pcb */ --- 4 unchanged lines hidden (view full) --- 64 int inp_flags; /* generic IP/datagram flags */ 65 u_char inp_ip_tos; /* type of service proto */ 66 u_char inp_ip_ttl; /* time to live proto */ 67 u_char inp_ip_p; /* protocol proto */ 68 u_char pad[1]; /* alignment */ 69 struct ip_moptions *inp_moptions; /* IP multicast options */ 70 LIST_ENTRY(inpcb) inp_portlist; /* list for this PCB's local port */ 71 struct inpcbport *inp_phd; /* head of list for this PCB's local port */ | 58struct inpcb { 59 LIST_ENTRY(inpcb) inp_hash; /* hash list */ 60 struct in_addr inp_faddr; /* foreign host table entry */ 61 struct in_addr inp_laddr; /* local host table entry */ 62 u_short inp_fport; /* foreign port */ 63 u_short inp_lport; /* local port */ 64 LIST_ENTRY(inpcb) inp_list; /* list for all PCBs of this proto */ 65 caddr_t inp_ppcb; /* pointer to per-protocol pcb */ --- 4 unchanged lines hidden (view full) --- 70 int inp_flags; /* generic IP/datagram flags */ 71 u_char inp_ip_tos; /* type of service proto */ 72 u_char inp_ip_ttl; /* time to live proto */ 73 u_char inp_ip_p; /* protocol proto */ 74 u_char pad[1]; /* alignment */ 75 struct ip_moptions *inp_moptions; /* IP multicast options */ 76 LIST_ENTRY(inpcb) inp_portlist; /* list for this PCB's local port */ 77 struct inpcbport *inp_phd; /* head of list for this PCB's local port */ |
78 u_quad_t inp_gencnt; /* generation count of this instance */ |
|
72}; | 79}; |
80/* 81 * The range of the generation count, as used in this implementation, 82 * is 9e19. We would have to create 300 billion connections per 83 * second for this number to roll over in a year. This seems sufficiently 84 * unlikely that we simply don't concern ourselves with that possibility. 85 */ |
|
73 74struct inpcbport { 75 LIST_ENTRY(inpcbport) phd_hash; 76 struct inpcbhead phd_pcblist; 77 u_short phd_port; 78}; 79 | 86 87struct inpcbport { 88 LIST_ENTRY(inpcbport) phd_hash; 89 struct inpcbhead phd_pcblist; 90 u_short phd_port; 91}; 92 |
80struct inpcbinfo { 81 struct inpcbhead *hashbase; 82 unsigned long hashmask; 83 struct inpcbporthead *porthashbase; 84 unsigned long porthashmask; 85 struct inpcbhead *listhead; 86 unsigned short lastport; 87 unsigned short lastlow; 88 unsigned short lasthi; | 93struct inpcbinfo { /* XXX documentation, prefixes */ 94 struct inpcbhead *hashbase; 95 u_long hashmask; 96 struct inpcbporthead *porthashbase; 97 u_long porthashmask; 98 struct inpcbhead *listhead; 99 u_short lastport; 100 u_short lastlow; 101 u_short lasthi; 102 struct vm_zone *ipi_zone; /* zone to allocate pcbs from */ 103 u_int ipi_count; /* number of pcbs in this list */ 104 u_quad_t ipi_gencnt; /* current generation count */ |
89}; 90 91#define INP_PCBHASH(faddr, lport, fport, mask) \ 92 (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) 93#define INP_PCBPORTHASH(lport, mask) \ 94 (ntohs((lport)) & (mask)) 95 96/* flags in inp_flags: */ --- 29 unchanged lines hidden (view full) --- 126struct inpcb * 127 in_pcblookup_hash __P((struct inpcbinfo *, 128 struct in_addr, u_int, struct in_addr, u_int, int)); 129void in_pcbnotify __P((struct inpcbhead *, struct sockaddr *, 130 u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int))); 131void in_pcbrehash __P((struct inpcb *)); 132int in_setpeeraddr __P((struct socket *so, struct sockaddr **nam)); 133int in_setsockaddr __P((struct socket *so, struct sockaddr **nam)); | 105}; 106 107#define INP_PCBHASH(faddr, lport, fport, mask) \ 108 (((faddr) ^ ((faddr) >> 16) ^ ntohs((lport) ^ (fport))) & (mask)) 109#define INP_PCBPORTHASH(lport, mask) \ 110 (ntohs((lport)) & (mask)) 111 112/* flags in inp_flags: */ --- 29 unchanged lines hidden (view full) --- 142struct inpcb * 143 in_pcblookup_hash __P((struct inpcbinfo *, 144 struct in_addr, u_int, struct in_addr, u_int, int)); 145void in_pcbnotify __P((struct inpcbhead *, struct sockaddr *, 146 u_int, struct in_addr, u_int, int, void (*)(struct inpcb *, int))); 147void in_pcbrehash __P((struct inpcb *)); 148int in_setpeeraddr __P((struct socket *so, struct sockaddr **nam)); 149int in_setsockaddr __P((struct socket *so, struct sockaddr **nam)); |
150 |
|
134#endif 135 136#endif | 151#endif 152 153#endif |