Thanks for the guidance. It seems to be working. Now let me go fix the rest of my bad form and clean up the header file.
----- Original Message ----
From: Guy Harris <guy@xxxxxxxxxxxx>
To: Developer support list for Wireshark <wireshark-dev@xxxxxxxxxxxxx>
Sent: Thursday, July 24, 2008 10:35:53 PM
Subject: Re: [Wireshark-dev] Plugin Dissector with multiple .c files
On Jul 24, 2008, at 3:45 PM, Jason Dick wrote:
> It appears that ett_keepalive is -1 when I run wireshark. I have
> defined the ett_keepalive and the ett subtree in the .h file.
>
> static gint ett_keepalive = -1;
> static gint *ett[] = {
> ...
> &ett_keepalive,
> ...
> };
The only things that should be defined in header files are macros and
data types (and inline functions if the compiler supports them; not
all compilers used to compile Wireshark do, so we don't use them).
Defining static variables in a header file is almost always a bad
idea, because each source file that includes the header file gets its
own private copy of those static variables; if one of those variables
gets changed, the other ones don't get changed to match.
> It all works when I have just one source file but when I moved these
> functions to the 2nd file, I started having this problem. Do I need
> to define these in the proto_register function and explicitly pass
> the ett subtree array?
If ett_keepalive is used in more than one .c file, then:
you need to define ett_keepalive in the same source file that has the
proto_register function, and do *NOT* define it as static;
you should define the ett[] array in the proto_register function, and
call proto_register_subtree_array() in that function;
you need to *declare* ett_keepalive in the .h file:
extern gint ett_keepalive;
If you do that, there will be only *one* ett_keepalive variable, and
it will be initialized by proto_register_subtree_array().
_______________________________________________
Wireshark-dev mailing list
Wireshark-dev@xxxxxxxxxxxxx
https://wireshark.org/mailman/listinfo/wireshark-dev