summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f5ff174)
raw | patch | inline | side by side (parent: f5ff174)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 23 Mar 2009 08:34:37 +0000 (09:34 +0100) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 23 Mar 2009 08:34:37 +0000 (09:34 +0100) |
src/liboping.c | patch | blob | history |
diff --git a/src/liboping.c b/src/liboping.c
index 101c9606d58138b0420afc7f563ebb86be8d4dbe..579aba31daf41087195d9d523115ea1e662be3b9 100644 (file)
--- a/src/liboping.c
+++ b/src/liboping.c
{
struct timeval diff;
pinghost_t *host = NULL;
- int family;
int recv_ttl;
/*
dprintf ("Read %zi bytes from fd = %i\n", payload_buffer_len, fd);
/* Iterate over all auxiliary data in msghdr */
- family = ph->addrfamily;
recv_ttl = -1;
+ ph->recv_ttl = -1;
for (cmsg = CMSG_FIRSTHDR (&msghdr); /* {{{ */
cmsg != NULL;
cmsg = CMSG_NXTHDR (&msghdr, cmsg))
{
- if (cmsg->cmsg_level == IPPROTO_IP) /* {{{ */
+ if (ph->addrfamily == AF_INET) /* {{{ */
{
- family = AF_INET;
+ if (cmsg->cmsg_level != IPPROTO_IP)
+ continue;
+
if (cmsg->cmsg_type == IP_TTL)
{
memcpy (&recv_ttl, CMSG_DATA (cmsg),
cmsg->cmsg_type);
}
} /* }}} */
- else if (cmsg->cmsg_level == IPPROTO_IPV6) /* {{{ */
+ else if (ph->addrfamily == AF_INET6) /* {{{ */
{
- family = AF_INET6;
+ if (cmsg->cmsg_level != IPPROTO_IPV6)
+ continue;
+
if (cmsg->cmsg_type == IPV6_HOPLIMIT)
{
memcpy (&recv_ttl, CMSG_DATA (cmsg),
}
} /* }}} for (cmsg) */
- if (family == AF_INET)
+ if (ph->addrfamily == AF_INET)
{
host = ping_receive_ipv4 (ph, payload_buffer, payload_buffer_len);
if (host == NULL)
return (-1);
}
- else if (family == AF_INET6)
+ else if (ph->addrfamily == AF_INET6)
{
host = ping_receive_ipv6 (ph, payload_buffer, payload_buffer_len);
if (host == NULL)
else
{
dprintf ("ping_receive_one: Unknown address family %i.\n",
- family);
+ ph->addrfamily);
return (-1);
}