]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/ntp/include/isc/ipv6.h
This commit was generated by cvs2svn to compensate for changes in r136644,
[FreeBSD/FreeBSD.git] / contrib / ntp / include / isc / ipv6.h
1 /*
2  * Copyright (C) 1999-2001  Internet Software Consortium.
3  *
4  * Permission to use, copy, modify, and distribute this software for any
5  * purpose with or without fee is hereby granted, provided that the above
6  * copyright notice and this permission notice appear in all copies.
7  *
8  * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
9  * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
10  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
11  * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
12  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
13  * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
14  * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
15  * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* $Id: ipv6.h,v 1.19 2002/04/03 06:38:33 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 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
106         (((a)->s6_addr32[0] == 0) &&    \
107          ((a)->s6_addr32[1] == 0) &&    \
108          ((a)->s6_addr32[2] == 0) &&    \
109          ((a)->s6_addr32[3] == 0))
110
111 /*
112  * Loopback
113  */
114 #define IN6_IS_ADDR_LOOPBACK(a)         \
115         (((a)->s6_addr32[0] == 0) &&    \
116          ((a)->s6_addr32[1] == 0) &&    \
117          ((a)->s6_addr32[2] == 0) &&    \
118          ((a)->s6_addr32[3] == htonl(1)))
119
120 /*
121  * IPv4 compatible
122  */
123 #define IN6_IS_ADDR_V4COMPAT(a)         \
124         (((a)->s6_addr32[0] == 0) &&    \
125          ((a)->s6_addr32[1] == 0) &&    \
126          ((a)->s6_addr32[2] == 0) &&    \
127          ((a)->s6_addr32[3] != 0) &&    \
128          ((a)->s6_addr32[3] != htonl(1)))
129
130 /*
131  * Mapped
132  */
133 #define IN6_IS_ADDR_V4MAPPED(a)               \
134         (((a)->s6_addr32[0] == 0) &&          \
135          ((a)->s6_addr32[1] == 0) &&          \
136          ((a)->s6_addr32[2] == htonl(0x0000ffff)))
137
138 /*
139  * Multicast
140  */
141 #define IN6_IS_ADDR_MULTICAST(a)        \
142         ((a)->s6_addr8[0] == 0xffU)
143
144 /*
145  * Unicast link / site local.
146  */
147 #define IN6_IS_ADDR_LINKLOCAL(a)        \
148         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
149 #define IN6_IS_ADDR_SITELOCAL(a)        \
150         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
151
152 #endif /* ISC_ONLY_IPV6 */
153 #endif /* ISC_IPV6_H */