X-Git-Url: https://unix4lyfe.org/gitweb/darkstat-debian/blobdiff_plain/85d7d6e7b81dff84df8ddc87815ce77b8d82bc07..3c6b3682c70be84db86e70c191016913a9836c31:/cap.c diff --git a/cap.c b/cap.c index 7e1c41b..62da77d 100644 --- a/cap.c +++ b/cap.c @@ -1,5 +1,5 @@ /* darkstat 3 - * copyright (c) 2001-2011 Emil Mikulic. + * copyright (c) 2001-2014 Emil Mikulic. * * cap.c: capture packets, and hand them off to decode and acct. * @@ -398,12 +398,21 @@ static void callback(u_char *user, /* Process any packets currently in the capture buffer. */ void cap_poll(fd_set *read_set _unused_on_linux_) { struct cap_iface *iface; + static int told = 0; STAILQ_FOREACH(iface, &cap_ifs, entries) { /* Once per capture poll, check our IP address. It's used in accounting * for traffic graphs. */ localip_update(iface->name, &iface->local_ips); + if (!told && iface->local_ips.num_addrs == 0) { + verbosef("interface '%s' has no addresses, " + "your graphs will be blank", + iface->name); + verbosef("please read the darkstat manpage, " + "and consider using the -l option"); + told = 1; + } for (;;) { struct timespec t; @@ -415,18 +424,19 @@ void cap_poll(fd_set *read_set _unused_on_linux_) { -1, /* count = entire buffer */ callback, (u_char*)iface); /* user = struct to pass to callback */ + timer_stop(&t, + 2 * CAP_TIMEOUT_MSEC * 1000000, + "pcap_dispatch took too long"); if (ret < 0) { warnx("pcap_dispatch('%s'): %s", iface->name, pcap_geterr(iface->pcap)); continue; } - timer_stop(&t, - 2 * CAP_TIMEOUT_MSEC * 1000000, - "pcap_dispatch took too long"); - if (0) /* debugging */ - verbosef("iface '%s' got %d pkts", iface->name, ret); +#if 0 /* debugging */ + verbosef("iface '%s' got %d pkts", iface->name, ret); +#endif #ifdef linux /* keep looping until we've dispatched all the outstanding packets */