Wireshark-dev: Re: [Wireshark-dev] Crash in capture dialog, monitor changed callback (bug 10685

From: Guy Harris <guy@xxxxxxxxxxxx>
Date: Fri, 28 Nov 2014 12:16:23 -0800
On Nov 28, 2014, at 8:13 AM, Peter Wu <peter@xxxxxxxxxxxxx> wrote:

> I came across a duplicated piece of code by grepping for the string "DLT
> n" which I originally found in ui/gtk/capture_dlg.c. Two questions:
> 
> - Can somebody reduce the duplication (two occurrences in
>   ui/gtk/capture_dlg.c, one in ui/qt/manage_interfaces_dialog.cpp)?

> - Why is the callback for capture_prep_monitor_changed_cb so huge?


The set of link-layer header types available on a Wi-Fi interface in monitor mode is, in most platforms, different from the set available when not in monitor mode; in most OSes, you get fake Ethernet headers from Wi-Fi interfaces in monitor mode and 802.11 headers, possibly with radio metadata headers and possibly a choice of multiple types of radio metadata headers (perhaps including "no radio metadata headers"), in monitor mode.

Therefore, the "choose a link-layer header type" widget for an interface has to change its contents if monitor mode is turned on or off for an interface.

If it's possible to share some or all of the code to change the widget with the code to set up the widget in the first place (presumably the source of the duplication), doing so would probably be a good idea.  If it's possible to share some of it between GTK+ and Qt (obviously sharing *all* of it won't be possible without significant additional work), that might also be a good thing to do.