Let capture_dev_user_pmode_find() say "not found".
"Not found" is different from "found, and false". Have it return a boolean "did I find the property" indication and, if it did, supply the property value through a pointer. Change-Id: Iaa942ea346410b35e512ff1a3821cbf60c88dfd6 Reviewed-on: https://code.wireshark.org/review/7916 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
666f9bcfda
commit
c67bc03355
|
@ -237,9 +237,17 @@ capture_dev_user_snaplen_find(const gchar *if_name, gboolean *hassnap, int *snap
|
|||
}
|
||||
|
||||
gboolean
|
||||
capture_dev_user_pmode_find(const gchar *if_name)
|
||||
capture_dev_user_pmode_find(const gchar *if_name, gboolean *pmode)
|
||||
{
|
||||
return (capture_dev_get_if_int_property(prefs.capture_devices_pmode, if_name) != 0);
|
||||
int value;
|
||||
|
||||
value = capture_dev_get_if_int_property(prefs.capture_devices_pmode, if_name);
|
||||
if (value == -1) {
|
||||
/* Not found or bad. */
|
||||
return FALSE;
|
||||
}
|
||||
*pmode = (value != 0);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
gchar*
|
||||
|
|
|
@ -85,8 +85,14 @@ gboolean capture_dev_user_snaplen_find(const gchar *if_name, gboolean *hassnap,
|
|||
/**
|
||||
* Find user-specified promiscuous mode that matches interface
|
||||
* name, if any.
|
||||
*
|
||||
* @param if_name The name of the interface.
|
||||
* @param pmode Pointer to a variable to be set to TRUE if promiscuous
|
||||
* mode should be used and FALSE if it shouldn't be used.
|
||||
*
|
||||
* @return TRUE if found or FALSE if not found.
|
||||
*/
|
||||
gboolean capture_dev_user_pmode_find(const gchar *if_name);
|
||||
gboolean capture_dev_user_pmode_find(const gchar *if_name, gboolean *pmode);
|
||||
|
||||
/**
|
||||
* Find user-specified capture filter that matches interface
|
||||
|
|
|
@ -1272,7 +1272,7 @@ insert_new_rows(GList *list)
|
|||
device.buffer = global_capture_opts.default_options.buffer_size;
|
||||
}
|
||||
#endif
|
||||
if ((device.pmode = capture_dev_user_pmode_find(if_string)) == -1) {
|
||||
if (!capture_dev_user_pmode_find(if_string, &device.pmode)) {
|
||||
device.pmode = global_capture_opts.default_options.promisc_mode;
|
||||
}
|
||||
if (!capture_dev_user_snaplen_find(if_string, &device.has_snaplen,
|
||||
|
@ -5688,8 +5688,7 @@ create_and_fill_model(GtkTreeView *view)
|
|||
}
|
||||
if (!linkname)
|
||||
linkname = g_strdup("unknown");
|
||||
pmode = capture_dev_user_pmode_find(device.name);
|
||||
if (pmode != -1) {
|
||||
if (capture_dev_user_pmode_find(device.name, &pmode)) {
|
||||
device.pmode = pmode;
|
||||
}
|
||||
if (capture_dev_user_snaplen_find(device.name, &hassnap, &snaplen)) {
|
||||
|
|
|
@ -1121,6 +1121,7 @@ ifopts_edit_ifsel_cb(GtkTreeSelection *selection _U_,
|
|||
#endif
|
||||
gint snaplen;
|
||||
gboolean hide, hide_enabled = TRUE, hassnap = FALSE, pmode;
|
||||
gboolean pmode_pref;
|
||||
if_capabilities_t *caps;
|
||||
gint selected = 0;
|
||||
|
||||
|
@ -1163,8 +1164,8 @@ ifopts_edit_ifsel_cb(GtkTreeSelection *selection _U_,
|
|||
|
||||
if (prefs.capture_prom_mode) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(if_pmode_cb), TRUE);
|
||||
} else if (capture_dev_user_pmode_find(if_name) != -1) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(if_pmode_cb), capture_dev_user_pmode_find(if_name));
|
||||
} else if (capture_dev_user_pmode_find(if_name, &pmode_pref)) {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(if_pmode_cb), pmode_pref);
|
||||
} else {
|
||||
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(if_pmode_cb), FALSE);
|
||||
}
|
||||
|
@ -1662,9 +1663,7 @@ ifopts_options_add(GtkListStore *list_store, if_info_t *if_info)
|
|||
if (prefs.capture_prom_mode) {
|
||||
pmode = TRUE;
|
||||
} else {
|
||||
if ((pmode = capture_dev_user_pmode_find(if_info->name)) != -1) {
|
||||
pmode = capture_dev_user_pmode_find(if_info->name);
|
||||
} else {
|
||||
if (!capture_dev_user_pmode_find(if_info->name, &pmode)) {
|
||||
pmode = FALSE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -276,7 +276,7 @@ scan_local_interfaces(void (*update_cb)(void))
|
|||
device.local = TRUE;
|
||||
device.if_info = *temp;
|
||||
device.last_packets = 0;
|
||||
if ((device.pmode = capture_dev_user_pmode_find(if_info->name)) == -1) {
|
||||
if (!capture_dev_user_pmode_find(if_info->name, &device.pmode)) {
|
||||
device.pmode = global_capture_opts.default_options.promisc_mode;
|
||||
}
|
||||
if (!capture_dev_user_snaplen_find(if_info->name, &device.has_snaplen,
|
||||
|
|
|
@ -498,8 +498,7 @@ void CaptureInterfacesDialog::updateInterfaces()
|
|||
}
|
||||
}
|
||||
|
||||
pmode = capture_dev_user_pmode_find(device->name);
|
||||
if (pmode != -1) {
|
||||
if (capture_dev_user_pmode_find(device->name, &pmode)) {
|
||||
device->pmode = pmode;
|
||||
}
|
||||
if (capture_dev_user_snaplen_find(device->name, &hassnap, &snaplen)) {
|
||||
|
|
Loading…
Reference in New Issue