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
)
22 __idna_to_ascii_lz (const char *input
, char **output
, int flags
)
27 __idna_to_unicode_lzlz (const char *input
, char **output
, int flags
)
33 #include "../sysdeps/posix/getaddrinfo.c"
35 service_user
*__nss_hosts_database attribute_hidden
;
38 /* This is the beginning of the real test code. The above defines
39 (among other things) the function rfc3484_sort. */
42 #if __BYTE_ORDER == __BIG_ENDIAN
45 # define h(n) __bswap_constant_32 (n)
50 __getline (char **lineptr
, size_t *n
, FILE *s
)
61 labels
= default_labels
;
62 precedence
= default_precedence
;
64 struct sockaddr_in so1
;
65 so1
.sin_family
= AF_INET
;
66 so1
.sin_addr
.s_addr
= h (0xc0a85f19);
68 struct sockaddr_in sa1
;
69 sa1
.sin_family
= AF_INET
;
70 sa1
.sin_addr
.s_addr
= h (0xe0a85f19);
73 ai1
.ai_family
= AF_INET
;
74 ai1
.ai_addr
= (struct sockaddr
*) &sa1
;
76 struct sockaddr_in6 so2
;
77 so2
.sin6_family
= AF_INET6
;
78 so2
.sin6_addr
.s6_addr32
[0] = h (0xfec01234);
79 so2
.sin6_addr
.s6_addr32
[1] = 1;
80 so2
.sin6_addr
.s6_addr32
[2] = 1;
81 so2
.sin6_addr
.s6_addr32
[3] = 1;
83 struct sockaddr_in6 sa2
;
84 sa2
.sin6_family
= AF_INET6
;
85 sa2
.sin6_addr
.s6_addr32
[0] = h (0x07d10001);
86 sa2
.sin6_addr
.s6_addr32
[1] = 1;
87 sa2
.sin6_addr
.s6_addr32
[2] = 1;
88 sa2
.sin6_addr
.s6_addr32
[3] = 1;
91 ai2
.ai_family
= AF_INET6
;
92 ai2
.ai_addr
= (struct sockaddr
*) &sa2
;
95 struct sort_result results
[2];
97 results
[0].dest_addr
= &ai1
;
98 results
[0].got_source_addr
= true;
99 results
[0].source_addr_len
= sizeof (so1
);
100 results
[0].source_addr_flags
= 0;
101 results
[0].service_order
= 0;
102 memcpy (&results
[0].source_addr
, &so1
, sizeof (so1
));
104 results
[1].dest_addr
= &ai2
;
105 results
[1].got_source_addr
= true;
106 results
[1].source_addr_len
= sizeof (so2
);
107 results
[1].source_addr_flags
= 0;
108 results
[1].service_order
= 1;
109 memcpy (&results
[1].source_addr
, &so2
, sizeof (so2
));
112 qsort (results
, 2, sizeof (results
[0]), rfc3484_sort
);
115 if (results
[0].dest_addr
->ai_family
== AF_INET6
)
117 puts ("wrong order in first test");
122 /* And again, this time with the reverse starting order. */
123 results
[1].dest_addr
= &ai1
;
124 results
[1].got_source_addr
= true;
125 results
[1].source_addr_len
= sizeof (so1
);
126 results
[1].source_addr_flags
= 0;
127 results
[1].service_order
= 1;
128 memcpy (&results
[1].source_addr
, &so1
, sizeof (so1
));
130 results
[0].dest_addr
= &ai2
;
131 results
[0].got_source_addr
= true;
132 results
[0].source_addr_len
= sizeof (so2
);
133 results
[0].source_addr_flags
= 0;
134 results
[0].service_order
= 0;
135 memcpy (&results
[0].source_addr
, &so2
, sizeof (so2
));
138 qsort (results
, 2, sizeof (results
[0]), rfc3484_sort
);
140 if (results
[0].dest_addr
->ai_family
== AF_INET6
)
142 puts ("wrong order in second test");
149 #define TEST_FUNCTION do_test ()
150 #include "../test-skeleton.c"