gchar *err_str;
interface_options interface_opts;
- /* retrieve the interface list to compare the option specfied against */
+ /*
+ * Retrieve the interface list against which to compare the specified
+ * option.
+ */
if_list = capture_interface_list(&err, &err_str);
if (if_list == NULL) {
switch (err) {
cmdarg_err("There are no interfaces on which a capture can be done");
break;
}
- return 1;
+ return 2;
}
-
/*
* If the argument is a number, treat it as an index into the list
* of adapters, as printed by "tshark -D".
}
-gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device)
+int
+capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device)
{
int status;
/* Did the user specify an interface to use? */
if (capture_opts->num_selected != 0 || capture_opts->ifaces->len != 0) {
- /* yes they did, exit immediately nothing further to do here */
- return TRUE;
+ /* yes they did, return immediately - nothing further to do here */
+ return 0;
}
/* No - is a default specified in the preferences file? */
if (capture_device != NULL) {
/* Yes - use it. */
status = capture_opts_add_iface_opt(capture_opts, capture_device);
- if (status == 0)
- return TRUE; /* interface found */
- return FALSE; /* some kind of error finding interface */
+ return status;
}
/* No default in preferences file, just pick the first interface from the list of interfaces. */
- status = capture_opts_add_iface_opt(capture_opts, "1");
- if (status == 0)
- return TRUE; /* success */
- return FALSE; /* some kind of error finding the first interface */
+ return capture_opts_add_iface_opt(capture_opts, "1");
}
-
-
#ifndef S_IFIFO
#define S_IFIFO _S_IFIFO
#endif
capture_opts_trim_ring_num_files(capture_options *capture_opts);
/* trim the interface entry */
-extern gboolean
+extern int
capture_opts_trim_iface(capture_options *capture_opts, const char *capture_device);
extern void
* "-L", "-d", and capturing act on a particular interface, so we have to
* have an interface; if none was specified, pick a default.
*/
- if (capture_opts_trim_iface(&global_capture_opts, NULL) == FALSE) {
+ status = capture_opts_trim_iface(&global_capture_opts, NULL);
+ if (status != 0) {
/* cmdarg_err() already called .... */
- exit_main(1);
+ exit_main(status);
}
/* Let the user know what interfaces were chosen. */
do we have support for live captures? */
#ifdef HAVE_LIBPCAP
/* trim the interface name and exit if that failed */
- if (!capture_opts_trim_iface(&global_capture_opts,
- ((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL)) {
- return 2;
- }
+ exit_status = capture_opts_trim_iface(&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;
/* if requested, list the link layer types and exit */
if (list_link_layer_types) {
if (start_capture || list_link_layer_types) {
/* Did the user specify an interface to use? */
- if (!capture_opts_trim_iface(&global_capture_opts,
- ((prefs_p->capture_device) && (*prefs_p->capture_device != '\0')) ? get_if_name(prefs_p->capture_device) : NULL)) {
- exit(2);
+ status = capture_opts_trim_iface(&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);
}
}
// if (start_capture || list_link_layer_types) {
// /* Did the user specify an interface to use? */
-// if (!capture_opts_trim_iface(&global_capture_opts,
-// (prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL)) {
-// exit(2);
+// status = capture_opts_trim_iface(&global_capture_opts,
+// (prefs_p->capture_device) ? get_if_name(prefs_p->capture_device) : NULL);
+// if (status != 0) {
+// exit(status);
// }
// }