4 /* Internal definitions used in the libc code. */
5 #define __getservbyname_r getservbyname_r
6 #define __socket socket
7 #define __getsockname getsockname
8 #define __inet_aton inet_aton
9 #define __gethostbyaddr_r gethostbyaddr_r
10 #define __gethostbyname2_r gethostbyname2_r
14 __check_pf (bool *p1
, bool *p2
)
19 __idna_to_ascii_lz (const char *input
, char **output
, int flags
)
24 __idna_to_unicode_lzlz (const char *input
, char **output
, int flags
)
29 #include "../sysdeps/posix/getaddrinfo.c"
31 service_user
*__nss_hosts_database attribute_hidden
;
34 /* This is the beginning of the real test code. The above defines
35 (among other things) the function rfc3484_sort. */
38 #if __BYTE_ORDER == __BIG_ENDIAN
41 # define h(n) __bswap_constant_32 (n)
48 struct sockaddr_in so1
;
49 so1
.sin_family
= AF_INET
;
50 so1
.sin_addr
.s_addr
= h (0xc0a85f19);
52 struct sockaddr_in sa1
;
53 sa1
.sin_family
= AF_INET
;
54 sa1
.sin_addr
.s_addr
= h (0xe0a85f19);
57 ai1
.ai_family
= AF_INET
;
58 ai1
.ai_addr
= (struct sockaddr
*) &sa1
;
60 struct sockaddr_in6 so2
;
61 so2
.sin6_family
= AF_INET6
;
62 so2
.sin6_addr
.s6_addr32
[0] = h (0xfec01234);
63 so2
.sin6_addr
.s6_addr32
[1] = 1;
64 so2
.sin6_addr
.s6_addr32
[2] = 1;
65 so2
.sin6_addr
.s6_addr32
[3] = 1;
67 struct sockaddr_in6 sa2
;
68 sa2
.sin6_family
= AF_INET6
;
69 sa2
.sin6_addr
.s6_addr32
[0] = h (0x07d10001);
70 sa2
.sin6_addr
.s6_addr32
[1] = 1;
71 sa2
.sin6_addr
.s6_addr32
[2] = 1;
72 sa2
.sin6_addr
.s6_addr32
[3] = 1;
75 ai2
.ai_family
= AF_INET6
;
76 ai2
.ai_addr
= (struct sockaddr
*) &sa2
;
79 struct sort_result results
[2];
81 results
[0].dest_addr
= &ai1
;
82 results
[0].got_source_addr
= true;
83 results
[0].source_addr_len
= sizeof (so1
);
84 memcpy (&results
[0].source_addr
, &so1
, sizeof (so1
));
86 results
[1].dest_addr
= &ai2
;
87 results
[1].got_source_addr
= true;
88 results
[1].source_addr_len
= sizeof (so2
);
89 memcpy (&results
[1].source_addr
, &so2
, sizeof (so2
));
92 qsort (results
, 2, sizeof (results
[0]), rfc3484_sort
);
95 if (results
[0].dest_addr
->ai_family
== AF_INET6
)
97 puts ("wrong order in first test");
102 /* And again, this time with the reverse starting order. */
103 results
[1].dest_addr
= &ai1
;
104 results
[1].got_source_addr
= true;
105 results
[1].source_addr_len
= sizeof (so1
);
106 memcpy (&results
[1].source_addr
, &so1
, sizeof (so1
));
108 results
[0].dest_addr
= &ai2
;
109 results
[0].got_source_addr
= true;
110 results
[0].source_addr_len
= sizeof (so2
);
111 memcpy (&results
[0].source_addr
, &so2
, sizeof (so2
));
114 qsort (results
, 2, sizeof (results
[0]), rfc3484_sort
);
116 if (results
[0].dest_addr
->ai_family
== AF_INET6
)
118 puts ("wrong order in second test");
125 #define TEST_FUNCTION do_test ()
126 #include "../test-skeleton.c"