Wireshark-dev: Re: [Wireshark-dev] Actualize kafka dissector
From: Dmitry Lazurkin <dilaz03@xxxxxxxxx>
Date: Tue, 15 Nov 2016 02:03:42 +0300
Second question about using "API version" value in dissect functions. This value may change parsing of packet. For now it passed as argument to some dissect functions. But for now it used only in root dissect function of request/response type (not passed to nested functions). I have next solutions for this:

---------------------------------------
Use current solution: always pass api_version variable to all functions and subfunctions.

Too many arguments for all functions. May be this is normal (:

---------------------------------------
Create context structure and pass it to functions/subfunctions:

typedef struct _kafka_context_t {
    tvbuff_t *tvb;
    packet_info *pinfo;
    guint16 api_version;
    int offset;
} kafka_context_t;

offset field is not necessary. Create instance of this struct in root dissect function as local variable and pass it to dissect functions by pointer. Use context like this:

proto_tree_add_item(tree, hf_kafka_string_len, ctx->tvb, ctx->offset, 2, ENC_BIG_ENDIAN);

Here i have question. Are many pointer dereferences perfomance issue?

---------------------------------------

Create separate function for parsing each version of packet with code duplication. Too much code but may be better for supporting.


I like context but passing version as separate argument is good too. Which solution is better in wireshark community?