rcapi.lua: way more dissection.
This commit is contained in:
parent
987ac49249
commit
ac048d5dde
|
@ -80,28 +80,131 @@ local command_ids = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local f_msg_len = ProtoField.uint16("rcapi.msg_len", "Message Length", base.DEC)
|
local f_total_length = ProtoField.uint16("rcapi.total_length", "Total Length", base.DEC)
|
||||||
local f_capi_len = ProtoField.uint16("rcapi.capi_len", "CAPI Message Length")
|
local f_datapart = ProtoField.bytes("rcapi.datapart", "Data Block")
|
||||||
|
|
||||||
|
local f_capi_len = ProtoField.uint16("rcapi.capi_len", "CAPI Message Length", base.DEC)
|
||||||
|
local f_app_id = ProtoField.uint16("rcapi.app_id", "Application ID", base.HEX)
|
||||||
local f_command_id = ProtoField.uint16("rcapi.command_id", "Command ID", base.HEX_DEC, command_ids)
|
local f_command_id = ProtoField.uint16("rcapi.command_id", "Command ID", base.HEX_DEC, command_ids)
|
||||||
|
local f_message_number = ProtoField.uint16("rcapi.message_number", "Message Number", base.DEC)
|
||||||
|
|
||||||
|
local f_ncci = ProtoField.uint32("rcapi.ncci", "Network Control Connection ID", base.HEX_DEC)
|
||||||
|
local f_data_handle = ProtoField.uint16("rcapi.data_handle", "Data Handle", base.HEX)
|
||||||
|
local f_data_len = ProtoField.uint16("rcapi.data_len", "Data Length", base.DEC)
|
||||||
|
local f_info = ProtoField.uint16("rcapi.info", "Info", base.HEX)
|
||||||
|
local f_flags = ProtoField.uint16("rcapi.flags", "Flags", base.HEX)
|
||||||
|
|
||||||
|
local f_Buffer = ProtoField.uint32("rcapi.Buffer", "Buffer pointer", base.HEX)
|
||||||
|
local f_messageBufferSize = ProtoField.uint16("rcapi.messageBufferSize", "Size of message buffers", base.DEC)
|
||||||
|
local f_maxLogicalConnections = ProtoField.uint16("rcapi.maxLogicalConnections", "Maximum number of logical connections", base.DEC)
|
||||||
|
local f_maxBDataBlocks = ProtoField.uint16("rcapi.maxBDataBlocks", "Number of data blocks available simultaneously", base.DEC)
|
||||||
|
local f_maxBDataLen = ProtoField.uint16("rcapi.maxBDataLen", "Maximum size of a data block", base.DEC)
|
||||||
|
local f_capiVersion = ProtoField.uint8("rcapi.capiVersion", "CAPI VErsion to register", base.DEC)
|
||||||
|
|
||||||
rcapi_protocol.fields = {
|
rcapi_protocol.fields = {
|
||||||
f_msg_len, f_capi_len, f_command_id,
|
f_total_length, f_datapart,
|
||||||
|
f_capi_len, f_app_id, f_command_id, f_message_number,
|
||||||
|
f_ncci, f_data_handle, f_data_len, f_info, f_flags,
|
||||||
|
f_Buffer, f_messageBufferSize, f_maxLogicalConnections, f_maxBDataBlocks, f_maxBDataLen,
|
||||||
|
f_capiVersion,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- RCAPI Section 2.1
|
||||||
|
local function dissect_register_req(tvb, pinfo, tree)
|
||||||
|
tree:add_le(f_Buffer, tvb(0, 4))
|
||||||
|
tree:add_le(f_messageBufferSize, tvb(4, 2))
|
||||||
|
tree:add_le(f_maxLogicalConnections, tvb(6, 2))
|
||||||
|
tree:add_le(f_maxBDataBlocks, tvb(8, 2))
|
||||||
|
tree:add_le(f_maxBDataLen, tvb(10, 2))
|
||||||
|
tree:add(f_capiVersion, tvb(12, 1))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- RCAPI Section 2.2
|
||||||
|
local function dissect_register_conf(tvb, pinfo, tree)
|
||||||
|
tree:add_le(f_info, tvb(0, 2))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Section 5.17
|
||||||
|
local function dissect_data_b3_req(tvb, pinfo, tree)
|
||||||
|
tree:add_le(f_ncci, tvb(0, 4))
|
||||||
|
-- data tvb(4, 4)
|
||||||
|
tree:add_le(f_data_len, tvb(8, 2))
|
||||||
|
tree:add_le(f_data_handle, tvb(10, 2))
|
||||||
|
tree:add_le(f_flags, tvb(12, 2))
|
||||||
|
-- data64
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Section 5.18
|
||||||
|
local function dissect_data_b3_conf(tvb, pinfo, tree)
|
||||||
|
tree:add_le(f_ncci, tvb(0, 4))
|
||||||
|
tree:add_le(f_data_handle, tvb(4, 2))
|
||||||
|
tree:add_le(f_info, tvb(6, 2))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Section 5.19
|
||||||
|
local function dissect_data_b3_ind(tvb, pinfo, tree)
|
||||||
|
tree:add_le(f_ncci, tvb(0, 4))
|
||||||
|
-- data tvb(4, 4)
|
||||||
|
tree:add_le(f_data_len, tvb(8, 2))
|
||||||
|
tree:add_le(f_data_handle, tvb(10, 2))
|
||||||
|
tree:add_le(f_flags, tvb(12, 2))
|
||||||
|
-- data64
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Section 5.20
|
||||||
|
local function dissect_data_b3_resp(tvb, pinfo, tree)
|
||||||
|
tree:add_le(f_ncci, tvb(0, 4))
|
||||||
|
tree:add_le(f_data_handle, tvb(4, 2))
|
||||||
|
end
|
||||||
|
|
||||||
|
-- CAPI common header, Seet Section 3.3 Message Structure
|
||||||
|
local function capi_dissect_pdu(tvb, pinfo, tree)
|
||||||
|
tree:add_le(f_capi_len, tvb(0, 2))
|
||||||
|
tree:add_le(f_app_id, tvb(2, 2))
|
||||||
|
tree:add(f_command_id, tvb(4, 2))
|
||||||
|
tree:add_le(f_message_number, tvb(6, 2))
|
||||||
|
|
||||||
|
local capi_len = tvb(0, 2):le_uint()
|
||||||
|
local command_id = tvb(4, 2):uint()
|
||||||
|
|
||||||
|
capi_data = tvb(8, capi_len-8)
|
||||||
|
if (command_id == 0xf2ff) then
|
||||||
|
dissect_register_req(capi_data(), pinfo, tree)
|
||||||
|
elseif (command_id == 0xf3ff) then
|
||||||
|
dissect_register_conf(capi_data(), pinfo, tree)
|
||||||
|
elseif (command_id == 0x8680) then
|
||||||
|
dissect_data_b3_req(capi_data(), pinfo, tree)
|
||||||
|
elseif (command_id == 0x8681) then
|
||||||
|
dissect_data_b3_conf(capi_data(), pinfo, tree)
|
||||||
|
elseif (command_id == 0x8682) then
|
||||||
|
dissect_data_b3_ind(capi_data(), pinfo, tree)
|
||||||
|
elseif (command_id == 0x8683) then
|
||||||
|
dissect_data_b3_resp(capi_data(), pinfo, tree)
|
||||||
|
end
|
||||||
|
|
||||||
|
pinfo.cols.info = string.format("%s", command_ids[command_id])
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
local function rcapi_dissect_pdu(buffer, pinfo, tree)
|
local function rcapi_dissect_pdu(buffer, pinfo, tree)
|
||||||
length = buffer:len()
|
length = buffer:len()
|
||||||
if length == 0 then return end
|
if length == 0 then return end
|
||||||
|
|
||||||
pinfo.cols.protocol = rcapi_protocol.name
|
pinfo.cols.protocol = rcapi_protocol.name
|
||||||
|
|
||||||
local subtree = tree:add(rcapi_protocol, buffer(), "RCAPI Data")
|
local subtree = tree:add(rcapi_protocol, buffer(), "Remote CAPI")
|
||||||
local command_id = buffer(6,2):uint()
|
local total_len = buffer(0, 2):uint()
|
||||||
|
local capi_len = buffer(2, 2):le_uint()
|
||||||
|
|
||||||
subtree:add(f_msg_len, buffer(0,2))
|
local capi_tvb = buffer(2, capi_len)
|
||||||
subtree:add_le(f_capi_len, buffer(2,2))
|
|
||||||
subtree:add(f_command_id, command_id)
|
|
||||||
|
|
||||||
pinfo.cols.info = string.format("%s", command_ids[command_id])
|
subtree:add(f_total_length, buffer(0, 2))
|
||||||
|
|
||||||
|
capi_dissect_pdu(capi_tvb, pinfo, subtree)
|
||||||
|
|
||||||
|
if (total_len - (2+capi_len) > 0) then
|
||||||
|
subtree:add(f_datapart, buffer(2+capi_len, total_len - (2+capi_len)))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- A Lua function that will be called for each PDU, to determine the
|
-- A Lua function that will be called for each PDU, to determine the
|
||||||
|
|
Loading…
Reference in New Issue