diff options
author | Gerald Combs <gerald@wireshark.org> | 2007-07-20 21:43:07 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2007-07-20 21:43:07 +0000 |
commit | c02e0c7b4a2f23916f6bdda16bd124e3a2b83419 (patch) | |
tree | a705612afd4276c7aa9f43738667b6b8a7da2520 /dumpcap.c | |
parent | c1a4caf1b24b7ce38434f8963b3590013912697b (diff) |
Remove the "-I" flag from dumpcap, and add a "-M" flag used to specify
that "-D" and "-L" should produce machine-readable output. Use this to
move an indirect get_pcap_linktype() call from the GUI to dumpcap.
svn path=/trunk/; revision=22367
Diffstat (limited to 'dumpcap.c')
-rw-r--r-- | dumpcap.c | 30 |
1 files changed, 17 insertions, 13 deletions
@@ -115,7 +115,7 @@ print_usage(gboolean print_ver) { fprintf(output, " -y <link type> link layer type (def: first appropriate)\n"); fprintf(output, " -D print list of interfaces and exit\n"); fprintf(output, " -L print list of link-layer types of iface and exit\n"); - fprintf(output, " -I [l|s] print a detailed interface list (l) or interface statistics (s).\n"); + fprintf(output, " -M for -D and -L, produce machine-readable output\n"); fprintf(output, "\n"); fprintf(output, "Stop conditions:\n"); fprintf(output, " -c <packet count> stop after n packets (def: infinite)\n"); @@ -246,10 +246,12 @@ main(int argc, char *argv[]) gboolean stats_known; struct pcap_stat stats; GLogLevelFlags log_flags; + gboolean list_interfaces = FALSE; gboolean list_link_layer_types = FALSE; + gboolean machine_readable = FALSE; int status; -#define OPTSTRING_INIT "a:b:c:Df:hI:i:Lps:vw:y:Z" +#define OPTSTRING_INIT "a:b:c:Df:hi:LMps:vw:y:Z" #ifdef _WIN32 #define OPTSTRING_WIN32 "B:" @@ -366,18 +368,14 @@ main(int argc, char *argv[]) /*** all non capture option specific ***/ case 'D': /* Print a list of capture devices and exit */ - status = capture_opts_list_interfaces(FALSE); - exit_main(status); + list_interfaces = TRUE; break; - /* XXX - We might want to use 'D' for this. Do we use GNU - * getopt on every platform (which supports optional arguments)? */ - /* XXX - Implement interface stats */ - case 'I': - status = capture_opts_list_interfaces(TRUE); - exit_main(status); case 'L': /* Print list of link-layer types and exit */ list_link_layer_types = TRUE; break; + case 'M': /* For -D and -L, print machine-readable output */ + machine_readable = TRUE; + break; default: case '?': /* Bad flag - print usage message */ cmdarg_err("Invalid Option: %s", argv[optind-1]); @@ -408,7 +406,10 @@ main(int argc, char *argv[]) exit_main(1); } - if (list_link_layer_types) { + if (list_interfaces && list_link_layer_types) { + cmdarg_err("Only one of -D or -L may be supplied."); + exit_main(1); + } else if (list_link_layer_types) { /* We're supposed to list the link-layer types for an interface; did the user also specify a capture file to be read? */ /* No - did they specify a ring buffer option? */ @@ -445,8 +446,11 @@ main(int argc, char *argv[]) /* get_interface_descriptive_name() is not available! */ g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "Interface: %s\n", capture_opts->iface); - if (list_link_layer_types) { - status = capture_opts_list_link_layer_types(capture_opts); + if (list_interfaces) { + status = capture_opts_list_interfaces(machine_readable); + exit_main(status); + } else if (list_link_layer_types) { + status = capture_opts_list_link_layer_types(capture_opts, machine_readable); exit_main(status); } |