Give Tethereal a "-D" flag, inspired by WinPcap's "-D" flag, which
prints a list of all network interfaces it found on which it can capture (the same list as the one that shows up in the "Interface" combo box in Ethereal's "Capture Preferences" dialog). svn path=/trunk/; revision=3194
This commit is contained in:
parent
7d274106ec
commit
40ba2e9e61
|
@ -7,6 +7,7 @@ Tethereal - Dump and analyze network traffic
|
|||
|
||||
B<tethereal>
|
||||
S<[ B<-c> count ]>
|
||||
S<[ B<-D> ]>
|
||||
S<[ B<-f> capture filter expression ]>
|
||||
S<[ B<-F> file format ]>
|
||||
S<[ B<-h> ]>
|
||||
|
@ -108,6 +109,15 @@ B<-r> flag was specified).
|
|||
Sets the default number of packets to read when capturing live
|
||||
data.
|
||||
|
||||
=item -D
|
||||
|
||||
Prints a list of the interfaces on which B<Tethereal> can capture, and
|
||||
exits. Note that "can capture" means that B<Tethereal> was able to open
|
||||
that device to do a live capture; if, on your system, a program doing a
|
||||
network capture must be run from an account with special privileges (for
|
||||
example, as root), then, if B<Tethereal> is run with the B<-D> flag and
|
||||
is not run from such an account, it will not list any interfaces.
|
||||
|
||||
=item -f
|
||||
|
||||
Sets the capture filter expression.
|
||||
|
|
28
tethereal.c
28
tethereal.c
|
@ -1,6 +1,6 @@
|
|||
/* tethereal.c
|
||||
*
|
||||
* $Id: tethereal.c,v 1.70 2001/03/24 09:24:41 guy Exp $
|
||||
* $Id: tethereal.c,v 1.71 2001/03/27 06:16:10 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -145,7 +145,7 @@ print_usage(void)
|
|||
fprintf(stderr, "This is GNU t%s %s, compiled with %s\n", PACKAGE,
|
||||
VERSION, comp_info_str);
|
||||
#ifdef HAVE_LIBPCAP
|
||||
fprintf(stderr, "t%s [ -vVhlp ] [ -c count ] [ -f <capture filter> ]\n", PACKAGE);
|
||||
fprintf(stderr, "t%s [ -DvVhlp ] [ -c count ] [ -f <capture filter> ]\n", PACKAGE);
|
||||
fprintf(stderr, "\t[ -F <capture file type> ] [ -i interface ] [ -n ]\n");
|
||||
fprintf(stderr, "\t[ -o <preference setting> ] ... [ -r infile ] [ -R <read filter> ]\n");
|
||||
fprintf(stderr, "\t[ -s snaplen ] [ -t <time stamp format> ] [ -w savefile ] [ -x ]\n");
|
||||
|
@ -187,7 +187,7 @@ main(int argc, char *argv[])
|
|||
#ifdef HAVE_LIBPCAP
|
||||
gboolean capture_filter_specified = FALSE;
|
||||
int packet_count = 0;
|
||||
GList *if_list;
|
||||
GList *if_list, *if_entry;
|
||||
gchar err_str[PCAP_ERRBUF_SIZE];
|
||||
#else
|
||||
gboolean capture_option_specified = FALSE;
|
||||
|
@ -304,6 +304,28 @@ main(int argc, char *argv[])
|
|||
arg_error = TRUE;
|
||||
#endif
|
||||
break;
|
||||
case 'D': /* Print a list of capture devices */
|
||||
if_list = get_interface_list(&err, err_str);
|
||||
if (if_list == NULL) {
|
||||
switch (err) {
|
||||
|
||||
case CANT_GET_INTERFACE_LIST:
|
||||
fprintf(stderr, "tethereal: Can't get list of interfaces: %s\n",
|
||||
err_str);
|
||||
break;
|
||||
|
||||
case NO_INTERFACES_FOUND:
|
||||
fprintf(stderr, "tethereal: There are no interfaces on which a capture can be done\n");
|
||||
break;
|
||||
}
|
||||
exit(2);
|
||||
}
|
||||
for (if_entry = g_list_first(if_list); if_entry != NULL;
|
||||
if_entry = g_list_next(if_entry))
|
||||
printf("%s\n", (char *)if_entry->data);
|
||||
free_interface_list(if_list);
|
||||
exit(0);
|
||||
break;
|
||||
case 'f':
|
||||
#ifdef HAVE_LIBPCAP
|
||||
capture_filter_specified = TRUE;
|
||||
|
|
Loading…
Reference in New Issue