aboutsummaryrefslogtreecommitdiffstats
path: root/tshark.c
diff options
context:
space:
mode:
authorMichael Tüxen <tuexen@fh-muenster.de>2011-05-18 18:03:58 +0000
committerMichael Tüxen <tuexen@fh-muenster.de>2011-05-18 18:03:58 +0000
commit985c2b78fdad23b1eed5415520063e0f3748af1f (patch)
treec906ca1b77e4f32e0c25b7a239b327b30af52fda /tshark.c
parentb031b9643af5d4380dd6808eeb43d3ce30c7606e (diff)
Support multiple interfaces when used with -L option.
Show multiple interfaces when capturing from them. svn path=/trunk/; revision=37249
Diffstat (limited to 'tshark.c')
-rw-r--r--tshark.c66
1 files changed, 45 insertions, 21 deletions
diff --git a/tshark.c b/tshark.c
index 001ad9fb30..8572096561 100644
--- a/tshark.c
+++ b/tshark.c
@@ -103,6 +103,7 @@
#include "log.h"
#include <epan/funnel.h>
+#define MSG_MAX_LENGTH 4096
/*
* This is the template for the decode as option; it is shared between the
@@ -1765,24 +1766,27 @@ main(int argc, char *argv[])
/* if requested, list the link layer types and exit */
if (list_link_layer_types) {
- /* Get the list of link-layer types for the capture device. */
- if_capabilities_t *caps;
-
- caps = capture_get_if_capabilities(global_capture_opts.iface,
- global_capture_opts.monitor_mode,
- &err_str);
- if (caps == NULL) {
- cmdarg_err("%s", err_str);
- g_free(err_str);
- return 2;
- }
- if (caps->data_link_types == NULL) {
- cmdarg_err("The capture device \"%s\" has no data link types.", global_capture_opts.iface);
- return 2;
+ guint i;
+ interface_options interface_opts;
+
+ /* Get the list of link-layer types for the capture devices. */
+ for (i = 0; i < global_capture_opts.ifaces->len; i++) {
+ if_capabilities_t *caps;
+
+ interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
+ caps = capture_get_if_capabilities(interface_opts.name, interface_opts.monitor_mode, &err_str);
+ if (caps == NULL) {
+ cmdarg_err("%s", err_str);
+ g_free(err_str);
+ return 2;
+ }
+ if (caps->data_link_types == NULL) {
+ cmdarg_err("The capture device \"%s\" has no data link types.", interface_opts.name);
+ return 2;
+ }
+ capture_opts_print_if_capabilities(caps, interface_opts.name, interface_opts.monitor_mode);
+ free_if_capabilities(caps);
}
- capture_opts_print_if_capabilities(caps, global_capture_opts.iface,
- global_capture_opts.monitor_mode);
- free_if_capabilities(caps);
return 0;
}
@@ -1968,6 +1972,8 @@ static gboolean
capture(void)
{
gboolean ret;
+ guint i;
+ GString *str = g_string_new("");
#ifdef USE_TSHARK_SELECT
fd_set readfds;
#endif
@@ -2041,9 +2047,27 @@ capture(void)
global_capture_opts.state = CAPTURE_PREPARING;
- /* Let the user know what interface was chosen. */
- global_capture_opts.iface_descr = get_interface_descriptive_name(global_capture_opts.iface);
- fprintf(stderr, "Capturing on %s\n", global_capture_opts.iface_descr);
+ /* Let the user know which interfaces were chosen. */
+ for (i = 0; i < global_capture_opts.ifaces->len; i++) {
+ interface_options interface_opts;
+
+ interface_opts = g_array_index(global_capture_opts.ifaces, interface_options, i);
+ interface_opts.descr = get_interface_descriptive_name(interface_opts.name);
+ global_capture_opts.ifaces = g_array_remove_index(global_capture_opts.ifaces, i);
+ g_array_insert_val(global_capture_opts.ifaces, i, interface_opts);
+ if (i > 0) {
+ if (global_capture_opts.ifaces->len > 2) {
+ g_string_append_printf(str, ",");
+ }
+ g_string_append_printf(str, " ");
+ if (i == global_capture_opts.ifaces->len - 1) {
+ g_string_append_printf(str, "and ");
+ }
+ }
+ g_string_append_printf(str, "%s", interface_opts.descr);
+ }
+ fprintf(stderr, "Capturing on %s\n", str->str);
+ g_string_free(str, TRUE);
ret = sync_pipe_start(&global_capture_opts);
@@ -3043,7 +3067,7 @@ print_columns(capture_file *cf)
* the same time, sort of like an "Update list of packets
* in real time" capture in Wireshark.)
*/
- if (global_capture_opts.iface != NULL)
+ if (global_capture_opts.ifaces->len > 0)
continue;
#endif
column_len = strlen(cf->cinfo.col_data[i]);