|
I am working on a protocol dissector where some fields are comprised of fewer than 8 bits. For example, the first 4 bits identify the packet type, and the next 16 bits the length of following data. Can I dissect fields with length less than one byte, and how can I display them? |
|
Absolutely. You can do this by specifying a nonzero bitmask when defining your header fields like so:
Then, simply add them to the tree as you have done for your other protocol fields:
Doing it this way keeps most of the bit-twiddling out of your dissector code, but still allows you to add fields of arbitrary widths and continuities to your protocol. Note that if you need to work with those bits directly you must extract them from the See README.developer for proto_tree_add_bits_item() and tvb_get_bits...
(13 Feb '12, 14:20)
Anders ♦
|
