Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How can I get the field's value of hf_register_info?

Sorry if my question isn't clear, I'm a bit lost in wireshark's code and all the dissector's examples.

My proto_register looks like this:

void
proto_register_mycustom(void) {

  static hf_register_info hf[] = {
    { &hf[F_NTM],
      { "ntm", "ntm",
      FT_STRING, BASE_NONE,
      NULL, 0x0, NULL, HFILL }},

I add an item like this:

proto_tree_add_item(tree_body, hf[field], tvb, offset + format.offset + offsetMsg, format.len, ENC_LITTLE_ENDIAN);

Is there a way to get the value in the type (FT_STRING or another one) of hf[field] without accessing it with offset and tvb?

I find this to be redundant:

tvb_get_gint32(tvb, offset + format.offset + offsetMsg, ENC_LITTLE_ENDIAN)

Regards,

click to hide/show revision 2
None

How can I get the field's value of hf_register_info?

Sorry if my question isn't clear, I'm a bit lost in wireshark's code and all the dissector's examples.

My proto_register looks like this:

void
proto_register_mycustom(void) {

  static hf_register_info hf[] = {
    { &hf[F_NTM],
      { "ntm", "ntm",
      FT_STRING, BASE_NONE,
      NULL, 0x0, NULL, HFILL }},

I add an item like this:

proto_tree_add_item(tree_body, hf[field], tvb, offset + format.offset + offsetMsg, format.len, ENC_LITTLE_ENDIAN);

Is there a way to get the value in the type (FT_STRING or another one) of hf[field] without accessing it with offset and tvb?

I find this to be redundant:

tvb_get_gint32(tvb, offset + format.offset + offsetMsg, ENC_LITTLE_ENDIAN)

Regards,

How can I get the field's value of hf_register_info?when adding it to the protocol tree?

Sorry if my question isn't clear, I'm a bit lost in wireshark's code and all the dissector's examples.

My proto_register looks like this:

void
proto_register_mycustom(void) {

  static hf_register_info hf[] = {
    { &hf[F_NTM],
      { "ntm", "ntm",
      FT_STRING, BASE_NONE,
FT_UINT16, BASE_DEC,
      NULL, 0x0, NULL, HFILL }},

I add an item like this:

proto_tree_add_item(tree_body, hf[field], tvb, offset + format.offset + offsetMsg, format.len, ENC_LITTLE_ENDIAN);

Is there a way to get the value in the type (FT_STRING or another one) of hf[field] without accessing it with offset and tvb?

I find this to be redundant:

tvb_get_gint32(tvb, offset + format.offset + offsetMsg, ENC_LITTLE_ENDIAN)

Regards,