forked from kaos/wireshark-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
49 lines (40 loc) · 1.17 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CAPNP = capnp
CAT = /bin/cat
SCHEMA = /usr/local/include/capnp/schema.capnp
TARGET = $(basename $(notdir $(input)))
define MSG
The purpose of this Makefile is to generate new schemas for the capnp dissector.
Usage:
make schema input=/path/to/schema-file.capnp
This will produce a plugins/schema-file_capnp.lua source file.
Any types in that schema is then loaded and used automagically
by the capnp protocol dissector.
endef
export MSG
define HEAD
local capnp_schema = require("capnp_schema")
-- fake atoms
local void = "void"
local empty = "empty"
local bit = "bit"
local byte = 1
local twoBytes = 2
local fourBytes = 4
local eightBytes = 8
local pointer = "pointer"
local inlineComposite = "inlineComposite"
local opaquePointer = "opaquePointer"
capnp_schema["$(TARGET)"] =
endef
export HEAD
all:
@echo "$$MSG"
schema: $(input) plugins/$(TARGET)_capnp.lua
%.lua: Makefile $(input)
echo "$$HEAD" > $@
$(CAPNP) compile -o$(CAT) $(input) -I/ |\
$(CAPNP) decode $(SCHEMA) CodeGeneratorRequest |\
sed -e 's/[[(]/{/g' -e 's/[])]/}/g' \
-e 's/<opaque pointer>/opaquePointer/g' \
-e 's/\([Ii]d = \)\([0-9][0-9]*\)/\1"\2"/g' \
-e 's/\(StructType = \)\([0-9][0-9]*\)/\1"\2"/g' >> $@