| 26 | #include "../src/misc.h" |
| 27 | |
| 28 | static int rig_network_addr(char *hoststr, char *portstr) |
| 29 | { |
| 30 | |
| 31 | struct in6_addr serveraddr; |
| 32 | struct addrinfo hints, *res; |
| 33 | int status; |
| 34 | |
| 35 | memset(&hints, 0, sizeof(hints)); |
| 36 | hints.ai_family = PF_UNSPEC; |
| 37 | hints.ai_socktype = SOCK_STREAM; |
| 38 | hints.ai_flags = AI_CANONNAME; |
| 39 | |
| 40 | |
| 41 | status = getaddrinfo(hoststr, portstr, &hints, &res); |
| 42 | |
| 43 | if (status == 0 && res->ai_family == AF_INET6) |
| 44 | { |
| 45 | printf("Using IPV6 for %s:%s\n", hoststr, portstr); |
| 46 | } |
| 47 | else if (status == 0) |
| 48 | { |
| 49 | printf("Using IPV4 for %s:%s\n", hoststr, portstr); |
| 50 | } |
| 51 | |
| 52 | if (status != 0) |
| 53 | { |
| 54 | printf("%s: cannot get host \"%s\": %s\n", |
| 55 | __func__, |
| 56 | hoststr, |
| 57 | gai_strerror(errno)); |
| 58 | return 1; |
| 59 | } |
| 60 | |
| 61 | status = inet_pton(AF_INET, hoststr, &serveraddr); |
| 62 | |
| 63 | if (status != 1) /* not valid IPv4 address, maybe IPV6? */ |
| 64 | { |
| 65 | status = inet_pton(AF_INET6, hoststr, &serveraddr); |
| 66 | |
| 67 | if (status != 1) /* nope */ |
| 68 | { |
| 69 | return 1; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | static int test_host(char *hoststr, char *host, char *port) |
| 77 | { |
no test coverage detected