summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 461ff59)
raw | patch | inline | side by side (parent: 461ff59)
author | octo <octo> | |
Mon, 17 Apr 2006 09:19:22 +0000 (09:19 +0000) | ||
committer | octo <octo> | |
Mon, 17 Apr 2006 09:19:22 +0000 (09:19 +0000) |
Small fix to give the correct socktype arg to `socket'.
src/liboping/liboping.c | patch | blob | history |
index 225dfa760c39894a05edea00eb76347d2fa6a347..57de9b5f18eecd20dd84368b51f08ec27d30e386 100644 (file)
--- a/src/liboping/liboping.c
+++ b/src/liboping/liboping.c
return (-1);
}
+ if (ai_list == NULL)
+ ping_set_error (obj, "getaddrinfo", "No hosts returned");
+
for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next)
{
ph->fd = -1;
si->sin_port = htons (ph->ident);
si->sin_addr.s_addr = htonl (INADDR_ANY);
+ ai_ptr->ai_socktype = SOCK_RAW;
ai_ptr->ai_protocol = IPPROTO_ICMP;
}
else if (ai_ptr->ai_family == AF_INET6)
si->sin6_port = htons (ph->ident);
si->sin6_addr = in6addr_any;
+ ai_ptr->ai_socktype = SOCK_RAW;
ai_ptr->ai_protocol = IPPROTO_ICMPV6;
}
else
{
- dprintf ("Unknown `ai_family': %i\n", ai_ptr->ai_family);
+ char errmsg[PING_ERRMSG_LEN];
+
+ snprintf (errmsg, PING_ERRMSG_LEN, "Unknown `ai_family': %i", ai_ptr->ai_family);
+ errmsg[PING_ERRMSG_LEN - 1] = '\0';
+
+ dprintf (errmsg);
+ ping_set_error (obj, "getaddrinfo", errmsg);
continue;
}
if (ph->fd == -1)
{
dprintf ("socket: %s\n", strerror (errno));
+ ping_set_error (obj, "socket", strerror (errno));
continue;
}
if (bind (ph->fd, (struct sockaddr *) &sockaddr, sockaddr_len) == -1)
{
dprintf ("bind: %s\n", strerror (errno));
+ ping_set_error (obj, "bind", strerror (errno));
close (ph->fd);
ph->fd = -1;
continue;
{
free (ph->hostname);
free (ph);
- ping_set_error (obj, "ping_host_add", "Unable to open socket");
return (-1);
}