Changeset 891:1a296eb42561

Show
Ignore:
Timestamp:
08/30/08 23:55:23 (4 months ago)
Author:
Phil <phil@secdev.org>
Message:

Created conf.default_l2 layer

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • scapy/arch/linux.py

    r890 r891  
    263263            lvl = 3 
    264264        else: 
    265             warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using Ethernet" % (sa_ll[0],sa_ll[1],sa_ll[3])) 
    266             cls = Ether 
     265            cls = conf.default_l2 
     266            warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name)) 
    267267            lvl = 2 
    268268 
     
    335335            self.LL = conf.l3types[sa_ll[1]] 
    336336        else: 
    337             warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using Ethernet" % (sa_ll[0],sa_ll[1],sa_ll[3])) 
    338             self.LL = Ether 
     337            self.LL = conf.default_l2 
     338            warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],self.LL.name)) 
    339339             
    340340    def recv(self, x): 
     
    399399            cls = conf.l3types[sa_ll[1]] 
    400400        else: 
    401             warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using Ethernet" % (sa_ll[0],sa_ll[1],sa_ll[3])) 
    402             cls = Ether 
     401            cls = conf.default_l2 
     402            warning("Unable to guess type (interface=%s protocol=%#x family=%i). Using %s" % (sa_ll[0],sa_ll[1],sa_ll[3],cls.name)) 
    403403 
    404404        try: 
  • scapy/arch/pcapdnet.py

    r890 r891  
    44## This program is published under a GPLv2 license 
    55 
     6import time,struct 
     7from fcntl import ioctl 
    68from scapy.data import * 
    79from scapy.config import conf 
     
    104106                    cls = conf.l2types[ll] 
    105107                else: 
    106                     warning("Unable to guess datalink type (interface=%s linktype=%i). Using Ethernet" % (self.iface, ll)) 
    107                     cls = Ether 
     108                    cls = conf.default_l2 
     109                    warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name)) 
    108110         
    109111                pkt = None 
     
    155157            i = dnet.intf() 
    156158            return i.get(ifname)["addr"].data 
    157          
    158159     
    159160     
     
    163164        def __init__(self, type = ETH_P_ALL, filter=None, promisc=None, iface=None, nofilter=0): 
    164165            self.iflist = {} 
     166            self.intf = dnet.intf() 
    165167            if iface is None: 
    166168                iface = conf.iface 
     
    193195            if iff is None: 
    194196                iff = conf.iface 
    195             ifs = self.iflist.get(iff
     197            ifs,cls = self.iflist.get(iff,(None,None)
    196198            if ifs is None: 
    197                 self.iflist[iff] = ifs = dnet.eth(iff) 
    198             sx = str(Ether()/x) 
     199                iftype = self.intf.get(iff)["type"] 
     200                if iftype == dnet.INTF_TYPE_ETH: 
     201                    try: 
     202                        cls = conf.l2types[1] 
     203                    except KeyError: 
     204                        warning("Unable to find Ethernet class. Using nothing") 
     205                    ifs = dnet.eth(iff) 
     206                else: 
     207                    ifs = dnet.ip() 
     208                self.iflist[iff] = ifs,cls 
     209            if cls is None: 
     210                sx = str(x) 
     211            else: 
     212                sx = str(cls()/x) 
    199213            x.sent_time = time.time() 
    200214            ifs.send(sx) 
     
    204218                cls = conf.l2types[ll] 
    205219            else: 
    206                 warning("Unable to guess datalink type (interface=%s linktype=%i). Using Ethernet" % (self.iface, ll)) 
    207                 cls = Ether 
     220                cls = conf.default_l2 
     221                warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name)) 
    208222     
    209223            pkt = self.ins.next() 
     
    271285                cls = conf.l2types[ll] 
    272286            else: 
    273                 warning("Unable to guess datalink type (interface=%s linktype=%i). Using Ethernet" % (self.iface, ll)) 
    274                 cls = Ether 
     287                cls = conf.default_l2 
     288                warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name)) 
    275289     
    276290            pkt = self.ins.next() 
  • scapy/layers/l2.py

    r880 r891  
    4747    if (tmp[0] & 0xf0) == 0xe0: # mcast @ 
    4848        return "01:00:5e:%.2x:%.2x:%.2x" % (tmp[1]&0x7f,tmp[2],tmp[3]) 
    49     iff,a,gw = config.conf.route.route(ip) 
    50     if ( (iff == "lo") or (ip == config.conf.route.get_if_bcast(iff)) ): 
     49    iff,a,gw = conf.route.route(ip) 
     50    if ( (iff == "lo") or (ip == conf.route.get_if_bcast(iff)) ): 
    5151        return "ff:ff:ff:ff:ff:ff" 
    5252    if gw != "0.0.0.0": 
    5353        ip = gw 
    5454 
    55     mac = config.conf.netcache.arp_cache.get(ip) 
     55    mac = conf.netcache.arp_cache.get(ip) 
    5656    if mac: 
    5757        return mac 
     
    6666    if res is not None: 
    6767        mac = res.payload.hwsrc 
    68         config.conf.netcache.arp_cache[ip] = mac 
     68        conf.netcache.arp_cache[ip] = mac 
    6969        return mac 
    7070    return None