Wireshark-dev: Re: [Wireshark-dev] How to build the simple ASN.1 UDP-based dissector example (f
From: Graham Bloice <graham.bloice@xxxxxxxxxxxxx>
Date: Tue, 13 Apr 2021 16:45:57 +0100
Just to reset what I think are some misconceptions here:

  1. CMake, despite having the verb "Make" in its name, doesn't make the application.  CMake makes something (depends on the platform, i.e. a Makefile or ninja build file or Visual Studio solution\project files) that then allows you to make the application, this is the "generator" specified when running CMake.  CMake can also create some source files, e.g. config.h for use when making the application.
  2. The CMake generation produces build artefacts that have multiple targets to make the distinct parts of a complex application such as Wireshark.
  3. There is a build target , that will generate all the asn1 based dissectors.  Each dissector also has its own specific target, e.g. .  This isn't run from the top level Wireshark target as we don't need to degenerate the asn1 dissectors on each build, only when something in them changes.
  4. The method to specify a build target vary with the build mechanism.  For VisualStudio you can specify the project file or the solution file with a /t:xxx argument to specify the target (each project file is a target).  Pascal has shown how it's done for Ninja builds.
  5. There is a target for each asn1 based dissector; "generate_dissector-foo" and a target to generate all the asn1 dissectors, "asn1".
  6. The magic part of CMake that invokes asn2wrs to generate the dissectors from the asn1 files (and other bits) is in cmake\modules\UserAsn2Wrs.cmake and this is invoked in each dissectors specific CMakeLists.txt via the CMake macro ASN2WRS().  The asn1 target is generated by the CMakeLists.txt in epan/dissectors/asn1 and simply adds each generated dissector target as a dependency of the asn1 target.

On Tue, 13 Apr 2021 at 16:03, Pascal Quantin <pascal@xxxxxxxxxxxxx> wrote:
Hi Vicent,

Le mar. 13 avr. 2021 à 16:53, Vincent Randal <vtrandal@xxxxxxxxx> a écrit :
I should give that a try. What version of Windows and tools are you using? I’m beat. I need to do something that works soon.

No need to install Windows; it works the same way on Linux. Go to your build folder and run:
ninja epan/dissectors/asn1/foo/generate_dissector-foo
Assuming you are using ninja, otherwise replace it by make.
The target should have been created iby running CMake after the addition of the CMakeListsCustom.txt file.

Best regards.


On Tue, Apr 13, 2021 at 8:47 AM Anders Broman via Wireshark-dev <wireshark-dev@xxxxxxxxxxxxx> wrote:

Hi,

I don’t think they are generated what will be generated are the files needed to DO the generation.

On windows the next step is to run

msbuild /m /p:Configuration=RelWithDebInfo  epan\dissectors\asn1\h248\generate_dissector-h248.vcxproj

which will the generate the .c and .h files

Regards

Anders

 

From: Wireshark-dev <wireshark-dev-bounces@xxxxxxxxxxxxx> On Behalf Of Vincent Randal
Sent: den 13 april 2021 16:40
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Subject: Re: [Wireshark-dev] How to build the simple ASN.1 UDP-based dissector example (foo)

 

Correct insofar as there are no generated files associated with asn1/foo directory. Namely, packet-foo.c and packet-foo.h did not get generated. But maybe that's not definitive proof that asn1/foo dissector did not get built. How else can I confirm the dissector was or was not built? Open Wireshark and attempt to apply "foo" as a display filter? It's not there.

 

On Tue, Apr 13, 2021 at 8:10 AM Anders Broman via Wireshark-dev <wireshark-dev@xxxxxxxxxxxxx> wrote:

Hi,

So you are saying that if you create foo dir like

epan/dissectors/asn1/foo/

Rename and update the custom cmake file to

set(CUSTOM_ASN1_SRC_DIR

                           foo

)

And place your source file and cmake.txt in the foo dir then rerun the cmake process

Nothing happens?

Try to delete the build dir  before rerunning cmake again?

I’m not sure on linux if the generate cmake file ends up under the build dir or in the source dir.

 

Regards

Anders

From: Wireshark-dev <wireshark-dev-bounces@xxxxxxxxxxxxx> On Behalf Of Vincent Randal
Sent: den 13 april 2021 15:32
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Subject: Re: [Wireshark-dev] How to build the simple ASN.1 UDP-based dissector example (foo)

 

I tried renaming ./epan/dissectors/asn1/CMakeListsCustom.txt.example to CMakeListsCustom.txt with an entry as follows:

# Add a list of your custom asn1 dissectors here
set(CUSTOM_ASN1_SRC_DIR
   foo
)

 

Again, the build did not update any targets even with that change. But this is progress because that underscores the Step by Step instructions need to be updated to something that works. Any more ideas?

 

On Tue, Apr 13, 2021 at 7:12 AM John Thacker <johnthacker@xxxxxxxxx> wrote:

On Tue, Apr 13, 2021, 8:32 AM Vincent Randal <vtrandal@xxxxxxxxx> wrote:

Hello everyone,

 

I need help building the simple ASN.1 UDP-based dissector example (foo); specifically, I need help building the generate_dissector-*proto* target (Step #6 below). I'm certainly missing something here.

 

 

(c) I created directory "foo" by extracting the attachment (foo.tgz) in epan/dissectors/asn1/

(d) There is a CMakeListsCustom.txt.example file in epan/dissectors/asn1 which already contains an entry for "foo".

(e) Since I don't know what to do in Step #6, I build Wireshare (using cmake), but no build targets get updated.

 

If the solution to this problem belongs in the Wireshark documentation, I would be glad to help update the documentation. Namely, I don't understand the usage of the 5 (five) CMakeListsCustom.txt.example files inWireshark source code.

 

The CMakeListsCustom.txt.example files are just that, examples. You need to copy or rename them to CMakeListsCustom.txt (without the .example) for them to have any effect (and edit them appropriately to add the dissector name to the list, not commented out.)

 

CMake is configured to look for the files by that name.

 

John Thacker



--
Graham Bloice