Example #1
0
     def recv(self, x=MTU):
         ll = self.ins.datalink()
         if ll in conf.l2types:
             cls = conf.l2types[ll]
         else:
             cls = conf.default_l2
             warning("Unable to guess datalink type (interface=%s linktype=%i). Using %s" % (self.iface, ll, cls.name))
 
         pkt = None
         while pkt is None:
             pkt = self.ins.next()
             if pkt is not None:
                 ts,pkt = pkt
             if scapy3k.arch.WINDOWS and pkt is None:
                 raise PcapTimeoutElapsed
         
         try:
             pkt = cls(pkt)
         except KeyboardInterrupt:
             raise
         except:
             if conf.debug_dissector:
                 raise
             pkt = conf.raw_layer(pkt)
         pkt.time = ts
         return pkt
Example #2
0
 def send(self, x):
     iff,a,gw  = x.route()
     if iff is None:
         iff = conf.iface
     ifs,cls = self.iflist.get(iff,(None,None))
     if ifs is None:
         iftype = self.intf.get(iff)["type"]
         if iftype == INTF_TYPE_ETH:
             try:
                 cls = conf.l2types[1]
             except KeyError:
                 warning("Unable to find Ethernet class. Using nothing")
             ifs = dnet_eth(iff)
         else:
             ifs = dnet_ip()
         self.iflist[iff] = ifs,cls
     if cls is None:
         #sx = str(x)
         sx = bytes(x)
     else:
         sx = bytes(cls()/x)
     x.sent_time = time.time()
     ifs.send(sx)