forked from osmocom/wireshark
![Gerald Combs](/assets/img/avatar_default.png)
Add the ability to rotate files after a specified number of packets (`-b packets:NUM`). Move some condition checks to capture_loop_write_packet_cb. Add `-a packets:NUM` in order to be consistent. It is functionally equivalent to the `-c` flag. Add a corresponding "packets" option to the Capture Interfaces dialog Output tab. Add initial tests for autostop and ringbuffer conditions. Change-Id: I66eb968927ed287deb8edb96db96d7c73526c257 Reviewed-on: https://code.wireshark.org/review/30534 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
46 lines
1.3 KiB
Python
Executable file
46 lines
1.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
#
|
|
# Wireshark tests
|
|
# By Gerald Combs <gerald@wireshark.org>
|
|
#
|
|
# Ported from a set of Bash scripts which were copyright 2005 Ulf Lamping
|
|
#
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
#
|
|
'''Write captures/dhcp.pcap to stdout, optionally writing only packet records or writing them slowly.'''
|
|
|
|
import argparse
|
|
import os
|
|
import os.path
|
|
import time
|
|
import sys
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description='Dump dhcp.pcap')
|
|
parser.add_argument('dump_type', choices=['cat', 'cat100', 'slow', 'raw'],
|
|
help='cat: Just dump the file. cat100: Dump 100 packet records. slow: Dump the file, pause, and dump its packet records. raw: Dump only the packet records.')
|
|
args = parser.parse_args()
|
|
|
|
dhcp_pcap = os.path.join(os.path.dirname(__file__), 'captures', 'dhcp.pcap')
|
|
|
|
dhcp_fd = open(dhcp_pcap, 'rb')
|
|
contents = dhcp_fd.read()
|
|
if args.dump_type != 'raw':
|
|
os.write(1, contents)
|
|
if args.dump_type == 'cat100':
|
|
# The capture contains 4 packets. Write 96 more.
|
|
for _ in range(24):
|
|
os.write(1, contents[24:])
|
|
if args.dump_type.startswith('cat'):
|
|
sys.exit(0)
|
|
if args.dump_type == 'slow':
|
|
time.sleep(1.5)
|
|
# slow, raw
|
|
os.write(1, contents[24:])
|
|
|
|
sys.exit(0)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|