P4 Wireshark dissector generator is a tool that allows P4 programmers to quickly generate a Wireshark dissector in Lua from the headers defined within a P4 file.
- P4 input file
- P4-HLIR
- Wireshark
To install, execute the setup script using:
sudo python setup.py install
To generate a dissector, run p4-gen-wireshark from your command line. The syntax is:
p4-gen-wireshark [-d <destination>] [-p <protocol>] <p4_source>
where:
-d <destination>
Destination file. If none given, the destination has the form
<pwd>/<p4_source>-<protocol>.lua
-p <protocol>
Protocol in P4 source file for which to build a dissector. Use instance
rather than header name (i.e. without a "_t" at the end). If none is given,
build a dissector for every protocol.
<p4_source>
P4 source file.
To use your dissector with Wireshark, open a terminal window and type:
wireshark -X lua_script:<dissector>
where:
<dissector>
Is the filename of your generated dissector.
You first need to install the pytest
Python package. You can then run:
pytest tests/test_p4_gen.py