summaryrefslogtreecommitdiffstats
path: root/plugins/check_curl.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/check_curl.c')
-rw-r--r--plugins/check_curl.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/plugins/check_curl.c b/plugins/check_curl.c
index c37d45d9..e1bc98dc 100644
--- a/plugins/check_curl.c
+++ b/plugins/check_curl.c
@@ -386,6 +386,7 @@ lookup_host (const char *host, char *buf, size_t buflen)
386 struct addrinfo hints, *res, *result; 386 struct addrinfo hints, *res, *result;
387 int errcode; 387 int errcode;
388 void *ptr; 388 void *ptr;
389 int s;
389 390
390 memset (&hints, 0, sizeof (hints)); 391 memset (&hints, 0, sizeof (hints));
391 hints.ai_family = address_family; 392 hints.ai_family = address_family;
@@ -399,19 +400,26 @@ lookup_host (const char *host, char *buf, size_t buflen)
399 res = result; 400 res = result;
400 401
401 while (res) { 402 while (res) {
402 inet_ntop (res->ai_family, res->ai_addr->sa_data, buf, buflen); 403 inet_ntop (res->ai_family, res->ai_addr->sa_data, buf, buflen);
403 switch (res->ai_family) { 404 switch (res->ai_family) {
404 case AF_INET: 405 case AF_INET:
405 ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr; 406 ptr = &((struct sockaddr_in *) res->ai_addr)->sin_addr;
407 break;
408 case AF_INET6:
409 ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
406 break; 410 break;
407 case AF_INET6:
408 ptr = &((struct sockaddr_in6 *) res->ai_addr)->sin6_addr;
409 break;
410 } 411 }
412
411 inet_ntop (res->ai_family, ptr, buf, buflen); 413 inet_ntop (res->ai_family, ptr, buf, buflen);
412 if (verbose >= 1) 414 if (verbose >= 1)
413 printf ("* getaddrinfo IPv%d address: %s\n", 415 printf ("* getaddrinfo IPv%d address: %s\n",
414 res->ai_family == PF_INET6 ? 6 : 4, buf); 416 res->ai_family == PF_INET6 ? 6 : 4, buf);
417
418 if (s = socket (res->ai_family, res->ai_socktype, res->ai_protocol) == -1)
419 continue;
420 if (bind (s, res->ai_addr, res->ai_addrlen == 0) )
421 break;
422
415 res = res->ai_next; 423 res = res->ai_next;
416 } 424 }
417 425