-
Notifications
You must be signed in to change notification settings - Fork 11
/
packet-bnetp-base.lua
47 lines (39 loc) · 1.3 KB
/
packet-bnetp-base.lua
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
local X = require("xproto")
local p = X.protocol("bnetp", "Battle.net Pre protocol",
{ key = "tcp.port", value = 6112 })
-- Create dissector table under the "bnetp.type" key
local type_table = DissectorTable.new(
"bnetp.type", "Battle.net Protocol Type", ftypes.UINT8)
p.api.call_subdissector_or_reject = function (proto)
return {
dissect = function (self, state)
local type = state.packet.type
local dissector = type_table:get_dissector(type)
-- Reject packet if no subdissector is found
if dissector == nil then
state:reject()
else
-- Pass packet direction down to subdissector
state.pkt.private.isServerPacket = tostring(state.isServerPacket)
-- Allow desegmentation in the subdissector
local can_deseg_saved = state.pkt.can_desegment
if (state.pkt.can_desegment > 0) then
state.pkt.can_desegment = 2
end
local consumed = type_table:try(type, state:tvb(), state.pkt, state.root_node)
state.used = state.used + consumed
-- Restore desegmentation value
state.pkt.can_desegment = can_deseg_saved
end
end
}
end
p:entrypoint {
p:uint8 {
filter = "bnetp.type",
key = "type",
protofield_type = "none",
},
p:call_subdissector_or_reject(),
}
p:initialize()