diff options
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | doc/NEWS | 4 | ||||
-rw-r--r-- | doc/README.html.in | 10 | ||||
-rw-r--r-- | man/ifplugd.8.xml.in | 4 | ||||
-rw-r--r-- | man/ifplugstatus.8.xml.in | 18 | ||||
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/ifplugd.c | 23 | ||||
-rw-r--r-- | src/ifplugstatus.c | 28 | ||||
-rw-r--r-- | src/interface.c | 19 | ||||
-rw-r--r-- | src/interface.h | 3 |
10 files changed, 83 insertions, 32 deletions
diff --git a/configure.ac b/configure.ac index 07b00be..c803c43 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. AC_PREREQ(2.59) -AC_INIT([ifplugd],[0.23],[mzvscyhtq (at) 0pointer (dot) de]) +AC_INIT([ifplugd],[0.24],[mzvscyhtq (at) 0pointer (dot) de]) AC_CONFIG_SRCDIR([src/ifplugd.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign -Wall]) @@ -147,7 +147,7 @@ if test x$subversion = xyes ; then subversion=no fi fi - + AM_CONDITIONAL([USE_SUBVERSION], [test "x$subversion" = xyes]) AC_CONFIG_FILES([src/Makefile Makefile man/Makefile conf/Makefile doc/Makefile doc/README.html patches/Makefile ifplugd.spec]) @@ -1,3 +1,7 @@ + +[[[ newer changes are recorded in the README file only ]]] + + 0.20 :: 9 Nov 2003 :: SVN 71 Error output fix Build system fix diff --git a/doc/README.html.in b/doc/README.html.in index e514323..d0ceace 100644 --- a/doc/README.html.in +++ b/doc/README.html.in @@ -42,6 +42,10 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.</p> <h2><a name="news">News</a></h2> +<div class="news-date">Mon Apr 12 2004: </div> <p class="news-text"><a +href="@PACKAGE_URL@ifplugd-0.24.tar.gz">Version +0.24</a> released, changes include: add <tt>IFF_RUNNING</tt> link check support and make it the default. This might break some setups. You may workaround this by passing <tt>-m</tt> to the daemon for selecting a different API. Please report breakages!</p> + <div class="news-date">Wed Apr 7 2004: </div> <p class="news-text"><a href="@PACKAGE_URL@ifplugd-0.23.tar.gz">Version 0.23</a> released, changes include: don't make <tt>/dev/tty1</tt> the controlling TTY when beeping</p> @@ -113,11 +117,11 @@ the interface when a cable is really connected.</p> <li>Supports the Linux <tt>SIOCETHTOOL</tt> (newer, aka <tt>ethtool</tt> API), <tt>SIOCGMIIREG</tt> (older, aka <tt>mii-diag</tt>/<tt>mii-tool</tt> API) and SIOCDEVPRIVATE (oldest, aka - <tt>mii-tool</tt> API) <tt>ioctl()</tt>s for getting link status.</li> + <tt>mii-tool</tt> API) <tt>ioctl()</tt>s for getting link status. Release 0.24 introduces support for link detection with the <tt>IFF_RUNNING</tt> interface flag.</li> <li>Syslog support</li> - <li>Small program - the binary is just 19 KB (plus 11 KB for <tt>libdaemon</tt>).</li> + <li>Small program - the binary is just 25 KB (plus 16 KB for <tt>libdaemon</tt>).</li> <li>Multiple ethernet interface support</li> @@ -289,7 +293,7 @@ compilation and <tt>make install</tt> (as root) for installation of <tt>${sysconfdir}/init.d/ifplugd</tt>, however no <tt>/etc/rc?.d/</tt> links are created for it.</p> -<p>Extensive installation instructions for <tt>ifplugd</tt> are available at <a href="http://www.acmc.uq.edu.au/~gbe/linux/installation_of_ifplugd.html">Geoff Ericksson's web site</a>.</p> +<p>Extensive installation instructions for installation of <tt>ifplugd</tt> on Fedora Core 1 are available at <a href="http://www.acmc.uq.edu.au/~gbe/linux/installation_of_ifplugd.html">Geoff Ericksson's web site</a>.</p> <h2><a name="acks">Acknowledgements</a></h2> diff --git a/man/ifplugd.8.xml.in b/man/ifplugd.8.xml.in index 4b57aef..e720ce2 100644 --- a/man/ifplugd.8.xml.in +++ b/man/ifplugd.8.xml.in @@ -136,8 +136,8 @@ <option> <p><opt>-m | --api-mode=</opt> <arg>MODE</arg></p> <optdesc><p> Force a specific link beat detection ioctl() API. Possible - values are auto, wlan, ethtool, mii, and priv for automatic - detection, wireless extension, SIOCETHTOOL, SIOCGMIIREG + values are auto, iff, wlan, ethtool, mii, and priv for automatic + detection, interface flag (IFF_RUNNING), wireless extension, SIOCETHTOOL, SIOCGMIIREG resp. SIOCPRIV. Only the first character of the argument is relevant, case insensitive. (default: auto) </p></optdesc> </option> diff --git a/man/ifplugstatus.8.xml.in b/man/ifplugstatus.8.xml.in index 1f4aed8..684ba02 100644 --- a/man/ifplugstatus.8.xml.in +++ b/man/ifplugstatus.8.xml.in @@ -32,10 +32,20 @@ <p>ifplugstatus is an utility which may be used to detect the link status of a local Linux ethernet device, much in the same way mii-diag, mii-tool and ethtool work. In fact it supports all - three different APIs these three tools use. Thus, it provides - maximal compatibility. The newest API (ethtool) is used first, - than the next older (mii-diag) and at last the oldest - (mii-tool). It may be used in shell script since it returns the + three different APIs these three tools use. In addition it supports + link checking with the IFF_RUNNING interface flag, which most modern + drivers (not only ethernet) support, and association status checking + with the wireless extension API for WLAN devices.</p> + + <p>The APIs are tried in the following order:</p> + + <p>First the cleanest API: <arg>IFF_RUNNING</arg> (aka ifconfig API)</p> + <p>Second the newest API: <arg>SIOCETHTOOL</arg> (aka ethtool API)</p> + <p>Third the next older API: <arg>SIOCGMIIREG</arg> (aka mii-diag API)</p> + <p>Than the WLAN API: <arg>wireless extension</arg> (aka iwconfig API)</p> + <p>Finally the oldest API: <arg>SIOCPRIV</arg> (aka mii-tool API)</p> + + <p>It may be used in shell script since it returns the current status as return value. It is especially useful to detect the available APIs on the used network driver. (Option <opt>-v</opt>)</p> diff --git a/src/Makefile.am b/src/Makefile.am index 6e36a96..fb849bc 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,7 +16,7 @@ # along with ifplugd; if not, write to the Free Software Foundation, # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. -AM_CFLAGS = $(LIBDAEMON_CFLAGS) -DSYSCONFDIR="\"$(sysconfdir)\"" +AM_CFLAGS = $(LIBDAEMON_CFLAGS) -DSYSCONFDIR="\"$(sysconfdir)\"" -D_GNU_SOURCE LDADD = $(LIBDAEMON_LIBS) sbin_PROGRAMS = ifplugd ifplugstatus diff --git a/src/ifplugd.c b/src/ifplugd.c index 28f1ce5..d9aa708 100644 --- a/src/ifplugd.c +++ b/src/ifplugd.c @@ -19,8 +19,6 @@ * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -#define _GNU_SOURCE - #include <stdlib.h> #include <stdio.h> #include <string.h> @@ -87,7 +85,7 @@ int disabled = 0; interface_status_t failure_status = IFSTATUS_ERR; -enum { API_AUTO, API_ETHTOOL, API_MII, API_PRIVATE, API_WLAN } api_mode = API_AUTO; +enum { API_AUTO, API_ETHTOOL, API_MII, API_PRIVATE, API_WLAN, API_IFF } api_mode = API_AUTO; interface_status_t (*detect_beat_func)(int, char*); interface_status_t (*cached_detect_beat_func)(int, char*) = NULL; @@ -256,17 +254,23 @@ interface_status_t detect_beat_auto(int fd, char *iface) { if (cached_detect_beat_func && (status = cached_detect_beat_func(fd, iface)) != IFSTATUS_ERR) return status; - if ((status = interface_detect_beat_mii(fd, iface)) != IFSTATUS_ERR) { - cached_detect_beat_func = interface_detect_beat_mii; - daemon_log(LOG_INFO, "Using detection mode: SIOCGMIIPHY"); + if ((status = interface_detect_beat_iff(fd, iface)) != IFSTATUS_ERR) { + cached_detect_beat_func = interface_detect_beat_iff; + daemon_log(LOG_INFO, "Using detection mode: IFF_RUNNING"); return status; } - + if ((status = interface_detect_beat_ethtool(fd, iface)) != IFSTATUS_ERR) { cached_detect_beat_func = interface_detect_beat_ethtool; daemon_log(LOG_INFO, "Using detection mode: SIOCETHTOOL"); return status; } + + if ((status = interface_detect_beat_mii(fd, iface)) != IFSTATUS_ERR) { + cached_detect_beat_func = interface_detect_beat_mii; + daemon_log(LOG_INFO, "Using detection mode: SIOCGMIIPHY"); + return status; + } if ((status = interface_detect_beat_wlan(fd, iface)) != IFSTATUS_ERR) { cached_detect_beat_func = interface_detect_beat_wlan; @@ -400,7 +404,8 @@ void work(void) { case API_ETHTOOL: detect_beat_func = interface_detect_beat_ethtool; break; case API_MII: detect_beat_func = interface_detect_beat_mii; break; case API_PRIVATE: detect_beat_func = interface_detect_beat_priv; break; - case API_WLAN: detect_beat_func = interface_detect_beat_wlan;break; + case API_WLAN: detect_beat_func = interface_detect_beat_wlan; break; + case API_IFF: detect_beat_func = interface_detect_beat_iff; break; default: detect_beat_func = detect_beat_auto; @@ -609,6 +614,7 @@ void usage(char *p) { case API_MII: m = "mii"; break; case API_PRIVATE: m = "priv"; break; case API_WLAN: m = "wlan"; break; + case API_IFF: m = "iff"; break; default: m = "auto"; } @@ -763,6 +769,7 @@ void parse_args(int argc, char *argv[]) { case 'p': api_mode = API_PRIVATE; break; case 'w': api_mode = API_WLAN; break; case 'a': api_mode = API_AUTO; break; + case 'i': api_mode = API_IFF; break; default: daemon_log(LOG_ERR, "Unknown API mode: %s", optarg); exit(2); diff --git a/src/ifplugstatus.c b/src/ifplugstatus.c index 12cdd89..e4db11b 100644 --- a/src/ifplugstatus.c +++ b/src/ifplugstatus.c @@ -51,7 +51,12 @@ int handle(char *iface) { if (verbose > 0) { printf("%s:\n", iface); - if ((s = interface_detect_beat_ethtool(fd, iface)) == IFSTATUS_ERR) + if ((s = interface_detect_beat_iff(fd, iface)) == IFSTATUS_ERR) + printf(" IFF_RUNNING failed.\n"); + else + printf(" IFF_RUNNING: %s\n", s == IFSTATUS_UP ? "link beat detected" : "unplugged"); + + if ((s = interface_detect_beat_ethtool(fd, iface)) == IFSTATUS_ERR) printf(" SIOCETHTOOL failed (%s)\n", strerror(errno)); else printf(" SIOCETHTOOL: %s\n", s == IFSTATUS_UP ? "link beat detected" : "unplugged"); @@ -60,23 +65,24 @@ int handle(char *iface) { printf(" SIOCGMIIPHY failed (%s)\n", strerror(errno)); else printf(" SIOCGMIIPHY: %s\n", s == IFSTATUS_UP ? "link beat detected" : "unplugged"); - - if ((s = interface_detect_beat_priv(fd, iface)) == IFSTATUS_ERR) - printf(" SIOCDEVPRIVATE failed (%s)\n", strerror(errno)); - else - printf(" SIOCDEVPRIVATE: %s\n", s == IFSTATUS_UP ? "link beat detected" : "unplugged"); if ((s = interface_detect_beat_wlan(fd, iface)) == IFSTATUS_ERR) printf(" Wireless failed.\n"); else printf(" Wireless: %s\n", s == IFSTATUS_UP ? "link beat detected" : "unplugged"); + if ((s = interface_detect_beat_priv(fd, iface)) == IFSTATUS_ERR) + printf(" SIOCDEVPRIVATE failed (%s)\n", strerror(errno)); + else + printf(" SIOCDEVPRIVATE: %s\n", s == IFSTATUS_UP ? "link beat detected" : "unplugged"); + } else { - - if ((s = interface_detect_beat_mii(fd, iface)) == IFSTATUS_ERR) - if ((s = interface_detect_beat_ethtool(fd, iface)) == IFSTATUS_ERR) - if ((s = interface_detect_beat_wlan(fd, iface)) == IFSTATUS_ERR) - s = interface_detect_beat_priv(fd, iface); + + if ((s = interface_detect_beat_iff(fd, iface)) == IFSTATUS_ERR) + if ((s = interface_detect_beat_ethtool(fd, iface)) == IFSTATUS_ERR) + if ((s = interface_detect_beat_mii(fd, iface)) == IFSTATUS_ERR) + if ((s = interface_detect_beat_wlan(fd, iface)) == IFSTATUS_ERR) + s = interface_detect_beat_priv(fd, iface); switch(s) { case IFSTATUS_UP: diff --git a/src/interface.c b/src/interface.c index d277612..6007172 100644 --- a/src/interface.c +++ b/src/interface.c @@ -163,6 +163,25 @@ interface_status_t interface_detect_beat_ethtool(int fd, char *iface) { return edata.data ? IFSTATUS_UP : IFSTATUS_DOWN; } +interface_status_t interface_detect_beat_iff(int fd, char *iface) { + + struct ifreq ifr; + + if (interface_auto_up) + interface_up(fd, iface); + + memset(&ifr, 0, sizeof(ifr)); + strncpy(ifr.ifr_name, iface, sizeof(ifr.ifr_name)-1); + + if (ioctl(fd, SIOCGIFFLAGS, &ifr) == -1) { + if (interface_do_message) + daemon_log(LOG_ERR, "SIOCGIFFLAGS failed: %s", strerror(errno)); + + return IFSTATUS_ERR; + } + + return ifr.ifr_flags & IFF_RUNNING ? IFSTATUS_UP : IFSTATUS_DOWN; +} static int get_wlan_qual_old(char *iface) { FILE *f; diff --git a/src/interface.h b/src/interface.h index d1f3826..2f35a84 100644 --- a/src/interface.h +++ b/src/interface.h @@ -1,7 +1,7 @@ #ifndef foointerfacehfoo #define foointerfacehfoo -/* $Id: interface.h 1.2 Wed, 23 Oct 2002 20:49:08 +0200 lennart $ */ +/* $Id$ */ /* * This file is part of ifplugd. @@ -32,5 +32,6 @@ interface_status_t interface_detect_beat_mii(int fd, char *iface); interface_status_t interface_detect_beat_priv(int fd, char *iface); interface_status_t interface_detect_beat_ethtool(int fd, char *iface); interface_status_t interface_detect_beat_wlan(int fd, char *iface); +interface_status_t interface_detect_beat_iff(int fd, char *iface); #endif |