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);
86 struct sockaddr_in sa1
;
87 sa1
.sin_family
= AF_INET
;
88 sa1
.sin_addr
.s_addr
= h (0xe0a85f19);
91 ai1
.ai_family
= AF_INET
;
92 ai1
.ai_addr
= (struct sockaddr
*) &sa1
;
94 struct sockaddr_in6 so2
;
95 so2
.sin6_family
= AF_INET6
;
96 so2
.sin6_addr
.s6_addr32
[0] = h (0xfec01234);
97 so2
.sin6_addr
.s6_addr32
[1] = 1;
98 so2
.sin6_addr
.s6_addr32
[2] = 1;
99 so2
.sin6_addr
.s6_addr32
[3] = 1;
101 struct sockaddr_in6 sa2
;
102 sa2
.sin6_family
= AF_INET6
;
103 sa2
.sin6_addr
.s6_addr32
[0] = h (0x07d10001);
104 sa2
.sin6_addr
.s6_addr32
[1] = 1;
105 sa2
.sin6_addr
.s6_addr32
[2] = 1;
106 sa2
.sin6_addr
.s6_addr32
[3] = 1;
109 ai2
.ai_family
= AF_INET6
;
110 ai2
.ai_addr
= (struct sockaddr
*) &sa2
;
113 struct sort_result results
[2];
116 results
[0].dest_addr
= &ai1
;
117 results
[0].got_source_addr
= true;
118 results
[0].source_addr_len
= sizeof (so1
);
119 results
[0].source_addr_flags
= 0;
120 results
[0].prefixlen
= 16;
121 results
[0].index
= 0;
122 memcpy (&results
[0].source_addr
, &so1
, sizeof (so1
));
125 results
[1].dest_addr
= &ai2
;
126 results
[1].got_source_addr
= true;
127 results
[1].source_addr_len
= sizeof (so2
);
128 results
[1].source_addr_flags
= 0;
129 results
[1].prefixlen
= 16;
130 results
[1].index
= 0;
131 memcpy (&results
[1].source_addr
, &so2
, sizeof (so2
));
135 struct sort_result_combo combo
= { .results
= results
, .nresults
= 2 };
136 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
139 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
141 puts ("wrong order in first test");
146 /* And again, this time with the reverse starting order. */
147 results
[1].dest_addr
= &ai1
;
148 results
[1].got_source_addr
= true;
149 results
[1].source_addr_len
= sizeof (so1
);
150 results
[1].source_addr_flags
= 0;
151 results
[1].prefixlen
= 16;
152 results
[1].index
= 0;
153 memcpy (&results
[1].source_addr
, &so1
, sizeof (so1
));
156 results
[0].dest_addr
= &ai2
;
157 results
[0].got_source_addr
= true;
158 results
[0].source_addr_len
= sizeof (so2
);
159 results
[0].source_addr_flags
= 0;
160 results
[0].prefixlen
= 16;
161 results
[0].index
= 0;
162 memcpy (&results
[0].source_addr
, &so2
, sizeof (so2
));
166 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
168 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
170 puts ("wrong order in second test");
177 #define TEST_FUNCTION do_test ()
178 #include "../test-skeleton.c"