Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / test / util_dump_dhcp_pcap.py
blob28b382376719270056557627e6197403342c41cd
1 #!/usr/bin/env python3
3 # Wireshark tests
4 # By Gerald Combs <gerald@wireshark.org>
6 # Ported from a set of Bash scripts which were copyright 2005 Ulf Lamping
8 # SPDX-License-Identifier: GPL-2.0-or-later
10 '''Write captures/dhcp.pcap to stdout, optionally writing only packet records or writing them slowly.'''
12 import argparse
13 import os
14 import os.path
15 import time
16 import sys
18 def main():
19 parser = argparse.ArgumentParser(description='Dump dhcp.pcap')
20 parser.add_argument('dump_type', choices=['cat', 'cat100', 'slow', 'raw'],
21 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.')
22 args = parser.parse_args()
24 dhcp_pcap = os.path.join(os.path.dirname(__file__), 'captures', 'dhcp.pcap')
26 dhcp_fd = open(dhcp_pcap, 'rb')
27 contents = dhcp_fd.read()
28 if args.dump_type != 'raw':
29 os.write(1, contents)
30 if args.dump_type == 'cat100':
31 # The capture contains 4 packets. Write 96 more.
32 for _ in range(24):
33 os.write(1, contents[24:])
34 if args.dump_type.startswith('cat'):
35 sys.exit(0)
36 if args.dump_type == 'slow':
37 time.sleep(1.5)
38 # slow, raw
39 os.write(1, contents[24:])
41 sys.exit(0)
43 if __name__ == '__main__':
44 main()