A stream pcapng writer with more control than wrpcapng()
| 2654 | |
| 2655 | |
| 2656 | class PcapNgWriter(RawPcapNgWriter): |
| 2657 | """A stream pcapng writer with more control than wrpcapng()""" |
| 2658 | |
| 2659 | def _get_time(self, |
| 2660 | packet, # type: Union[bytes, Packet] |
| 2661 | sec, # type: Optional[float] |
| 2662 | usec # type: Optional[int] |
| 2663 | ): |
| 2664 | # type: (...) -> Tuple[float, int] |
| 2665 | if hasattr(packet, "time"): |
| 2666 | if sec is None: |
| 2667 | sec = float(packet.time) |
| 2668 | |
| 2669 | if usec is None: |
| 2670 | usec = 0 |
| 2671 | |
| 2672 | return sec, usec # type: ignore |
| 2673 | |
| 2674 | |
| 2675 | @conf.commands.register |