Ask Your Question
0

writing a modular dissector plugin [closed]

asked 2018-04-17 13:01:01 +0000

tof gravatar image

updated 2018-04-17 13:45:51 +0000

Hello

After having spent a few hours in prototyping my custom protocol dissector with LUA, I decided to switch to C implementation as we already have a code base in C/C++ parsing the frames.

I have now a basic dissector written in C. (on Win10 x64 / VS2015 / 2.9.0rc of WS)

I wanted to split my packet-foo.c file into several .h/.c/(*.cpp) files. (I didn't write any C code for a long time, but I think I may not be too far). I get something like that:

#include "config.h"
#include <epan/packet.h>
#include "fooheader.h"   //HERE IS MY PROBLEM
//I'm getting the following:
//Error C1083   Cannot open include file: 'fooheader.h': No such file or directory

static int proto_foo = -1;


static int
dissect_foo(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data)
{
    //...
    extractHeader();
    //...
}

I tried different things in the CMakeList.txt, but didn't find out how to remedy. What did I miss?

I had already extracted some code in that fooheader.cpp/fooheader.h file for the header extraction. Including "fooheader.h" from fooheader.c doesn't seem to be a problem. Why is it the case from the base file (packet-foo.c)?

Thanks

Christophe

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by tof
close date 2018-04-17 16:03:20.306378

Comments

Not sure what problem you try to point to, I can only suggest looking at the other plugin dissectors in the source tree (e.g. wimax) to see how multiple files are being included in the build.

Jaap gravatar imageJaap ( 2018-04-17 13:34:35 +0000 )edit

Thanks @Jaap. I've updated the code part indicating the error at compilation

tof gravatar imagetof ( 2018-04-17 13:46:49 +0000 )edit

2 Answers

Sort by ยป oldest newest most voted
0

answered 2018-04-17 16:00:23 +0000

tof gravatar image

OK, I got it. As a C# developer, I was creating the new files directly in VS (right click, add...). But as the build tree is generated from Cmake, this approcah is not valid.

Now that I create the new source files in the source directory and no more in the compilation directory everything is fine.

edit flag offensive delete link more
0

answered 2018-04-17 13:54:58 +0000

grahamb gravatar image

Visual Studio has a slightly different search order for include files than other compilers, details here.

If you use the quoted form, then the directory containing the source file is prepended onto the search path.

What is the relationship of the path to the source file you show above (packet-foo.c ??) and the file you are attempting to include, fooheader.h?

edit flag offensive delete link more

Comments

They are in the same folder

tof gravatar imagetof ( 2018-04-17 13:56:34 +0000 )edit

Then I don't think it's a failure to include, more likely a failure to parse properly. What is the error reported?

grahamb gravatar imagegrahamb ( 2018-04-17 14:04:13 +0000 )edit

Question Tools

1 follower

Stats

Asked: 2018-04-17 13:01:01 +0000

Seen: 50 times

Last updated: Apr 17