summaryrefslogtreecommitdiffstats
path: root/build_spec.sh
diff options
context:
space:
mode:
authorbt <bt@rctt.net>2026-03-10 14:11:01 +0100
committerbt <bt@rctt.net>2026-03-10 14:11:01 +0100
commite5644d24c51634c0e263a758bd57b797d5949c9c (patch)
tree5f6f33ebb064df45693fc75e0d454f0f11ce4654 /build_spec.sh
parent6dcbb66fcafce3da6d7c00d9679946b77f6f6186 (diff)
downloadsolec-e5644d24c51634c0e263a758bd57b797d5949c9c.tar.gz
solec-e5644d24c51634c0e263a758bd57b797d5949c9c.zip
Use Kaitai to describe protocol spec, autogenerate Wireshark plugin and diagram
Diffstat (limited to 'build_spec.sh')
-rwxr-xr-xbuild_spec.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/build_spec.sh b/build_spec.sh
new file mode 100755
index 0000000..ae78b81
--- /dev/null
+++ b/build_spec.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+if [[ "$OSTYPE" == "darwin"* ]]; then
+ SED=gsed
+else
+ SED=sed
+fi
+
+kaitai-struct-compiler -t graphviz solec.ksy
+dot -Tsvg solec.dot > solec.svg
+rm solec.dot
+
+~/bin/kaitai-struct-compiler-ws/bin/kaitai-struct-compiler -t wireshark --read-pos solec.ksy
+
+${SED} -i -e '5s/.*/package.path = "kaitai_struct_lua_runtime\/?.lua" .. package.path/' solec.lua
+${SED} -i -e 's/, self.payload_type//' solec.lua
+
+cat <<EOT >> solec.lua
+local tcp_port = DissectorTable.get("tcp.port")
+tcp_port:add(9999, proto)
+EOT
+