aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2011-03-01 17:29:09 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2011-03-01 17:29:09 +0000
commit5da016099ad3475ad6773b726f321118ab449892 (patch)
treed5bc954bcf1ceca920cd835b1d688ef706af1381
parent3fac9089cb0659f92e24624d96402f41b8ebda87 (diff)
Make HAVE_PCAP_REMOTE and HAVE_PCAP_SETSAMPLING independent
as in other places of the code. Such that this is consistently used. While there, clean up some whitespaces. This fix was provided by Irene Ruengeler which testing remote capturing (with multiple interfaces). svn path=/trunk/; revision=36112
-rw-r--r--capture_opts.c50
-rw-r--r--capture_opts.h21
2 files changed, 35 insertions, 36 deletions
diff --git a/capture_opts.c b/capture_opts.c
index 793477c997..9ca76427c2 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -69,11 +69,11 @@ capture_opts_init(capture_options *capture_opts, void *cf)
capture_opts->datatx_udp = FALSE;
capture_opts->nocap_rpcap = TRUE;
capture_opts->nocap_local = FALSE;
+#endif
#ifdef HAVE_PCAP_SETSAMPLING
capture_opts->sampling_method = CAPTURE_SAMP_NONE;
capture_opts->sampling_param = 0;
#endif
-#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
capture_opts->buffer_size = 1; /* 1 MB */
#endif
@@ -130,7 +130,7 @@ capture_opts_log(const char *log_domain, GLogLevelFlags log_level, capture_optio
g_log(log_domain, log_level, "Interface : %s", capture_opts->iface);
/* iface_descr may not been filled in and some C Libraries hate a null ptr for %s */
g_log(log_domain, log_level, "Interface Descr : %s",
- capture_opts->iface_descr ? capture_opts->iface_descr : "<null>");
+ capture_opts->iface_descr ? capture_opts->iface_descr : "<null>");
#ifdef HAVE_PCAP_REMOTE
g_log(log_domain, log_level, "Capture source : %s",
capture_opts->src_type == CAPTURE_IFLOCAL ? "Local interface" :
@@ -467,7 +467,7 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
break;
case 'i': /* Use interface x */
status = capture_opts_add_iface_opt(capture_opts, optarg_str_p);
- if(status != 0) {
+ if (status != 0) {
return status;
}
break;
@@ -506,10 +506,10 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
case 's': /* Set the snapshot (capture) length */
capture_opts->has_snaplen = TRUE;
capture_opts->snaplen = get_natural_int(optarg_str_p, "snapshot length");
- /*
- * Make a snapshot length of 0 equivalent to the maximum packet
- * length, mirroring what tcpdump does.
- */
+ /*
+ * Make a snapshot length of 0 equivalent to the maximum packet
+ * length, mirroring what tcpdump does.
+ */
if (capture_opts->snaplen == 0)
capture_opts->snaplen = WTAP_MAX_PACKET_SIZE;
break;
@@ -539,7 +539,7 @@ capture_opts_add_opt(capture_options *capture_opts, int opt, const char *optarg_
capture_opts->linktype = linktype_name_to_val(optarg_str_p);
if (capture_opts->linktype == -1) {
cmdarg_err("The specified data link type \"%s\" isn't valid",
- optarg_str_p);
+ optarg_str_p);
return 1;
}
break;
@@ -660,10 +660,10 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
}
if_info = (if_info_t *)if_list->data; /* first interface */
capture_opts->iface = g_strdup(if_info->name);
- /* We don't set iface_descr here because doing so requires
- * capture_ui_utils.c which requires epan/prefs.c which is
- * probably a bit too much dependency for here...
- */
+ /* We don't set iface_descr here because doing so requires
+ * capture_ui_utils.c which requires epan/prefs.c which is
+ * probably a bit too much dependency for here...
+ */
free_interface_list(if_list);
}
}
@@ -683,15 +683,15 @@ gboolean capture_opts_trim_iface(capture_options *capture_opts, const char *capt
/* copied from filesystem.c */
static int capture_opts_test_for_fifo(const char *path)
{
- struct stat statb;
+ struct stat statb;
- if (ws_stat(path, &statb) < 0)
- return errno;
+ if (ws_stat(path, &statb) < 0)
+ return errno;
- if (S_ISFIFO(statb.st_mode))
- return ESPIPE;
- else
- return 0;
+ if (S_ISFIFO(statb.st_mode))
+ return ESPIPE;
+ else
+ return 0;
}
static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_pipe)
@@ -714,17 +714,17 @@ static gboolean capture_opts_output_to_pipe(const char *save_file, gboolean *is_
err = capture_opts_test_for_fifo(save_file);
switch (err) {
- case ENOENT: /* it doesn't exist, so we'll be creating it,
- and it won't be a FIFO */
- case 0: /* found it, but it's not a FIFO */
+ case ENOENT: /* it doesn't exist, so we'll be creating it,
+ and it won't be a FIFO */
+ case 0: /* found it, but it's not a FIFO */
break;
- case ESPIPE: /* it is a FIFO */
+ case ESPIPE: /* it is a FIFO */
*is_pipe = TRUE;
break;
- default: /* couldn't stat it */
- break; /* ignore: later attempt to open */
+ default: /* couldn't stat it */
+ break; /* ignore: later attempt to open */
/* will generate a nice msg */
}
}
diff --git a/capture_opts.h b/capture_opts.h
index 478d41be54..9cd688c32e 100644
--- a/capture_opts.h
+++ b/capture_opts.h
@@ -57,7 +57,7 @@ typedef enum {
CAPTURE_AUTH_NULL, /**< No authentication */
CAPTURE_AUTH_PWD /**< User/password authentication */
} capture_auth;
-
+#endif
#ifdef HAVE_PCAP_SETSAMPLING
/**
* Method of packet sampling (dropping some captured packets),
@@ -72,7 +72,6 @@ typedef enum {
in N milliseconds */
} capture_sampling;
#endif
-#endif
/** Capture options coming from user interface */
typedef struct capture_options_tag {
@@ -81,17 +80,17 @@ typedef struct capture_options_tag {
gboolean has_cfilter; /**< TRUE if capture filter specified on command line */
gchar *cfilter; /**< Capture filter string */
gchar *iface; /**< the network interface to capture from */
- gchar *iface_descr; /**< A human readable description of iface.
- *< NOTE: capture_opts.c is not able to
- *< set this field because doing so
- *< requires too many dependencies.
- *< Readers of this field should use
- *< get_iface_description() from
- *< "capture_ui_utils.h" to access it. */
+ gchar *iface_descr; /**< A human readable description of iface.
+ *< NOTE: capture_opts.c is not able to
+ *< set this field because doing so
+ *< requires too many dependencies.
+ *< Readers of this field should use
+ *< get_iface_description() from
+ *< "capture_ui_utils.h" to access it. */
#ifdef HAVE_PCAP_REMOTE
capture_source src_type; /**< Capturing on remote interface */
gchar *remote_host; /**< Host name or network address
- *< for remote capturing */
+ *< for remote capturing */
gchar *remote_port; /**< TCP port of remote RPCAP server */
capture_auth auth_type;
@@ -101,11 +100,11 @@ typedef struct capture_options_tag {
gboolean datatx_udp; /**< Whether to use UDP for data transfer */
gboolean nocap_rpcap; /**< Whether to capture RPCAP own traffic */
gboolean nocap_local; /**< TODO: Whether to capture local traffic */
+#endif
#ifdef HAVE_PCAP_SETSAMPLING
capture_sampling sampling_method; /**< PCAP packet sampling method */
int sampling_param; /**< PCAP packet sampling parameter */
#endif
-#endif
#if defined(_WIN32) || defined(HAVE_PCAP_CREATE)
int buffer_size; /**< the capture buffer size (MB) */
#endif