Ask Your Question

Revision history [back]

Have a look at the dissect_ip_options function in packet-ip.c.

That starts with an overall options length value, then loops over the options, reading the option length in each iteration and subtracting that from the overall length until there are no options left.

You could create a similar function for submessages, starting with the remaining length of the packet, then in the loop reading the submessage id and length, processing the submessage and going around the loop again (if there are bytes remaining.