mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Gracefully handle arp_open failure
This commit is contained in:
parent
7f2764927b
commit
5b78ef236e
2 changed files with 21 additions and 14 deletions
|
|
@ -769,6 +769,7 @@ bool NpingTarget::determineNextHopMACAddress() {
|
|||
/* Maybe the system ARP cache will be more helpful */
|
||||
nping_print(DBG_3," > Checking system's ARP cache...");
|
||||
a = arp_open();
|
||||
if (a) {
|
||||
addr_ston((sockaddr *)&targetss, &ae.arp_pa);
|
||||
if (arp_get(a, &ae) == 0) {
|
||||
mac_cache_set(&targetss, ae.arp_ha.addr_eth.data);
|
||||
|
|
@ -779,6 +780,10 @@ bool NpingTarget::determineNextHopMACAddress() {
|
|||
}
|
||||
arp_close(a);
|
||||
nping_print(DBG_3," > No relevant entries found in system's ARP cache.");
|
||||
}
|
||||
else {
|
||||
nping_print(DBG_3," > Failed to open system's ARP cache.");
|
||||
}
|
||||
|
||||
|
||||
/* OK, the last choice is to send our own damn ARP request (and
|
||||
|
|
|
|||
2
tcpip.cc
2
tcpip.cc
|
|
@ -1663,6 +1663,7 @@ bool getNextHopMAC(const char *iface, const u8 *srcmac, const struct sockaddr_st
|
|||
|
||||
/* Maybe the system ARP cache will be more helpful */
|
||||
a = arp_open();
|
||||
if (a) {
|
||||
addr_ston((sockaddr *) dstss, &ae.arp_pa);
|
||||
if (arp_get(a, &ae) == 0) {
|
||||
mac_cache_set(dstss, ae.arp_ha.addr_eth.data);
|
||||
|
|
@ -1671,6 +1672,7 @@ bool getNextHopMAC(const char *iface, const u8 *srcmac, const struct sockaddr_st
|
|||
return true;
|
||||
}
|
||||
arp_close(a);
|
||||
}
|
||||
|
||||
/* OK, the last choice is to send our own damn ARP request (and
|
||||
retransmissions if necessary) to determine the MAC */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue