Wireshark-dev: [Wireshark-dev] Handling weight for PRIORITY and HEADERS frames for HTTP2 with l

From: Alexander Gryanko <xpahos@xxxxxxxxx>
Date: Fri, 22 Dec 2017 03:19:33 +0300
Hello,

When I try to dissect HTTP2 messages, I found one confusing thing. Here is a definition of fields:

{ &hf_http2_weight,
    { "Weight", "http2.headers.weight",
       FT_UINT8, BASE_DEC, NULL, 0x0,
      "An 8-bit weight for the identified priority", HFILL }
},
{ &hf_http2_weight_real,
    { "Weight real", "http2.headers.weight_real",
       FT_UINT8, BASE_DEC, NULL, 0x0,
      "Real Weight value (Add one to value)", HFILL }
},

Function to fill this fields:

/* helper function to get the priority dependence for the frames that feature them:
   HEADERS and PRIORITY */
static guint
dissect_frame_prio(tvbuff_t *tvb, proto_tree *http2_tree, guint offset, guint8 flags)
{
    proto_tree *ti;
    guint8 weight;

    if(flags & HTTP2_FLAGS_PRIORITY)
    {
        proto_tree_add_item(http2_tree, hf_http2_excl_dependency, tvb, offset, 4, ENC_NA);
        proto_tree_add_item(http2_tree, hf_http2_stream_dependency, tvb, offset, 4, ENC_BIG_ENDIAN);
        offset += 4;
        proto_tree_add_item(http2_tree, hf_http2_weight, tvb, offset, 1, ENC_BIG_ENDIAN);
        weight = tvb_get_guint8(tvb, offset);
        /* 6.2: Weight:  An 8-bit weight for the stream; Add one to the value to obtain a weight between 1 and 256 */
        ti = proto_tree_add_uint(http2_tree, hf_http2_weight_real, tvb, offset, 1, weight+1);
        PROTO_ITEM_SET_GENERATED(ti);
        offset++;
    }

    return offset;
}

So, when we try to access weights for PRIORITY, we need to create a field with Field.new("http2.headers.weight"). Maybe it will be better to split weights for PRIORITY and HEADERS to two different fields http2.priority.weight* and http2.headers.weight*?