6 /* Internal definitions used in the libc code. */
7 #define __getservbyname_r getservbyname_r
8 #define __socket socket
9 #define __getsockname getsockname
10 #define __inet_aton inet_aton
11 #define __gethostbyaddr_r gethostbyaddr_r
12 #define __gethostbyname2_r gethostbyname2_r
13 #define __qsort_r qsort_r
17 __check_pf (bool *p1
, bool *p2
, struct in6addrinfo
**in6ai
, size_t *in6ailen
)
26 __free_in6ai (struct in6addrinfo
*ai
)
32 __check_native (uint32_t a1_index
, int *a1_native
,
33 uint32_t a2_index
, int *a2_native
)
39 __idna_to_ascii_lz (const char *input
, char **output
, int flags
)
46 __idna_to_unicode_lzlz (const char *input
, char **output
, int flags
)
54 _res_hconf_init (void)
59 #include "../sysdeps/posix/getaddrinfo.c"
62 /* This is the beginning of the real test code. The above defines
63 (among other things) the function rfc3484_sort. */
66 #if __BYTE_ORDER == __BIG_ENDIAN
69 # define h(n) __bswap_constant_32 (n)
72 struct sockaddr_in addrs
[] =
74 { .sin_family
= AF_INET
, .sin_addr
= { h (0x0aa85f19) } },
75 { .sin_family
= AF_INET
, .sin_addr
= { h (0xac105f19) } },
76 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0000219) } },
77 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a86d1d) } },
78 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a85d03) } },
79 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a82c3d) } },
80 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a86002) } },
81 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a802f3) } },
82 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a80810) } },
83 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a85e02) } }
85 #define naddrs (sizeof (addrs) / sizeof (addrs[0]))
86 static struct addrinfo ais
[naddrs
];
87 static struct sort_result results
[naddrs
];
88 static size_t order
[naddrs
];
90 static int expected
[naddrs
] =
92 9, 4, 3, 6, 5, 7, 8, 2, 0, 1
97 __getline (char **lineptr
, size_t *n
, FILE *s
)
108 labels
= default_labels
;
109 precedence
= default_precedence
;
110 scopes
= default_scopes
;
112 struct sockaddr_in so
;
113 so
.sin_family
= AF_INET
;
114 so
.sin_addr
.s_addr
= h (0xc0a85f19);
115 /* Clear the rest of the structure to avoid warnings. */
116 memset (so
.sin_zero
, '\0', sizeof (so
.sin_zero
));
118 for (int i
= 0; i
< naddrs
; ++i
)
120 ais
[i
].ai_family
= AF_INET
;
121 ais
[i
].ai_addr
= (struct sockaddr
*) &addrs
[i
];
122 results
[i
].dest_addr
= &ais
[i
];
123 results
[i
].got_source_addr
= true;
124 memcpy(&results
[i
].source_addr
, &so
, sizeof (so
));
125 results
[i
].source_addr_len
= sizeof (so
);
126 results
[i
].source_addr_flags
= 0;
127 results
[i
].prefixlen
= 8;
128 results
[i
].index
= 0;
133 struct sort_result_combo combo
= { .results
= results
, .nresults
= naddrs
};
134 qsort_r (order
, naddrs
, sizeof (order
[0]), rfc3484_sort
, &combo
);
137 for (int i
= 0; i
< naddrs
; ++i
)
139 struct in_addr addr
= ((struct sockaddr_in
*) (results
[order
[i
]].dest_addr
->ai_addr
))->sin_addr
;
141 int here
= memcmp (&addr
, &addrs
[expected
[i
]].sin_addr
,
142 sizeof (struct in_addr
));
143 printf ("[%d] = %s: %s\n", i
, inet_ntoa (addr
), here
? "FAIL" : "OK");
150 #define TEST_FUNCTION do_test ()
151 #include "../test-skeleton.c"