On Mittwoch, 24. Oktober 2018 13:21:28 CEST Jonathan Haws wrote: [...]
while (retries-- && !(arpreq.arp_flags & ATF_COM)) {
ipv4_request_mac_resolve(addr);
usleep(200000);
if (ioctl(interface->netsock, SIOCGARP, &arpreq) < 0)
return -1;
}
if (arpreq.arp_flags & ATF_COM) { memcpy(mac, arpreq.arp_ha.sa_data, sizeof(*mac)); } else {
According to gary [1], this doesn't work because the ioctl fails for him and then the function returns immediately (before the while loop).
Please adjust your patch - but please don't use his code - it looks rather ugly and also doesn't work for multiple retries. You most likely want to drop the if-ioctl completely and then put everything in your while loop:
while (ioctl(interface->netsock, SIOCGARP, &arpreq) < 0 || !(arpreq.arp_flags & ATF_COM)) { if (retries-- <= 0) break;
ipv4_request_mac_resolve(addr); usleep(200000); }
But feel to propose a different (cleaner) approach.
Kind regards, Sven
[1] https://lists.open-mesh.org/pipermail/b.a.t.m.a.n/2018-October/018195.html