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
)
23 __check_native (uint32_t a1_index
, int *a1_native
,
24 uint32_t a2_index
, int *a2_native
)
28 __idna_to_ascii_lz (const char *input
, char **output
, int flags
)
33 __idna_to_unicode_lzlz (const char *input
, char **output
, int flags
)
39 #include "../sysdeps/posix/getaddrinfo.c"
41 service_user
*__nss_hosts_database attribute_hidden
;
44 /* This is the beginning of the real test code. The above defines
45 (among other things) the function rfc3484_sort. */
48 #if __BYTE_ORDER == __BIG_ENDIAN
51 # define h(n) __bswap_constant_32 (n)
56 __getline (char **lineptr
, size_t *n
, FILE *s
)
67 labels
= default_labels
;
68 precedence
= default_precedence
;
69 scopes
= default_scopes
;
71 struct sockaddr_in so1
;
72 so1
.sin_family
= AF_INET
;
73 so1
.sin_addr
.s_addr
= h (0xc0a85f19);
75 struct sockaddr_in sa1
;
76 sa1
.sin_family
= AF_INET
;
77 sa1
.sin_addr
.s_addr
= h (0xe0a85f19);
80 ai1
.ai_family
= AF_INET
;
81 ai1
.ai_addr
= (struct sockaddr
*) &sa1
;
83 struct sockaddr_in6 so2
;
84 so2
.sin6_family
= AF_INET6
;
85 so2
.sin6_addr
.s6_addr32
[0] = h (0xfec01234);
86 so2
.sin6_addr
.s6_addr32
[1] = 1;
87 so2
.sin6_addr
.s6_addr32
[2] = 1;
88 so2
.sin6_addr
.s6_addr32
[3] = 1;
90 struct sockaddr_in6 sa2
;
91 sa2
.sin6_family
= AF_INET6
;
92 sa2
.sin6_addr
.s6_addr32
[0] = h (0x07d10001);
93 sa2
.sin6_addr
.s6_addr32
[1] = 1;
94 sa2
.sin6_addr
.s6_addr32
[2] = 1;
95 sa2
.sin6_addr
.s6_addr32
[3] = 1;
98 ai2
.ai_family
= AF_INET6
;
99 ai2
.ai_addr
= (struct sockaddr
*) &sa2
;
102 struct sort_result results
[2];
105 results
[0].dest_addr
= &ai1
;
106 results
[0].got_source_addr
= true;
107 results
[0].source_addr_len
= sizeof (so1
);
108 results
[0].source_addr_flags
= 0;
109 results
[0].prefixlen
= 16;
110 results
[0].index
= 0;
111 memcpy (&results
[0].source_addr
, &so1
, sizeof (so1
));
114 results
[1].dest_addr
= &ai2
;
115 results
[1].got_source_addr
= true;
116 results
[1].source_addr_len
= sizeof (so2
);
117 results
[1].source_addr_flags
= 0;
118 results
[1].prefixlen
= 16;
119 results
[1].index
= 0;
120 memcpy (&results
[1].source_addr
, &so2
, sizeof (so2
));
124 struct sort_result_combo combo
= { .results
= results
, .nresults
= 2 };
125 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
128 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
130 puts ("wrong order in first test");
135 /* And again, this time with the reverse starting order. */
136 results
[1].dest_addr
= &ai1
;
137 results
[1].got_source_addr
= true;
138 results
[1].source_addr_len
= sizeof (so1
);
139 results
[1].source_addr_flags
= 0;
140 results
[1].prefixlen
= 16;
141 results
[1].index
= 0;
142 memcpy (&results
[1].source_addr
, &so1
, sizeof (so1
));
145 results
[0].dest_addr
= &ai2
;
146 results
[0].got_source_addr
= true;
147 results
[0].source_addr_len
= sizeof (so2
);
148 results
[0].source_addr_flags
= 0;
149 results
[0].prefixlen
= 16;
150 results
[0].index
= 0;
151 memcpy (&results
[0].source_addr
, &so2
, sizeof (so2
));
155 qsort_r (order
, 2, sizeof (order
[0]), rfc3484_sort
, &combo
);
157 if (results
[order
[0]].dest_addr
->ai_family
== AF_INET6
)
159 puts ("wrong order in second test");
166 #define TEST_FUNCTION do_test ()
167 #include "../test-skeleton.c"