Read a pcap or pcapng file and return a packet list :param count: read only packets
(filename, count=-1)
| 1302 | |
| 1303 | @conf.commands.register |
| 1304 | def rdpcap(filename, count=-1): |
| 1305 | # type: (Union[IO[bytes], str], int) -> PacketList |
| 1306 | """Read a pcap or pcapng file and return a packet list |
| 1307 | |
| 1308 | :param count: read only <count> packets |
| 1309 | """ |
| 1310 | # Rant: Our complicated use of metaclasses and especially the |
| 1311 | # __call__ function is, of course, not supported by MyPy. |
| 1312 | # One day we should simplify this mess and use a much simpler |
| 1313 | # layout that will actually be supported and properly dissected. |
| 1314 | with PcapReader(filename) as fdesc: # type: ignore |
| 1315 | return fdesc.read_all(count=count) |
| 1316 | |
| 1317 | |
| 1318 | # NOTE: Type hinting |
no test coverage detected