forked from osmocom/wireshark
Get rid of NO_INTERFACES_FOUND - it's not an error.
It just means "pcap didn't give me any interfaces, and didn't report an error". Hopefully, in the future, there will be pcap APIs that distinguish between the (admittedly unlikely, these days) case of "there really *are* no interfaces on which *anybody* can capture" and "you don't have sufficient permission to capture", and we can report the latter as an error. (Given that pcap supports more than just "regular interfaces", though, there are cases where you don't have permission to capture on those but you have permission to capture raw USB traffic, for example, so perhaps what's really needed is per-interface indications of permissions.) Change-Id: I7b8abb0829e8502f5259c95e8af31655f79d36a1 Reviewed-on: https://code.wireshark.org/review/3169 Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
parent
4261109e1e
commit
f6ce0cdacd
|
@ -116,6 +116,8 @@ capture_interface_list(int *err, char **err_str, void (*update_cb)(void))
|
|||
|
||||
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_MESSAGE, "Capture Interface List ...");
|
||||
|
||||
*err = 0;
|
||||
|
||||
/* Try to get our interface list */
|
||||
ret = sync_interface_list_open(&data, &primary_msg, &secondary_msg, update_cb);
|
||||
if (ret != 0) {
|
||||
|
@ -188,9 +190,6 @@ capture_interface_list(int *err, char **err_str, void (*update_cb)(void))
|
|||
}
|
||||
g_strfreev(raw_list);
|
||||
|
||||
/* Check to see if we built a list */
|
||||
if (if_list == NULL)
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
#ifdef HAVE_PCAP_REMOTE
|
||||
if (remote_interface_list && g_list_length(remote_interface_list) > 0) {
|
||||
append_remote_list(if_list);
|
||||
|
|
|
@ -457,17 +457,11 @@ capture_opts_add_iface_opt(capture_options *capture_opts, const char *optarg_str
|
|||
}
|
||||
if_list = capture_interface_list(&err, &err_str, NULL);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
case DONT_HAVE_PCAP:
|
||||
if (err == 0)
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
else {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
break;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
|
|
@ -308,7 +308,7 @@ get_interface_list(int *err, char **err_str)
|
|||
/*
|
||||
* No interfaces found.
|
||||
*/
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
*err = 0;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
}
|
||||
|
|
|
@ -437,7 +437,7 @@ get_interface_list_findalldevs_ex(const char *source,
|
|||
/*
|
||||
* No interfaces found.
|
||||
*/
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
*err = 0;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
return NULL;
|
||||
|
@ -474,7 +474,7 @@ get_interface_list_findalldevs(int *err, char **err_str)
|
|||
/*
|
||||
* No interfaces found.
|
||||
*/
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
*err = 0;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
return NULL;
|
||||
|
|
|
@ -865,7 +865,7 @@ get_interface_list(int *err, char **err_str)
|
|||
/*
|
||||
* No interfaces found.
|
||||
*/
|
||||
*err = NO_INTERFACES_FOUND;
|
||||
*err = 0;
|
||||
if (err_str != NULL)
|
||||
*err_str = NULL;
|
||||
}
|
||||
|
|
|
@ -81,8 +81,7 @@ extern GList *capture_interface_list(int *err, char **err_str, void (*update_cb)
|
|||
|
||||
/* Error values from "get_interface_list()/capture_interface_list()". */
|
||||
#define CANT_GET_INTERFACE_LIST 1 /* error getting list */
|
||||
#define NO_INTERFACES_FOUND 2 /* list is empty */
|
||||
#define DONT_HAVE_PCAP 3 /* couldn't load WinPcap */
|
||||
#define DONT_HAVE_PCAP 2 /* couldn't load WinPcap */
|
||||
|
||||
void free_interface_list(GList *if_list);
|
||||
|
||||
|
|
26
dumpcap.c
26
dumpcap.c
|
@ -1430,16 +1430,11 @@ print_statistics_loop(gboolean machine_readable)
|
|||
|
||||
if_list = get_interface_list(&err, &err_str);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
case DONT_HAVE_PCAP:
|
||||
if (err == 0)
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
else {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
break;
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
@ -4755,15 +4750,7 @@ main(int argc, char *argv[])
|
|||
|
||||
if_list = capture_interface_list(&err, &err_str,NULL);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
case DONT_HAVE_PCAP:
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
exit_main(2);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
if (err == 0) {
|
||||
/*
|
||||
* If we're being run by another program, just give them
|
||||
* an empty list of interfaces, don't report this as
|
||||
|
@ -4774,7 +4761,10 @@ main(int argc, char *argv[])
|
|||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
exit_main(2);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
exit_main(2);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
11
tshark.c
11
tshark.c
|
@ -1377,16 +1377,11 @@ main(int argc, char *argv[])
|
|||
#ifdef HAVE_LIBPCAP
|
||||
if_list = capture_interface_list(&err, &err_str,NULL);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
case DONT_HAVE_PCAP:
|
||||
if (err == 0)
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
else {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
break;
|
||||
}
|
||||
return 2;
|
||||
}
|
||||
|
|
|
@ -2329,16 +2329,11 @@ main(int argc, char *argv[])
|
|||
#ifdef HAVE_LIBPCAP
|
||||
if_list = capture_interface_list(&err, &err_str,main_window_update);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
case DONT_HAVE_PCAP:
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
break;
|
||||
if (err == 0)
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
else {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
}
|
||||
exit(2);
|
||||
}
|
||||
|
|
|
@ -1076,6 +1076,13 @@ fill_capture_box(void)
|
|||
capture_interface_list(&error, &err_str,main_window_update);
|
||||
switch (error) {
|
||||
|
||||
case 0:
|
||||
label_text = g_strdup("No interface can be used for capturing in "
|
||||
"this system with the current configuration.\n"
|
||||
"\n"
|
||||
"See Capture Help below for details.");
|
||||
break;
|
||||
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
label_text = g_strdup_printf("No interface can be used for capturing in "
|
||||
"this system with the current configuration.\n\n"
|
||||
|
@ -1085,13 +1092,6 @@ fill_capture_box(void)
|
|||
err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
label_text = g_strdup("No interface can be used for capturing in "
|
||||
"this system with the current configuration.\n"
|
||||
"\n"
|
||||
"See Capture Help below for details.");
|
||||
break;
|
||||
|
||||
case DONT_HAVE_PCAP:
|
||||
label_text = g_strdup("WinPcap doesn't appear to be installed. "
|
||||
"In order to capture packets, WinPcap "
|
||||
|
@ -1140,7 +1140,7 @@ fill_capture_box(void)
|
|||
g_signal_connect(w, "activate-link", G_CALLBACK(activate_link_cb), NULL);
|
||||
#endif
|
||||
g_object_set_data(G_OBJECT(welcome_hb), CAPTURE_LABEL, w);
|
||||
if (error == CANT_GET_INTERFACE_LIST || error == NO_INTERFACES_FOUND) {
|
||||
if (error == CANT_GET_INTERFACE_LIST || error == 0) {
|
||||
item_hb_refresh = welcome_button(GTK_STOCK_REFRESH,
|
||||
"Refresh Interfaces",
|
||||
"Get a new list of the local interfaces.",
|
||||
|
|
|
@ -1775,7 +1775,7 @@ ifopts_if_liststore_add(void)
|
|||
|
||||
if_list = capture_interface_list(&err, &err_str, main_window_update); /* if_list = ptr to first element of list (or NULL) */
|
||||
if (if_list == NULL) {
|
||||
if (err != NO_INTERFACES_FOUND) {
|
||||
if (err != 0) {
|
||||
simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, "%s", err_str);
|
||||
}
|
||||
g_free(err_str);
|
||||
|
|
|
@ -673,16 +673,11 @@ int main(int argc, char *argv[])
|
|||
#ifdef HAVE_LIBPCAP
|
||||
if_list = capture_interface_list(&err, &err_str,main_window_update);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
case DONT_HAVE_PCAP:
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
break;
|
||||
if (err == 0)
|
||||
cmdarg_err("There are no interfaces on which a capture can be done");
|
||||
else {
|
||||
cmdarg_err("%s", err_str);
|
||||
g_free(err_str);
|
||||
}
|
||||
exit(2);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue