aboutsummaryrefslogtreecommitdiffstats
path: root/tethereal.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2000-01-16 02:48:12 +0000
committerGuy Harris <guy@alum.mit.edu>2000-01-16 02:48:12 +0000
commit7f30e566a0257e7319a2e6a052476afd46924b12 (patch)
treeebe8cc252f6efe9166f3a6a14517cfd937290a17 /tethereal.c
parent66a0ac1ca116c350549aa006772c67c891602b8f (diff)
downloadwireshark-7f30e566a0257e7319a2e6a052476afd46924b12.tar.gz
wireshark-7f30e566a0257e7319a2e6a052476afd46924b12.tar.bz2
wireshark-7f30e566a0257e7319a2e6a052476afd46924b12.zip
Move the routine to get a list of the network interfaces on the system
to "util.c", and provide a routine to free that list as well. When picking an interface on which to do a capture (if no "-i" flag was specified), use that routine, and pick the first interface on the list. svn path=/trunk/; revision=1495
Diffstat (limited to 'tethereal.c')
-rw-r--r--tethereal.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/tethereal.c b/tethereal.c
index c2df1026d4..65c39516dd 100644
--- a/tethereal.c
+++ b/tethereal.c
@@ -1,6 +1,6 @@
/* tethereal.c
*
- * $Id: tethereal.c,v 1.7 2000/01/15 10:47:56 oabad Exp $
+ * $Id: tethereal.c,v 1.8 2000/01/16 02:47:46 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -152,6 +152,7 @@ main(int argc, char *argv[])
int err;
#ifdef HAVE_LIBPCAP
int packet_count = 0;
+ GList *if_list;
gchar err_str[PCAP_ERRBUF_SIZE];
#else
gboolean capture_option_specified = FALSE;
@@ -380,13 +381,24 @@ main(int argc, char *argv[])
#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);
+ /* No - pick the first one from the list of interfaces. */
+ 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);
}
+ cf.iface = g_strdup(if_list->data); /* first interface */
+ free_interface_list(if_list);
}
capture(packet_count);
#else