File tree Expand file tree Collapse file tree 2 files changed +14
-8
lines changed
Expand file tree Collapse file tree 2 files changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,7 @@ def getmacbyip(ip, chainCC=0):
7171 """Return MAC address corresponding to a given IP address"""
7272 if isinstance (ip , Net ):
7373 ip = next (iter (ip ))
74- ip = inet_ntoa (inet_aton (ip ))
74+ ip = inet_ntoa (inet_aton (ip or "0.0.0.0" ))
7575 tmp = [orb (e ) for e in inet_aton (ip )]
7676 if (tmp [0 ] & 0xf0 ) == 0xe0 : # mcast @
7777 return "01:00:5e:%.2x:%.2x:%.2x" % (tmp [1 ] & 0x7f , tmp [2 ], tmp [3 ])
@@ -85,13 +85,16 @@ def getmacbyip(ip, chainCC=0):
8585 if mac :
8686 return mac
8787
88- res = srp1 (Ether (dst = ETHER_BROADCAST ) / ARP (op = "who-has" , pdst = ip ),
89- type = ETH_P_ARP ,
90- iface = iff ,
91- timeout = 2 ,
92- verbose = 0 ,
93- chainCC = chainCC ,
94- nofilter = 1 )
88+ try :
89+ res = srp1 (Ether (dst = ETHER_BROADCAST ) / ARP (op = "who-has" , pdst = ip ),
90+ type = ETH_P_ARP ,
91+ iface = iff ,
92+ timeout = 2 ,
93+ verbose = 0 ,
94+ chainCC = chainCC ,
95+ nofilter = 1 )
96+ except Exception :
97+ return None
9598 if res is not None :
9699 mac = res .payload .hwsrc
97100 conf .netcache .arp_cache [ip ] = mac
Original file line number Diff line number Diff line change @@ -10697,6 +10697,9 @@ test_IPID_count()
1069710697############
1069810698+ ARP
1069910699
10700+ = Simple Ether() / ARP() show
10701+ (Ether() / ARP()).show()
10702+
1070010703= ARP for IPv4
1070110704
1070210705p = raw(ARP())
You can’t perform that action at this time.
0 commit comments