This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

registering hf_register_info array in dissect_XXX function

0

Hi,

Is it a good practice to register some entries of hf_register_info array from dissect_XXX function instead of proto_register_XXX() function.

Reason being : the value_string structure assigned to some fields(through vals() function) changes based on the data fetched from packet in dissector code. Basically I have a requirement where the same field and with the same value will be assigned different names based on some data part of packet.

Looking for your help..Thanks in advance :)

asked 02 Mar '12, 10:24

ashish_goel's gravatar image

ashish_goel
15121216
accept rate: 0%


One Answer:

0

The normal approach for this kind of thing is to just register all the possible hf's you might need. So: it is not good practice to register them in the dissect_XXX() function.

There are times when it's truly not possible to register them all ahead of time; I'm thinking of, for example, the MATE plugin: the hf's it needs depend on the configuration file. IIRC it does some kind of delayed initialization. But I'm pretty sure it's still done before dissection begins.

answered 05 Mar '12, 11:15

JeffMorriss's gravatar image

JeffMorriss ♦
6.2k572
accept rate: 27%

can you elaborate a more on the delayed initialization part?? How it is done before dissection??

(05 Mar '12, 19:09) ashish_goel

Actually I'm not too sure: I just know (well, I'm pretty sure anyway) that the MATE plugin can't register it's hf_ entries until it has read its configuration file which means it ends up regitering the hf_ entries "late." But I could be wrong about that. If you're really interested, I'd suggest studying how MATE does it.

(06 Mar '12, 06:50) JeffMorriss ♦