| lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #include <netdb.h> | 
|  | 2 | #include <stdio.h> | 
|  | 3 | #include <sys/socket.h> | 
|  | 4 |  | 
|  | 5 | static int | 
|  | 6 | do_test (void) | 
|  | 7 | { | 
|  | 8 | int retval = 0; | 
|  | 9 |  | 
|  | 10 | struct sockaddr_in6 s; | 
|  | 11 | s.sin6_family = AF_INET6; | 
|  | 12 | s.sin6_port = htons (80); | 
|  | 13 | s.sin6_flowinfo = 0; | 
|  | 14 | s.sin6_addr = (struct in6_addr) IN6ADDR_ANY_INIT; | 
|  | 15 | s.sin6_scope_id = 0; | 
|  | 16 | char buf[1000]; | 
|  | 17 | buf[0] = '\0'; | 
|  | 18 | int r = getnameinfo((struct sockaddr *) &s, sizeof (s), buf, sizeof (buf), | 
|  | 19 | NULL, 0, NI_NUMERICSERV); | 
|  | 20 | printf("r = %d, buf = \"%s\"\n", r, buf); | 
|  | 21 | if (r != 0) | 
|  | 22 | { | 
|  | 23 | puts ("failed without NI_NAMEREQD"); | 
|  | 24 | retval = 1; | 
|  | 25 | } | 
|  | 26 |  | 
|  | 27 | buf[0] = '\0'; | 
|  | 28 | r = getnameinfo((struct sockaddr *) &s, sizeof (s), buf, sizeof (buf), | 
|  | 29 | NULL, 0, NI_NUMERICSERV | NI_NAMEREQD); | 
|  | 30 | printf("r = %d, buf = \"%s\"\n", r, buf); | 
|  | 31 | if (r != EAI_NONAME) | 
|  | 32 | { | 
|  | 33 | puts ("did not fail with EAI_NONAME with NI_NAMEREQD set"); | 
|  | 34 | retval = 1; | 
|  | 35 | } | 
|  | 36 |  | 
|  | 37 | return retval; | 
|  | 38 | } | 
|  | 39 |  | 
|  | 40 | #define TEST_FUNCTION do_test () | 
|  | 41 | #include "../test-skeleton.c" |