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

Message Box from Dissector Plugin

0

Hi,

is there a possibility to create / open a message box from my own wireshark plugin?

asked 06 Feb '12, 07:41

Nic's gravatar image

Nic
14556
accept rate: 0%


One Answer:

0

There is a possibility to report an error that, IF your dissector is running in Wireshark, will appear as a message box. If it's running in TShark, it will appear as text on the standard output.

The following functions are declared in epan/report_err.h:

To report an arbitrary message, call

report_failure(const char *msg_format, ...);

It takes, as arguments, a printf-style format string and arguments.

To report an error from an attempt to open a file, call

report_open_failure(const char *filename, int err, gboolean for_writing);

It takes, as arguments:

  • the pathname of the file being opened
  • an errno value
  • a Boolean that's TRUE if the failed attempt was to was open the file for writing and FALSE if it was to open the file for reading

To report an error from an attempt to open a file for reading, call

report_read_failure(const char *filename, int err);

It takes the pathname of the file and an errno value as arguments.

To report an error from an attempt to open a file for writing, call

report_write_failure(const char *filename, int err);

It takes the pathname of the file and an errno value as arguments.

answered 06 Feb '12, 09:03

Guy%20Harris's gravatar image

Guy Harris ♦♦
17.4k335196
accept rate: 19%

Hi Guy,

thank you for your answer. This works fine. But is there a possibility to add a dialog with some labels and checkboxes? I tried to use the GtkWidget but this has errors while compiling.

(06 Feb '12, 09:43) Nic

That's a different question, and the answer to it is "no". We do not, and never will, support GUI functions in dissectors, as dissectors can run in command-line programs or Web servers or....

If you want the user to be able to configure options for a dissector, you can register a dissector preference; a checkbox sounds like a Boolean preference, which will show up in the entry for a dissector in the Preferences dialog box as a checkbox. They can also be set from the command line with the "-o" flag.

(06 Feb '12, 09:54) Guy Harris ♦♦

It's actually possible to open a dialog from a Lua dissector, but IMO dialogs should be spawned from outside a dissector (or postdissector or tap) to avoid bugs like repeatedly opening a dialog based on a trigger that occurs multiple times in a pcap.

(06 Feb '12, 10:38) bstn

One would hope that people aren't opening dialogs in dissectors to provide an option better implemented as a preference.

(06 Feb '12, 11:06) Guy Harris ♦♦