=item -i
-Sets the name of the interface to use for live packet capture. It
-should match one of the names listed in "B<netstat -i>" or "B<ifconfig -a>".
+Sets the name of the network interface to use for live packet capture.
+It should match one of the names listed in "B<netstat -i>" or
+"B<ifconfig -a>".
=item -k
-Starts the capture session immediately; this option requires
-the B<-i> parameter, specifying the interface on which the capture
-should be done.
+Starts the capture session immediately. If the B<-i> flag was
+specified, the capture uses the specified interface. Otherwise,
+B<Ethereal> searches the list of interfaces on the system for the
+lowest-numbered, configured-up interface (excluding loopback
+interfaces); ties are broken by choosing the earliest match.
=item -m
=item -i
-Sets the name of the interface to use for live packet capture. It
-should match one of the names listed in "B<netstat -i>" or "B<ifconfig -a>".
+Sets the name of the network interface to use for live packet capture.
+It should match one of the names listed in "B<netstat -i>" or
+"B<ifconfig -a>". If no interface is specified, B<Ethereal> searches
+the list of interfaces on the system for the lowest-numbered,
+configured-up interface (excluding loopback interfaces); ties are broken
+by choosing the earliest match.
=item -n
/* main.c
*
- * $Id: main.c,v 1.87 2000/01/15 00:22:51 gram Exp $
+ * $Id: main.c,v 1.88 2000/01/15 06:05:21 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
#ifdef HAVE_LIBPCAP
gboolean start_capture = FALSE;
gchar *save_file = NULL;
+ gchar err_str[PCAP_ERRBUF_SIZE];
#else
gboolean capture_option_specified = FALSE;
#endif
#endif
#ifdef HAVE_LIBPCAP
if (start_capture) {
+ /* We're supposed to do a live capture; did the user specify an interface
+ to use? */
if (cf.iface == NULL) {
- fprintf(stderr, "ethereal: \"-k\" flag was specified without \"-i\" flag\n");
- exit(1);
+ /* No - have libpcap pick one. */
+ cf.iface = pcap_lookupdev(err_str);
+ if (cf.iface == NULL) {
+ /* It couldn't pick one. */
+ fprintf(stderr, "ethereal: %s\n", err_str);
+ exit(2);
+ }
}
}
if (capture_child) {
/* tethereal.c
*
- * $Id: tethereal.c,v 1.4 2000/01/14 23:26:18 nneul Exp $
+ * $Id: tethereal.c,v 1.5 2000/01/15 06:04:59 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
fprintf(stderr, "This is GNU %s %s, compiled with %s\n", PACKAGE,
VERSION, comp_info_str);
- fprintf(stderr, "t%s -i iface [ -vVh ] [ -c count ] [ -f <filter expression> ]\n", PACKAGE);
+ fprintf(stderr, "t%s [ -vVh ] [ -c count ] [ -f <filter expression> ] [ -i iface ]\n", PACKAGE);
fprintf(stderr, "\t[ -r infile ] [ -R <filter expression> ] [ -s snaplen ]\n");
fprintf(stderr, "\t[ -t <time stamp format> ] [ -w savefile ]\n");
}
#endif
char *pf_path;
int err;
-#ifndef HAVE_LIBPCAP
+#ifdef HAVE_LIBPCAP
+ gchar err_str[PCAP_ERRBUF_SIZE];
+#else
gboolean capture_option_specified = FALSE;
#endif
gchar *cf_name = NULL, *rfilter = NULL;
exit(2);
}
cf_name[0] = '\0';
-#ifdef HAVE_LIBPCAP
} else {
- if (!cf.iface) {
- print_usage();
- fprintf(stderr, "\nPlease specify an interface with the -i option.\n");
- exit(1);
+ /* No capture file specified, so we're supposed to do a live capture;
+ do we have support for live captures? */
+#ifdef HAVE_LIBPCAP
+ /* Yes; did the user specify an interface to use? */
+ if (cf.iface == NULL) {
+ /* No - have libpcap pick one. */
+ cf.iface = pcap_lookupdev(err_str);
+ if (cf.iface == NULL) {
+ /* It couldn't pick one. */
+ fprintf(stderr, "tethereal: %s\n", err_str);
+ exit(2);
+ }
+
+ /* Let the user know what interface was chosen. */
+ printf("Capturing on %s\n", cf.iface);
}
capture();
+#else
+ /* No - complain. */
+ fprintf(stderr, "This version of Tethereal was not built with support for capturing packets.\n");
+ exit(2);
#endif
}