18
18
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19
19
* KIND, either express or implied.
21
* $Id: resolve.c,v 1.8 2008-02-28 00:55:06 yangtse Exp $
21
* $Id: resolve.c,v 1.13 2008-10-28 20:03:22 danf Exp $
22
22
***************************************************************************/
61
64
/* include memdebug.h last */
62
65
#include "memdebug.h"
67
static bool use_ipv6 = FALSE;
68
static const char *ipv_inuse = "IPv4";
66
70
const char *serverlogfile=""; /* for a util.c function we don't use */
68
72
int main(int argc, char *argv[])
75
const char *host = NULL;
75
79
if(!strcmp("--version", argv[arg])) {
85
89
else if(!strcmp("--ipv6", argv[arg])) {
91
94
else if(!strcmp("--ipv4", argv[arg])) {
92
95
/* for completeness, we support this option as well */
126
/* getaddrinfo() resolve */
128
struct addrinfo hints;
130
memset(&hints, 0, sizeof(hints));
131
hints.ai_family = PF_INET6;
132
hints.ai_socktype = SOCK_STREAM;
133
hints.ai_flags = AI_CANONNAME;
134
rc = (getaddrinfo)(host, "80", &hints, &ai);
130
/* Check that the system has IPv6 enabled before checking the resolver */
131
int s = socket(PF_INET6, SOCK_DGRAM, 0);
133
/* an ipv6 address was requested and we can't get/use one */
140
/* getaddrinfo() resolve */
142
struct addrinfo hints;
144
memset(&hints, 0, sizeof(hints));
145
hints.ai_family = PF_INET6;
146
hints.ai_socktype = SOCK_STREAM;
147
hints.ai_flags = AI_CANONNAME;
148
/* Use parenthesis around function to stop it from being replaced by
149
the macro in memdebug.h */
150
rc = (getaddrinfo)(host, "80", &hints, &ai);
154
puts("IPv6 support has been disabled in this program");
139
printf("Resolving '%s' didn't work\n", host);
159
printf("Resolving %s '%s' didn't work\n", ipv_inuse, host);