diff --git a/scapy/utils.py b/scapy/utils.py index 1a2e36330..2b13fd413 100644 --- a/scapy/utils.py +++ b/scapy/utils.py @@ -912,6 +912,11 @@ sync: do not bufferize writes to the capture file def _write_packet(self, packet, sec=None, usec=None, caplen=None, wirelen=None): """writes a single packet to the pcap file """ + if isinstance(packet, tuple): + for pkt in packet: + self._write_packet(pkt, sec=sec, usec=usec, caplen=caplen, + wirelen=wirelen) + return if caplen is None: caplen = len(packet) if wirelen is None: @@ -944,6 +949,8 @@ sync: do not bufferize writes to the capture file class PcapWriter(RawPcapWriter): """A stream PCAP writer with more control than wrpcap()""" def _write_header(self, pkt): + if isinstance(pkt, tuple) and pkt: + pkt = pkt[0] if self.linktype == None: try: self.linktype = conf.l2types[pkt.__class__] @@ -953,6 +960,10 @@ class PcapWriter(RawPcapWriter): RawPcapWriter._write_header(self, pkt) def _write_packet(self, packet): + if isinstance(packet, tuple): + for pkt in packet: + self._write_packet(pkt) + return sec = int(packet.time) usec = int(round((packet.time-sec)*1000000)) s = str(packet)