def next(self): """Return next packet (timestamp, raw_packet)""" c = pcap_next_ex(self.pcap, byref(self.header), byref(self.pkt_data)) # noqa: E501 if not c > 0: return ts = self.header.contents.ts.tv_sec + float( self.header.contents.ts.tv_usec) / 1000000 # noqa: E501 pkt = b"".join( chb(i) for i in self.pkt_data[:self.header.contents.len]) # noqa: E501 return ts, pkt
def next(self): """ Returns the next packet as the tuple (timestamp, raw_packet) """ c = pcap_next_ex(self.pcap, byref(self.header), byref(self.pkt_data)) if not c > 0: return None, None ts = self.header.contents.ts.tv_sec + float( self.header.contents.ts.tv_usec) / 1e6 # noqa: E501 pkt = bytes(bytearray(self.pkt_data[:self.header.contents.len])) return ts, pkt