quick and dirty implementation of IPv6 support for issue #2
This commit is contained in:
parent
fb4c7e2e36
commit
dbab7f4f27
@ -3,6 +3,8 @@
|
||||
#include <errno.h>
|
||||
#include <pthread.h>
|
||||
#include <getopt.h>
|
||||
#include <netdb.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <confuse.h>
|
||||
|
||||
#include "yasnd.h"
|
||||
@ -171,11 +173,34 @@ void check_host(int num,host_decl* host)
|
||||
// Set default signal handlers
|
||||
signal(SIGTERM, SIG_DFL);
|
||||
signal(SIGHUP, SIG_DFL);
|
||||
// Define temporary variable
|
||||
char tmp[100];
|
||||
// Get host address info from hostname
|
||||
struct addrinfo hints, *res;
|
||||
memset(&hints, 0, sizeof(hints));
|
||||
//
|
||||
char tmp[50];
|
||||
// STUB: need to check IPv6 support for current host here!
|
||||
//
|
||||
// prefer any address family(both IPv4 and IPv6)
|
||||
hints.ai_family = AF_UNSPEC;
|
||||
if ((getaddrinfo(host->hostname, NULL, &hints, &res)) != 0)
|
||||
{
|
||||
sprintf(tmp, "Error: Failed to resolve hostname '%s'", host->hostname);
|
||||
log_event(tmp);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
sprintf(tmp, "Pinging host %s", host->hostname);
|
||||
log_debug(tmp,DEBUG_BASE);
|
||||
execl("/bin/ping","/bin/ping","-c 1","-n",host->hostname,(char*) 0);
|
||||
// host is IPv6 capable?
|
||||
if (res->ai_family == AF_INET6)
|
||||
{
|
||||
execl("/bin/ping6","/bin/ping6","-c 1","-n",host->hostname,(char*) 0);
|
||||
}
|
||||
else
|
||||
// host is IPv4 capable?
|
||||
{
|
||||
execl("/bin/ping","/bin/ping","-c 1","-n",host->hostname,(char*) 0);
|
||||
}
|
||||
// STUB: check result of exec call
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user