From be12502123b9380178e202cb9e944017146d1761 Mon Sep 17 00:00:00 2001 From: pbi Date: Fri, 29 Apr 2005 20:37:39 +0000 Subject: [PATCH] - added L2 recognition for L2pcapListenSocket - workarround for a bug in libpcap/wrapper?. .next() sometimes returns None - added consistant get_if_addr() and get_if_raw_addr() - added ifadd(), ifdel() and ifchange() methods to Route class --- scapy.py | 121 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 108 insertions(+), 13 deletions(-) diff --git a/scapy.py b/scapy.py index 2ba2e4558..5976e1d9c 100755 --- a/scapy.py +++ b/scapy.py @@ -21,6 +21,12 @@ # # $Log: scapy.py,v $ +# Revision 0.9.17.87 2005/04/29 22:37:39 pbi +# - added L2 recognition for L2pcapListenSocket +# - workarround for a bug in libpcap/wrapper?. .next() sometimes returns None +# - added consistant get_if_addr() and get_if_raw_addr() +# - added ifadd(), ifdel() and ifchange() methods to Route class +# # Revision 0.9.17.86 2005/04/27 21:14:24 pbi # - small code cleaning # @@ -745,7 +751,7 @@ from __future__ import generators -RCSID="$Id: scapy.py,v 0.9.17.86 2005/04/27 21:14:24 pbi Exp $" +RCSID="$Id: scapy.py,v 0.9.17.87 2005/04/29 22:37:39 pbi Exp $" VERSION = RCSID.split()[2]+"beta" @@ -1224,12 +1230,13 @@ class Route: self.routes = read_routes() def __repr__(self): - rt = "Network Netmask Gateway Iface\n" + rt = "Network Netmask Gateway Iface Output IP\n" for net,msk,gw,iface,addr in self.routes: - rt += "%-15s %-15s %-15s %s\n" % (ltoa(net), + rt += "%-15s %-15s %-15s %-15s %-15s\n" % (ltoa(net), ltoa(msk), gw, - iface) + iface, + addr) return rt def make_route(self, host=None, net=None, gw=None, dev=None): @@ -1249,8 +1256,7 @@ class Route: nhop = thenet dev,ifaddr,x = self.route(nhop) else: - ifreq = ioctl(self.s, SIOCGIFADDR,struct.pack("16s16x",dev)) - ifaddr = socket.inet_ntoa(ifreq[20:24]) + ifaddr = get_if_addr(dev) return (atol(thenet),(1L<