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', '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':
30 if args
.dump_type
== 'cat100':
31 # The capture contains 4 packets. Write 96 more.
33 os
.write(1, contents
[24:])
34 if args
.dump_type
.startswith('cat'):
36 if args
.dump_type
== 'slow':
39 os
.write(1, contents
[24:])
43 if __name__
== '__main__':