Wireshark LUA dissector to capture Profisafe packets across two way communication

Viewed 83

There are two devices , IODevice and IOController.The Profisafe data consists of 13 byte.The profinet data telegram structure consists of 60 bytes. enter image description here

The profisafe data for IODevice -> IOController communication starts from 21st byte while the the profisafe data for IOController -> IODevice communication starts from 22nd byte.

I am interested in fetching the data bytes of the profisafe.I have written the Lua script where I am able to correctly dissect the profisafe data for one way communication i.e either IODevice -> IOController or IOController -> IODevice as they have different starting byte for profisafe data.

function profisafe_proto.dissector(buffer,pinfo,tree)
 -- this captures only the Profinet IO data . See the image
 local profisafe_io = profi_f()
 local subtree = tree:add(profisafe_proto, "Profisafe IO Data")
 -- add the offset 5(16 + 5 = 21) for IODevice -> IOController and offset 6(16 + 6 = 22) 
   for  IOController -> IODevice and capture the bytes one by one
  

How can I capture bidirectional communication in the same LUA script?I would like to do something like this:

   if  IODevice -> IOController
      add offset 5
       while( i <= 13)
          array[i] = telegram[offset + i]
    else IOController -> IODevice
       add offset 6
       while( i <= 13)
          array[i] = telegram[offset + i]
0 Answers
Related