Ah, yes - I see the issue now. I'll update that when I get back. And I apologize for the top posting! My phone's email client doesn't do inline too well...
Sent from my Verizon, Samsung Galaxy smartphone
-------- Original message -------- From: Sven Eckelmann sven@narfation.org Date: 10/25/18 3:42 AM (GMT-07:00) To: b.a.t.m.a.n@lists.open-mesh.org Cc: Jonathan Haws jhaws@sdl.usu.edu, guohuizou2000@sina.com Subject: Re: [B.A.T.M.A.N.] [PATCH v2] alfred: Request MAC resolution for IPv4 address not in ARP cache
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