Write a list of packets to a pcap file :param filename: the name of the file to write packets to, or an open, writable file-like object. The file descriptor will be closed at the end of the call, so do not use an object you do not want to close (e.g., running wrpcap(sys.
(filename, # type: Union[IO[bytes], str]
pkt, # type: _PacketIterable
*args, # type: Any
**kargs # type: Any
)
| 1261 | |
| 1262 | @conf.commands.register |
| 1263 | def wrpcap(filename, # type: Union[IO[bytes], str] |
| 1264 | pkt, # type: _PacketIterable |
| 1265 | *args, # type: Any |
| 1266 | **kargs # type: Any |
| 1267 | ): |
| 1268 | # type: (...) -> None |
| 1269 | """Write a list of packets to a pcap file |
| 1270 | |
| 1271 | :param filename: the name of the file to write packets to, or an open, |
| 1272 | writable file-like object. The file descriptor will be |
| 1273 | closed at the end of the call, so do not use an object you |
| 1274 | do not want to close (e.g., running wrpcap(sys.stdout, []) |
| 1275 | in interactive mode will crash Scapy). |
| 1276 | :param gz: set to 1 to save a gzipped capture |
| 1277 | :param linktype: force linktype value |
| 1278 | :param endianness: "<" or ">", force endianness |
| 1279 | :param sync: do not bufferize writes to the capture file |
| 1280 | """ |
| 1281 | with PcapWriter(filename, *args, **kargs) as fdesc: |
| 1282 | fdesc.write(pkt) |
| 1283 | |
| 1284 | |
| 1285 | @conf.commands.register |
no test coverage detected