udhcp: s/sipservers/sipsrv/ to match other similar option names
[oweals/busybox.git] / networking / udhcp / arpping.c
index 3df0f39b704903f05420b9dff138aa2459ec5f30..7c8c24446c50a7ae47048fc1a1a82256cb8240f6 100644 (file)
@@ -1,7 +1,5 @@
 /* vi: set sw=4 ts=4: */
 /*
- * arpping.c
- *
  * Mostly stolen from: dhcpcd - DHCP client daemon
  * by Yoichi Hariguchi <yoichi@fore.com>
  *
@@ -87,15 +85,16 @@ int FAST_FUNC arpping(uint32_t test_nip,
        /* wait for arp reply, and check it */
        timeout_ms = 2000;
        do {
+               typedef uint32_t aliased_uint32_t FIX_ALIASING;
                int r;
-               unsigned prevTime = monotonic_us();
+               unsigned prevTime = monotonic_ms();
 
                pfd[0].events = POLLIN;
                r = safe_poll(pfd, 1, timeout_ms);
                if (r < 0)
                        break;
                if (r) {
-                       r = read(s, &arp, sizeof(arp));
+                       r = safe_read(s, &arp, sizeof(arp));
                        if (r < 0)
                                break;
 
@@ -107,7 +106,7 @@ int FAST_FUNC arpping(uint32_t test_nip,
                         && arp.operation == htons(ARPOP_REPLY)
                         /* don't check it: Linux doesn't return proper tHaddr (fixed in 2.6.24?) */
                         /* && memcmp(arp.tHaddr, from_mac, 6) == 0 */
-                        && *((uint32_t *) arp.sInaddr) == test_nip
+                        && *(aliased_uint32_t*)arp.sInaddr == test_nip
                        ) {
                                /* if ARP source MAC matches safe_mac
                                 * (which is client's MAC), then it's not a conflict
@@ -119,7 +118,7 @@ int FAST_FUNC arpping(uint32_t test_nip,
                                break;
                        }
                }
-               timeout_ms -= ((unsigned)monotonic_us() - prevTime) / 1000;
+               timeout_ms -= (unsigned)monotonic_ms() - prevTime;
        } while (timeout_ms > 0);
 
  ret: