Skip to content
Snippets Groups Projects
Commit 60bf436a authored by Guillaume Valadon's avatar Guillaume Valadon
Browse files

Ensure that the 'ip' variable contains a valid IP address

--HG--
branch : Issue #803 - 2
parent 421c0420
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,7 @@ def getmacbyip(ip, chainCC=0): ...@@ -50,6 +50,7 @@ def getmacbyip(ip, chainCC=0):
"""Return MAC address corresponding to a given IP address""" """Return MAC address corresponding to a given IP address"""
if isinstance(ip,Net): if isinstance(ip,Net):
ip = iter(ip).next() ip = iter(ip).next()
ip = inet_ntoa(inet_aton(ip))
tmp = map(ord, inet_aton(ip)) tmp = map(ord, inet_aton(ip))
if (tmp[0] & 0xf0) == 0xe0: # mcast @ if (tmp[0] & 0xf0) == 0xe0: # mcast @
return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3]) return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment