Lua sub-dissector for rtcp inside a proprietary protocol

95 Views Asked by At

I am new to lua script. I am working on dissecting a proprietary protocol. Inside the protocol bytes there are 8 bytes related to rtcp, like, rtcp version, padding, reception report count, packet type, length and ssrc. A total of 8 bytes. my question is, how to sub-dissect those bytes inside my proprietary protocol?

Basically I need to use rtcp sub-dissector to present the below:

10.. .... = Version: RFC 1889 Version (2)  
..0. .... = Padding: False  
...0 0001 = Reception report count: 1  
Packet type: Report (200)  
Length: 12 (52 bytes)  
SSRC: 0x107bb175 (276541813)  

I am trying the below code:

my_proto = Proto("my_proto",  "My Protocol")  

magic_number = ProtoField.uint32("my_proto.magic_number", "Magic number", base.DEC)  
version     = ProtoField.uint16("my_proto.version"     , "Version"    , base.DEC)  

my_proto.fields = { magic_number, version )  

function my_proto.dissector(buffer, pinfo, tree)  
  length = buffer:reported_length_remaining()  
  local offset = 0  
  if length < 16 then return end  

    local subtree = tree:add(my_proto, buffer:range(offset,length), "My protocol (Report)")  

    subtree:add(magic_number, buffer(offset,4))  
    offset = offset + 4  
    subtree:add(version,     buffer(offset,2))  
    offset = offset + 2  
    -- Then I have 8 bytes related to rtcp protocol, i.e. version, padding, etc.  
        Dissector.get("rtcp"):call(buffer(offset, offset+8):tvb(), pinfo, subtree)  

This line: Dissector.get("rtcp"):call(buffer(offset, offset+8):tvb(), pinfo, subtree) is not working for me. I need it to be presented as below:

10.. .... = Version: RFC 1889 Version (2)  
..0. .... = Padding: False  
...0 0001 = Reception report count: 1  
Packet type: Report (200)  
Length: 12 (52 bytes)  
SSRC: 0x107bb175 (276541813)  

Any help please?

0

There are 0 best solutions below