in6_pcb.h revision 1.1.2.3 1 /*
2 * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
3 * 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
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of the project nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 */
29
30 /*
31 * Copyright (c) 1982, 1986, 1990, 1993
32 * The Regents of the University of California. All rights reserved.
33 *
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
36 * are met:
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
42 * 3. All advertising materials mentioning features or use of this software
43 * must display the following acknowledgement:
44 * This product includes software developed by the University of
45 * California, Berkeley and its contributors.
46 * 4. Neither the name of the University nor the names of its contributors
47 * may be used to endorse or promote products derived from this software
48 * without specific prior written permission.
49 *
50 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
51 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
52 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
53 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
54 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
55 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
56 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
57 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
58 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
59 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * SUCH DAMAGE.
61 *
62 * @(#)in_pcb.h 8.1 (Berkeley) 6/10/93
63 */
64
65 #ifndef _NETINET6_IN6_PCB_H_
66 #define _NETINET6_IN6_PCB_H_
67
68 #include <sys/queue.h>
69
70 /*
71 * Common structure pcb for internet protocol implementation.
72 * Here are stored pointers to local and foreign host table
73 * entries, local and foreign socket numbers, and pointers
74 * up (to a socket structure) and down (to a protocol-specific)
75 * control block.
76 */
77 struct icmp6_filter;
78 struct inpcbpolicy;
79
80 struct in6pcb {
81 struct in6pcb *in6p_next, *in6p_prev;
82 /* pointers to other pcb's */
83 struct in6pcb *in6p_head; /* pointer back to chain of
84 in6pcb's for this protocol */
85 struct in6_addr in6p_faddr; /* foreign host table entry */
86 u_short in6p_fport; /* foreign port */
87 struct in6_addr in6p_laddr; /* local host table entry */
88 u_short in6p_lport; /* local port */
89 u_int32_t in6p_flowinfo; /* priority and flowlabel */
90 struct socket *in6p_socket; /* back pointer to socket */
91 caddr_t in6p_ppcb; /* pointer to per-protocol pcb */
92 struct route_in6 in6p_route; /* placeholder for routing entry */
93 int in6p_flags; /* generic IP6/datagram flags */
94 int in6p_hops; /* default hop limit */
95 struct ip6_hdr in6p_ip6; /* header prototype */
96 struct mbuf *in6p_options; /* IP6 options */
97 struct ip6_pktopts *in6p_outputopts; /* IP6 options for outgoing packets */
98 struct ip6_moptions *in6p_moptions; /* IP6 multicast options */
99 u_short in6p_ifindex;
100 /* should move the following just after next/prev */
101 LIST_ENTRY(in6pcb) in6p_hlist; /* hash chain */
102 u_long in6p_hash; /* hash value */
103 #if 1 /*IPSEC*/
104 struct inpcbpolicy *in6p_sp; /* security policy. */
105 #endif
106 struct icmp6_filter *in6p_icmp6filt;
107 int in6p_cksum; /* IPV6_CHECKSUM setsockopt */
108 };
109
110 #define in6p_ip6_nxt in6p_ip6.ip6_nxt /* for KAME src sync over BSD*'s */
111
112 /* flags in in6p_flags */
113 #define IN6P_RECVOPTS 0x01 /* receive incoming IP6 options */
114 #define IN6P_RECVRETOPTS 0x02 /* receive IP6 options for reply */
115 #define IN6P_RECVDSTADDR 0x04 /* receive IP6 dst address */
116 #define IN6P_HIGHPORT 0x10 /* user wants "high" port binding */
117 #define IN6P_LOWPORT 0x20 /* user wants "low" port binding */
118 #define IN6P_ANONPORT 0x40 /* port chosen for user */
119 #define IN6P_FAITH 0x80 /* accept FAITH'ed connections */
120 #define IN6P_PKTINFO 0x010000
121 #define IN6P_HOPLIMIT 0x020000
122 #define IN6P_NEXTHOP 0x040000
123 #define IN6P_HOPOPTS 0x080000
124 #define IN6P_DSTOPTS 0x100000
125 #define IN6P_RTHDR 0x200000
126 #define IN6P_CONTROLOPTS (0x3f0000 | IN6P_RECVOPTS | IN6P_RECVRETOPTS | IN6P_RECVDSTADDR)
127
128 #define IN6PLOOKUP_WILDCARD 1
129 #define IN6PLOOKUP_SETLOCAL 2
130
131 /* compute hash value for foreign and local in6_addr and port */
132 #define IN6_HASH(faddr, fport, laddr, lport) \
133 (((faddr)->s6_addr32[0] ^ (faddr)->s6_addr32[1] ^ \
134 (faddr)->s6_addr32[2] ^ (faddr)->s6_addr32[3] ^ \
135 (laddr)->s6_addr32[0] ^ (laddr)->s6_addr32[1] ^ \
136 (laddr)->s6_addr32[2] ^ (laddr)->s6_addr32[3]) \
137 + (fport) + (lport))
138
139 #define sotoin6pcb(so) ((struct in6pcb *)(so)->so_pcb)
140
141 #ifdef _KERNEL
142 void in6_losing __P((struct in6pcb *));
143 int in6_pcballoc __P((struct socket *, struct in6pcb *));
144 int in6_pcbbind __P((struct in6pcb *, struct mbuf *));
145 int in6_pcbconnect __P((struct in6pcb *, struct mbuf *));
146 void in6_pcbdetach __P((struct in6pcb *));
147 void in6_pcbdisconnect __P((struct in6pcb *));
148 struct in6pcb *
149 in6_pcblookup __P((struct in6pcb *,
150 struct in6_addr *, u_int, struct in6_addr *,
151 u_int, int));
152 int in6_pcbnotify __P((struct in6pcb *, struct sockaddr *,
153 u_int, struct in6_addr *, u_int, int,
154 void (*)(struct in6pcb *, int)));
155 int in6_pcbsetport __P((struct in6_addr *, struct in6pcb *));
156 void in6_rtchange __P((struct in6pcb *, int));
157 void in6_setpeeraddr __P((struct in6pcb *, struct mbuf *));
158 void in6_setsockaddr __P((struct in6pcb *, struct mbuf *));
159 struct in6_addr *in6_selectsrc __P((struct sockaddr_in6 *,
160 struct ip6_pktopts *,
161 struct ip6_moptions *,
162 struct route_in6 *,
163 struct in6_addr *, int *));
164 int in6_selecthlim __P((struct in6pcb *, struct ifnet *));
165
166 #ifndef TCP6
167 extern struct rtentry *
168 in6_pcbrtentry __P((struct in6pcb *));
169 extern struct in6pcb *in6_pcblookup_connect __P((struct in6pcb *,
170 struct in6_addr *, u_int, struct in6_addr *, u_int, int));
171 extern struct in6pcb *in6_pcblookup_bind __P((struct in6pcb *,
172 struct in6_addr *, u_int, int));
173 #endif
174 #endif /* _KERNEL */
175
176 #endif /* !_NETINET6_IN6_PCB_H_ */
177