Ask Your Question
0

save fields with different mask as an unique field

asked 2020-04-07 14:26:42 +0000

parvaz gravatar image

updated 2020-04-07 14:30:09 +0000

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)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-04-07 16:37:07 +0000

Jaap gravatar image

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.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-04-07 14:26:42 +0000

Seen: 173 times

Last updated: Apr 07 '20