From: Roy Marples Date: Fri, 30 May 2008 09:52:09 +0000 (+0000) Subject: Parse the ARP packet better. X-Git-Tag: v4.0.2~302 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=855c5820e78e34cb6d29cb3422c7fd10eacc3cfc;p=thirdparty%2Fdhcpcd.git Parse the ARP packet better. --- diff --git a/net.c b/net.c index 1deed0a1..5f74ac6c 100644 --- a/net.c +++ b/net.c @@ -647,7 +647,7 @@ arp_claim(struct interface *iface, struct in_addr address) { -1, POLLIN, 0 } }; int bytes; - int s = 0; + int s; struct timeval stopat; struct timeval now; @@ -656,7 +656,7 @@ arp_claim(struct interface *iface, struct in_addr address) return 0; } - if (!IN_LINKLOCAL(ntohl(iface->addr.s_addr)) && + if (!IN_LINKLOCAL(ntohl(iface->addr.s_addr)) || !IN_LINKLOCAL(ntohl(address.s_addr))) logger(LOG_INFO, "checking %s is available on attached networks", @@ -677,8 +677,6 @@ arp_claim(struct interface *iface, struct in_addr address) memset(&null_addr, 0, sizeof(null_addr)); for (;;) { - s = 0; - /* Only poll if we have a timeout */ if (timeout > 0) { /* Obey IPV4LL timings, but make us faster for @@ -692,7 +690,8 @@ arp_claim(struct interface *iface, struct in_addr address) strerror(errno)); break; } - } + } else + s = 0; /* Timed out */ if (s == 0) { @@ -774,7 +773,7 @@ arp_claim(struct interface *iface, struct in_addr address) /* Get pointers to the hardware addreses */ hw_s = arp_reply + sizeof(reply); - hw_t = hw_s + reply.ar_pln; + hw_t = hw_s + reply.ar_hln + reply.ar_pln; /* Ensure we got all the data */ if ((hw_t + reply.ar_hln + reply.ar_pln) - arp_reply > bytes) continue;