forked from osmocom/wireshark
In Tethereal, allow capture filters and read filters either to be
specifies with "-f" and "-R" flags, respectively, or specified with non-flag command-line arguments, as tcpdump and snoop allow. svn path=/trunk/; revision=1663
This commit is contained in:
parent
7dbd7d73f6
commit
ca9d89b2ba
|
@ -19,8 +19,9 @@ S<[ B<-s> snaplen ]>
|
|||
S<[ B<-t> time stamp format ]>
|
||||
S<[ B<-v> ]>
|
||||
S<[ B<-V> ]>
|
||||
S<[ B<-w> savefile]>
|
||||
S<[ B<-w> savefile ]>
|
||||
S<[ B<-x> ]>
|
||||
S<[ filter expression ]>
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
|
@ -83,6 +84,13 @@ Compressed file support uses (and therefore requires) the zlib library.
|
|||
If the zlib library is not present, B<Tethereal> will compile, but will
|
||||
be unable to read compressed files.
|
||||
|
||||
A capture or read filter can either be specified with the B<-f> or B<-R>
|
||||
option, respectively, in which case the entire filter expression must be
|
||||
specified as a single argument (which means that if it contains spaces,
|
||||
it must be quoted), or can be specified with command-line arguments
|
||||
after the option arguments, in which case all the arguments after the
|
||||
filter arguments are treated as a filter expression.
|
||||
|
||||
=head1 OPTIONS
|
||||
|
||||
=over 4
|
||||
|
|
30
tethereal.c
30
tethereal.c
|
@ -1,6 +1,6 @@
|
|||
/* tethereal.c
|
||||
*
|
||||
* $Id: tethereal.c,v 1.19 2000/02/19 07:59:54 guy Exp $
|
||||
* $Id: tethereal.c,v 1.20 2000/02/22 07:07:46 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -174,6 +174,7 @@ main(int argc, char *argv[])
|
|||
char *pf_path;
|
||||
int err;
|
||||
#ifdef HAVE_LIBPCAP
|
||||
gboolean capture_filter_specified = FALSE;
|
||||
int packet_count = 0;
|
||||
GList *if_list;
|
||||
gchar err_str[PCAP_ERRBUF_SIZE];
|
||||
|
@ -287,6 +288,7 @@ main(int argc, char *argv[])
|
|||
break;
|
||||
case 'f':
|
||||
#ifdef HAVE_LIBPCAP
|
||||
capture_filter_specified = TRUE;
|
||||
cf.cfilter = g_strdup(optarg);
|
||||
#else
|
||||
capture_option_specified = TRUE;
|
||||
|
@ -361,6 +363,32 @@ main(int argc, char *argv[])
|
|||
}
|
||||
}
|
||||
|
||||
/* If no capture filter or read filter has been specified, and there are
|
||||
still command-line arguments, treat them as the tokens of a capture
|
||||
filter (if no "-r" flag was specified) or a read filter (if a "-r"
|
||||
flag was specified. */
|
||||
if (optind < argc) {
|
||||
if (cf_name != NULL) {
|
||||
if (rfilter != NULL) {
|
||||
fprintf(stderr,
|
||||
"tethereal: Read filters were specified both with \"-R\" and with additional command-line arguments\n");
|
||||
exit(2);
|
||||
}
|
||||
rfilter = get_args_as_string(argc, argv, optind);
|
||||
} else {
|
||||
#ifdef HAVE_LIBPCAP
|
||||
if (capture_filter_specified) {
|
||||
fprintf(stderr,
|
||||
"tethereal: Capture filters were specified both with \"-f\" and with additional command-line arguments\n");
|
||||
exit(2);
|
||||
}
|
||||
cf.cfilter = get_args_as_string(argc, argv, optind);
|
||||
#else
|
||||
capture_option_specified = TRUE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef HAVE_LIBPCAP
|
||||
if (capture_option_specified)
|
||||
fprintf(stderr, "This version of Tethereal was not built with support for capturing packets.\n");
|
||||
|
|
42
util.c
42
util.c
|
@ -1,7 +1,7 @@
|
|||
/* util.c
|
||||
* Utility routines
|
||||
*
|
||||
* $Id: util.c,v 1.36 2000/02/09 19:17:52 gram Exp $
|
||||
* $Id: util.c,v 1.37 2000/02/22 07:07:46 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -183,6 +183,46 @@ get_dirname(char *path)
|
|||
return path;
|
||||
}
|
||||
|
||||
/*
|
||||
* Collect command-line arguments as a string consisting of the arguments,
|
||||
* separated by spaces.
|
||||
*/
|
||||
char *
|
||||
get_args_as_string(int argc, char **argv, int optind)
|
||||
{
|
||||
int len;
|
||||
int i;
|
||||
char *argstring;
|
||||
|
||||
/*
|
||||
* Find out how long the string will be.
|
||||
*/
|
||||
len = 0;
|
||||
for (i = optind; i < argc; i++) {
|
||||
len += strlen(argv[i]);
|
||||
len++; /* space, or '\0' if this is the last argument */
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate the buffer for the string.
|
||||
*/
|
||||
argstring = g_malloc(len);
|
||||
|
||||
/*
|
||||
* Now construct the string.
|
||||
*/
|
||||
strcpy(argstring, "");
|
||||
i = optind;
|
||||
for (;;) {
|
||||
strcat(argstring, argv[i]);
|
||||
i++;
|
||||
if (i == argc)
|
||||
break;
|
||||
strcat(argstring, " ");
|
||||
}
|
||||
return argstring;
|
||||
}
|
||||
|
||||
static char *
|
||||
setup_tmpdir(char *dir)
|
||||
{
|
||||
|
|
8
util.h
8
util.h
|
@ -1,7 +1,7 @@
|
|||
/* util.h
|
||||
* Utility definitions
|
||||
*
|
||||
* $Id: util.h,v 1.18 2000/01/29 16:41:15 gram Exp $
|
||||
* $Id: util.h,v 1.19 2000/02/22 07:07:47 guy Exp $
|
||||
*
|
||||
* Ethereal - Network traffic analyzer
|
||||
* By Gerald Combs <gerald@zing.org>
|
||||
|
@ -48,6 +48,12 @@ int create_tempfile(char *, int, const char *);
|
|||
* variable, or a default directory if HOME is not set */
|
||||
const char* get_home_dir(void);
|
||||
|
||||
/*
|
||||
* Collect command-line arguments as a string consisting of the arguments,
|
||||
* separated by spaces.
|
||||
*/
|
||||
char *get_args_as_string(int argc, char **argv, int optind);
|
||||
|
||||
void ASCII_to_EBCDIC(guint8 *buf, guint bytes);
|
||||
guint8 ASCII_to_EBCDIC1(guint8 c);
|
||||
void EBCDIC_to_ASCII(guint8 *buf, guint bytes);
|
||||
|
|
Loading…
Reference in New Issue