Wireshark-dev: Re: [Wireshark-dev] splitting dissector code

From: Riya Dixit <Riya.Dixit@xxxxxxx>
Date: Thu, 21 Jul 2022 07:31:18 +0000
You are referring to right document, can I not have one main file dissecting up till the common byte for all pldm message and them write a different function for different spec like bios, base in different files and call that function in the main dissector code. 
I was trying to do this but then how should I handle proto_register_foo

From: Wireshark-dev <wireshark-dev-bounces@xxxxxxxxxxxxx> on behalf of Guy Harris <gharris@xxxxxxxxx>
Sent: Thursday, July 21, 2022 12:55:43 PM
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Subject: [EXTERNAL] Re: [Wireshark-dev] splitting dissector code
 
On Jul 20, 2022, at 11:58 PM, Riya Dixit <Riya.Dixit@xxxxxxx> wrote:

> I am beginner in writing a small dissector for PLDM protocol.

Is that this PLDM protocol?

        https://www.dmtf.org/sites/default/files/standards/documents/DSP0240_1.1.0.pdf

> And I am stuck at a situation where I should split the dissector code into different files based of different specifications (I don’t imply having different dissectors).

I.e., by "different specifications" you don't mean "different versions of the protocol that have different packet formats and thus might involve different dissectors for different versions", you mean "the protocol is described by several different documents" - for example, there's a base standard for the core of the protocol, and various profiles for various different types of information sent using the protocol, and the base standard and documents for various profiles are separate?

> Is it possible to have proto_register_pldm for a dissector in two different file

No, because the names of the proto_register routines are not local to the source file, they're global, and you can no more have multiple versions of a non-static C function named proto_register_pldm() in a library than you can have multiple versions of a non-static function named C foo() in a library.

> or one dissector can have only one definition in packet-pldm.c file. What is the right way to solve it

That depends on what it is you're trying to do.  We'll need more details; for example, if this is the DTMF PLDM protocol, do you want one file for the PLDM base specification listed above, and other files for, for example, the BIOS Control and Configuration Specification:

        https://www.dmtf.org/sites/default/files/standards/documents/DSP0247_1.0.0.pdf

and so on?  If so, then you would *not* have multiple proto_register_pldm() routines - the file for the base specification would have a routine named proto_register_pldm(), and, for example, the file for the code to dissect stuff from the BIOS Control and Configuration Specification would have a registration routine named proto_register_pldm_bios_c_and_c() or something such as that.
___________________________________________________________________________
Sent via:    Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx>
Archives:    https://www.wireshark.org/lists/wireshark-dev
Unsubscribe: https://www.wireshark.org/mailman/options/wireshark-dev
             mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe