First time here? Check out the FAQ!
THIS IS A TEST INSTANCE. Feel free to ask and answer questions, but take care to avoid triggering too many notifications.
0

save fields with different mask as an unique field

hi. in my dissector, i have 2 fields with different mask, so i define 2 fields as below:

{ &hf_myproto_name1, { "Name", "myproto.name1", FT_UINT16, BASE_DEC, NULL, 0xFFFE, NULL, HFILL } },
{ &hf_myproto_name2, { "Name", "myproto.name2", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL } },

is it possible that i define these two fields as an unique field ? (i want to save these two fields as an unique in hf_register_info)

parvaz's avatar
1
parvaz
asked 2020-04-07 14:26:42 +0000, updated 2020-04-07 14:30:09 +0000
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

From what I understand is that you would like to combine these two? I would come up with something like this:

{ &hf_myproto_name, { "Name", "myproto.name", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL } },
{ &hf_myproto_name1, { "Name", "myproto.name1", FT_UINT16, BASE_DEC, NULL, 0xFFFE, NULL, HFILL } },
{ &hf_myproto_name2, { "Name", "myproto.name2", FT_UINT8, BASE_DEC, NULL, 0x0F, NULL, HFILL } },

then use

proto_tree_add_item(..., hf_myproto_name, offset, 2, ....);
proto_tree_add_item(..., hf_myproto_name1, offset, 2, ....);
proto_tree_add_item(..., hf_myproto_name2, offset+1, 1, ....);

Although this usually makes little sense for decimal values, rather for hex values.

Jaap's avatar
13.7k
Jaap
answered 2020-04-07 16:37:07 +0000
edit flag offensive 0 remove flag delete link

Comments

add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer