summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: cca4bb7)
raw | patch | inline | side by side (parent: cca4bb7)
author | octo <octo> | |
Tue, 2 May 2006 08:19:19 +0000 (08:19 +0000) | ||
committer | octo <octo> | |
Tue, 2 May 2006 08:19:19 +0000 (08:19 +0000) |
Fix for comiling with older glibc: It didn't know `EAI_OVERFLOW'.
`ping_send_all' now returns non-zero if something goes wrong..
`ping_send_all' now returns non-zero if something goes wrong..
src/liboping.c | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index 610c22de50d9e7c2dc1953d3c23563706a103bae..db3b9592e78ec164352efac8f31d21da700e8886 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
* +-> ping_send_one_ipv4 *
* `-> ping_send_one_ipv6 *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-static ssize_t ping_sendto (pinghost_t *ph, const void *buf, size_t buflen)
+static ssize_t ping_sendto (pingobj_t *obj, pinghost_t *ph,
+ const void *buf, size_t buflen)
{
ssize_t ret;
ret = sendto (ph->fd, buf, buflen, 0,
(struct sockaddr *) ph->addr, ph->addrlen);
+ if (ret < 0)
+ ping_set_error (obj, "sendto", strerror (errno));
+
return (ret);
}
-static int ping_send_one_ipv4 (pinghost_t *ph)
+static int ping_send_one_ipv4 (pingobj_t *obj, pinghost_t *ph)
{
struct icmp *icmp4;
int status;
dprintf ("Sending ICMPv4 package with ID 0x%04x\n", ph->ident);
- status = ping_sendto (ph, buf, buflen);
+ status = ping_sendto (obj, ph, buf, buflen);
if (status < 0)
{
perror ("ping_sendto");
return (0);
}
-static int ping_send_one_ipv6 (pinghost_t *ph)
+static int ping_send_one_ipv6 (pingobj_t *obj, pinghost_t *ph)
{
struct icmp6_hdr *icmp6;
int status;
dprintf ("Sending ICMPv6 package with ID 0x%04x\n", ph->ident);
- status = ping_sendto (ph, buf, buflen);
+ status = ping_sendto (obj, ph, buf, buflen);
if (status < 0)
{
perror ("ping_sendto");
return (0);
}
-static int ping_send_all (pinghost_t *ph)
+static int ping_send_all (pingobj_t *obj)
{
+ pinghost_t *ph;
pinghost_t *ptr;
+ int ret;
+
+ ret = 0;
+ ph = obj->head;
+
for (ptr = ph; ptr != NULL; ptr = ptr->next)
{
/* start timer.. The GNU `ping6' starts the timer before
{
dprintf ("gettimeofday: %s\n", strerror (errno));
timerclear (ptr->timer);
+ ret--;
continue;
}
else
if (ptr->addrfamily == AF_INET6)
{
dprintf ("Sending ICMPv6 echo request to `%s'\n", ptr->hostname);
- if (ping_send_one_ipv6 (ptr) != 0)
+ if (ping_send_one_ipv6 (obj, ptr) != 0)
{
timerclear (ptr->timer);
+ ret--;
continue;
}
}
else if (ptr->addrfamily == AF_INET)
{
dprintf ("Sending ICMPv4 echo request to `%s'\n", ptr->hostname);
- if (ping_send_one_ipv4 (ptr) != 0)
+ if (ping_send_one_ipv4 (obj, ptr) != 0)
{
timerclear (ptr->timer);
+ ret--;
continue;
}
}
{
dprintf ("Unknown address family: %i\n", ptr->addrfamily);
timerclear (ptr->timer);
+ ret--;
continue;
}
ptr->sequence++;
}
- /* FIXME */
- return (0);
+ return (ret);
}
/*
{
int ret;
- if (ping_send_all (obj->head) < 0)
+ if (ping_send_all (obj) < 0)
return (-1);
if ((ret = ping_receive_all (obj)) < 0)
NI_NUMERICHOST);
if (ret != 0)
{
- if ((ret == EAI_OVERFLOW)
- || (ret == EAI_MEMORY))
+ if ((ret == EAI_MEMORY)
+#ifdef EAI_OVERFLOW
+ || (ret == EAI_OVERFLOW)
+#endif
+ )
ret = ENOMEM;
else if (ret == EAI_SYSTEM)
/* XXX: Not thread-safe! */