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

My Packet Data: 04 1A 0C 68 00 01 00 00 4D 15 00 04 9D F6 10 3A | 9E 0E 95 34 9E 33 38 D3 75 31 74 63 5E 07:

Node: 04 1A Counter: 0C 68 Type: 00 01 Channel: 00 00 RTU: 4D 15 Number of Register(s): 00 04 Register: 9D F6 Register Data: 10 3A

I need my Dissector to loop through and add the below until the total Number of Register(s) 00 04 is satisfied: "proto_tree_add_item(ar_tree, hf_ar_reg, tvb, MSG_REG_OS, MSG_REG_SZ, ENC_NA );" & "proto_tree_add_item(ar_tree, hf_ar_regdata, tvb, MSG_REGDATA_OS, MSG_REGDATA_SZ, ENC_NA );"

Thoughts?

asked 18 Jan '13, 05:54

jballard1979's gravatar image

jballard1979
207710
accept rate: 0%


Trick is to get the value out of the TVB:

    guint16 num_of_registers = tvb_get_ntohs(tvb, offset);
where offset is the offset in the TVB where this count can be found (MSG_NUM_REG_OS ?). Now loop, call proto_tree_add_item() and advance the offset while you go:
    offset = MSG_REG_OS;
    for (i=0; i<num_of_registers; i++)
    {
        proto_tree_add_item(ar_tree, hf_ar_reg, tvb, offset, MSG_REG_SZ, ENC_NA);
        offset += MSG_REG_SZ;
        proto_tree_add_item(ar_tree, hf_ar_regdata, tvb, offset, MSG_REGDATA_SZ, ENC_NA);
        offset += MSG_REGDATA_SZ;
    }

permanent link

answered 18 Jan '13, 15:21

Jaap's gravatar image

Jaap ♦
11.7k16101
accept rate: 14%

edited 18 Jan '13, 15:22

AWESOME... Worked like a charm. Thanks :)

(18 Jan '13, 16:23) jballard1979
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×637
×16
×5

question asked: 18 Jan '13, 05:54

question was seen: 1,880 times

last updated: 18 Jan '13, 16:23

p​o​w​e​r​e​d by O​S​Q​A