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)
47 struct sockaddr_in addrs
[] =
49 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a86d1d) } },
50 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a85d03) } },
51 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a82c3d) } },
52 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a86002) } },
53 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a802f3) } },
54 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a80810) } },
55 { .sin_family
= AF_INET
, .sin_addr
= { h (0xc0a85e02) } }
57 #define naddrs (sizeof (addrs) / sizeof (addrs[0]))
58 static struct addrinfo ais
[naddrs
];
59 static struct sort_result results
[naddrs
];
61 static int expected
[naddrs
] =
70 struct sockaddr_in so
;
71 so
.sin_family
= AF_INET
;
72 so
.sin_addr
.s_addr
= h (0xc0a85f19);
74 for (int i
= 0; i
< naddrs
; ++i
)
76 ais
[i
].ai_family
= AF_INET
;
77 ais
[i
].ai_addr
= (struct sockaddr
*) &addrs
[i
];
78 results
[i
].dest_addr
= &ais
[i
];
79 results
[i
].got_source_addr
= true;
80 memcpy(&results
[i
].source_addr
, &so
, sizeof (so
));
81 results
[i
].source_addr_len
= sizeof (so
);
82 results
[i
].source_addr_flags
= 0;
85 qsort (results
, naddrs
, sizeof (results
[0]), rfc3484_sort
);
88 for (int i
= 0; i
< naddrs
; ++i
)
90 struct in_addr addr
= ((struct sockaddr_in
*) (results
[i
].dest_addr
->ai_addr
))->sin_addr
;
92 int here
= memcmp (&addr
, &addrs
[expected
[i
]].sin_addr
,
93 sizeof (struct in_addr
));
94 printf ("[%d] = %s: %s\n", i
, inet_ntoa (addr
), here
? "FAIL" : "OK");
101 #define TEST_FUNCTION do_test ()
102 #include "../test-skeleton.c"