/* vi: set sw=4 ts=4: */
/*
- * arpping.c
- *
* Mostly stolen from: dhcpcd - DHCP client daemon
* by Yoichi Hariguchi <yoichi@fore.com>
*
/* 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;
&& 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
break;
}
}
- timeout_ms -= ((unsigned)monotonic_us() - prevTime) / 1000;
+ timeout_ms -= (unsigned)monotonic_ms() - prevTime;
} while (timeout_ms > 0);
ret: