small cleanup
[anytun.git] / wireshark-lua / satp.lua
blob140f971c46e7858221a4eaa45a4b2fa4a3edbaf7
1 do
2 -- satp example
3 -- declare our protocol
5 local proto_satp = Proto("SATP","Secure Anycast Tunneling Protocol")
7 local payload_types = {
8 [0x0800] = "IPv4",
9 [0x6558] = "Ethernet",
10 [0x86DD] = "IPv6"
13 local payload_dissector = {
14 [0x0800] = "ip",
15 [0x6558] = "eth",
16 [0x86DD] = "ipv6"
19 local field_seq = ProtoField.uint32("satp.seq","Sequence Number",base.DEC)
20 local field_sid = ProtoField.uint16("satp.sid","Sender ID",base.DEC)
21 local field_mux = ProtoField.uint16("satp.mux","Mux",base.DEC)
22 local field_ptype = ProtoField.uint16("satp.ptype","Payload Type (plain?)",base.HEX,payload_types)
24 proto_satp.fields = { field_seq, field_sid, field_mux, field_ptype }
27 -- create a function to dissect it
28 function proto_satp.dissector(buffer,pinfo,tree)
29 local info_string = "Sender Id: " .. buffer(4,2):uint() .. ", Mux: " .. buffer(6,2):uint() .. ", SeqNr: " .. buffer(0,4):uint()
30 pinfo.cols.protocol = "SATP"
31 pinfo.cols.info = info_string
33 local subtree = tree:add(proto_satp,buffer(),"SATP, " .. info_string)
35 subtree:add(field_seq, buffer(0,4))
36 subtree:add(field_sid, buffer(4,2))
37 subtree:add(field_mux, buffer(6,2))
39 local payload_type = buffer(8,2):uint()
41 if payload_dissector[payload_type] ~= nil then
42 subtree:add(field_ptype, buffer(8,2))
43 Dissector.get(payload_dissector[payload_type]):call(buffer(10):tvb(),pinfo,tree)
44 else
45 Dissector.get("data"):call(buffer(8):tvb(),pinfo,tree)
46 end
47 end
49 -- load the udp.port table
51 udp_table = DissectorTable.get("udp.port")
53 -- register our protocol to handle udp port 4444
54 udp_table:add(4444,proto_satp)
55 end