class RdpcapSource(Source): """Read packets from a PCAP file send them to low exit. +----------+ >>-| |->> | | >-| [pcap]--|-> +----------+ """ def __init__(self, fname, name=None): Source.__init__(self, name=name) self.fname = fname self.f = PcapReader(self.fname) def start(self): print "start" self.f = PcapReader(self.fname) self.is_exhausted = False def stop(self): print "stop" self.f.close() def fileno(self): return self.f.fileno() def deliver(self): p = self.f.recv() print "deliver %r" % p if p is None: self.is_exhausted = True else: self._send(p)
class RdpcapSource(Source): """Read packets from a PCAP file send them to low exit. +----------+ >>-| |->> | | >-| [pcap]--|-> +----------+ """ def __init__(self, fname, name=None): Source.__init__(self, name=name) self.fname = fname self.f = PcapReader(self.fname) def start(self): print("start") self.f = PcapReader(self.fname) self.is_exhausted = False def stop(self): print("stop") self.f.close() def fileno(self): return self.f.fileno() def check_recv(self): return True def deliver(self): p = self.f.recv() print("deliver %r" % p) if p is None: self.is_exhausted = True else: self._send(p)
class RdpcapSource(Source): """Read packets from a PCAP file send them to low exit. .. code:: +----------+ >>-| |->> | | >-| [pcap]--|-> +----------+ """ def __init__(self, fname, name=None): Source.__init__(self, name=name) self.fname = fname self.f = PcapReader(self.fname) def start(self): self.f = PcapReader(self.fname) self.is_exhausted = False def stop(self): self.f.close() def fileno(self): return self.f.fileno() def check_recv(self): return True def deliver(self): try: p = self.f.recv() self._send(p) except EOFError: self.is_exhausted = True