2 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
3 * Use is subject to license terms.
5 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
8 * Copyright (c) 1982, 1986 Regents of the University of California.
11 * Redistribution and use in source and binary forms are permitted
12 * provided that this notice is preserved and that due credit is given
13 * to the University of California at Berkeley. The name of the University
14 * may not be used to endorse or promote products derived from this
15 * software without specific prior written permission. This software
16 * is provided ``as is'' without express or implied warranty.
20 * Constants and structures defined by the internet system,
21 * according to following documents
23 * Internet ASSIGNED NUMBERS (RFC1700) and its successors:
24 * http://www.iana.org/assignments/protocol-numbers
25 * http://www.iana.org/assignments/port-numbers
26 * Basic Socket Interface Extensions for IPv6 (RFC2133 and its successors)
33 #include <sys/feature_tests.h>
39 #include <sys/types.h>
41 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
42 #include <sys/socket_impl.h>
43 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
49 * The socklen definitions are reproduced here from sys/socket.h so as to
50 * not introduce that namespace into existing users of netinet/in.h.
52 typedef uint32_t socklen_t
;
53 #endif /* _SOCKLEN_T */
56 * Symbols such as htonl() are required to be exposed through this file,
57 * per XNS Issue 5. This is achieved by inclusion of <sys/byteorder.h>
59 #include <sys/byteorder.h>
63 typedef uint16_t in_port_t
;
67 * Note: IPv4 address data structures usage conventions.
68 * The "in_addr_t" type below (required by Unix standards)
69 * is NOT a typedef of "struct in_addr" and violates the usual
70 * conventions where "struct <name>" and <name>_t are corresponding
72 * To minimize confusion, kernel data structures/usage prefers use
73 * of "ipaddr_t" as atomic uint32_t type and avoid using "in_addr_t"
74 * The user level APIs continue to follow the historic popular
75 * practice of using "struct in_addr".
79 typedef uint32_t in_addr_t
;
84 typedef uint32_t ipaddr_t
;
87 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
91 uint8_t _S6_u8
[16]; /* IPv6 address */
92 uint16_t _S6_u16
[8]; /* IPv6 address */
93 uint32_t _S6_u32
[4]; /* IPv6 address */
96 #define s6_addr _S6_un._S6_u8
99 #define s6_addr8 _S6_un._S6_u8
100 #define s6_addr16 _S6_un._S6_u16
101 #define s6_addr32 _S6_un._S6_u32
104 #if __UNLEASHED_VISIBLE
105 #define IN6ADDR_INITIALIZER(a, b, c, d) \
108 BE_32(a), BE_32(b), BE_32(c), BE_32(d) \
113 typedef struct in6_addr in6_addr_t
;
115 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
119 typedef uint16_t sa_family_t
;
125 * Some of these constant names are copied for the DTrace IP provider in
126 * usr/src/lib/libdtrace/common/{ip.d.in, ip.sed.in}, which should be kept
129 #define IPPROTO_IP 0 /* dummy for IP */
130 #define IPPROTO_HOPOPTS 0 /* Hop by hop header for IPv6 */
131 #define IPPROTO_ICMP 1 /* control message protocol */
132 #define IPPROTO_IGMP 2 /* group control protocol */
133 #define IPPROTO_GGP 3 /* gateway^2 (deprecated) */
134 #define IPPROTO_ENCAP 4 /* IP in IP encapsulation */
135 #define IPPROTO_TCP 6 /* tcp */
136 #define IPPROTO_EGP 8 /* exterior gateway protocol */
137 #define IPPROTO_PUP 12 /* pup */
138 #define IPPROTO_UDP 17 /* user datagram protocol */
139 #define IPPROTO_IDP 22 /* xns idp */
140 #define IPPROTO_IPV6 41 /* IPv6 encapsulated in IP */
141 #define IPPROTO_ROUTING 43 /* Routing header for IPv6 */
142 #define IPPROTO_FRAGMENT 44 /* Fragment header for IPv6 */
143 #define IPPROTO_RSVP 46 /* rsvp */
144 #define IPPROTO_ESP 50 /* IPsec Encap. Sec. Payload */
145 #define IPPROTO_AH 51 /* IPsec Authentication Hdr. */
146 #define IPPROTO_ICMPV6 58 /* ICMP for IPv6 */
147 #define IPPROTO_NONE 59 /* No next header for IPv6 */
148 #define IPPROTO_DSTOPTS 60 /* Destination options */
149 #define IPPROTO_HELLO 63 /* "hello" routing protocol */
150 #define IPPROTO_ND 77 /* UNOFFICIAL net disk proto */
151 #define IPPROTO_EON 80 /* ISO clnp */
152 #define IPPROTO_OSPF 89 /* OSPF */
153 #define IPPROTO_PIM 103 /* PIM routing protocol */
154 #define IPPROTO_SCTP 132 /* Stream Control */
155 /* Transmission Protocol */
157 #define IPPROTO_RAW 255 /* raw IP packet */
158 #define IPPROTO_MAX 256
160 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
161 #define PROTO_SDP 257 /* Sockets Direct Protocol */
162 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
165 * Port/socket numbers: network standard functions
167 * Entries should exist here for each port number compiled into an ON
168 * component, such as snoop.
170 #define IPPORT_ECHO 7
171 #define IPPORT_DISCARD 9
172 #define IPPORT_SYSTAT 11
173 #define IPPORT_DAYTIME 13
174 #define IPPORT_NETSTAT 15
175 #define IPPORT_CHARGEN 19
176 #define IPPORT_FTP 21
177 #define IPPORT_TELNET 23
178 #define IPPORT_SMTP 25
179 #define IPPORT_TIMESERVER 37
180 #define IPPORT_NAMESERVER 42
181 #define IPPORT_WHOIS 43
182 #define IPPORT_DOMAIN 53
183 #define IPPORT_MDNS 5353
184 #define IPPORT_MTP 57
187 * Port/socket numbers: host specific functions
189 #define IPPORT_BOOTPS 67
190 #define IPPORT_BOOTPC 68
191 #define IPPORT_TFTP 69
192 #define IPPORT_RJE 77
193 #define IPPORT_FINGER 79
194 #define IPPORT_HTTP 80
195 #define IPPORT_HTTP_ALT 8080
196 #define IPPORT_TTYLINK 87
197 #define IPPORT_SUPDUP 95
198 #define IPPORT_NTP 123
199 #define IPPORT_NETBIOS_NS 137
200 #define IPPORT_NETBIOS_DGM 138
201 #define IPPORT_NETBIOS_SSN 139
202 #define IPPORT_LDAP 389
203 #define IPPORT_SLP 427
204 #define IPPORT_MIP 434
205 #define IPPORT_SMB 445 /* a.k.a. microsoft-ds */
208 * Internet Key Exchange (IKE) ports
210 #define IPPORT_IKE 500
211 #define IPPORT_IKE_NATT 4500
216 #define IPPORT_EXECSERVER 512
217 #define IPPORT_LOGINSERVER 513
218 #define IPPORT_CMDSERVER 514
219 #define IPPORT_PRINTER 515
220 #define IPPORT_EFSSERVER 520
225 #define IPPORT_BIFFUDP 512
226 #define IPPORT_WHOSERVER 513
227 #define IPPORT_SYSLOG 514
228 #define IPPORT_TALK 517
229 #define IPPORT_ROUTESERVER 520
230 #define IPPORT_RIPNG 521
235 #define IPPORT_DHCPV6C 546
236 #define IPPORT_DHCPV6S 547
238 #define IPPORT_SOCKS 1080
241 * Ports < IPPORT_RESERVED are reserved for
242 * privileged processes (e.g. root).
243 * Ports > IPPORT_USERRESERVED are reserved
244 * for servers, not necessarily privileged.
246 #define IPPORT_RESERVED 1024
247 #define IPPORT_USERRESERVED 5000
252 #define IMPLINK_IP 155
253 #define IMPLINK_LOWEXPER 156
254 #define IMPLINK_HIGHEXPER 158
257 * IPv4 Internet address
258 * This definition contains obsolete fields for compatibility
259 * with SunOS 3.x and 4.2bsd. The presence of subnets renders
260 * divisions into fixed fields misleading at best. New code
261 * should use only the s_addr field.
264 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
265 #define _S_un_b S_un_b
266 #define _S_un_w S_un_w
267 #define _S_addr S_addr
269 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
273 struct { uint8_t s_b1
, s_b2
, s_b3
, s_b4
; } _S_un_b
;
274 struct { uint16_t s_w1
, s_w2
; } _S_un_w
;
275 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
279 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
281 #define s_addr _S_un._S_addr /* should be used for all code */
282 #define s_host _S_un._S_un_b.s_b2 /* OBSOLETE: host on imp */
283 #define s_net _S_un._S_un_b.s_b1 /* OBSOLETE: network */
284 #define s_imp _S_un._S_un_w.s_w2 /* OBSOLETE: imp */
285 #define s_impno _S_un._S_un_b.s_b4 /* OBSOLETE: imp # */
286 #define s_lh _S_un._S_un_b.s_b3 /* OBSOLETE: logical host */
290 * Definitions of bits in internet address integers.
291 * On subnets, the decomposition of addresses to host and net parts
292 * is done according to subnet mask, not the masks here.
294 * Note that with the introduction of CIDR, IN_CLASSA, IN_CLASSB,
295 * IN_CLASSC, IN_CLASSD and IN_CLASSE macros have become "de-facto
296 * obsolete". IN_MULTICAST macro should be used to test if a address
297 * is a multicast address.
299 #define IN_CLASSA(i) (((i) & 0x80000000U) == 0)
300 #define IN_CLASSA_NET 0xff000000U
301 #define IN_CLASSA_NSHIFT 24
302 #define IN_CLASSA_HOST 0x00ffffffU
303 #define IN_CLASSA_MAX 128
305 #define IN_CLASSB(i) (((i) & 0xc0000000U) == 0x80000000U)
306 #define IN_CLASSB_NET 0xffff0000U
307 #define IN_CLASSB_NSHIFT 16
308 #define IN_CLASSB_HOST 0x0000ffffU
309 #define IN_CLASSB_MAX 65536
311 #define IN_CLASSC(i) (((i) & 0xe0000000U) == 0xc0000000U)
312 #define IN_CLASSC_NET 0xffffff00U
313 #define IN_CLASSC_NSHIFT 8
314 #define IN_CLASSC_HOST 0x000000ffU
316 #define IN_CLASSD(i) (((i) & 0xf0000000U) == 0xe0000000U)
317 #define IN_CLASSD_NET 0xf0000000U /* These aren't really */
318 #define IN_CLASSD_NSHIFT 28 /* net and host fields, but */
319 #define IN_CLASSD_HOST 0x0fffffffU /* routing needn't know */
321 #define IN_CLASSE(i) (((i) & 0xf0000000U) == 0xf0000000U)
322 #define IN_CLASSE_NET 0xffffffffU
324 #define IN_MULTICAST(i) IN_CLASSD(i)
327 * We have removed CLASS E checks from the kernel
328 * But we preserve these defines for userland in order
329 * to avoid compile breakage of some 3rd party piece of software
332 #define IN_EXPERIMENTAL(i) (((i) & 0xe0000000U) == 0xe0000000U)
333 #define IN_BADCLASS(i) (((i) & 0xf0000000U) == 0xf0000000U)
336 #define INADDR_ANY 0x00000000U
337 #define INADDR_LOOPBACK 0x7F000001U
338 #define INADDR_BROADCAST 0xffffffffU /* must be masked */
339 #define INADDR_NONE 0xffffffffU
341 #define INADDR_UNSPEC_GROUP 0xe0000000U /* 224.0.0.0 */
342 #define INADDR_ALLHOSTS_GROUP 0xe0000001U /* 224.0.0.1 */
343 #define INADDR_ALLRTRS_GROUP 0xe0000002U /* 224.0.0.2 */
344 #define INADDR_ALLRPTS_GROUP 0xe0000016U /* 224.0.0.22, IGMPv3 */
345 #define INADDR_MAX_LOCAL_GROUP 0xe00000ffU /* 224.0.0.255 */
347 /* Scoped IPv4 prefixes (in host byte-order) */
348 #define IN_AUTOCONF_NET 0xa9fe0000U /* 169.254/16 */
349 #define IN_AUTOCONF_MASK 0xffff0000U
350 #define IN_PRIVATE8_NET 0x0a000000U /* 10/8 */
351 #define IN_PRIVATE8_MASK 0xff000000U
352 #define IN_PRIVATE12_NET 0xac100000U /* 172.16/12 */
353 #define IN_PRIVATE12_MASK 0xfff00000U
354 #define IN_PRIVATE16_NET 0xc0a80000U /* 192.168/16 */
355 #define IN_PRIVATE16_MASK 0xffff0000U
357 /* RFC 3927 IPv4 link local address (i in host byte-order) */
358 #define IN_LINKLOCAL(i) (((i) & IN_AUTOCONF_MASK) == IN_AUTOCONF_NET)
360 #define IN_LOOPBACKNET 127 /* official! */
363 * IPv4 Socket address.
366 sa_family_t sin_family
;
368 struct in_addr sin_addr
;
369 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
372 unsigned char sin_zero
[8];
373 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
376 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
378 * IPv6 socket address.
380 struct sockaddr_in6
{
381 sa_family_t sin6_family
;
383 uint32_t sin6_flowinfo
;
384 struct in6_addr sin6_addr
;
385 uint32_t sin6_scope_id
; /* Depends on scope of sin6_addr */
386 uint32_t __sin6_src_id
; /* Impl. specific - UDP replies */
390 * Macros for accessing the traffic class and flow label fields from
392 * These are designed to be applied to a 32-bit value.
397 #define IPV6_FLOWINFO_FLOWLABEL 0x000fffffU
398 #define IPV6_FLOWINFO_TCLASS 0x0ff00000U
400 #else /* _BIG_ENDIAN */
403 #define IPV6_FLOWINFO_FLOWLABEL 0xffff0f00U
404 #define IPV6_FLOWINFO_TCLASS 0x0000f00fU
406 #endif /* _BIG_ENDIAN */
409 * We don't use IN6ADDR_INITIALIZER here because (1) we don't want to rely
410 * on __UNLEASHED_VISIBLE, and (2) the macro uses C99 syntax and we want these
411 * to be usable with older compilers.
413 * const struct in6_addr IN6ADDR_ANY_INIT;
414 * const struct in6_addr IN6ADDR_LOOPBACK_INIT;
417 #define IN6ADDR_ANY_INIT { { { 0, 0, 0, 0, \
422 #define IN6ADDR_LOOPBACK_INIT { { { 0, 0, 0, 0, \
428 * RFC 2553 specifies the following macros. Their type is defined
429 * as "int" in the RFC but they only have boolean significance
430 * (zero or non-zero). For the purposes of our comment notation,
431 * we assume a hypothetical type "bool" defined as follows to
432 * write the prototypes assumed for macros in our comments better.
438 * IN6 macros used to test for special IPv6 addresses
441 * bool IN6_IS_ADDR_UNSPECIFIED (const struct in6_addr *);
442 * bool IN6_IS_ADDR_LOOPBACK (const struct in6_addr *);
443 * bool IN6_IS_ADDR_MULTICAST (const struct in6_addr *);
444 * bool IN6_IS_ADDR_LINKLOCAL (const struct in6_addr *);
445 * bool IN6_IS_ADDR_SITELOCAL (const struct in6_addr *);
446 * bool IN6_IS_ADDR_V4MAPPED (const struct in6_addr *);
447 * bool IN6_IS_ADDR_V4MAPPED_ANY(const struct in6_addr *); -- Not from RFC2553
448 * bool IN6_IS_ADDR_V4COMPAT (const struct in6_addr *);
449 * bool IN6_IS_ADDR_MC_RESERVED (const struct in6_addr *); -- Not from RFC2553
450 * bool IN6_IS_ADDR_MC_NODELOCAL(const struct in6_addr *);
451 * bool IN6_IS_ADDR_MC_LINKLOCAL(const struct in6_addr *);
452 * bool IN6_IS_ADDR_MC_SITELOCAL(const struct in6_addr *);
453 * bool IN6_IS_ADDR_MC_ORGLOCAL (const struct in6_addr *);
454 * bool IN6_IS_ADDR_MC_GLOBAL (const struct in6_addr *);
455 * bool IN6_IS_ADDR_6TO4 (const struct in6_addr *); -- Not from RFC2553
456 * bool IN6_ARE_6TO4_PREFIX_EQUAL(const struct in6_addr *,
457 * const struct in6_addr *); -- Not from RFC2553
458 * bool IN6_IS_ADDR_LINKSCOPE (const struct in6addr *); -- Not from RFC2553
461 #define IN6_IS_ADDR_UNSPECIFIED(addr) \
462 (((addr)->_S6_un._S6_u32[3] == 0) && \
463 ((addr)->_S6_un._S6_u32[2] == 0) && \
464 ((addr)->_S6_un._S6_u32[1] == 0) && \
465 ((addr)->_S6_un._S6_u32[0] == 0))
468 #define IN6_IS_ADDR_LOOPBACK(addr) \
469 (((addr)->_S6_un._S6_u32[3] == 0x00000001) && \
470 ((addr)->_S6_un._S6_u32[2] == 0) && \
471 ((addr)->_S6_un._S6_u32[1] == 0) && \
472 ((addr)->_S6_un._S6_u32[0] == 0))
473 #else /* _BIG_ENDIAN */
474 #define IN6_IS_ADDR_LOOPBACK(addr) \
475 (((addr)->_S6_un._S6_u32[3] == 0x01000000) && \
476 ((addr)->_S6_un._S6_u32[2] == 0) && \
477 ((addr)->_S6_un._S6_u32[1] == 0) && \
478 ((addr)->_S6_un._S6_u32[0] == 0))
479 #endif /* _BIG_ENDIAN */
482 #define IN6_IS_ADDR_MULTICAST(addr) \
483 (((addr)->_S6_un._S6_u32[0] & 0xff000000) == 0xff000000)
484 #else /* _BIG_ENDIAN */
485 #define IN6_IS_ADDR_MULTICAST(addr) \
486 (((addr)->_S6_un._S6_u32[0] & 0x000000ff) == 0x000000ff)
487 #endif /* _BIG_ENDIAN */
490 #define IN6_IS_ADDR_LINKLOCAL(addr) \
491 (((addr)->_S6_un._S6_u32[0] & 0xffc00000) == 0xfe800000)
492 #else /* _BIG_ENDIAN */
493 #define IN6_IS_ADDR_LINKLOCAL(addr) \
494 (((addr)->_S6_un._S6_u32[0] & 0x0000c0ff) == 0x000080fe)
495 #endif /* _BIG_ENDIAN */
498 #define IN6_IS_ADDR_SITELOCAL(addr) \
499 (((addr)->_S6_un._S6_u32[0] & 0xffc00000) == 0xfec00000)
500 #else /* _BIG_ENDIAN */
501 #define IN6_IS_ADDR_SITELOCAL(addr) \
502 (((addr)->_S6_un._S6_u32[0] & 0x0000c0ff) == 0x0000c0fe)
503 #endif /* _BIG_ENDIAN */
506 #define IN6_IS_ADDR_V4MAPPED(addr) \
507 (((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \
508 ((addr)->_S6_un._S6_u32[1] == 0) && \
509 ((addr)->_S6_un._S6_u32[0] == 0))
510 #else /* _BIG_ENDIAN */
511 #define IN6_IS_ADDR_V4MAPPED(addr) \
512 (((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \
513 ((addr)->_S6_un._S6_u32[1] == 0) && \
514 ((addr)->_S6_un._S6_u32[0] == 0))
515 #endif /* _BIG_ENDIAN */
518 * IN6_IS_ADDR_V4MAPPED - A IPv4 mapped INADDR_ANY
519 * Note: This macro is currently NOT defined in RFC2553 specification
520 * and not a standard macro that portable applications should use.
523 #define IN6_IS_ADDR_V4MAPPED_ANY(addr) \
524 (((addr)->_S6_un._S6_u32[3] == 0) && \
525 ((addr)->_S6_un._S6_u32[2] == 0x0000ffff) && \
526 ((addr)->_S6_un._S6_u32[1] == 0) && \
527 ((addr)->_S6_un._S6_u32[0] == 0))
528 #else /* _BIG_ENDIAN */
529 #define IN6_IS_ADDR_V4MAPPED_ANY(addr) \
530 (((addr)->_S6_un._S6_u32[3] == 0) && \
531 ((addr)->_S6_un._S6_u32[2] == 0xffff0000U) && \
532 ((addr)->_S6_un._S6_u32[1] == 0) && \
533 ((addr)->_S6_un._S6_u32[0] == 0))
534 #endif /* _BIG_ENDIAN */
536 /* Exclude loopback and unspecified address */
538 #define IN6_IS_ADDR_V4COMPAT(addr) \
539 (((addr)->_S6_un._S6_u32[2] == 0) && \
540 ((addr)->_S6_un._S6_u32[1] == 0) && \
541 ((addr)->_S6_un._S6_u32[0] == 0) && \
542 !((addr)->_S6_un._S6_u32[3] == 0) && \
543 !((addr)->_S6_un._S6_u32[3] == 0x00000001))
545 #else /* _BIG_ENDIAN */
546 #define IN6_IS_ADDR_V4COMPAT(addr) \
547 (((addr)->_S6_un._S6_u32[2] == 0) && \
548 ((addr)->_S6_un._S6_u32[1] == 0) && \
549 ((addr)->_S6_un._S6_u32[0] == 0) && \
550 !((addr)->_S6_un._S6_u32[3] == 0) && \
551 !((addr)->_S6_un._S6_u32[3] == 0x01000000))
552 #endif /* _BIG_ENDIAN */
556 * IN6_IS_ADDR_MC_RESERVED macro is currently NOT defined in RFC2553
557 * specification and not a standard macro that portable applications
561 #define IN6_IS_ADDR_MC_RESERVED(addr) \
562 (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff000000)
564 #else /* _BIG_ENDIAN */
565 #define IN6_IS_ADDR_MC_RESERVED(addr) \
566 (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000000ff)
567 #endif /* _BIG_ENDIAN */
570 #define IN6_IS_ADDR_MC_NODELOCAL(addr) \
571 (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff010000)
572 #else /* _BIG_ENDIAN */
573 #define IN6_IS_ADDR_MC_NODELOCAL(addr) \
574 (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000001ff)
575 #endif /* _BIG_ENDIAN */
578 #define IN6_IS_ADDR_MC_LINKLOCAL(addr) \
579 (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff020000)
580 #else /* _BIG_ENDIAN */
581 #define IN6_IS_ADDR_MC_LINKLOCAL(addr) \
582 (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000002ff)
583 #endif /* _BIG_ENDIAN */
586 #define IN6_IS_ADDR_MC_SITELOCAL(addr) \
587 (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff050000)
588 #else /* _BIG_ENDIAN */
589 #define IN6_IS_ADDR_MC_SITELOCAL(addr) \
590 (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000005ff)
591 #endif /* _BIG_ENDIAN */
594 #define IN6_IS_ADDR_MC_ORGLOCAL(addr) \
595 (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff080000)
596 #else /* _BIG_ENDIAN */
597 #define IN6_IS_ADDR_MC_ORGLOCAL(addr) \
598 (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x000008ff)
599 #endif /* _BIG_ENDIAN */
602 #define IN6_IS_ADDR_MC_GLOBAL(addr) \
603 (((addr)->_S6_un._S6_u32[0] & 0xff0f0000) == 0xff0e0000)
604 #else /* _BIG_ENDIAN */
605 #define IN6_IS_ADDR_MC_GLOBAL(addr) \
606 (((addr)->_S6_un._S6_u32[0] & 0x00000fff) == 0x00000eff)
607 #endif /* _BIG_ENDIAN */
610 * The IN6_IS_ADDR_MC_SOLICITEDNODE macro is not defined in any standard or
611 * RFC, and shouldn't be used by portable applications. It is used to see
612 * if an address is a solicited-node multicast address, which is prefixed
613 * with ff02:0:0:0:0:1:ff00::/104.
616 #define IN6_IS_ADDR_MC_SOLICITEDNODE(addr) \
617 (((addr)->_S6_un._S6_u32[0] == 0xff020000) && \
618 ((addr)->_S6_un._S6_u32[1] == 0x00000000) && \
619 ((addr)->_S6_un._S6_u32[2] == 0x00000001) && \
620 (((addr)->_S6_un._S6_u32[3] & 0xff000000) == 0xff000000))
622 #define IN6_IS_ADDR_MC_SOLICITEDNODE(addr) \
623 (((addr)->_S6_un._S6_u32[0] == 0x000002ff) && \
624 ((addr)->_S6_un._S6_u32[1] == 0x00000000) && \
625 ((addr)->_S6_un._S6_u32[2] == 0x01000000) && \
626 (((addr)->_S6_un._S6_u32[3] & 0x000000ff) == 0x000000ff))
630 * Macros to a) test for 6to4 IPv6 address, and b) to test if two
631 * 6to4 addresses have the same /48 prefix, and, hence, are from the
636 #define IN6_IS_ADDR_6TO4(addr) \
637 (((addr)->_S6_un._S6_u32[0] & 0xffff0000) == 0x20020000)
638 #else /* _BIG_ENDIAN */
639 #define IN6_IS_ADDR_6TO4(addr) \
640 (((addr)->_S6_un._S6_u32[0] & 0x0000ffff) == 0x00000220)
641 #endif /* _BIG_ENDIAN */
643 #define IN6_ARE_6TO4_PREFIX_EQUAL(addr1, addr2) \
644 (((addr1)->_S6_un._S6_u32[0] == (addr2)->_S6_un._S6_u32[0]) && \
645 ((addr1)->_S6_un._S6_u8[4] == (addr2)->_S6_un._S6_u8[4]) && \
646 ((addr1)->_S6_un._S6_u8[5] == (addr2)->_S6_un._S6_u8[5]))
649 * IN6_IS_ADDR_LINKSCOPE
650 * Identifies an address as being either link-local, link-local multicast or
651 * node-local multicast. All types of addresses are considered to be unique
652 * within the scope of a given link.
654 #define IN6_IS_ADDR_LINKSCOPE(addr) \
655 (IN6_IS_ADDR_LINKLOCAL(addr) || IN6_IS_ADDR_MC_LINKLOCAL(addr) || \
656 IN6_IS_ADDR_MC_NODELOCAL(addr))
659 * Useful utility macros for operations with IPv6 addresses
660 * Note: These macros are NOT defined in the RFC2553 or any other
661 * standard specification and are not standard macros that portable
662 * applications should use.
666 * IN6_V4MAPPED_TO_INADDR
667 * IN6_V4MAPPED_TO_IPADDR
668 * Assign a IPv4-Mapped IPv6 address to an IPv4 address.
669 * Note: These macros are NOT defined in RFC2553 or any other standard
670 * specification and are not macros that portable applications should
673 * void IN6_V4MAPPED_TO_INADDR(const in6_addr_t *v6, struct in_addr *v4);
674 * void IN6_V4MAPPED_TO_IPADDR(const in6_addr_t *v6, ipaddr_t v4);
677 #define IN6_V4MAPPED_TO_INADDR(v6, v4) \
678 ((v4)->s_addr = (v6)->_S6_un._S6_u32[3])
679 #define IN6_V4MAPPED_TO_IPADDR(v6, v4) \
680 ((v4) = (v6)->_S6_un._S6_u32[3])
683 * IN6_INADDR_TO_V4MAPPED
684 * IN6_IPADDR_TO_V4MAPPED
685 * Assign a IPv4 address address to an IPv6 address as a IPv4-mapped
687 * Note: These macros are NOT defined in RFC2553 or any other standard
688 * specification and are not macros that portable applications should
691 * void IN6_INADDR_TO_V4MAPPED(const struct in_addr *v4, in6_addr_t *v6);
692 * void IN6_IPADDR_TO_V4MAPPED(const ipaddr_t v4, in6_addr_t *v6);
696 #define IN6_INADDR_TO_V4MAPPED(v4, v6) \
697 ((v6)->_S6_un._S6_u32[3] = (v4)->s_addr, \
698 (v6)->_S6_un._S6_u32[2] = 0x0000ffff, \
699 (v6)->_S6_un._S6_u32[1] = 0, \
700 (v6)->_S6_un._S6_u32[0] = 0)
701 #define IN6_IPADDR_TO_V4MAPPED(v4, v6) \
702 ((v6)->_S6_un._S6_u32[3] = (v4), \
703 (v6)->_S6_un._S6_u32[2] = 0x0000ffff, \
704 (v6)->_S6_un._S6_u32[1] = 0, \
705 (v6)->_S6_un._S6_u32[0] = 0)
706 #else /* _BIG_ENDIAN */
707 #define IN6_INADDR_TO_V4MAPPED(v4, v6) \
708 ((v6)->_S6_un._S6_u32[3] = (v4)->s_addr, \
709 (v6)->_S6_un._S6_u32[2] = 0xffff0000U, \
710 (v6)->_S6_un._S6_u32[1] = 0, \
711 (v6)->_S6_un._S6_u32[0] = 0)
712 #define IN6_IPADDR_TO_V4MAPPED(v4, v6) \
713 ((v6)->_S6_un._S6_u32[3] = (v4), \
714 (v6)->_S6_un._S6_u32[2] = 0xffff0000U, \
715 (v6)->_S6_un._S6_u32[1] = 0, \
716 (v6)->_S6_un._S6_u32[0] = 0)
717 #endif /* _BIG_ENDIAN */
721 * Extract the embedded IPv4 address from the prefix to a 6to4 IPv6
723 * Note: This macro is NOT defined in RFC2553 or any other standard
724 * specification and is not a macro that portable applications should
726 * Note: we don't use the IPADDR form of the macro because we need
727 * to do a bytewise copy; the V4ADDR in the 6to4 address is not
730 * void IN6_6TO4_TO_V4ADDR(const in6_addr_t *v6, struct in_addr *v4);
733 #define IN6_6TO4_TO_V4ADDR(v6, v4) \
734 ((v4)->_S_un._S_un_b.s_b1 = (v6)->_S6_un._S6_u8[2], \
735 (v4)->_S_un._S_un_b.s_b2 = (v6)->_S6_un._S6_u8[3], \
736 (v4)->_S_un._S_un_b.s_b3 = (v6)->_S6_un._S6_u8[4], \
737 (v4)->_S_un._S_un_b.s_b4 = (v6)->_S6_un._S6_u8[5])
741 * Given an IPv4 address and an IPv6 address for output, a 6to4 address
742 * will be created from the IPv4 Address.
743 * Note: This method for creating 6to4 addresses is not standardized
744 * outside of Solaris. The newly created 6to4 address will be of the form
745 * 2002:<V4ADDR>:<SUBNETID>::<HOSTID>, where SUBNETID will equal 0 and
746 * HOSTID will equal 1.
748 * void IN6_V4ADDR_TO_6TO4(const struct in_addr *v4, in6_addr_t *v6)
752 #define IN6_V4ADDR_TO_6TO4(v4, v6) \
753 ((v6)->_S6_un._S6_u8[0] = 0x20, \
754 (v6)->_S6_un._S6_u8[1] = 0x02, \
755 (v6)->_S6_un._S6_u8[2] = (v4)->_S_un._S_un_b.s_b1, \
756 (v6)->_S6_un._S6_u8[3] = (v4)->_S_un._S_un_b.s_b2, \
757 (v6)->_S6_un._S6_u8[4] = (v4)->_S_un._S_un_b.s_b3, \
758 (v6)->_S6_un._S6_u8[5] = (v4)->_S_un._S_un_b.s_b4, \
759 (v6)->_S6_un._S6_u8[6] = 0, \
760 (v6)->_S6_un._S6_u8[7] = 0, \
761 (v6)->_S6_un._S6_u32[2] = 0, \
762 (v6)->_S6_un._S6_u32[3] = 0x00000001U)
764 #define IN6_V4ADDR_TO_6TO4(v4, v6) \
765 ((v6)->_S6_un._S6_u8[0] = 0x20, \
766 (v6)->_S6_un._S6_u8[1] = 0x02, \
767 (v6)->_S6_un._S6_u8[2] = (v4)->_S_un._S_un_b.s_b1, \
768 (v6)->_S6_un._S6_u8[3] = (v4)->_S_un._S_un_b.s_b2, \
769 (v6)->_S6_un._S6_u8[4] = (v4)->_S_un._S_un_b.s_b3, \
770 (v6)->_S6_un._S6_u8[5] = (v4)->_S_un._S_un_b.s_b4, \
771 (v6)->_S6_un._S6_u8[6] = 0, \
772 (v6)->_S6_un._S6_u8[7] = 0, \
773 (v6)->_S6_un._S6_u32[2] = 0, \
774 (v6)->_S6_un._S6_u32[3] = 0x01000000U)
775 #endif /* _BIG_ENDIAN */
778 * IN6_ARE_ADDR_EQUAL (defined in RFC2292)
779 * Compares if IPv6 addresses are equal.
780 * Note: Compares in order of high likelyhood of a miss so we minimize
781 * compares. (Current heuristic order, compare in reverse order of
784 * bool IN6_ARE_ADDR_EQUAL(const struct in6_addr *,
785 * const struct in6_addr *);
787 #define IN6_ARE_ADDR_EQUAL(addr1, addr2) \
788 (((addr1)->_S6_un._S6_u32[3] == (addr2)->_S6_un._S6_u32[3]) && \
789 ((addr1)->_S6_un._S6_u32[2] == (addr2)->_S6_un._S6_u32[2]) && \
790 ((addr1)->_S6_un._S6_u32[1] == (addr2)->_S6_un._S6_u32[1]) && \
791 ((addr1)->_S6_un._S6_u32[0] == (addr2)->_S6_un._S6_u32[0]))
794 * IN6_ARE_PREFIXEDADDR_EQUAL (not defined in RFCs)
795 * Compares if prefixed parts of IPv6 addresses are equal.
797 * uint32_t IN6_MASK_FROM_PREFIX(int, int);
798 * bool IN6_ARE_PREFIXEDADDR_EQUAL(const struct in6_addr *,
799 * const struct in6_addr *,
802 #define IN6_MASK_FROM_PREFIX(qoctet, prefix) \
803 ((((qoctet) + 1) * 32 < (prefix)) ? 0xFFFFFFFFu : \
804 ((((qoctet) * 32) >= (prefix)) ? 0x00000000u : \
805 0xFFFFFFFFu << (((qoctet) + 1) * 32 - (prefix))))
807 #define IN6_ARE_PREFIXEDADDR_EQUAL(addr1, addr2, prefix) \
808 (((ntohl((addr1)->_S6_un._S6_u32[0]) & \
809 IN6_MASK_FROM_PREFIX(0, prefix)) == \
810 (ntohl((addr2)->_S6_un._S6_u32[0]) & \
811 IN6_MASK_FROM_PREFIX(0, prefix))) && \
812 ((ntohl((addr1)->_S6_un._S6_u32[1]) & \
813 IN6_MASK_FROM_PREFIX(1, prefix)) == \
814 (ntohl((addr2)->_S6_un._S6_u32[1]) & \
815 IN6_MASK_FROM_PREFIX(1, prefix))) && \
816 ((ntohl((addr1)->_S6_un._S6_u32[2]) & \
817 IN6_MASK_FROM_PREFIX(2, prefix)) == \
818 (ntohl((addr2)->_S6_un._S6_u32[2]) & \
819 IN6_MASK_FROM_PREFIX(2, prefix))) && \
820 ((ntohl((addr1)->_S6_un._S6_u32[3]) & \
821 IN6_MASK_FROM_PREFIX(3, prefix)) == \
822 (ntohl((addr2)->_S6_un._S6_u32[3]) & \
823 IN6_MASK_FROM_PREFIX(3, prefix))))
825 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
829 * Options for use with [gs]etsockopt at the IP level.
831 * Note: Some of the IP_ namespace has conflict with and
832 * and is exposed through <xti.h>. (It also requires exposing
833 * options not implemented). The options with potential
834 * for conflicts use #ifndef guards.
837 #define IP_OPTIONS 1 /* set/get IP per-packet options */
840 #define IP_HDRINCL 2 /* int; header is included with data (raw) */
843 #define IP_TOS 3 /* int; IP type of service and precedence */
847 #define IP_TTL 4 /* int; IP time to live */
850 #define IP_RECVOPTS 0x5 /* int; receive all IP options w/datagram */
851 #define IP_RECVRETOPTS 0x6 /* int; receive IP options for response */
852 #define IP_RECVDSTADDR 0x7 /* int; receive IP dst addr w/datagram */
853 #define IP_RETOPTS 0x8 /* ip_opts; set/get IP per-packet options */
854 #define IP_RECVIF 0x9 /* int; receive the inbound interface index */
855 #define IP_RECVSLLA 0xa /* sockaddr_dl; get source link layer address */
856 #define IP_RECVTTL 0xb /* uint8_t; get TTL for inbound packet */
858 #define IP_MULTICAST_IF 0x10 /* set/get IP multicast interface */
859 #define IP_MULTICAST_TTL 0x11 /* set/get IP multicast timetolive */
860 #define IP_MULTICAST_LOOP 0x12 /* set/get IP multicast loopback */
861 #define IP_ADD_MEMBERSHIP 0x13 /* add an IP group membership */
862 #define IP_DROP_MEMBERSHIP 0x14 /* drop an IP group membership */
863 #define IP_BLOCK_SOURCE 0x15 /* block mcast pkts from source */
864 #define IP_UNBLOCK_SOURCE 0x16 /* unblock mcast pkts from source */
865 #define IP_ADD_SOURCE_MEMBERSHIP 0x17 /* add mcast group/source pair */
866 #define IP_DROP_SOURCE_MEMBERSHIP 0x18 /* drop mcast group/source pair */
867 #define IP_NEXTHOP 0x19 /* send directly to next hop */
869 * IP_PKTINFO and IP_RECVPKTINFO have same value. Size of argument passed in
870 * is used to differentiate b/w the two.
872 #define IP_PKTINFO 0x1a /* specify src address and/or index */
873 #define IP_RECVPKTINFO 0x1a /* recv dest/matched addr and index */
874 #define IP_DONTFRAG 0x1b /* don't fragment packets */
876 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
878 * Different preferences that can be requested from IPSEC protocols.
880 #define IP_SEC_OPT 0x22 /* Used to set IPSEC options */
881 #define IPSEC_PREF_NEVER 0x01
882 #define IPSEC_PREF_REQUIRED 0x02
883 #define IPSEC_PREF_UNIQUE 0x04
885 * This can be used with the setsockopt() call to set per socket security
886 * options. When the application uses per-socket API, we will reflect
887 * the request on both outbound and inbound packets.
890 typedef struct ipsec_req
{
891 uint_t ipsr_ah_req
; /* AH request */
892 uint_t ipsr_esp_req
; /* ESP request */
893 uint_t ipsr_self_encap_req
; /* Self-Encap request */
894 uint8_t ipsr_auth_alg
; /* Auth algs for AH */
895 uint8_t ipsr_esp_alg
; /* Encr algs for ESP */
896 uint8_t ipsr_esp_auth_alg
; /* Auth algs for ESP */
900 * MCAST_* options are protocol-independent. The actual definitions
901 * are with the v6 options below; this comment is here to note the
904 * #define MCAST_JOIN_GROUP 0x29
905 * #define MCAST_LEAVE_GROUP 0x2a
906 * #define MCAST_BLOCK_SOURCE 0x2b
907 * #define MCAST_UNBLOCK_SOURCE 0x2c
908 * #define MCAST_JOIN_SOURCE_GROUP 0x2d
909 * #define MCAST_LEAVE_SOURCE_GROUP 0x2e
911 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
914 * SunOS private (potentially not portable) IP_ option names
916 #define IP_BOUND_IF 0x41 /* bind socket to an ifindex */
917 #define IP_UNSPEC_SRC 0x42 /* use unspecified source address */
918 #define IP_BROADCAST_TTL 0x43 /* use specific TTL for broadcast */
919 /* can be reused 0x44 */
920 #define IP_DHCPINIT_IF 0x45 /* accept all unicast DHCP traffic */
923 * Option values and names (when !_XPG5) shared with <xti_inet.h>
926 #define IP_REUSEADDR 0x104
930 #define IP_DONTROUTE 0x105
934 #define IP_BROADCAST 0x106
938 * The following option values are reserved by <xti_inet.h>
940 * T_IP_OPTIONS 0x107 - IP per-packet options
941 * T_IP_TOS 0x108 - IP per packet type of service
945 * Default value constants for multicast attributes controlled by
946 * IP*_MULTICAST_LOOP and IP*_MULTICAST_{TTL,HOPS} options.
948 #define IP_DEFAULT_MULTICAST_TTL 1 /* normally limit m'casts to 1 hop */
949 #define IP_DEFAULT_MULTICAST_LOOP 1 /* normally hear sends if a member */
951 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
953 * Argument structure for IP_ADD_MEMBERSHIP and IP_DROP_MEMBERSHIP.
956 struct in_addr imr_multiaddr
; /* IP multicast address of group */
957 struct in_addr imr_interface
; /* local IP address of interface */
961 * Argument structure for IP_BLOCK_SOURCE, IP_UNBLOCK_SOURCE,
962 * IP_ADD_SOURCE_MEMBERSHIP, and IP_DROP_SOURCE_MEMBERSHIP.
964 struct ip_mreq_source
{
965 struct in_addr imr_multiaddr
; /* IP address of group */
966 struct in_addr imr_sourceaddr
; /* IP address of source */
967 struct in_addr imr_interface
; /* IP address of interface */
971 * Argument structure for IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP on
975 struct in6_addr ipv6mr_multiaddr
; /* IPv6 multicast addr */
976 unsigned int ipv6mr_interface
; /* interface index */
980 * Use #pragma pack() construct to force 32-bit alignment on amd64.
981 * This is needed to keep the structure size and offsets consistent
982 * between a 32-bit app and the 64-bit amd64 kernel in structures
983 * where 64-bit alignment would create gaps (in this case, structures
984 * which have a uint32_t followed by a struct sockaddr_storage).
986 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
991 * Argument structure for MCAST_JOIN_GROUP and MCAST_LEAVE_GROUP.
994 uint32_t gr_interface
; /* interface index */
995 struct sockaddr_storage gr_group
; /* group address */
999 * Argument structure for MCAST_BLOCK_SOURCE, MCAST_UNBLOCK_SOURCE,
1000 * MCAST_JOIN_SOURCE_GROUP, MCAST_LEAVE_SOURCE_GROUP.
1002 struct group_source_req
{
1003 uint32_t gsr_interface
; /* interface index */
1004 struct sockaddr_storage gsr_group
; /* group address */
1005 struct sockaddr_storage gsr_source
; /* source address */
1009 * Argument for SIOC[GS]MSFILTER ioctls
1011 struct group_filter
{
1012 uint32_t gf_interface
; /* interface index */
1013 struct sockaddr_storage gf_group
; /* multicast address */
1014 uint32_t gf_fmode
; /* filter mode */
1015 uint32_t gf_numsrc
; /* number of sources */
1016 struct sockaddr_storage gf_slist
[1]; /* source address */
1019 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
1023 #define GROUP_FILTER_SIZE(numsrc) \
1024 (sizeof (struct group_filter) - sizeof (struct sockaddr_storage) \
1025 + (numsrc) * sizeof (struct sockaddr_storage))
1028 * Argument for SIOC[GS]IPMSFILTER ioctls (IPv4-specific)
1030 struct ip_msfilter
{
1031 struct in_addr imsf_multiaddr
; /* IP multicast address of group */
1032 struct in_addr imsf_interface
; /* local IP address of interface */
1033 uint32_t imsf_fmode
; /* filter mode */
1034 uint32_t imsf_numsrc
; /* number of sources in src_list */
1035 struct in_addr imsf_slist
[1]; /* start of source list */
1038 #define IP_MSFILTER_SIZE(numsrc) \
1039 (sizeof (struct ip_msfilter) - sizeof (struct in_addr) \
1040 + (numsrc) * sizeof (struct in_addr))
1043 * Multicast source filter manipulation functions: defined in RFC 3678.
1045 int setsourcefilter(int, uint32_t, struct sockaddr
*, socklen_t
, uint32_t,
1046 uint_t
, struct sockaddr_storage
*);
1048 int getsourcefilter(int, uint32_t, struct sockaddr
*, socklen_t
, uint32_t *,
1049 uint_t
*, struct sockaddr_storage
*);
1051 int setipv4sourcefilter(int, struct in_addr
, struct in_addr
, uint32_t,
1052 uint32_t, struct in_addr
*);
1054 int getipv4sourcefilter(int, struct in_addr
, struct in_addr
, uint32_t *,
1055 uint32_t *, struct in_addr
*);
1058 * Definitions needed for [gs]etsourcefilter(), [gs]etipv4sourcefilter()
1060 #define MCAST_INCLUDE 1
1061 #define MCAST_EXCLUDE 2
1064 * Argument struct for IP_PKTINFO option
1066 typedef struct in_pktinfo
{
1067 unsigned int ipi_ifindex
; /* send/recv interface index */
1068 struct in_addr ipi_spec_dst
; /* matched source address */
1069 struct in_addr ipi_addr
; /* src/dst address in IP hdr */
1073 * Argument struct for IPV6_PKTINFO option
1075 struct in6_pktinfo
{
1076 struct in6_addr ipi6_addr
; /* src/dst IPv6 address */
1077 unsigned int ipi6_ifindex
; /* send/recv interface index */
1081 * Argument struct for IPV6_MTUINFO option
1083 struct ip6_mtuinfo
{
1084 struct sockaddr_in6 ip6m_addr
; /* dst address including zone ID */
1085 uint32_t ip6m_mtu
; /* path MTU in host byte order */
1089 * IPv6 routing header types
1091 #define IPV6_RTHDR_TYPE_0 0
1093 extern socklen_t
inet6_rth_space(int type
, int segments
);
1094 extern void *inet6_rth_init(void *bp
, socklen_t bp_len
, int type
, int segments
);
1095 extern int inet6_rth_add(void *bp
, const struct in6_addr
*addr
);
1096 extern int inet6_rth_reverse(const void *in
, void *out
);
1097 extern int inet6_rth_segments(const void *bp
);
1098 extern struct in6_addr
*inet6_rth_getaddr(const void *bp
, int index
);
1100 extern int inet6_opt_init(void *extbuf
, socklen_t extlen
);
1101 extern int inet6_opt_append(void *extbuf
, socklen_t extlen
, int offset
,
1102 uint8_t type
, socklen_t len
, uint_t align
, void **databufp
);
1103 extern int inet6_opt_finish(void *extbuf
, socklen_t extlen
, int offset
);
1104 extern int inet6_opt_set_val(void *databuf
, int offset
, void *val
,
1106 extern int inet6_opt_next(void *extbuf
, socklen_t extlen
, int offset
,
1107 uint8_t *typep
, socklen_t
*lenp
, void **databufp
);
1108 extern int inet6_opt_find(void *extbufp
, socklen_t extlen
, int offset
,
1109 uint8_t type
, socklen_t
*lenp
, void **databufp
);
1110 extern int inet6_opt_get_val(void *databuf
, int offset
, void *val
,
1112 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
1115 * Argument structure for IP_ADD_PROXY_ADDR.
1116 * Note that this is an unstable, experimental interface. It may change
1117 * later. Don't use it unless you know what it is.
1120 struct in_addr in_prefix_addr
;
1121 unsigned int in_prefix_len
;
1125 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
1129 #define IPV6_UNICAST_HOPS 0x5 /* hop limit value for unicast */
1131 /* argument type: uint_t */
1132 #define IPV6_MULTICAST_IF 0x6 /* outgoing interface for */
1133 /* multicast packets. */
1134 /* argument type: struct in6_addr */
1135 #define IPV6_MULTICAST_HOPS 0x7 /* hop limit value to use for */
1136 /* multicast packets. */
1137 /* argument type: uint_t */
1138 #define IPV6_MULTICAST_LOOP 0x8 /* enable/disable delivery of */
1139 /* multicast packets on same socket. */
1140 /* argument type: uint_t */
1141 #define IPV6_JOIN_GROUP 0x9 /* join an IPv6 multicast group. */
1142 /* argument type: struct ipv6_mreq */
1143 #define IPV6_LEAVE_GROUP 0xa /* leave an IPv6 multicast group */
1144 /* argument type: struct ipv6_mreq */
1147 * Other XPG6 constants.
1149 #define INET_ADDRSTRLEN 16 /* max len IPv4 addr in ascii dotted */
1150 /* decimal notation. */
1151 #define INET6_ADDRSTRLEN 46 /* max len of IPv6 addr in ascii */
1152 /* standard colon-hex notation. */
1154 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
1156 #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
1159 * IPV6_ADD_MEMBERSHIP and IPV6_DROP_MEMBERSHIP are being kept
1160 * for backward compatibility. They have the same meaning as IPV6_JOIN_GROUP
1161 * and IPV6_LEAVE_GROUP respectively.
1163 #define IPV6_ADD_MEMBERSHIP 0x9 /* join an IPv6 multicast group. */
1164 /* argument type: struct ipv6_mreq */
1165 #define IPV6_DROP_MEMBERSHIP 0xa /* leave an IPv6 multicast group */
1166 /* argument type: struct ipv6_mreq */
1168 #define IPV6_PKTINFO 0xb /* addr plus interface index */
1169 /* arg type: "struct in6_pktingo" - */
1170 #define IPV6_HOPLIMIT 0xc /* hoplimit for datagram */
1171 #define IPV6_NEXTHOP 0xd /* next hop address */
1172 #define IPV6_HOPOPTS 0xe /* hop by hop options */
1173 #define IPV6_DSTOPTS 0xf /* destination options - after */
1174 /* the routing header */
1175 #define IPV6_RTHDR 0x10 /* routing header */
1176 #define IPV6_RTHDRDSTOPTS 0x11 /* destination options - before */
1177 /* the routing header */
1178 #define IPV6_RECVPKTINFO 0x12 /* enable/disable IPV6_PKTINFO */
1179 #define IPV6_RECVHOPLIMIT 0x13 /* enable/disable IPV6_HOPLIMIT */
1180 #define IPV6_RECVHOPOPTS 0x14 /* enable/disable IPV6_HOPOPTS */
1183 * This options exists for backwards compatability and should no longer be
1184 * used. Use IPV6_RECVDSTOPTS instead.
1186 #define _OLD_IPV6_RECVDSTOPTS 0x15
1188 #define IPV6_RECVRTHDR 0x16 /* enable/disable IPV6_RTHDR */
1191 * enable/disable IPV6_RTHDRDSTOPTS. Now obsolete. IPV6_RECVDSTOPTS enables
1192 * the receipt of both headers.
1194 #define IPV6_RECVRTHDRDSTOPTS 0x17
1196 #define IPV6_CHECKSUM 0x18 /* Control checksum on raw sockets */
1197 #define IPV6_RECVTCLASS 0x19 /* enable/disable IPV6_CLASS */
1198 #define IPV6_USE_MIN_MTU 0x20 /* send packets with minimum MTU */
1199 #define IPV6_DONTFRAG 0x21 /* don't fragment packets */
1200 #define IPV6_SEC_OPT 0x22 /* Used to set IPSEC options */
1201 #define IPV6_SRC_PREFERENCES 0x23 /* Control socket's src addr select */
1202 #define IPV6_RECVPATHMTU 0x24 /* receive PMTU info */
1203 #define IPV6_PATHMTU 0x25 /* get the PMTU */
1204 #define IPV6_TCLASS 0x26 /* traffic class */
1205 #define IPV6_V6ONLY 0x27 /* v6 only socket option */
1208 * enable/disable receipt of both both IPV6_DSTOPTS headers.
1210 #define IPV6_RECVDSTOPTS 0x28
1213 * protocol-independent multicast membership options.
1215 #define MCAST_JOIN_GROUP 0x29 /* join group for all sources */
1216 #define MCAST_LEAVE_GROUP 0x2a /* leave group */
1217 #define MCAST_BLOCK_SOURCE 0x2b /* block specified source */
1218 #define MCAST_UNBLOCK_SOURCE 0x2c /* unblock specified source */
1219 #define MCAST_JOIN_SOURCE_GROUP 0x2d /* join group for specified source */
1220 #define MCAST_LEAVE_SOURCE_GROUP 0x2e /* leave source/group pair */
1222 /* 32Bit field for IPV6_SRC_PREFERENCES */
1223 #define IPV6_PREFER_SRC_HOME 0x00000001
1224 #define IPV6_PREFER_SRC_COA 0x00000002
1225 #define IPV6_PREFER_SRC_PUBLIC 0x00000004
1226 #define IPV6_PREFER_SRC_TMP 0x00000008
1227 #define IPV6_PREFER_SRC_NONCGA 0x00000010
1228 #define IPV6_PREFER_SRC_CGA 0x00000020
1230 #define IPV6_PREFER_SRC_MIPMASK (IPV6_PREFER_SRC_HOME | IPV6_PREFER_SRC_COA)
1231 #define IPV6_PREFER_SRC_MIPDEFAULT IPV6_PREFER_SRC_HOME
1232 #define IPV6_PREFER_SRC_TMPMASK (IPV6_PREFER_SRC_PUBLIC | IPV6_PREFER_SRC_TMP)
1233 #define IPV6_PREFER_SRC_TMPDEFAULT IPV6_PREFER_SRC_PUBLIC
1234 #define IPV6_PREFER_SRC_CGAMASK (IPV6_PREFER_SRC_NONCGA | IPV6_PREFER_SRC_CGA)
1235 #define IPV6_PREFER_SRC_CGADEFAULT IPV6_PREFER_SRC_NONCGA
1237 #define IPV6_PREFER_SRC_MASK (IPV6_PREFER_SRC_MIPMASK |\
1238 IPV6_PREFER_SRC_TMPMASK | IPV6_PREFER_SRC_CGAMASK)
1240 #define IPV6_PREFER_SRC_DEFAULT (IPV6_PREFER_SRC_MIPDEFAULT |\
1241 IPV6_PREFER_SRC_TMPDEFAULT | IPV6_PREFER_SRC_CGADEFAULT)
1244 * SunOS private (potentially not portable) IPV6_ option names
1246 #define IPV6_BOUND_IF 0x41 /* bind to an ifindex */
1247 #define IPV6_UNSPEC_SRC 0x42 /* source of packets set to */
1248 /* unspecified (all zeros) */
1251 * Miscellaneous IPv6 constants.
1253 #define IPV6_PAD1_OPT 0 /* pad byte in IPv6 extension hdrs */
1255 #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
1258 * Extern declarations for pre-defined global const variables
1260 #if !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__)
1263 extern const struct in6_addr in6addr_any
;
1264 extern const struct in6_addr in6addr_loopback
;
1266 extern struct in6_addr in6addr_any
;
1267 extern struct in6_addr in6addr_loopback
;
1270 #endif /* !defined(_XPG4_2) || defined(_XPG6) || defined(__EXTENSIONS__) */
1276 #endif /* _NETINET_IN_H */