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
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
/* 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>
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];
break;
case 'f':
#ifdef HAVE_LIBPCAP
+ capture_filter_specified = TRUE;
cf.cfilter = g_strdup(optarg);
#else
capture_option_specified = TRUE;
}
}
+ /* 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");
/* 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>
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)
{
/* 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>
* 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);