Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] still unclear how to build a new ASN.1-based dissector

From: Vincent Randal <vtrandal@xxxxxxxxx>
Date: Sun, 18 Apr 2021 21:06:24 -0600
CORRECTION:  I omitted the troublesome steps (underlined) when describing the problem:
git clone https://<wireshark repo> wireshark
cd wireshark
git checkout wireshark-3.4.4
cd wireshark/epan/dissectors
cp ~/myfoo.tgz . #copy dissector code into wireshark clone
tar xvf myfoo.tgz #extract the dissector code (details in previous email)
cd ../../..
mkdir build
cd build
cmake ../wireshark #this step worked previously but not on a fresh wireshark clone now
make asn1 #with relevant entries in two CMakeListsCustom files
make

On Sun, Apr 18, 2021 at 8:15 PM Vincent Randal <vtrandal@xxxxxxxxx> wrote:
Hello Wireshark-dev community,

Apparently, I still don't have the correct sequence of steps necessary for first time generation of "packet-myfoo.c" and "packet-myfoo.h" for a new ASN.1-based dissector called myfoo. Details follow.

I would like to understand (much better than I do) how to add an ASN.1-based dissector to epan/dissectors/asn1 in a fresh clone of wireshark. I got a lot of help from a lot of people last week (for which I am grateful) but I must still be missing a step here:
git clone https://<wireshark repo> wireshark
cd wireshark
git checkout wireshark-3.4.4
cd ..
mkdir build
cd build
cmake ../wireshark #this step worked previously but not on a fresh wireshark clone now
make asn1 #with relevant entries in two CMakeListsCustom files
make

When I add my dissector folder "myfoo" to epan/dissectors/asn1 here's the relevant error messages from cmake (with some highlighting by me):
-- Configuring done
CMake Error at epan/dissectors/CMakeLists.txt:2004 (add_library):
  Cannot find source file:

    /home/vtrandal/ws1/wireshark/epan/dissectors/packet-myfoo.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .m .M .mm .h .hh .h++ .hm
  .hpp .hxx .in .txx

CMake Error at epan/dissectors/CMakeLists.txt:2004 (add_library):
  No SOURCES given to target: dissectors

[end of cmake error messages]

The point of the above cmake error messages is that the "packet-myfoo.c" and "packet-myfoo.h" files have not yet been generated (and I don't know how to generate them). I do not know how I got past the cmake step before, but I was lucky (and unlucky now). The ASN.1-based dissector code is in the attached .tgz file which I extract in epan/dissectors as follows:
tar xvf myfoo.tgz
./CMakeListsCustom.txt <== contains entry for myfoo
./asn1/CMakeListsCustom.txt <== contains entry for myfoo
./asn1/myfoo/
./asn1/myfoo/myfoo.asn
./asn1/myfoo/myfoo.cnf
./asn1/myfoo/CMakeLists.txt
./asn1/myfoo/packet-myfoo-template.h
./asn1/myfoo/packet-myfoo-template.c

I apologize in advance for being thick-headed about the process of adding a new ASN.1-based dissector to epan/dissectors/asn1 in Wireshark. With help from a lot of people I got it to compile previously (again for which I am grateful). But I cannot repeat that success starting with a fresh clone of wireshark regardless of the branch. Somehow I still don't have the correct sequence of steps necessary to generate "packet-myfoo.c" and "packet-myfoo.h" the first time. With my dissector code in epan/dissectors the cmake step fails and I cannot make  anything.

Vincent

NOTE: The attached dissector code is based on the simple ASN.1-based dissector example online. https://www.wireshark.org/docs/wsdg_html_chunked/SimpleASN1BasedDissector.html