Wireshark-dev: Re: [Wireshark-dev] 回复: how to use the wireshark source code to developapplicat
From: Pascal Quantin <[email protected]>
Date: Sun, 30 Mar 2014 13:55:57 +0200
(back to the mailing list)


2014-03-30 11:54 GMT+02:00 我想不无聊 <[email protected]>:
If i define the  variable in the wireshark directory and i use it in the /wiretap and  /epan/dissectors whether or not should i use the  WS_DLL_PUBLIC macro,and by the way i use the wireshark 1.6.5 edition,then what should i do.

If you use Wireshark 1.6.5 source code, you must declare your structure as WS_VAR_IMPORT instead of extern, and add it to wtap.def file. Something like:
WS_VAR_IMPORT performance* performance_test;

and in wtap.def:
performance_test DATA

You can look at other examples of the use of WS_VAR_IMPORT in the source code.

Regards,
Pascal.

PS: there is no need to send multiple emails to the mailing list with the same question over and over.


------------------ 原始邮件 ------------------
发件人: "Pascal Quantin";<[email protected]>;
发送时间: 2014年3月30日(星期天) 下午5:06
收件人: "Developer support list for Wireshark"<[email protected]>;
主题: Re: [Wireshark-dev] how to use the wireshark source code to developapplication?


Le 30 mars 2014 08:58, "我想不无聊" <[email protected]> a écrit :
>
> I want to store some information about packets and transmit among files,so i create a file in wireshark root directory,named performance.h:
>
> //performance.h
> #include <glib.h>
> typedef struct performance_s
> {
> gfloat time[100];
>        gfloat delay[100];
> guint32 packetSize[100];
> guint32 payload;
> guint32 index;
> guint32 temp_size;
> gfloat temp_time;
> }performance;
> extern peformance* performance_test;
>
> in the file ,i declare a struct and declare a pointer to it,then i want to use the variable "performance_test" in file wiretap/libpcap.c, epan/dissectors/packet-ieee80211.c,so i define the variable "peformance_test" in performance.c in wireshark root directory  and include the head file in wiretap/libpcap.c, epan/dissectors/packet-ieee80211.c ,but once i use the variable in these two files,when i compile the wireshark project,it come up with one error:undefined reference to 'peformance_test'.
>
> it looks like the variable peformance_test should be defined and used in the same file ,if i want to use it in different files,i think i should modify the makefile.common to change the compile process ,but i don't know how .could someone help me fix it,please!

Hi,

Assuming you work on the master branch (Wireshark 1.11.X), if you want to use in libwireshark a variable defined in libwiretap, you should export the symbol with the WS_DLL_PUBLIC macro instead of using extern. Do not forget to include ws_symbol_export.h file also.
You can search in the code for examples of the use of this macro.

Regards,
Pascal.