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.'''
19 parser = argparse.ArgumentParser(description='Dump dhcp.pcap')
20 parser.add_argument('dump_type', choices=['cat', 'slow', 'raw'],
21 help='cat: Just dump the file. slow: Dump the file, pause, and dump its packet records. raw: Dump only the packet records.')
22 args = parser.parse_args()
24 if sys.version_info[0] < 3 and sys.platform == "win32":
26 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
28 dhcp_pcap = os.path.join(os.path.dirname(__file__), 'captures', 'dhcp.pcap')
30 dhcp_fd = open(dhcp_pcap, 'rb')
31 contents = dhcp_fd.read()
32 if args.dump_type != 'raw':
34 if args.dump_type == 'cat':
36 if args.dump_type == 'slow':
39 os.write(1, contents[24:])
42 if __name__ == '__main__':