This is a static archive of our old Q&A Site. Please post any new questions and answers at ask.wireshark.org.

Wireshark Plugin Help

0

Hi All,

Recently I began to work with Wireshark, so I have little experience with the "plugin" environment or setup. When I attempted to install the plugin by building Wireshark, I got the following errors. Could someone tell me what I'm doing wrong and/or what I can do to fix it?

Thanks!

Ian

packet-ipa.c
c:\Program Files (x86)\wireshark\epan/reassemble.h(69) : error C2061: syntax error : identifier 'guint32'

c:\Program Files (x86)\wireshark\epan/reassemble.h(70) : error C2061: syntax error : identifier 'offset'

c:\Program Files (x86)\wireshark\epan/reassemble.h(70) : error C2059: syntax error : ';'

[non-relevant errors snipped for brevity]

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.EXE"' : return code '0x2'

Stop.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0
VC\BIN\nmake.exe"' : return code '0x2'

Stop.

NMAKE : fatal error U1077: 'if' : return code '0x2'

Stop.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0
VC\BIN\nmake.exe"' : return code '0x2'

Stop.

NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0
VC\BIN\nmake.exe"' : return code '0x2'

Stop.

asked 11 Jun ‘12, 10:47

Ian's gravatar image

Ian
10227
accept rate: 0%

edited 11 Jun ‘12, 14:08

grahamb's gravatar image

grahamb ♦
19.8k330206


2 Answers:

1

From the first error line you seem to be missing the path to glibconfig.h that has the definition of guint32. I suspect that your build environment is't set up correctly. Have you followed all the steps in the Developers Guide for Win32 builds exactly as laid out?

answered 11 Jun '12, 12:03

grahamb's gravatar image

grahamb ♦
19.8k330206
accept rate: 22%

@grahamb,

Thanks for that note, corrected that and half of the errors disappeared.

(11 Jun '12, 12:12) Ian

Okay, however, ...

guint8 flags = tvb_get_guint8(tvb, offset);

is still coming back as an improper use of the guint8 variable, why would this be? A previous use of guint8...

guint8 packet_type = tvb_get_guint8(tvb,0);

did indeed work, but why wouldn't the former line?

(11 Jun '12, 12:30) Ian

What's the exact error message for the error?

It's always best to ensure you can compile a standard copy of Wireshark before you try to add anything new. Have you managed that?

(11 Jun '12, 13:10) grahamb ♦

I have indeed, and everything works fine, but this is the first plugin from scratch for me.


packet-ipa.c(284) : error C2275: 'guint8' : illegal use of this type as an expression C:\wireshark-win32-libs-1.6\gtk2\lib\glib2.0\include\glibconfig.h(36) : see declaration of 'guint8' packet-ipa.c(284) : error C2146: syntax error : missing ';' before identifier 'flags' packet-ipa.c(284) : error C2065: 'flags' : undeclared identifier

(11 Jun '12, 13:22) Ian

Possibly missing a statement terminator on the previous line?

Can you post a bit of context for the erroring statement?

(11 Jun '12, 13:28) grahamb ♦

Can't see the issue :-( Is flags declared earlier in the function?

When stuck like this I just comment out bits until I find what the compiler is upset about.

(11 Jun '12, 13:54) grahamb ♦

Ya, I did mass chunks of commenting and it compiled for the first time :) I'll keep at it, thanks!

(11 Jun '12, 14:03) Ian

I think Anders nailed it. You can't declare flags there.

(11 Jun '12, 15:56) cmaynard ♦♦

While this is true for .c files (I think this is part of the C standard), the usual VS error for this is: error C2143: syntax error : missing ';' before 'type'.

Using this file:

void main(void) { int dummy = 0; dummy = 4*2; int dummy2 = dummy; }

Gives the output:

c:\users\graham\Documents>cl test.c Microsoft (R) C/C++ Optimizing Compiler Version 16.00.40219.01 for x64 Copyright (C) Microsoft Corporation. All rights reserved.

test.c test.c(5) : error C2143: syntax error : missing ';' before 'type'

The error is the same for VS2005 & VS2010

(12 Jun '12, 02:12) grahamb ♦

if you compile that with gcc -pedantic it tells the reason for the error:

[email protected]:/soft$ gcc -pedantic test.c
test.c:1:6: warning: return type of ‘main’ is not ‘int’ [-Wmain]
test.c: In function ‘main’:
test.c:5:1: warning: ISO C90 forbids mixed declarations and code [-pedantic]

Seems to be the C90 standard. gcc accepts the code and does only warn with -pedantic.

(12 Jun '12, 02:44) Kurt Knochner ♦

And that's why we declare all vars in dissectors at the start of the function, for portability. From the Developers Guide (1.1.1 Portability):

Don't declare variables in the middle of executable code; not all C compilers support that. Variables should be declared outside a function, or at the beginning of a function or compound statement.

Still not sure why the OP is getting a different error though.

(12 Jun '12, 03:08) grahamb ♦

Still not sure why the OP is getting a different error though.

hard to say without the code. I assume your previous statement ("Possibly missing a statement terminator") nails it down, as uncommenting large parts of the code "fixes" the problem.

(12 Jun '12, 05:13) Kurt Knochner ♦

Got it to work, thanks guys :)

(12 Jun '12, 07:16) Ian

what was the problem?

(12 Jun '12, 07:29) Kurt Knochner ♦

And that's why we declare all vars in dissectors at the start of the function, for portability. From the Developers Guide (1.1.1 Portability):

Don't declare variables in the middle of executable code; not all C compilers support that. Variables should be declared outside a function, or at the beginning of a function or compound statement.


What Graham said basically summed it up: VS didn't like me putting declarations within functions themselves, so I declared all vars that were giving me errors at the beginning :)

(12 Jun '12, 07:35) Ian
showing 5 of 15 show 10 more comments

0

There is a syntax error in your code either before or with the include statement for

#include <epan/reassemble.h>

Please post 10-20 lines of your code in front of the include statement.

Regards
Kurt

answered 11 Jun '12, 11:34

Kurt%20Knochner's gravatar image

Kurt Knochner ♦
24.8k1039237
accept rate: 15%

Hi Kurt,

Thanks for replying so quickly, here's the lines.

ifdef HAVE_CONFIG_H

include "config.h"

endif

/ Include only as needed /

include <stdio.h>

include <gmodule.h>

include <stdlib.h>

include <string.h>

include <glib.h>

include <epan packet.h="">

include <epan prefs.h="">

include <epan emem.h="">

include <epan reassemble.h="">

(11 Jun '12, 12:09) Ian

the last include statements look pretty strange, but I guess that's just a copy-paste error with the Q&A site, right?

(11 Jun '12, 12:51) Kurt Knochner ♦

Ya, it should be:

include <epan.reassemble.h> with the # in front

(11 Jun '12, 13:23) Ian
1

Windows does not like declarations in the middle of the code, is that what you are doing?

(11 Jun '12, 13:45) Anders ♦

These are declarations at the top of the plugin I'm trying to write, and I was showing Kurt that the include statements should be correct.

#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

/* Include only as needed */ #include <stdio.h> #include <gmodule.h> #include <stdlib.h> #include <string.h>

#include <glib.h>

#include <epan/packet.h> #include <epan/prefs.h> #include <epan/emem.h> #include <epan/reassemble.h>

(11 Jun ‘12, 13:54) Ian

Loose the gmodule.h include.

(12 Jun ‘12, 05:45) Jaap ♦
showing 5 of 6 show 1 more comments