aboutsummaryrefslogtreecommitdiffstats
path: root/ui/iface_lists.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2015-03-22 16:58:42 -0700
committerGuy Harris <guy@alum.mit.edu>2015-03-23 00:00:42 +0000
commit1b4120846ee1a139f7d3ff9c2bfe2eab593745bb (patch)
treef500d385ecbe57b324b5eda1dd6875893630beeb /ui/iface_lists.c
parentc474bb86912aedb13669fb14627b2ad29f082b40 (diff)
Centralize the code to set the active_dlt value for a device.
We were doing it similarly, but not the same, in several places; make a common routine for it. Have that code check to make sure the DLT_ value in question is actually supported by the device; if not, pick the first supported DLT_ value, if any; this keeps it from, for example, picking a bad DLT_ value if your defaults were set based on monitor mode being on but monitor mode actually being off, or vice versa. Change-Id: I1722bfeaf60429bc5c6f665fdea3d466052b13bd Reviewed-on: https://code.wireshark.org/review/7795 Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'ui/iface_lists.c')
-rw-r--r--ui/iface_lists.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/ui/iface_lists.c b/ui/iface_lists.c
index 1310c30a3f..1dfb9b88c3 100644
--- a/ui/iface_lists.c
+++ b/ui/iface_lists.c
@@ -244,28 +244,10 @@ scan_local_interfaces(void (*update_cb)(void))
device.monitor_mode_supported = caps->can_set_rfmon;
#endif
/*
- * If there's a preference for the link-layer header type for
- * this interface, use it. If not, use the all-interface
- * default; if that's not set on the command line, that will
- * be -1, meaning "use per-interface defaults", otherwise
- * we'll fail if it's not one of the types the interface
- * supports.
- */
- if ((device.active_dlt = capture_dev_user_linktype_find(if_info->name)) == -1) {
- device.active_dlt = global_capture_opts.default_options.linktype;
- }
-
- /*
* Process the list of link-layer header types.
- * If the active link-layer header type wasn't set from a
- * preference or a global option (meaning it's -1), default
- * to the first link-layer header type in the list.
*/
for (lt_entry = caps->data_link_types; lt_entry != NULL; lt_entry = g_list_next(lt_entry)) {
data_link_info = (data_link_info_t *)lt_entry->data;
- if (linktype_count == 0 && device.active_dlt == -1) {
- device.active_dlt = data_link_info->dlt;
- }
link = (link_row *)g_malloc(sizeof(link_row));
if (data_link_info->description != NULL) {
link->dlt = data_link_info->dlt;
@@ -277,6 +259,11 @@ scan_local_interfaces(void (*update_cb)(void))
device.links = g_list_append(device.links, link);
linktype_count++;
}
+
+ /*
+ * Set the active DLT for the device appropriately.
+ */
+ set_active_dlt(&device, global_capture_opts.default_options.linktype);
} else {
#if defined(HAVE_PCAP_CREATE)
device.monitor_mode_enabled = FALSE;