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