Wireshark-dev: Re: [Wireshark-dev] Iteration in dissectors?
From: Chris Maynard <Chris.Maynard@xxxxxxxxx>
Date: Sun, 22 Jan 2012 18:16:37 +0000 (UTC)
Tyson Key <tyson.key@...> writes:

> My (partially working) iteration code looks like:
> 
> 	     /* Start counting from 13 */
> 	     for (rwe_pos = 13; rwe_pos < tvb_get_guint8(tvb, 13); rwe_pos++) {
> 	       proto_tree_add_item(felica_tree, hf_felica_block_nbr, tvb,
> rwe_pos + 1, 1, ENC_BIG_ENDIAN);
> 	     }

How about something like this:

    /* Start counting from 14 */
    for (rwe_pos = 14; rwe_pos < tvb_get_guint8(tvb, 12); rwe_pos+=2) {
        proto_tree_add_item(felica_tree, hf_felica_block_nbr, tvb, rwe_pos, 1,
ENC_BIG_ENDIAN);
    }

... or if you want the 0x80 byte highlighted as part of the block number
(instead of skipping it), then do something like:

    /* Start counting from 13 */
    for (rwe_pos = 13; rwe_pos < tvb_get_guint8(tvb, 12); rwe_pos+=2) {
        proto_tree_add_uint(felica_tree, hf_felica_block_nbr, tvb, rwe_pos, 2,
tvb_get_guint8(tvb, rwe_pos + 1));
    }

- Chris