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
16 __check_pf (bool *p1
, bool *p2
, struct in6addrinfo
**in6ai
, size_t *in6ailen
)
25 __free_in6ai (struct in6addrinfo
*ai
)
31 __check_native (uint32_t a1_index
, int *a1_native
,
32 uint32_t a2_index
, int *a2_native
)
38 __idna_to_ascii_lz (const char *input
, char **output
, int flags
)
45 __idna_to_unicode_lzlz (const char *input
, char **output
, int flags
)
53 _res_hconf_init (void)
58 #include "../sysdeps/posix/getaddrinfo.c"
60 service_user
*__nss_hosts_database attribute_hidden
;
63 /* This is the beginning of the real test code. The above defines
64 (among other things) the function rfc3484_sort. */
67 #if __BYTE_ORDER == __BIG_ENDIAN
70 # define h(n) __bswap_constant_32 (n)
75 __getline (char **lineptr
, size_t *n
, FILE *s
)
86 labels
= default_labels
;
87 precedence
= default_precedence
;
88 scopes
= default_scopes
;
90 struct sockaddr_in so1
;
91 so1
.sin_family
= AF_INET
;
92 so1
.sin_addr
.s_addr
= h (0xc0a85f19);
93 /* Clear the rest of the structure to avoid warnings. */
94 memset (so1
.sin_zero
, '\0', sizeof (so1
.sin_zero
));
96 struct sockaddr_in sa1
;
97 sa1
.sin_family
= AF_INET
;
98 sa1
.sin_addr
.s_addr
= h (0xe0a85f19);
101 ai1
.ai_family
= AF_INET
;
102 ai1
.ai_addr
= (struct sockaddr
*) &sa1
;
104 struct sockaddr_in6 so2
;
105 so2
.sin6_family
= AF_INET6
;
106 so2
.sin6_addr
.s6_addr32
[0] = h (0xfec01234);
107 so2
.sin6_addr
.s6_addr32
[1] = 1;
108 so2
.sin6_addr
.s6_addr32
[2] = 1;
109 so2
.sin6_addr
.s6_addr32
[3] = 1;
111 struct sockaddr_in6 sa2
;
112 sa2
.sin6_family
= AF_INET6
;
113 sa2
.sin6_addr
.s6_addr32
[0] = h (0x07d10001);
114 sa2
.sin6_addr
.s6_addr32
[1] = 1;
115 sa2
.sin6_addr
.s6_addr32
[2] = 1;
116 sa2
.sin6_addr
.s6_addr32
[3] = 1;
119 ai2
.ai_family
= AF_INET6
;
120 ai2
.ai_addr
= (struct sockaddr
*) &sa2
;
123 struct sort_result results
[2];
126 results
[0].dest_addr
= &ai1
;
127 results
[0].got_source_addr
= true;
128 results
[0].source_addr_len
= sizeof (so1
);
129 results
[0].source_addr_flags
= 0;
130 results
[0].prefixlen
= 16;
131 results
[0].index
= 0;
132 memcpy (&results
[0].source_addr
, &so1
, sizeof (so1
));
135 results
[1].dest_addr
= &ai2
;
136 results
[1].got_source_addr
= true;
137 results
[1].source_addr_len
= sizeof (so2
);
138 results
[1].source_addr_flags
= 0;
139 results
[1].prefixlen
= 16;
140 results
[1].index
= 0;
141 memcpy (&results
[1].source_addr
, &so2
, sizeof (so2
));
145 struct sort_result_combo combo
= { .results
= results
, .nresults
= 2 };
146 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
149 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
151 puts ("wrong order in first test");
156 /* And again, this time with the reverse starting order. */
157 results
[1].dest_addr
= &ai1
;
158 results
[1].got_source_addr
= true;
159 results
[1].source_addr_len
= sizeof (so1
);
160 results
[1].source_addr_flags
= 0;
161 results
[1].prefixlen
= 16;
162 results
[1].index
= 0;
163 memcpy (&results
[1].source_addr
, &so1
, sizeof (so1
));
166 results
[0].dest_addr
= &ai2
;
167 results
[0].got_source_addr
= true;
168 results
[0].source_addr_len
= sizeof (so2
);
169 results
[0].source_addr_flags
= 0;
170 results
[0].prefixlen
= 16;
171 results
[0].index
= 0;
172 memcpy (&results
[0].source_addr
, &so2
, sizeof (so2
));
176 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
178 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
180 puts ("wrong order in second test");
187 #define TEST_FUNCTION do_test ()
188 #include "../test-skeleton.c"