libdnet
libdnet copied to clipboard
arp_loop() returns invalid entries
In ./src/arp-win32.c
, arp_loop()
will add invalid ARP-entries
(because of incomplete ARP requests etc.). Was this intentional?
It seems strange to do that (comparing to the arp -a
command on Win8.1).
The ARP-table now:
dnet.exe arp show
10.0.0.1 at 1c:bd:b9:c0:63:c6 <<
10.0.0.20 at 68:63:59:4e:98:f0
10.0.0.255 at ff:ff:ff:ff:ff:ff
224.0.0.22 at 01:00:5e:00:00:16
224.0.0.252 at 01:00:5e:00:00:fc
239.255.255.250 at 01:00:5e:7f:ff:fa
10.0.0.1 at 00:00:00:00:00:00 << duplicated illegal entry
224.0.0.22 at 01:00:5e:00:00:16
But after my little patch below, it seems better:
10.0.0.1 at 1c:bd:b9:c0:63:c6
10.0.0.20 at 68:63:59:4e:98:f0
10.0.0.255 at ff:ff:ff:ff:ff:ff
224.0.0.22 at 01:00:5e:00:00:16
224.0.0.252 at 01:00:5e:00:00:fc
239.255.255.250 at 01:00:5e:7f:ff:fa
224.0.0.22 at 01:00:5e:00:00:16
No duplicate. Patch:
--- a/src/arp-win32.c 2015-06-25 21:02:17
+++ b/src/arp-win32.c 2015-06-26 14:22:20
@@ -119,6 +119,9 @@
for (i = 0; i < (int)arp->iptable->dwNumEntries; i++) {
if (arp->iptable->table[i].dwPhysAddrLen != ETH_ADDR_LEN)
continue;
+ if (arp->iptable->table[i].dwType == MIB_IPNET_TYPE_INVALID)
+ continue;
+
entry.arp_pa.addr_ip = arp->iptable->table[i].dwAddr;
memcpy(&entry.arp_ha.addr_eth,
arp->iptable->table[i].bPhysAddr, ETH_ADDR_LEN);