1 -- declare our protocol
2 gwlan_proto = Proto("gnunet","Gnunet Layer")
3 -- create a function to dissect it
4 local f = gwlan_proto.fields
6 f.len = ProtoField.uint16 ("gnunet.len", "Gnunet Message Len")
7 f.type = ProtoField.uint16 ("gnunet.type", "Gnunet Message Type")
8 -- rhs_proto.fields.sequence = ProtoField.uint16("rhs.sequence","Sequence number")
9 f_proto = DissectorTable.new("gnunet.proto", "Gnunet Protocoll", FT_UINT16, BASE_DEC)
10 --gwlan_proto.fields = {f_len, f_type}
12 function gwlan_proto.dissector(buffer,pinfo,tree)
13 pinfo.cols.protocol = "Gnunet Packet"
14 gnunet_packet_disector(buffer,pinfo,tree)
17 function gwlan_proto.init()
20 function gnunet_packet_disector(buffer,pinfo,tree)
21 if (buffer:len() > 4) then
22 local len = buffer(0,2):uint()
23 local type = buffer(2,2):uint()
24 if (len <= buffer:len()) then
25 local dissect = f_proto:get_dissector(type)
26 if dissect ~= nil then
27 dissect:call(buffer(0, len):tvb(), pinfo, tree)
29 local subtree = tree:add(fragmentack, buffer(),"Gnunet Packet Type: " .. buffer(2,2):uint() .. "(" .. buffer:len() .. ")")
30 gnunet_message_header(buffer, pinfo, subtree)
33 --if (len < buffer:len()) then
34 -- gwlan_proto.dissector(buffer(len, buffer:len() - len):tvb(), pinfo, tree)
37 if (buffer:len() == 4) then
38 local subtree = tree:add(fragmentack, buffer(),"Gnunet Packet (" .. buffer:len() .. ")")
39 gnunet_message_header(buffer, pinfo, subtree)
44 function gnunet_message_header(buffer, pinfo, tree)
45 if (buffer:len() >= 4) then
46 local len = buffer(0,2)
47 local type = buffer(2,2)
48 tree:add(buffer(0,2), "Message Len: " .. buffer(0,2):uint())
49 tree:add(buffer(2,2), "Message Type: " .. buffer(2,2):uint())
53 -- load the udp.port table
54 llc_table = DissectorTable.get("llc.dsap")
55 -- register our protocol to handle llc.dsap 0x1e
56 llc_table:add(31,gwlan_proto)
58 fragmentack = Proto("gnunet.fragmentack","Gnunet Fragment Ack")
60 function fragmentack.dissector(buffer,pinfo,tree)
61 pinfo.cols.protocol = "Gnunet Fragment Ack"
62 local subtree = tree:add(fragmentack, buffer(),"Gnunet Data ack (" .. buffer:len() .. ")")
63 gnunet_message_header(buffer, pinfo, subtree)
64 if buffer:len() >= 16 then
65 subtree:add(buffer(4,4),"Fragment Id: " .. buffer(4,4):uint())
66 subtree:add(buffer(8,8),"Bits: " .. buffer(8,8))
70 fragment = Proto("gnunet.fragment","Gnunet Fragment")
72 function fragment.dissector(buffer,pinfo,tree)
73 pinfo.cols.protocol = "Gnunet Fragment"
74 local subtree = tree:add(fragment, buffer(),"Gnunet Fragment (" .. buffer:len() .. ")")
75 gnunet_message_header(buffer, pinfo, subtree)
76 if buffer:len() >= 13 then
77 subtree:add(buffer(4,4),"Fragment Id: " .. buffer(4,4):uint())
78 subtree:add(buffer(8,2),"Total Size: " .. buffer(8,2):uint())
79 subtree:add(buffer(10,2),"Offset: " .. buffer(10,2):uint())
80 if buffer(10,2):uint() == 0 then
81 if (buffer(8,2):uint() <= buffer:len() - 12) then
82 gnunet_packet_disector(buffer(12):tvb(),pinfo,tree)
85 subtree:add(buffer(12), "Data: " .. buffer(12))
90 hello = Proto("gnunet.hello","Gnunet Hello Message")
92 function hello.dissector(buffer,pinfo,tree)
93 pinfo.cols.protocol = "Gnunet Hello Message"
94 local subtree = tree:add(hello, buffer(),"Gnunet Hello Message (" .. buffer:len() .. ")")
95 gnunet_message_header(buffer, pinfo, subtree)
96 if buffer:len() > (264 + 8) then
97 subtree:add(buffer(4,4),"Reserved: " .. buffer(4,4):uint())
98 RsaPublicKeyBinaryEncoded(buffer(8 , 264):tvb(),pinfo, subtree)
100 subtree:add(buffer(4), "SIZE WRONG (< 272)")
104 wlan = Proto("gnunet.wlan","Gnunet WLAN Message")
106 function wlan.dissector(buffer,pinfo,tree)
107 pinfo.cols.protocol = "Gnunet WLAN Message"
108 local subtree = tree:add(wlan, buffer(),"Gnunet WLAN Message (" .. buffer:len() .. ")")
109 gnunet_message_header(buffer, pinfo, subtree)
110 if buffer:len() > (4 + 4 + 2*64) then
111 subtree:add(buffer(4,4),"CRC: " .. buffer(4,4):uint())
112 local peer = GNUNET_PeerIdentity(buffer(8,64), pinfo, subtree)
113 peer:append_text(" Traget")
114 peer = GNUNET_PeerIdentity(buffer(8 + 64,64), pinfo, subtree)
115 peer:append_text(" Source")
117 subtree:add(buffer(8), "SIZE WRONG (< 4 + 4 + 2*64)")
119 if (buffer:len() - (4 + 4 + 2*64) > 0) then
120 gnunet_packet_disector(buffer(4 + 4 + 2*64):tvb(),pinfo,tree)
124 function RsaPublicKeyBinaryEncoded(buffer,pinfo,tree)
125 local subtree = tree:add(gwlan_proto,buffer(),"Gnunet RsaPublicKeyBinaryEncoded(" .. buffer:len() .. ")")
126 subtree:add(buffer(0,2),"Len: " .. buffer(0,2):uint())
127 subtree:add(buffer(2,2),"Sizen: " .. buffer(2,2):uint())
128 subtree:add(buffer(4,258),"Pub Key: " .. buffer(4,258))
129 subtree:add(buffer(262,2),"Padding: " .. buffer(262,2):uint())
132 function GNUNET_PeerIdentity(buffer,pinfo,tree)
133 local subtree = tree:add(gwlan_proto,buffer(),"Gnunet PeerIdentity(" .. buffer:len() .. ")")
134 subtree:add(buffer(0),"hashPubKey: " .. buffer(0))
138 transport_session_keepalive = Proto("gnunet.transport_session_keepalive","Gnunet transport session keepalive")
140 function transport_session_keepalive.dissector(buffer,pinfo,tree)
141 pinfo.cols.protocol = "Gnunet transport session keepalive"
142 local subtree = tree:add(transport_session_keepalive, buffer(),"Gnunet transport session keepalive (" .. buffer:len() .. ")")
143 gnunet_message_header(buffer, pinfo, subtree)
147 f_proto:add(39,transport_session_keepalive)
148 f_proto:add(19,fragmentack)
149 f_proto:add(18,fragment)
150 f_proto:add(16,hello)