Go to the documentation of this file.
39 #ifdef HAVE_NETINET_IN_H
40 # include <netinet/in.h>
63 #define ARES_IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
65 #define ARES_IPV6_ADDR_SCOPE_NODELOCAL 0x01
66 #define ARES_IPV6_ADDR_SCOPE_INTFACELOCAL 0x01
67 #define ARES_IPV6_ADDR_SCOPE_LINKLOCAL 0x02
68 #define ARES_IPV6_ADDR_SCOPE_SITELOCAL 0x05
69 #define ARES_IPV6_ADDR_SCOPE_ORGLOCAL 0x08
70 #define ARES_IPV6_ADDR_SCOPE_GLOBAL 0x0e
72 #define ARES_IN_LOOPBACK(a) ((((long int)(a)) & 0xff000000) == 0x7f000000)
75 #define ARES_IN6_IS_ADDR_ULA(a) (((a)->s6_addr[0] & 0xfe) == 0xfc)
79 #define ARES_IN6_IS_ADDR_TEREDO(a) \
80 ((*(const unsigned int *)(const void *)(&(a)->s6_addr[0]) == ntohl(0x20010000)))
82 #define ARES_IN6_IS_ADDR_6TO4(a) \
83 (((a)->s6_addr[0] == 0x20) && ((a)->s6_addr[1] == 0x02))
85 #define ARES_IN6_IS_ADDR_6BONE(a) \
86 (((a)->s6_addr[0] == 0x3f) && ((a)->s6_addr[1] == 0xfe))
116 else if (
addr->sa_family == AF_INET)
119 unsigned long int na = ntohl(
addr4->sin_addr.s_addr);
121 (na & 0xffff0000) == 0xa9fe0000)
147 if (
addr->sa_family == AF_INET)
208 if (
addr->sa_family == AF_INET)
257 const struct in6_addr *
a2)
259 const char *p1 = (
const char *)
a1;
260 const char *p2 = (
const char *)
a2;
262 for (
i = 0;
i <
sizeof(*a1); ++
i)
270 for (j = 0; j < CHAR_BIT; ++j)
272 if (
x & (1 << (CHAR_BIT - 1)))
274 return i * CHAR_BIT + j;
279 return sizeof(*a1) * CHAR_BIT;
290 int scope_src1, scope_dst1, scope_match1;
291 int scope_src2, scope_dst2, scope_match2;
292 int label_src1, label_dst1, label_match1;
293 int label_src2, label_dst2, label_match2;
294 int precedence1, precedence2;
295 int prefixlen1, prefixlen2;
298 if (
a1->has_src_addr !=
a2->has_src_addr)
300 return a2->has_src_addr -
a1->has_src_addr;
306 scope_match1 = (scope_src1 == scope_dst1);
310 scope_match2 = (scope_src2 == scope_dst2);
312 if (scope_match1 != scope_match2)
314 return scope_match2 - scope_match1;
324 label_match1 = (label_src1 == label_dst1);
328 label_match2 = (label_src2 == label_dst2);
330 if (label_match1 != label_match2)
332 return label_match2 - label_match1;
338 if (precedence1 != precedence2)
340 return precedence2 - precedence1;
346 if (scope_dst1 != scope_dst2)
348 return scope_dst1 - scope_dst2;
352 if (
a1->has_src_addr &&
a1->ai->ai_addr->sa_family ==
AF_INET6 &&
353 a2->has_src_addr &&
a2->ai->ai_addr->sa_family ==
AF_INET6)
363 if (prefixlen1 != prefixlen2)
365 return prefixlen2 - prefixlen1;
373 return a1->original_order -
a2->original_order;
385 const struct sockaddr *
addr,
386 struct sockaddr *src_addr)
392 switch (
addr->sa_family)
395 len =
sizeof(
struct sockaddr_in);
408 if (errno == EAFNOSUPPORT)
422 while (
ret == -1 && errno == EINTR);
430 if (getsockname(sock, src_addr, &
len) != 0)
471 for (
i = 0,
cur = list_sentinel->
ai_next; i < nelem; ++i, cur = cur->ai_next)
490 list_sentinel->
ai_next = elems[0].ai;
491 for (
i = 0;
i < nelem - 1; ++
i)
495 elems[nelem - 1].ai->
ai_next = NULL;
#define ARES_IN6_IS_ADDR_ULA(a)
#define ARES_IN6_IS_ADDR_6TO4(a)
#define ARES_IPV6_ADDR_SCOPE_GLOBAL
ares_socket_t ares__open_socket(ares_channel channel, int af, int type, int protocol)
static int rfc6724_compare(const void *ptr1, const void *ptr2)
#define ARES_IN_LOOPBACK(a)
wrapped_grpc_channel * channel
void *(* ares_malloc)(size_t size)=default_malloc
#define ARES_IPV6_ADDR_SCOPE_NODELOCAL
#define CARES_INADDR_CAST(type, var)
#define ARES_IPV6_ADDR_SCOPE_SITELOCAL
static int get_precedence(const struct sockaddr *addr)
struct ares_addrinfo_node * ai
static struct sockaddr_in6 addr6
int ares__connect_socket(ares_channel channel, ares_socket_t sockfd, const struct sockaddr *addr, ares_socklen_t addrlen)
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
static struct sockaddr_in addr4
static int common_prefix_len(const struct in6_addr *a1, const struct in6_addr *a2)
void ares__close_socket(ares_channel, ares_socket_t)
static int get_scope(const struct sockaddr *addr)
static int find_src_addr(ares_channel channel, const struct sockaddr *addr, struct sockaddr *src_addr)
#define ARES_IN6_IS_ADDR_TEREDO(a)
UniquePtr< SSL_SESSION > ret
struct ares_addrinfo_node * ai_next
void(* ares_free)(void *ptr)=default_free
#define ARES_IPV6_ADDR_MC_SCOPE(a)
#define ARES_IPV6_ADDR_SCOPE_LINKLOCAL
struct ares_in6_addr sin6_addr
#define ARES_IN6_IS_ADDR_6BONE(a)
int ares__sortaddrinfo(ares_channel channel, struct ares_addrinfo_node *list_sentinel)
static int get_label(const struct sockaddr *addr)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:43