Add Wireshark Lua dissector generator backend for Emboss#113
Add Wireshark Lua dissector generator backend for Emboss#113
Conversation
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
|
@copilot create emboss test structs for Ethernet header, ipv4 header, and UDB header, along with a dummy payload just bytes. Set the fields correctly and then print out the dissection using the command line tshark using the built-in dissectors. Then do the same thing with our custom dissectors and show the difference. In this way you will have another good unit test |
1 similar comment
|
@copilot create emboss test structs for Ethernet header, ipv4 header, and UDB header, along with a dummy payload just bytes. Set the fields correctly and then print out the dissection using the command line tshark using the built-in dissectors. Then do the same thing with our custom dissectors and show the difference. In this way you will have another good unit test |
- Created network_headers.emb with Ethernet, IPv4, and UDP structs - Added generate_and_test.py to demonstrate complete workflow - Added test_network_dissector.py to create test PCAP and compare dissectors - Includes README documentation for the test suite - Demonstrates enum value strings for EtherType and IpProtocol - Shows comparison between tshark built-in and custom Emboss dissectors Co-authored-by: AaronWebster <3766083+AaronWebster@users.noreply.github.com>
Created a comprehensive network protocol test suite in commit 2188668. The test includes: Files Created:
Features Demonstrated:
Run the test: python3 testdata/generate_and_test.pyThe generated Lua dissector includes:
When tshark is available, the test creates a PCAP file and shows side-by-side comparison of built-in dissectors (using |
Implements a code generator backend that produces Wireshark Lua dissectors from Emboss protocol definitions, enabling automatic protocol analysis in Wireshark.
Implementation
Generator core (
compiler/back_end/lua/dissector_generator.py): Transforms IR into Wireshark ProtoField declarations and dissector functions. Handles enum value strings, documentation extraction, and type mapping (UInt/Int → uint8/16/32/64).Bazel integration (
build_defs.bzl): Addedemboss_lua_libraryrule with aspect-based code generation, parallel to existingcc_emboss_library.Annotation support: Recognizes
[(wireshark_filter): "name"]attribute on structs and fields for custom display filter names.Usage
Generates dissector with:
myproto.msg_type,myproto.seq_num--comments (hash comments ignored)Files
compiler/back_end/lua/{dissector_generator.py, emboss_codegen_lua.py, build_defs.bzl, BUILD}testdata/{wireshark_test.emb, example_protocol.emb}- examples demonstrating featurestestdata/network_headers.emb- real-world network protocol headers (Ethernet, IPv4, UDP)testdata/{generate_and_test.py, test_network_dissector.py, NETWORK_TEST_README.md}- comprehensive test suitecompiler/back_end/lua/{README.md, QUICKSTART.md}- usage documentationNetwork Protocol Test Suite
Added comprehensive test demonstrating the dissector with real network protocols:
network_headers.emb: Emboss definitions for Ethernet II, IPv4, and UDP headers matching RFC specificationsgenerate_and_test.py: Complete workflow from .emb → IR → Lua dissector → test PCAPtest_network_dissector.py: Creates test packets and compares tshark built-in dissectors vs custom Emboss dissectorRun the test:
The test creates a complete packet (Ethernet + IPv4 + UDP + payload) and demonstrates how the generated dissector parses it with proper field names, enum value strings, and hierarchical structure.
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.