]> CyberLeo.Net >> Repos - FreeBSD/releng/9.2.git/blob - contrib/ntp/include/isc/ipv6.h
- Copy stable/9 to releng/9.2 as part of the 9.2-RELEASE cycle.
[FreeBSD/releng/9.2.git] / contrib / ntp / include / isc / ipv6.h
1 /*
2  * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
3  * Copyright (C) 1999-2002  Internet Software Consortium.
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11  * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15  * PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: ipv6.h,v 1.17.12.4 2004/03/09 05:21:09 marka Exp $ */
19
20 #ifndef ISC_IPV6_H
21 #define ISC_IPV6_H 1
22
23 /*
24  * Also define LWRES_IPV6_H to keep it from being included if liblwres is
25  * being used, or redefinition errors will occur.
26  */
27 #define LWRES_IPV6_H 1
28
29 /*****
30  ***** Module Info
31  *****/
32
33 /*
34  * IPv6 definitions for systems which do not support IPv6.
35  *
36  * MP:
37  *      No impact.
38  *
39  * Reliability:
40  *      No anticipated impact.
41  *
42  * Resources:
43  *      N/A.
44  *
45  * Security:
46  *      No anticipated impact.
47  *
48  * Standards:
49  *      RFC 2553.
50  */
51
52 /***
53  *** Imports.
54  ***/
55
56 #include <isc/int.h>
57 #include <isc/platform.h>
58
59 /*
60  * We probably don't need this on NTP
61  */
62 #ifdef ISC_ONLY_IPV6 
63 /***
64  *** Types.
65  ***/
66
67 struct in6_addr {
68         union {
69                 isc_uint8_t     _S6_u8[16];
70                 isc_uint16_t    _S6_u16[8];
71                 isc_uint32_t    _S6_u32[4];
72         } _S6_un;
73 };
74 #define s6_addr         _S6_un._S6_u8
75 #define s6_addr8        _S6_un._S6_u8
76 #define s6_addr16       _S6_un._S6_u16
77 #define s6_addr32       _S6_un._S6_u32
78
79 #define IN6ADDR_ANY_INIT        {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}
80 #define IN6ADDR_LOOPBACK_INIT   {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}
81
82 LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any;
83 LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback;
84
85 struct sockaddr_in6 {
86 #ifdef ISC_PLATFORM_HAVESALEN
87         isc_uint8_t             sin6_len;
88         isc_uint8_t             sin6_family;
89 #else
90         isc_uint16_t            sin6_family;
91 #endif
92         isc_uint16_t            sin6_port;
93         isc_uint32_t            sin6_flowinfo;
94         struct in6_addr         sin6_addr;
95         isc_uint32_t            sin6_scope_id;
96 };
97
98 #ifdef ISC_PLATFORM_HAVESALEN
99 #define SIN6_LEN 1
100 #endif
101
102 /*
103  * Unspecified
104  */
105 #ifndef IN6_IS_ADDR_UNSPECIFIED
106 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
107         (((a)->s6_addr32[0] == 0) &&    \
108          ((a)->s6_addr32[1] == 0) &&    \
109          ((a)->s6_addr32[2] == 0) &&    \
110          ((a)->s6_addr32[3] == 0))
111 #endif
112 /*
113  * Loopback
114  */
115 #define IN6_IS_ADDR_LOOPBACK(a)         \
116         (((a)->s6_addr32[0] == 0) &&    \
117          ((a)->s6_addr32[1] == 0) &&    \
118          ((a)->s6_addr32[2] == 0) &&    \
119          ((a)->s6_addr32[3] == htonl(1)))
120
121 /*
122  * IPv4 compatible
123  */
124 #define IN6_IS_ADDR_V4COMPAT(a)         \
125         (((a)->s6_addr32[0] == 0) &&    \
126          ((a)->s6_addr32[1] == 0) &&    \
127          ((a)->s6_addr32[2] == 0) &&    \
128          ((a)->s6_addr32[3] != 0) &&    \
129          ((a)->s6_addr32[3] != htonl(1)))
130
131 /*
132  * Mapped
133  */
134 #define IN6_IS_ADDR_V4MAPPED(a)               \
135         (((a)->s6_addr32[0] == 0) &&          \
136          ((a)->s6_addr32[1] == 0) &&          \
137          ((a)->s6_addr32[2] == htonl(0x0000ffff)))
138
139 /*
140  * Multicast
141  */
142 #ifndef IN6_IS_ADDR_MULTICAST
143 #define IN6_IS_ADDR_MULTICAST(a)        \
144         ((a)->s6_addr8[0] == 0xffU)
145 #endif
146 /*
147  * Unicast link / site local.
148  */
149 #define IN6_IS_ADDR_LINKLOCAL(a)        \
150         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
151 #define IN6_IS_ADDR_SITELOCAL(a)        \
152         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
153
154 #endif /* ISC_ONLY_IPV6 */
155 #endif /* ISC_IPV6_H */