Print this page
inet_pton
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/inet/ip6.h
+++ new/usr/src/uts/common/inet/ip6.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 +/*
26 + * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
27 + */
25 28
26 29 #ifndef _INET_IP6_H
27 30 #define _INET_IP6_H
28 31
29 32 #ifdef __cplusplus
30 33 extern "C" {
31 34 #endif
32 35
33 36 #include <sys/isa_defs.h>
34 37
35 38 #ifdef _KERNEL
36 39 /* icmp6_t is used in the prototype of icmp_inbound_error_fanout_v6() */
37 40 #include <netinet/icmp6.h>
38 41 #endif /* _KERNEL */
39 42
40 43 /* version number for IPv6 - hard to get this one wrong! */
41 44 #define IPV6_VERSION 6
42 45
43 46 #define IPV6_HDR_LEN 40
44 47
45 48 #define IPV6_ADDR_LEN 16
46 49
47 50 /*
48 51 * IPv6 address scopes. The values of these enums also match the scope
49 52 * field of multicast addresses.
50 53 */
51 54 typedef enum {
52 55 IP6_SCOPE_INTFLOCAL = 1, /* Multicast addresses only */
53 56 IP6_SCOPE_LINKLOCAL,
54 57 IP6_SCOPE_SUBNETLOCAL, /* Multicast addresses only */
55 58 IP6_SCOPE_ADMINLOCAL, /* Multicast addresses only */
56 59 IP6_SCOPE_SITELOCAL,
57 60 IP6_SCOPE_GLOBAL
58 61 } in6addr_scope_t;
59 62
60 63 /* From RFC 3542 - setting for IPV6_USE_MIN_MTU socket option */
61 64 #define IPV6_USE_MIN_MTU_MULTICAST -1 /* Default */
62 65 #define IPV6_USE_MIN_MTU_NEVER 0
63 66 #define IPV6_USE_MIN_MTU_ALWAYS 1
64 67
65 68 #ifdef _KERNEL
66 69
67 70 /* Extract the scope from a multicast address */
68 71 #ifdef _BIG_ENDIAN
69 72 #define IN6_ADDR_MC_SCOPE(addr) \
70 73 (((addr)->s6_addr32[0] & 0x000f0000) >> 16)
71 74 #else
72 75 #define IN6_ADDR_MC_SCOPE(addr) \
73 76 (((addr)->s6_addr32[0] & 0x00000f00) >> 8)
74 77 #endif
75 78
76 79 /* Default IPv4 TTL for IPv6-in-IPv4 encapsulated packets */
77 80 #define IPV6_DEFAULT_HOPS 60 /* XXX What should it be? */
78 81
79 82 /* Max IPv6 TTL */
80 83 #define IPV6_MAX_HOPS 255
81 84
82 85 /* Minimum IPv6 MTU from rfc2460 */
83 86 #define IPV6_MIN_MTU 1280
84 87
85 88 /* EUI-64 based token length */
86 89 #define IPV6_TOKEN_LEN 64
87 90
88 91 /* Length of an advertised IPv6 prefix */
89 92 #define IPV6_PREFIX_LEN 64
90 93
91 94 /* Default and maximum tunnel encapsulation limits. See RFC 2473. */
92 95 #define IPV6_DEFAULT_ENCAPLIMIT 4
93 96 #define IPV6_MAX_ENCAPLIMIT 255
94 97
95 98 /*
96 99 * Minimum and maximum extension header lengths for IPv6. The 8-bit
97 100 * length field of each extension header (see rfc2460) specifies the
98 101 * number of 8 octet units of data in the header not including the
99 102 * first 8 octets. A value of 0 would indicate 8 bytes (0 * 8 + 8),
100 103 * and 255 would indicate 2048 bytes (255 * 8 + 8).
101 104 */
102 105 #define MIN_EHDR_LEN 8
103 106 #define MAX_EHDR_LEN 2048
104 107
105 108 #ifdef _BIG_ENDIAN
106 109 #define IPV6_DEFAULT_VERS_AND_FLOW 0x60000000
107 110 #define IPV6_VERS_AND_FLOW_MASK 0xF0000000
108 111 #define V6_MCAST 0xFF000000
109 112 #define V6_LINKLOCAL 0xFE800000
110 113
111 114 #define IPV6_FLOW_TCLASS(x) (((x) & IPV6_FLOWINFO_TCLASS) >> 20)
112 115 #define IPV6_TCLASS_FLOW(f, c) (((f) & ~IPV6_FLOWINFO_TCLASS) |\
113 116 ((c) << 20))
114 117 #else
115 118 #define IPV6_DEFAULT_VERS_AND_FLOW 0x00000060
116 119 #define IPV6_VERS_AND_FLOW_MASK 0x000000F0
117 120 #define V6_MCAST 0x000000FF
118 121 #define V6_LINKLOCAL 0x000080FE
119 122
120 123 #define IPV6_FLOW_TCLASS(x) ((((x) & 0xf000U) >> 12) |\
121 124 (((x) & 0xf) << 4))
122 125 #define IPV6_TCLASS_FLOW(f, c) (((f) & ~IPV6_FLOWINFO_TCLASS) |\
123 126 ((((c) & 0xf) << 12) |\
124 127 (((c) & 0xf0) >> 4)))
125 128 #endif
126 129
127 130 /*
128 131 * UTILITY MACROS FOR ADDRESSES.
129 132 */
130 133
131 134 /*
132 135 * Convert an IPv4 address mask to an IPv6 mask. Pad with 1-bits.
133 136 */
134 137 #define V4MASK_TO_V6(v4, v6) ((v6).s6_addr32[0] = 0xffffffffUL, \
135 138 (v6).s6_addr32[1] = 0xffffffffUL, \
136 139 (v6).s6_addr32[2] = 0xffffffffUL, \
137 140 (v6).s6_addr32[3] = (v4))
138 141
139 142 /*
140 143 * Convert aligned IPv4-mapped IPv6 address into an IPv4 address.
141 144 * Note: We use "v6" here in definition of macro instead of "(v6)"
142 145 * Not possible to use "(v6)" here since macro is used with struct
143 146 * field names as arguments.
144 147 */
145 148 #define V4_PART_OF_V6(v6) v6.s6_addr32[3]
146 149
147 150 #ifdef _BIG_ENDIAN
148 151 #define V6_OR_V4_INADDR_ANY(a) ((a).s6_addr32[3] == 0 && \
149 152 ((a).s6_addr32[2] == 0xffffU || \
150 153 (a).s6_addr32[2] == 0) && \
151 154 (a).s6_addr32[1] == 0 && \
152 155 (a).s6_addr32[0] == 0)
153 156
154 157 #else
155 158 #define V6_OR_V4_INADDR_ANY(a) ((a).s6_addr32[3] == 0 && \
156 159 ((a).s6_addr32[2] == 0xffff0000U || \
157 160 (a).s6_addr32[2] == 0) && \
158 161 (a).s6_addr32[1] == 0 && \
159 162 (a).s6_addr32[0] == 0)
160 163 #endif /* _BIG_ENDIAN */
161 164
162 165 /* IPv4-mapped CLASSD addresses */
163 166 #ifdef _BIG_ENDIAN
164 167 #define IN6_IS_ADDR_V4MAPPED_CLASSD(addr) \
165 168 (((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \
166 169 (CLASSD((addr)->_S6_un._S6_u32[3])) && \
167 170 ((addr)->_S6_un._S6_u32[1] == 0) && \
168 171 ((addr)->_S6_un._S6_u32[0] == 0))
169 172 #else /* _BIG_ENDIAN */
170 173 #define IN6_IS_ADDR_V4MAPPED_CLASSD(addr) \
171 174 (((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \
172 175 (CLASSD((addr)->_S6_un._S6_u32[3])) && \
173 176 ((addr)->_S6_un._S6_u32[1] == 0) && \
174 177 ((addr)->_S6_un._S6_u32[0] == 0))
175 178 #endif /* _BIG_ENDIAN */
176 179
177 180 /* Clear an IPv6 addr */
178 181 #define V6_SET_ZERO(a) ((a).s6_addr32[0] = 0, \
179 182 (a).s6_addr32[1] = 0, \
180 183 (a).s6_addr32[2] = 0, \
181 184 (a).s6_addr32[3] = 0)
182 185
183 186 /* Mask comparison: is IPv6 addr a, and'ed with mask m, equal to addr b? */
184 187 #define V6_MASK_EQ(a, m, b) \
185 188 ((((a).s6_addr32[0] & (m).s6_addr32[0]) == (b).s6_addr32[0]) && \
186 189 (((a).s6_addr32[1] & (m).s6_addr32[1]) == (b).s6_addr32[1]) && \
187 190 (((a).s6_addr32[2] & (m).s6_addr32[2]) == (b).s6_addr32[2]) && \
188 191 (((a).s6_addr32[3] & (m).s6_addr32[3]) == (b).s6_addr32[3]))
189 192
190 193 #define V6_MASK_EQ_2(a, m, b) \
191 194 ((((a).s6_addr32[0] & (m).s6_addr32[0]) == \
192 195 ((b).s6_addr32[0] & (m).s6_addr32[0])) && \
193 196 (((a).s6_addr32[1] & (m).s6_addr32[1]) == \
194 197 ((b).s6_addr32[1] & (m).s6_addr32[1])) && \
195 198 (((a).s6_addr32[2] & (m).s6_addr32[2]) == \
196 199 ((b).s6_addr32[2] & (m).s6_addr32[2])) && \
197 200 (((a).s6_addr32[3] & (m).s6_addr32[3]) == \
198 201 ((b).s6_addr32[3] & (m).s6_addr32[3])))
199 202
200 203 /* Copy IPv6 address (s), logically and'ed with mask (m), into (d) */
201 204 #define V6_MASK_COPY(s, m, d) \
202 205 ((d).s6_addr32[0] = (s).s6_addr32[0] & (m).s6_addr32[0], \
203 206 (d).s6_addr32[1] = (s).s6_addr32[1] & (m).s6_addr32[1], \
204 207 (d).s6_addr32[2] = (s).s6_addr32[2] & (m).s6_addr32[2], \
205 208 (d).s6_addr32[3] = (s).s6_addr32[3] & (m).s6_addr32[3])
206 209
207 210 #define ILL_FRAG_HASH_V6(v6addr, i) \
208 211 ((ntohl((v6addr).s6_addr32[3]) ^ (i ^ (i >> 8))) % \
209 212 ILL_FRAG_HASH_TBL_COUNT)
210 213
211 214
212 215 /*
213 216 * GLOBAL EXTERNALS
214 217 */
215 218 extern const in6_addr_t ipv6_all_ones;
216 219 extern const in6_addr_t ipv6_all_zeros;
217 220 extern const in6_addr_t ipv6_loopback;
218 221 extern const in6_addr_t ipv6_all_hosts_mcast;
↓ open down ↓ |
184 lines elided |
↑ open up ↑ |
219 222 extern const in6_addr_t ipv6_all_rtrs_mcast;
220 223 extern const in6_addr_t ipv6_all_v2rtrs_mcast;
221 224 extern const in6_addr_t ipv6_solicited_node_mcast;
222 225 extern const in6_addr_t ipv6_unspecified_group;
223 226
224 227 /*
225 228 * FUNCTION PROTOTYPES
226 229 */
227 230
228 231 extern void convert2ascii(char *buf, const in6_addr_t *addr);
229 -extern char *inet_ntop(int, const void *, char *, int);
230 -extern int inet_pton(int, char *, void *);
231 232 extern void icmp_param_problem_nexthdr_v6(mblk_t *, boolean_t,
232 233 ip_recv_attr_t *);
233 234 extern void icmp_pkt2big_v6(mblk_t *, uint32_t, boolean_t,
234 235 ip_recv_attr_t *);
235 236 extern void icmp_time_exceeded_v6(mblk_t *, uint8_t, boolean_t,
236 237 ip_recv_attr_t *);
237 238 extern void icmp_unreachable_v6(mblk_t *, uint8_t, boolean_t,
238 239 ip_recv_attr_t *);
239 240 extern mblk_t *icmp_inbound_v6(mblk_t *, ip_recv_attr_t *);
240 241 extern void icmp_inbound_error_fanout_v6(mblk_t *, icmp6_t *,
241 242 ip_recv_attr_t *);
242 243 extern void icmp_update_out_mib_v6(ill_t *, icmp6_t *);
243 244
244 245 extern boolean_t conn_wantpacket_v6(conn_t *, ip_recv_attr_t *, ip6_t *);
245 246
246 247 extern in6addr_scope_t ip_addr_scope_v6(const in6_addr_t *);
247 248 extern void ip_build_hdrs_v6(uchar_t *, uint_t, const ip_pkt_t *, uint8_t,
248 249 uint32_t);
249 250 extern void ip_fanout_udp_multi_v6(mblk_t *, ip6_t *, uint16_t, uint16_t,
250 251 ip_recv_attr_t *);
251 252 extern void ip_fanout_send_icmp_v6(mblk_t *, uint_t, uint8_t,
252 253 ip_recv_attr_t *);
253 254 extern void ip_fanout_proto_v6(mblk_t *, ip6_t *, ip_recv_attr_t *);
254 255 extern int ip_find_hdr_v6(mblk_t *, ip6_t *, boolean_t, ip_pkt_t *,
255 256 uint8_t *);
256 257 extern in6_addr_t ip_get_dst_v6(ip6_t *, const mblk_t *, boolean_t *);
257 258 extern ip6_rthdr_t *ip_find_rthdr_v6(ip6_t *, uint8_t *);
258 259 extern boolean_t ip_hdr_length_nexthdr_v6(mblk_t *, ip6_t *,
259 260 uint16_t *, uint8_t **);
260 261 extern int ip_hdr_length_v6(mblk_t *, ip6_t *);
261 262 extern uint32_t ip_massage_options_v6(ip6_t *, ip6_rthdr_t *, netstack_t *);
262 263 extern void ip_forward_xmit_v6(nce_t *, mblk_t *, ip6_t *, ip_recv_attr_t *,
263 264 uint32_t, uint32_t);
264 265 extern mblk_t *ip_fraghdr_add_v6(mblk_t *, uint32_t, ip_xmit_attr_t *);
265 266 extern int ip_fragment_v6(mblk_t *, nce_t *, iaflags_t, uint_t, uint32_t,
266 267 uint32_t, zoneid_t, zoneid_t, pfirepostfrag_t postfragfn,
267 268 uintptr_t *ixa_cookie);
268 269 extern int ip_process_options_v6(mblk_t *, ip6_t *,
269 270 uint8_t *, uint_t, uint8_t, ip_recv_attr_t *);
270 271 extern void ip_process_rthdr(mblk_t *, ip6_t *, ip6_rthdr_t *,
271 272 ip_recv_attr_t *);
272 273 extern int ip_total_hdrs_len_v6(const ip_pkt_t *);
273 274 extern mblk_t *ipsec_early_ah_v6(mblk_t *, ip_recv_attr_t *);
274 275 extern int ipsec_ah_get_hdr_size_v6(mblk_t *, boolean_t);
275 276 extern void ip_send_potential_redirect_v6(mblk_t *, ip6_t *, ire_t *,
276 277 ip_recv_attr_t *);
277 278 extern void ip_rput_v6(queue_t *, mblk_t *);
278 279 extern mblk_t *mld_input(mblk_t *, ip_recv_attr_t *);
279 280 extern void mld_joingroup(ilm_t *);
280 281 extern void mld_leavegroup(ilm_t *);
281 282 extern void mld_timeout_handler(void *);
282 283
283 284 extern void pr_addr_dbg(char *, int, const void *);
284 285 extern void *ip6_kstat_init(netstackid_t, ip6_stat_t *);
285 286 extern void ip6_kstat_fini(netstackid_t, kstat_t *);
286 287 extern size_t ip6_get_src_preferences(ip_xmit_attr_t *, uint32_t *);
287 288 extern int ip6_set_src_preferences(ip_xmit_attr_t *, uint32_t);
288 289
289 290 #endif /* _KERNEL */
290 291
291 292 #ifdef __cplusplus
292 293 }
293 294 #endif
294 295
295 296 #endif /* _INET_IP6_H */
↓ open down ↓ |
55 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX