• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* MIT License
2  *
3  * Copyright (c) 2005 Dominick Meglio
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy
6  * of this software and associated documentation files (the "Software"), to deal
7  * in the Software without restriction, including without limitation the rights
8  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9  * copies of the Software, and to permit persons to whom the Software is
10  * furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  *
24  * SPDX-License-Identifier: MIT
25  */
26 
27 #ifndef ARES_IPV6_H
28 #define ARES_IPV6_H
29 
30 #ifdef HAVE_NETINET6_IN6_H
31 #  include <netinet6/in6.h>
32 #endif
33 
34 #if defined(USE_WINSOCK)
35 #  if defined(HAVE_IPHLPAPI_H)
36 #    include <iphlpapi.h>
37 #  endif
38 #  if defined(HAVE_NETIOAPI_H)
39 #    include <netioapi.h>
40 #  endif
41 #endif
42 
43 #ifndef HAVE_PF_INET6
44 #  define PF_INET6 AF_INET6
45 #endif
46 
47 #ifndef HAVE_STRUCT_SOCKADDR_IN6
48 struct sockaddr_in6 {
49   unsigned short       sin6_family;
50   unsigned short       sin6_port;
51   unsigned long        sin6_flowinfo;
52   struct ares_in6_addr sin6_addr;
53   unsigned int         sin6_scope_id;
54 };
55 #endif
56 
57 typedef union {
58   struct sockaddr     sa;
59   struct sockaddr_in  sa4;
60   struct sockaddr_in6 sa6;
61 } ares_sockaddr;
62 
63 #ifndef HAVE_STRUCT_ADDRINFO
64 struct addrinfo {
65   int              ai_flags;
66   int              ai_family;
67   int              ai_socktype;
68   int              ai_protocol;
69   ares_socklen_t   ai_addrlen; /* Follow rfc3493 struct addrinfo */
70   char            *ai_canonname;
71   struct sockaddr *ai_addr;
72   struct addrinfo *ai_next;
73 };
74 #endif
75 
76 #ifndef NS_IN6ADDRSZ
77 #  ifndef HAVE_STRUCT_IN6_ADDR
78 /* We cannot have it set to zero, so we pick a fixed value here */
79 #    define NS_IN6ADDRSZ 16
80 #  else
81 #    define NS_IN6ADDRSZ sizeof(struct in6_addr)
82 #  endif
83 #endif
84 
85 #ifndef NS_INADDRSZ
86 #  define NS_INADDRSZ sizeof(struct in_addr)
87 #endif
88 
89 #ifndef NS_INT16SZ
90 #  define NS_INT16SZ 2
91 #endif
92 
93 /* Windows XP Compatibility with later MSVC/Mingw versions */
94 #if defined(_WIN32)
95 #  if !defined(IF_MAX_STRING_SIZE)
96 #    define IF_MAX_STRING_SIZE 256 /* =256 in <ifdef.h> */
97 #  endif
98 #  if !defined(NDIS_IF_MAX_STRING_SIZE)
99 #    define NDIS_IF_MAX_STRING_SIZE IF_MAX_STRING_SIZE   /* =256 in <ifdef.h> */
100 #  endif
101 #endif
102 
103 #ifndef IF_NAMESIZE
104 #  ifdef IFNAMSIZ
105 #    define IF_NAMESIZE IFNAMSIZ
106 #  else
107 #    define IF_NAMESIZE 32
108 #  endif
109 #endif
110 
111 /* Defined in inet_net_pton.c for no particular reason. */
112 extern const struct ares_in6_addr ares_in6addr_any; /* :: */
113 
114 
115 #endif /* ARES_IPV6_H */
116