From 75bc91398f00f5a628e5e7242a1f24e487ffaf13 Mon Sep 17 00:00:00 2001 From: Phil <phil@secdev.org> Date: Sun, 8 Mar 2009 10:56:21 +0100 Subject: [PATCH] Fixed getmacbyip() to work with Net() objects --- scapy/layers/l2.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scapy/layers/l2.py b/scapy/layers/l2.py index f6978440..e6aece94 100644 --- a/scapy/layers/l2.py +++ b/scapy/layers/l2.py @@ -4,6 +4,7 @@ ## This program is published under a GPLv2 license import os,struct,time +from scapy.base_classes import Net from scapy.config import conf from scapy.packet import * from scapy.ansmachine import * @@ -43,6 +44,8 @@ conf.netcache.new_cache("arp_cache", 120) # cache entries expire after 120s @conf.commands.register def getmacbyip(ip, chainCC=0): """Return MAC address corresponding to a given IP address""" + if isinstance(ip,Net): + ip = iter(ip).next() tmp = map(ord, inet_aton(ip)) if (tmp[0] & 0xf0) == 0xe0: # mcast @ return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3]) -- GitLab