[Bro-Dev] Array parsing and indexing

Martina Balintova balint.martina at gmail.com
Mon Nov 7 06:33:50 PST 2016


Hi,
could you pls help me with one parser? I am trying to parse protocol that
can contain list of chained commands coming in one packet. Lets say that
structure looks like this:

 type Request(header: Head) = record {
   cmd_count : uint8;
   reserved : uint8;
   cmds : uint16[cmd_count];
   params: Request_Array(cmds, header)[cmd_count];
 };

 cmd_count contains number of commands that are chained, cmds are command
IDENTIFIERS listed one after another up to cmd_count and params are
parameters and argument for individual commands. Individual params have
different types depending on command indentifiers listed in cmds array.
Could you pls help me define these two types? how should 'params' look
like? How can I pass index into cmds array?

 type Request_Array(index: uint16, header: Head) = case index of {
   INDEX_00 -> open  : request_open(header);
   INDEX_01 -> find  : request_find(header);
   default  -> empty : bytestring &restofdata &transient;
 };


example of packet:
{
cmd_count : 3
_reserved_
  cmds: 0, 0, 1
  params[0]: ....
  params[0]: ....
  params[1]:.....
}

Any suggestions?
  Martina
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.icsi.berkeley.edu/pipermail/bro-dev/attachments/20161107/25c3cc29/attachment.html 


More information about the bro-dev mailing list