-- DSMCC dissector -- $Revision$ do -- The port(s) to register the dissector on local server_port = 13819 -- Message type ids local ServerInteractiveSessionRequest = 0xabc0 local ServerInteractiveSessionConfirm = 0xabc1 -- Message type string local message_types = { [ServerInteractiveSessionRequest] = "ServerInteractiveSessionRequest" ,[ServerInteractiveSessionConfirm] = "ServerInteractiveSessionConfirm" } -- message dissector list local message_dissectors = { [0] = Proto("dsmcc.unknown_dsmcc_message", "unknown dsmcc message") , [ServerInteractiveSessionRequest] = Proto("dsmcc.serverinteractivesessionrequest", "ServerInteractiveSessionRequest") , [ServerInteractiveSessionConfirm] = Proto("dsmcc.serverinteractivesessionconfirm", "ServerInteractiveSessionConfirm") } -- -- unknown message dissector -- local unknown_dsmcc_message = message_dissectors[0] unknown_dsmcc_message.fields.payload = ProtoField.bytes("dsmcc.payload", "payload") function unknown_dsmcc_message.dissector(buffer, pinfo, tree) tree:add(unknown_dsmcc_message.fields.payload, buffer(0)) end -- -- ServerInteractiveSessionRequest dissector -- local ServerInteractiveSessionRequest = message_dissectors[ServerInteractiveSessionRequest] ServerInteractiveSessionRequest.fields.sessionId = ProtoField.bytes("dsmcc.sessionId", "sessionId", base.HEX, nil, nil) ServerInteractiveSessionRequest.fields.reserved = ProtoField.bytes("dsmcc.reserved", "reserved", base.HEX, nil, nil) ServerInteractiveSessionRequest.fields.clientId = ProtoField.bytes("dsmcc.clientId", "clientId", base.HEX, nil, nil) ServerInteractiveSessionRequest.fields.serverId = ProtoField.bytes("dsmcc.serverId", "serverId", base.HEX, nil, nil) ServerInteractiveSessionRequest.fields.originatingNetworkId = ProtoField.bytes("dsmcc.originatingNetworkId", "originatingNetworkId", base.HEX, nil, nil) function ServerInteractiveSessionRequest.dissector(buffer, pinfo, tree) local fields = ServerInteractiveSessionRequest.fields tree:add(fields.sessionId, buffer(0,10)) tree:add(fields.reserved, buffer(10,2)) tree:add(fields.clientId, buffer(12,20)) tree:add(fields.serverId, buffer(32,20)) tree:add(fields.originatingNetworkId, buffer(52,20)) pinfo.cols.info = tostring(pinfo.cols.info) .. ' (' .. tostring(buffer(0,10):bytes()) .. '), ' end -- -- ServerInteractiveSessionConfirm dissector -- local ServerInteractiveSessionConfirm = message_dissectors[ServerInteractiveSessionConfirm] ServerInteractiveSessionConfirm.fields.sessionId = ProtoField.bytes("dsmcc.sessionId", "sessionId", base.HEX, nil, nil) ServerInteractiveSessionConfirm.fields.rsrMgtNetworkId = ProtoField.bytes("dsmcc.rsrMgtNetworkId", "rsrMgtNetworkId", base.HEX, nil, nil) ServerInteractiveSessionConfirm.fields.response = ProtoField.bytes("dsmcc.response", "response", base.HEX, nil, nil) function ServerInteractiveSessionConfirm.dissector(buffer, pinfo, tree) local fields = ServerInteractiveSessionConfirm.fields tree:add(fields.sessionId, buffer(0,10)) tree:add(fields.rsrMgtNetworkId, buffer(10,20)) tree:add(fields.response, buffer(30,2)) pinfo.cols.info = tostring(pinfo.cols.info) .. ' (' .. tostring(buffer(0,10):bytes()) .. '), ' pinfo.cols.info = tostring(pinfo.cols.info) .. ' (' .. 'res:' .. tostring(buffer(30,2):uint()) .. '), ' end -- -- Dissector Proto and message header definition -- dsmcc_proto = Proto("dsmcc","DSMCC Client Protocol") dsmcc_proto.fields.protocol_discriminator = ProtoField.uint8("dsmcc.protocol_discriminator", "protocol_discriminator", base.HEX) dsmcc_proto.fields.type = ProtoField.uint16("dsmcc.type", "type", base.HEX) dsmcc_proto.fields.message_id = ProtoField.uint16("dsmcc.message_id", "message_id", base.HEX) dsmcc_proto.fields.transaction_id = ProtoField.uint16("dsmcc.transaction_id", "transaction_id", base.HEX) dsmcc_proto.fields.reserve = ProtoField.uint16("dsmcc.reserve", "reserve", base.HEX) dsmcc_proto.fields.adaptation_len = ProtoField.uint16("dsmcc.adaptation_len", "adaptation_len", base.DEC) dsmcc_proto.fields.message_len = ProtoField.uint16("dsmcc.message_len", "message_len", base.DEC) -- -- DSMCC dissector for the message header. Individual messages are dissected by message specific methods. -- function dsmcc_proto.dissector(buffer,pinfo,tree) pinfo.cols.protocol = "DSMCC" local offset = 0 local header_len = 12 local message_type = buffer(offset+2, 2):uint() if (message_type ~= 0xabc0 and message_type ~= 0xabc1) then orig_dissector:call( buffer, pinfo, tree ) local sub_message_start = 12 + buffer(9,1):uint() pinfo.cols.info = tostring(pinfo.cols.info) .. ' (' .. tostring(buffer(sub_message_start,10):bytes()) .. '), ' return end pinfo.cols.info = "" -- create trees local fields = dsmcc_proto.fields local subtree = tree:add(dsmcc_proto,buffer(),"DSMCC") local headertree = subtree:add(dsmcc_proto, buffer(offset,header_len), "DSMCC Message Header") -- populate fields headertree:add(fields.protocol_discriminator, buffer(offset+0,1)) headertree:add(fields.type, buffer(offset+1,1)) headertree:add(fields.message_id, buffer(offset+2,2)) headertree:add(fields.transaction_id, buffer(offset+4,4)) headertree:add(fields.reserve, buffer(offset+8,1)) headertree:add(fields.adaptation_len, buffer(offset+9,1)) headertree:add(fields.message_len, buffer(offset+10,2)) -- Pass the message off to the specific dissector local message_string = message_types[message_type] or string.format("Unknown (0x%02x)", message_type) pinfo.cols.info = message_string local sub_message_start = 12 + buffer(9,1):uint() local sub_message_length = buffer(10,2):uint() - buffer(9,1):uint() if (sub_message_length > 0 and message_dissectors[message_type]) then message_dissectors[message_type].dissector:call(buffer:range(sub_message_start,sub_message_length):tvb(), pinfo, subtree:add(dsmcc_proto, buffer(sub_message_start), message_string)) end end -- -- -- dsmcc_proto_wrapper = Proto("dsmccwrappers","CloudTV DSMCC Client Protocol Wrappers") function dsmcc_proto_wrapper.dissector(buffer,pinfo,tree) print("In the dissector") -- orig_dissector:call( buffer, pinfo, tree ) dsmcc_proto.dissector:call(buffer, pinfo, tree) end -- -- Register the dissector on the specified server ports. -- proto_table = DissectorTable.get("tcp.port") orig_dissector = proto_table:get_dissector( server_port ) proto_table:add(server_port, dsmcc_proto_wrapper) end