diff --git a/capture_opts.c b/capture_opts.c index 3c88d282ff..785a22a5c1 100644 --- a/capture_opts.c +++ b/capture_opts.c @@ -928,9 +928,12 @@ capture_opts_trim_ring_num_files(capture_options *capture_opts) #endif } - +/* + * If no interface was specified explicitly, pick a default. + */ int -capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device) +capture_opts_default_iface_if_necessary(capture_options *capture_opts, + const char *capture_device) { int status; diff --git a/capture_opts.h b/capture_opts.h index b6dfa80ece..c380b9d145 100644 --- a/capture_opts.h +++ b/capture_opts.h @@ -252,9 +252,10 @@ capture_opts_trim_snaplen(capture_options *capture_opts, int snaplen_min); extern void capture_opts_trim_ring_num_files(capture_options *capture_opts); -/* trim the interface entry */ +/* pick default interface if none was specified */ extern int -capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device); +capture_opts_default_iface_if_necessary(capture_options *capture_opts, + const char *capture_device); extern void collect_ifaces(capture_options *capture_opts); diff --git a/dumpcap.c b/dumpcap.c index bea4537176..509398c843 100644 --- a/dumpcap.c +++ b/dumpcap.c @@ -4716,7 +4716,7 @@ main(int argc, char *argv[]) * "-L", "-d", and capturing act on a particular interface, so we have to * have an interface; if none was specified, pick a default. */ - status = capture_opts_trim_iface(&global_capture_opts, NULL); + status = capture_opts_default_iface_if_necessary(&global_capture_opts, NULL); if (status != 0) { /* cmdarg_err() already called .... */ exit_main(status); diff --git a/tshark.c b/tshark.c index 2481db9817..a0c1991799 100644 --- a/tshark.c +++ b/tshark.c @@ -1937,11 +1937,11 @@ main(int argc, char *argv[]) } } else { /* No capture file specified, so we're supposed to do a live capture - (or get a list of link-layer types for a live capture device); + or get a list of link-layer types for a live capture device; do we have support for live captures? */ #ifdef HAVE_LIBPCAP - /* trim the interface name and exit if that failed */ - exit_status = capture_opts_trim_iface(&global_capture_opts, + /* if no interface was specified, pick a default */ + exit_status = capture_opts_default_iface_if_necessary(&global_capture_opts, ((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL); if (exit_status != 0) return exit_status; diff --git a/ui/gtk/main.c b/ui/gtk/main.c index f88f5fd6b6..580642478d 100644 --- a/ui/gtk/main.c +++ b/ui/gtk/main.c @@ -2848,8 +2848,10 @@ main(int argc, char *argv[]) } if (start_capture || list_link_layer_types) { - /* Did the user specify an interface to use? */ - status = capture_opts_trim_iface(&global_capture_opts, + /* We're supposed to do a live capture or get a list of link-layer + types for a live capture device; if the user didn't specify an + interface to use, pick a default. */ + status = capture_opts_default_iface_if_necessary(&global_capture_opts, ((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL); if (status != 0) { exit(status); diff --git a/ui/qt/main.cpp b/ui/qt/main.cpp index 97bbef5db8..19679a9bb6 100644 --- a/ui/qt/main.cpp +++ b/ui/qt/main.cpp @@ -905,8 +905,10 @@ int main(int argc, char *argv[]) // } // if (start_capture || list_link_layer_types) { -// /* Did the user specify an interface to use? */ -// status = capture_opts_trim_iface(&global_capture_opts, +// /* We're supposed to do a live capture or get a list of link-layer +// types for a live capture device; if the user didn't specify an +// interface to use, pick a default. */ +// status = capture_opts_default_iface_if_necessary(&global_capture_opts, // (prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL); // if (status != 0) { // exit(status);