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
)
32 #include "../sysdeps/posix/getaddrinfo.c"
34 service_user
*__nss_hosts_database attribute_hidden
;
37 /* This is the beginning of the real test code. The above defines
38 (among other things) the function rfc3484_sort. */
41 #if __BYTE_ORDER == __BIG_ENDIAN
44 # define h(n) __bswap_constant_32 (n)
49 __getline (char **lineptr
, size_t *n
, FILE *s
)
60 labels
= default_labels
;
61 precedence
= default_precedence
;
63 struct sockaddr_in so1
;
64 so1
.sin_family
= AF_INET
;
65 so1
.sin_addr
.s_addr
= h (0xc0a85f19);
67 struct sockaddr_in sa1
;
68 sa1
.sin_family
= AF_INET
;
69 sa1
.sin_addr
.s_addr
= h (0xe0a85f19);
72 ai1
.ai_family
= AF_INET
;
73 ai1
.ai_addr
= (struct sockaddr
*) &sa1
;
75 struct sockaddr_in6 so2
;
76 so2
.sin6_family
= AF_INET6
;
77 so2
.sin6_addr
.s6_addr32
[0] = h (0xfec01234);
78 so2
.sin6_addr
.s6_addr32
[1] = 1;
79 so2
.sin6_addr
.s6_addr32
[2] = 1;
80 so2
.sin6_addr
.s6_addr32
[3] = 1;
82 struct sockaddr_in6 sa2
;
83 sa2
.sin6_family
= AF_INET6
;
84 sa2
.sin6_addr
.s6_addr32
[0] = h (0x07d10001);
85 sa2
.sin6_addr
.s6_addr32
[1] = 1;
86 sa2
.sin6_addr
.s6_addr32
[2] = 1;
87 sa2
.sin6_addr
.s6_addr32
[3] = 1;
90 ai2
.ai_family
= AF_INET6
;
91 ai2
.ai_addr
= (struct sockaddr
*) &sa2
;
94 struct sort_result results
[2];
96 results
[0].dest_addr
= &ai1
;
97 results
[0].got_source_addr
= true;
98 results
[0].source_addr_len
= sizeof (so1
);
99 results
[0].source_addr_flags
= 0;
100 memcpy (&results
[0].source_addr
, &so1
, sizeof (so1
));
102 results
[1].dest_addr
= &ai2
;
103 results
[1].got_source_addr
= true;
104 results
[1].source_addr_len
= sizeof (so2
);
105 results
[1].source_addr_flags
= 0;
106 memcpy (&results
[1].source_addr
, &so2
, sizeof (so2
));
109 qsort (results
, 2, sizeof (results
[0]), rfc3484_sort
);
112 if (results
[0].dest_addr
->ai_family
== AF_INET6
)
114 puts ("wrong order in first test");
119 /* And again, this time with the reverse starting order. */
120 results
[1].dest_addr
= &ai1
;
121 results
[1].got_source_addr
= true;
122 results
[1].source_addr_len
= sizeof (so1
);
123 results
[1].source_addr_flags
= 0;
124 memcpy (&results
[1].source_addr
, &so1
, sizeof (so1
));
126 results
[0].dest_addr
= &ai2
;
127 results
[0].got_source_addr
= true;
128 results
[0].source_addr_len
= sizeof (so2
);
129 results
[0].source_addr_flags
= 0;
130 memcpy (&results
[0].source_addr
, &so2
, sizeof (so2
));
133 qsort (results
, 2, sizeof (results
[0]), rfc3484_sort
);
135 if (results
[0].dest_addr
->ai_family
== AF_INET6
)
137 puts ("wrong order in second test");
144 #define TEST_FUNCTION do_test ()
145 #include "../test-skeleton.c"