dofile(DATA_DIR.."ctp_def.lua") spbx_ctp_proto = Proto("CTP", "Container Transport Protocol") local f_szTag = ProtoField.string("tag", "Protocol Tag(tag)\t\t") local f_connId = ProtoField.uint16("connId", "Container Id(connId)\t", base.DEC) local f_evtType = ProtoField.uint8("type", "Protocol Type(evt)\t\t", base.DEC, evt_type) local f_ucNMsg = ProtoField.uint8("nMsg", "Total Messages(Nmsg)\t", base.DEC) local c_usCtpcId = ProtoField.uint16("ctpcId", "CTPC Container Id(ctpcId)\t\t\t", base.DEC) local c_usAppTyp = ProtoField.uint16("appTyp", "APP Id(appTyp)\t\t\t\t", base.DEC, app_type) local c_ulcfgloop = ProtoField.uint32("loopback", "Loopback Mode(cfg_loopback)\t\t\t", base.DEC, {[0] = "Disable", [1] = "Enable"}) local c_ulcfgThbt = ProtoField.uint32("cfgThbt", "Configure Heart Siganel Period(us)(cfg_Thbt)\t", base.DEC) local c_ulcfgThbl = ProtoField.uint32("cfgThbl", "Configure Lost Heart Siganel Times(us)(cfg_Thbl)\t", base.DEC) local c_ulcfgThretry = ProtoField.uint32("cfgThretury", "Configure Message Timeout(us)(cfg_Tretry)\t", base.DEC) local c_ulNmsg = ProtoField.uint32("cfgNmsg", "Configure Max Messages(cfg_Nmsg)\t\t", base.DEC) local c_ulmsgLen = ProtoField.uint32("cfgmsgLen", "Configure Size Of Per Messages(cfg_msgLen)\t", base.DEC) local s_usCtpsId = ProtoField.uint16("ctpsId", "CTPS Container Id(ctpsId)\t", base.DEC) local n_ucCsn = ProtoField.uint8("csn", "Container Serial Index(csn)\t", base.DEC) local n_ucNack = ProtoField.uint8("nAck", "Total ACKs(Nacksn)\t", base.DEC) local n_ucAckTbl = ProtoField.uint8("ackTbl", " ", base.DEC) local n_usEvt = ProtoField.uint16("evt", "Message Event(evt)\t\t", base.DEC, evt_name) local n_usRef = ProtoField.uint16("ref", "Message Reference(ref)\t", base.DEC) local n_uId = ProtoField.uint32("id", "Message Id(id)\t\t", base.DEC) local n_uReqId = ProtoField.uint32("reqid", "Message Request Id(reqId)\t", base.DEC) local n_uX = ProtoField.uint32("usX", "x Value(x)\t\t", base.DEC) local n_uY = ProtoField.uint32("usY", "y Value(y)\t\t", base.DEC) local n_usLen = ProtoField.uint16("len", "Message Size(len)\t\t", base.DEC) local n_aMsg = ProtoField.bytes("msg", "Message Content\t\t") local lnk_dstRtpPort = ProtoField.uint32("lnkdstRtpPort", "Dest Rtp UDP Port\t", base.DEC) local lnk_Fc = ProtoField.int32("lnkFc", "Voice Code\t", base.DEC) local lnk_Tp = ProtoField.int32("lnkTp", "Time Of RTP Package\t", base.DEC) local lnk_Dir = ProtoField.uint32("lnkDir", "Link Dir\t\t", base.DEC, link_dir_type) local lnk_DestIp = ProtoField.string("lnkDstIp", "Link Dest Ip Addr\t", base.DEC) local mgc_evtRid = ProtoField.uint32("evtRid", "MGC Event RID\t", base.DEC) local lnk_srcPort = ProtoField.uint32("lnkSrcPort", "Link Src Port\t", base.DEC, link_port_type) local mg_sendDtNum = ProtoField.uint16("mgSndDtNum", "Send DTMF Number\t", base.DEC) local mg_sendDtStr = ProtoField.string("obsSndDTStr", "Send DTMF String\t", base.DEC) local rpf_startTime = ProtoField.uint32("rpfStartTime", "Start Time\t", base.DEC) local rpf_len = ProtoField.int32("rpflen", "Play Times(ms)\t", base.DEC) local rpf_evtProc = ProtoField.int32("rpfevtProc", "PROC Period(ms)\t", base.DEC) local rpf_loopCnt = ProtoField.int32("rpfLoopCnt", "Replay Counts\t", base.DEC) local rpf_isStopPre = ProtoField.int32("rpfisStopPre", "Is Stop First\t", base.DEC) local rpf_filename = ProtoField.string("rpfFileName", "File Name\t\t", base.DEC) local obs_evt_name = ProtoField.uint32("obsHook", "HOOK Event\t", base.DEC, obs_evt_type) local obs_fxshookstatus = ProtoField.uint32("obsHookStatus", "HOOK Status\t", base.DEC, {[0] = "HOOK OFF", [1] = "HOOK ON"}) local obs_rcvDTRlt = ProtoField.uint32("obsrcvDTRlt", "DTMF Rcv Result\t", base.DEC) local obs_rcvDTPara = ProtoField.uint32("obsrcvDTPara", "DTMF Rcv Params\t", base.DEC) local obs_rcvDTNum = ProtoField.uint32("obsrcvDTNum", "DTMF Rcv Number\t", base.DEC) local obs_rcvDTStr = ProtoField.string("obsrcvDTStr", "DTMF String\t", base.DEC) local api_evtType = ProtoField.uint32("apiEvtType", "Event Type\t", base.DEC, mgc_to_api_evt_name) local api_u8Type = ProtoField.uint8("apiu8Type", "u8Type\t\t", base.DEC) local api_u8State = ProtoField.uint8("apiu8State", "u8State\t\t", base.DEC) local api_u16Para = ProtoField.uint32("apiu16Para", "u16Para\t\t", base.DEC) local api_u32Para = ProtoField.uint32("apiu32Para", "u32Para\t\t", base.DEC) local api_u32User = ProtoField.uint32("apiu32User", "u32User\t\t", base.DEC) local api_u64Reserved = ProtoField.uint64("apiu64Reserved", "u64Reserved\t", base.DEC) local api_u16BufLen = ProtoField.uint16("apiu16BufLen", "u16BufLen\t\t", base.DEC) local api_pBuf = ProtoField.bytes("apipBuf", "pBuf\t\t") spbx_ctp_proto.fields = { -- Package Head f_szTag, f_connId, f_evtType, f_ucNMsg, -- Items Of CID Message c_usCtpcId, c_usAppTyp, c_ulcfgloop, c_ulcfgThbt, c_ulcfgThbl, c_ulcfgThretry, c_ulNmsg, c_ulmsgLen, -- Items Of SID Message s_usCtpsId, -- Items Of CNNTR Message n_ucCsn, n_ucNack, n_ucAckTbl, n_usEvt, n_usRef, n_uId, n_uReqId, n_uX, n_uY, n_usLen, n_aMsg, -- Link Message lnk_dstRtpPort, lnk_Fc, lnk_Tp, lnk_Dir, lnk_DestIp, mgc_evtRid, lnk_srcPort, rpf_startTime, rpf_len, rpf_evtProc, rpf_loopCnt, rpf_isStopPre, rpf_filename, mg_sendDtNum, mg_sendDtStr, obs_evt_name, obs_fxshookstatus, obs_rcvDTRlt, obs_rcvDTPara, obs_rcvDTNum, obs_rcvDTStr, api_evtType, api_u8Type, api_u8State, api_u16Para, api_u32Para, api_u32User, api_u64Reserved, api_u16BufLen, api_pBuf } function process_message(proType, msg_item, cnntr_msg_len, buffer, offset) local tmpVal; local loffset = offset - cnntr_msg_len - 10 if proType == 1 then local msg_ctx = msg_item:add(spbx_ctp_proto, buffer(loffset, cnntr_msg_len + 10), "Mg_Link Extern Message Info") tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(mgc_evtRid, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(lnk_srcPort, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 loffset = loffset + 2 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(lnk_dstRtpPort, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(lnk_Fc, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(lnk_Tp, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(lnk_Dir, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 -- skip 4 bytes loffset = loffset + 4 tmpVal = buffer(loffset, 2):uint() loffset = loffset + 2 tempItem = msg_ctx:add(lnk_DestIp, buffer(loffset, tmpVal)) loffset = loffset + tmpVal elseif proType == 6 then local msg_ctx = msg_item:add(spbx_ctp_proto, buffer(loffset, cnntr_msg_len + 10), "Mg_SendDtmf Extern Message Info") tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(mgc_evtRid, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 loffset = loffset + 18 tmpVal = buffer(loffset, 2):uint() tempItem = msg_ctx:add(mg_sendDtNum, buffer(loffset, 2)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 2 tempItem = msg_ctx:add(mg_sendDtStr, buffer(loffset, tmpVal)) tempItem:append_text(" (" .. tmpVal - 1 .. " chars)") loffset = loffset + tmpVal elseif proType == 15 then --MrcSigReqI6A1Init(src, reqId, SIG_Rp_PlayFileEx, startTime, len, evtproc, uLoopCnt, isStopPre, 0, fileName, evtRid); local msg_ctx = msg_item:add(spbx_ctp_proto, buffer(loffset, cnntr_msg_len + 10), "Rp_PlayFile Extern Message Info") tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(mgc_evtRid, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(rpf_startTime, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 loffset = loffset + 2 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(rpf_len, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(rpf_evtProc, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(rpf_loopCnt, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(rpf_isStopPre, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 -- skip 4 bytes loffset = loffset + 4 tmpVal = buffer(loffset, 2):uint() loffset = loffset + 2 tempItem = msg_ctx:add(rpf_filename, buffer(loffset, tmpVal)) tempItem:append_text(" (" .. tmpVal .. " bytes)") loffset = loffset + tmpVal elseif proType >= 10003 and proType <= 10007 then tmpVal = buffer(loffset, 4):uint() local msg_ctx = msg_item:add(spbx_ctp_proto, buffer(loffset, cnntr_msg_len + 10), "OBS Event Message Info") tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(obs_evt_name, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 if tmpVal == 4 then tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(obs_fxshookstatus, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 elseif tmpVal == 14 then -- p->y tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(obs_rcvDTRlt, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 -- p->len -- skip 2 bytes loffset = loffset + 2 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(obs_rcvDTPara, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(obs_rcvDTNum, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 -- skip 4 bytes loffset = loffset + 4 tmpVal = buffer(loffset, 2):uint() loffset = loffset + 2 msg_ctx:add(obs_rcvDTStr, buffer(loffset, tmpVal)) loffset = loffset + tmpVal end elseif proType == 10008 then local msg_ctx = msg_item:add(spbx_ctp_proto, buffer(loffset, cnntr_msg_len + 10), "API Event Extern Message Info") --api_u32User, api_u64Reserved, api_u16BufLen, api_pBuf tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(api_evtType, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(api_u32Para, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 -- skip 2 bytes loffset = loffset + 2 tmpVal = buffer(loffset, 1):uint() tempItem = msg_ctx:add(api_u8Type, buffer(loffset, 1)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 1 tmpVal = buffer(loffset, 1):uint() tempItem = msg_ctx:add(api_u8State, buffer(loffset, 1)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 1 tmpVal = buffer(loffset, 2):uint() tempItem = msg_ctx:add(api_u16Para, buffer(loffset, 2)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 2 tmpVal = buffer(loffset, 4):uint() tempItem = msg_ctx:add(api_u32User, buffer(loffset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 4 tmpVal = buffer(loffset, 8):uint64() tempItem = msg_ctx:add(api_u64Reserved, buffer(loffset, 8)) --tempItem:append_text(" (" .. string.format("0x%016X", tmpVal) .. ")") loffset = loffset + 8 -- skip 4 bytes loffset = loffset + 4 tmpVal = buffer(loffset, 2):uint() tempItem = msg_ctx:add(api_u16BufLen, buffer(loffset, 2)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") loffset = loffset + 2 msg_ctx:add(api_pBuf, buffer(loffset, tmpVal)) loffset = loffset + tmpVal end return offset end function spbx_ctp_proto.dissector(buffer, pinfo, tree) pinfo.cols.protocol:set("CTP") local buf_len = buffer:len() local myProtoTree = tree:add(spbx_ctp_proto, buffer(0, 8), "SPBX CTP Protocol Head Information") local offset = 0 myProtoTree:add_le(f_szTag, buffer(offset, 4)) offset = offset + 4 myProtoTree:add(f_connId, buffer(offset, 2)) offset = offset + 2 local evtType = buffer(offset, 1):uint() myProtoTree:add(f_evtType, buffer(offset, 1)) offset = offset + 1 local msgNum = buffer(offset, 1):uint() myProtoTree:add(f_ucNMsg, buffer(offset, 1)) offset = offset + 1 if evtType == 1 then local cidTree = tree:add(spbx_ctp_proto, buffer(8, buf_len - 8), "CID Message Information") local cid_ctpcid = buffer(offset, 2):uint() cidTree:add(c_usCtpcId, cid_ctpcid) offset = offset + 2 local cid_apptyp = buffer(offset, 2):uint() cidTree:add(c_usAppTyp, buffer(offset, 2)) offset = offset + 2 cidTree:add(c_ulcfgloop, buffer(offset, 4)) offset = offset + 4 cidTree:add(c_ulcfgThbt, buffer(offset, 4)) offset = offset + 4 cidTree:add(c_ulcfgThbl, buffer(offset, 4)) offset = offset + 4 cidTree:add(c_ulcfgThretry, buffer(offset, 4)) offset = offset + 4 cidTree:add(c_ulNmsg, buffer(offset, 4)) offset = offset + 4 cidTree:add(c_ulmsgLen, buffer(offset, 4)) offset = offset + 4 pinfo.cols.info:set("CID: CTPC_ID = " .. cid_ctpcid .. ", APP_TYPE = " .. app_type[cid_apptyp]) elseif evtType == 2 then local sidTree = tree:add(spbx_ctp_proto, buffer(8, buf_len - 8), "SID Message Information") local sid_ctpsid = buffer(offset, 2):uint() sidTree:add(s_usCtpsId, buffer(offset, 2)) offset = offset + 2 pinfo.cols.info:set("SID: CTPS_ID = " .. sid_ctpsid) elseif evtType == 3 then local cnntr_Tree = tree:add(spbx_ctp_proto, buffer(8, buf_len - 8), "CNNTR Message Information") local cnntr_csn = buffer(offset, 1):uint() cnntr_Tree:add(n_ucCsn, buffer(offset, 1)) offset = offset + 1 local cnntr_nack = buffer(offset, 1):uint() local cnntr_nack_item = cnntr_Tree:add(spbx_ctp_proto, buffer(9, cnntr_nack + 1), "ACKs Information(Nacksn) [" .. cnntr_nack .. " acks]") offset = offset + 1 if cnntr_nack > 0 then for i = 1, cnntr_nack do local ack_id = buffer(offset, 1):uint() local ack_items = cnntr_nack_item:add(n_ucAckTbl, buffer(offset, 1)) offset = offset + 1 ack_items:prepend_text("ACK Container Serial Index[" .. i - 1 .."]") end end if msgNum > 0 then local cnntr_msg_item = cnntr_Tree:add(spbx_ctp_proto, buffer(offset, buf_len - offset), "Message Information [" .. msgNum .. " messages]") for i = 1, msgNum do local cnntr_msg_len = buffer(offset + 20, 2):uint() local msg_item = cnntr_msg_item:add(spbx_ctp_proto, buffer(offset, cnntr_msg_len + 12), "Message [" .. i - 1 .. "] Content") local proType = buffer(offset, 2):uint() local tempItem = msg_item:add(n_usEvt, buffer(offset, 2)) tempItem:append_text(" (" .. string.format("0x%08X", proType) .. ")") offset = offset + 2 tmpVal = buffer(offset, 2):uint() tempItem = msg_item:add(n_usRef, buffer(offset, 2)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") offset = offset + 2 tmpVal = buffer(offset, 4):uint() tempItem = msg_item:add(n_uId, buffer(offset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") offset = offset + 4 tmpVal = buffer(offset, 4):uint() tempItem = msg_item:add(n_uReqId, buffer(offset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") offset = offset + 4 tmpVal = buffer(offset, 4):uint() tempItem = msg_item:add(n_uX, buffer(offset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") offset = offset + 4 tmpVal = buffer(offset, 4):uint() tempItem = msg_item:add(n_uY, buffer(offset, 4)) tempItem:append_text(" (" .. string.format("0x%08X", tmpVal) .. ")") offset = offset + 4 local extMsgLen = buffer(offset, 2):uint() tempItem = msg_item:add(n_usLen, buffer(offset, 2)) tempItem:append_text(" (" .. string.format("0x%08X", extMsgLen) .. ")") offset = offset + 2 msg_item:add(n_aMsg, buffer(offset, cnntr_msg_len)) offset = offset + cnntr_msg_len if extMsgLen > 0 then offset = process_message(proType, msg_item, cnntr_msg_len, buffer, offset) end end end if msgNum == 0 then -- Heart Message pinfo.cols.info:set("HEART: CSN = " .. cnntr_csn .. ", Nack = " .. cnntr_nack) else -- Container Message pinfo.cols.info:set("CNNTR: CSN = " .. cnntr_csn .. ", Nack = " .. cnntr_nack .. " Nmsg = " .. msgNum) end else end end local ctp_udp_port_table = DissectorTable.get("udp.port") local spbx_ctp_port = 4396 ctp_udp_port_table:add(spbx_ctp_port, spbx_ctp_proto)