Go to the documentation of this file.
48 #include <sys/types.h>
71 unsigned char*
a = (
unsigned char*)&sa->
sin6_addr;
72 unsigned char*
b = (
unsigned char*)&sb->
sin6_addr;
74 while (cur_bit < 128) {
75 int high_bit = 1 << (CHAR_BIT - 1);
76 int a_val =
a[cur_bit / CHAR_BIT] & (high_bit >> (cur_bit % CHAR_BIT));
77 int b_val =
b[cur_bit / CHAR_BIT] & (high_bit >> (cur_bit % CHAR_BIT));
89 return bits32[0] == 0 && bits32[1] == 0 && bits32[2] == 0 &&
90 bits32[3] == htonl(1);
95 return bits32[0] == 0 && bits32[1] == 0 && bits32[2] == htonl(0x0000ffff);
100 return bits32[0] == 0 && bits32[1] == 0 && bits32[2] == 0 && bits32[3] != 0 &&
101 bits32[3] != htonl(1);
106 return bytes[0] == 0xfe && (
bytes[1] & 0xc0) == 0xc0;
111 return bytes[0] == 0xfe && (
bytes[1] & 0xc0) == 0x80;
121 return (
bytes[0] & 0xfe) == 0xfc;
137 switch (((
struct sockaddr*)address)->sa_family) {
224 if (
first->source_addr_exists !=
second->source_addr_exists) {
225 return first->source_addr_exists ? -1 : 1;
233 bool first_src_dst_scope_matches =
false;
236 first_src_dst_scope_matches =
true;
238 bool second_src_dst_scope_matches =
false;
241 second_src_dst_scope_matches =
true;
243 if (first_src_dst_scope_matches != second_src_dst_scope_matches) {
244 return first_src_dst_scope_matches ? -1 : 1;
252 bool first_label_matches =
false;
255 first_label_matches =
true;
257 bool second_label_matches =
false;
260 second_label_matches =
true;
262 if (first_label_matches != second_label_matches) {
263 return first_label_matches ? -1 : 1;
283 if (
first->source_addr_exists &&
286 second->source_addr_exists &&
289 int first_match_length =
295 return second_match_length - first_match_length;
326 return (
int)(
first->original_index -
second->original_index);
341 memset(&expected_source_addr, 0,
sizeof(expected_source_addr));
342 if (memcmp(&expected_source_addr, &sortable->
source_addr,
350 size_t sortables_len) {
351 for (
size_t i = 0;
i < sortables_len;
i++) {
355 &sortables[
i].dest_addr, &sortables[
i].source_addr);
bool address_sorting_get_source_addr_for_testing(const address_sorting_address *dest, address_sorting_address *source)
static int rfc_6724_compare(const void *a, const void *b)
address_sorting_address source_addr
const address_sorting_source_addr_factory_vtable * vtable
return memset(p, 0, total)
static address_sorting_source_addr_factory * g_current_source_addr_factory
static int in6_is_addr_ula(const struct in6_addr *ipv6_address)
static int in6_is_addr_v4compat(const struct in6_addr *ipv6_address)
static bool address_sorting_get_source_addr(const address_sorting_address *dest, address_sorting_address *source)
void address_sorting_shutdown()
static int in6_is_addr_linklocal(const struct in6_addr *ipv6_address)
static int compare_source_dest_labels_match(const address_sorting_sortable *first, const address_sorting_sortable *second)
static int in6_is_addr_loopback(const struct in6_addr *ipv6_address)
static int in6_is_addr_teredo(const struct in6_addr *ipv6_address)
@ ADDRESS_SORTING_AF_INET
static void sanity_check_private_fields_are_unused(const address_sorting_sortable *sortable)
static int get_label_value(const address_sorting_address *resolved_addr)
static int compare_source_dest_scope_matches(const address_sorting_sortable *first, const address_sorting_sortable *second)
static int compare_dest_scope(const address_sorting_sortable *first, const address_sorting_sortable *second)
address_sorting_family address_sorting_abstract_get_family(const address_sorting_address *address)
static int in6_is_addr_6bone(const struct in6_addr *ipv6_address)
address_sorting_source_addr_factory * address_sorting_create_source_addr_factory_for_current_platform()
void address_sorting_init()
bool(* get_source_addr)(struct address_sorting_source_addr_factory *factory, const address_sorting_address *dest_addr, address_sorting_address *source_addr)
static int get_precedence_value(const address_sorting_address *resolved_addr)
void qsort(void *a, size_t n, size_t es, int(*cmp)(const void *, const void *))
static int sockaddr_get_scope(const address_sorting_address *resolved_addr)
@ ADDRESS_SORTING_UNKNOWN_FAMILY
void address_sorting_rfc_6724_sort(address_sorting_sortable *sortables, size_t sortables_len)
static int compare_source_addr_exists(const address_sorting_sortable *first, const address_sorting_sortable *second)
void address_sorting_override_source_addr_factory_for_testing(address_sorting_source_addr_factory *factory)
static int compare_dest_precedence(const address_sorting_sortable *first, const address_sorting_sortable *second)
static int in6_is_addr_sitelocal(const struct in6_addr *ipv6_address)
static const int kIPv6AddrScopeLinkLocal
@ ADDRESS_SORTING_AF_INET6
static int in6_is_addr_6to4(const struct in6_addr *ipv6_address)
static int ipv6_prefix_match_length(const struct sockaddr_in6 *sa, const struct sockaddr_in6 *sb)
struct ares_in6_addr sin6_addr
static int in6_is_addr_v4mapped(const struct in6_addr *ipv6_address)
void(* destroy)(struct address_sorting_source_addr_factory *factory)
static const int kIPv6AddrScopeSiteLocal
static const int kIPv6AddrScopeGlobal
static int compare_source_dest_prefix_match_lengths(const address_sorting_sortable *first, const address_sorting_sortable *second)
if(p->owned &&p->wrapped !=NULL)
grpc
Author(s):
autogenerated on Fri May 16 2025 02:57:40