5 /* Internal definitions used in the libc code. */
6 #define __getservbyname_r getservbyname_r
7 #define __socket socket
8 #define __getsockname getsockname
9 #define __inet_aton inet_aton
10 #define __gethostbyaddr_r gethostbyaddr_r
11 #define __gethostbyname2_r gethostbyname2_r
15 __check_pf (bool *p1
, bool *p2
, struct in6addrinfo
**in6ai
, size_t *in6ailen
)
24 __check_native (uint32_t a1_index
, int *a1_native
,
25 uint32_t a2_index
, int *a2_native
)
31 __idna_to_ascii_lz (const char *input
, char **output
, int flags
)
38 __idna_to_unicode_lzlz (const char *input
, char **output
, int flags
)
46 _res_hconf_init (void)
50 #include "../sysdeps/posix/getaddrinfo.c"
52 service_user
*__nss_hosts_database attribute_hidden
;
55 /* This is the beginning of the real test code. The above defines
56 (among other things) the function rfc3484_sort. */
59 #if __BYTE_ORDER == __BIG_ENDIAN
62 # define h(n) __bswap_constant_32 (n)
67 __getline (char **lineptr
, size_t *n
, FILE *s
)
78 labels
= default_labels
;
79 precedence
= default_precedence
;
80 scopes
= default_scopes
;
82 struct sockaddr_in so1
;
83 so1
.sin_family
= AF_INET
;
84 so1
.sin_addr
.s_addr
= h (0xc0a85f19);
85 /* Clear the rest of the structure to avoid warnings. */
86 memset (so1
.sin_zero
, '\0', sizeof (so1
.sin_zero
));
88 struct sockaddr_in sa1
;
89 sa1
.sin_family
= AF_INET
;
90 sa1
.sin_addr
.s_addr
= h (0xe0a85f19);
93 ai1
.ai_family
= AF_INET
;
94 ai1
.ai_addr
= (struct sockaddr
*) &sa1
;
96 struct sockaddr_in6 so2
;
97 so2
.sin6_family
= AF_INET6
;
98 so2
.sin6_addr
.s6_addr32
[0] = h (0xfec01234);
99 so2
.sin6_addr
.s6_addr32
[1] = 1;
100 so2
.sin6_addr
.s6_addr32
[2] = 1;
101 so2
.sin6_addr
.s6_addr32
[3] = 1;
103 struct sockaddr_in6 sa2
;
104 sa2
.sin6_family
= AF_INET6
;
105 sa2
.sin6_addr
.s6_addr32
[0] = h (0x07d10001);
106 sa2
.sin6_addr
.s6_addr32
[1] = 1;
107 sa2
.sin6_addr
.s6_addr32
[2] = 1;
108 sa2
.sin6_addr
.s6_addr32
[3] = 1;
111 ai2
.ai_family
= AF_INET6
;
112 ai2
.ai_addr
= (struct sockaddr
*) &sa2
;
115 struct sort_result results
[2];
118 results
[0].dest_addr
= &ai1
;
119 results
[0].got_source_addr
= true;
120 results
[0].source_addr_len
= sizeof (so1
);
121 results
[0].source_addr_flags
= 0;
122 results
[0].prefixlen
= 16;
123 results
[0].index
= 0;
124 memcpy (&results
[0].source_addr
, &so1
, sizeof (so1
));
127 results
[1].dest_addr
= &ai2
;
128 results
[1].got_source_addr
= true;
129 results
[1].source_addr_len
= sizeof (so2
);
130 results
[1].source_addr_flags
= 0;
131 results
[1].prefixlen
= 16;
132 results
[1].index
= 0;
133 memcpy (&results
[1].source_addr
, &so2
, sizeof (so2
));
137 struct sort_result_combo combo
= { .results
= results
, .nresults
= 2 };
138 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
141 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
143 puts ("wrong order in first test");
148 /* And again, this time with the reverse starting order. */
149 results
[1].dest_addr
= &ai1
;
150 results
[1].got_source_addr
= true;
151 results
[1].source_addr_len
= sizeof (so1
);
152 results
[1].source_addr_flags
= 0;
153 results
[1].prefixlen
= 16;
154 results
[1].index
= 0;
155 memcpy (&results
[1].source_addr
, &so1
, sizeof (so1
));
158 results
[0].dest_addr
= &ai2
;
159 results
[0].got_source_addr
= true;
160 results
[0].source_addr_len
= sizeof (so2
);
161 results
[0].source_addr_flags
= 0;
162 results
[0].prefixlen
= 16;
163 results
[0].index
= 0;
164 memcpy (&results
[0].source_addr
, &so2
, sizeof (so2
));
168 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
170 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
172 puts ("wrong order in second test");
179 #define TEST_FUNCTION do_test ()
180 #include "../test-skeleton.c"