From 3a46885c17ba051ced802e3d35b9ddc6bf10edf6 Mon Sep 17 00:00:00 2001
From: Lennart Poettering
Date: Mon, 12 Apr 2004 13:58:11 +0000
Subject: preparation for 0.24
git-svn-id: file:///home/lennart/svn/public/ifplugd/trunk@109 2bf48fe7-cfc1-0310-909f-d9042e1e0fef
---
configure.ac | 4 ++--
doc/NEWS | 4 ++++
doc/README.html.in | 10 +++++++---
man/ifplugd.8.xml.in | 4 ++--
man/ifplugstatus.8.xml.in | 18 ++++++++++++++----
src/Makefile.am | 2 +-
src/ifplugd.c | 23 +++++++++++++++--------
src/ifplugstatus.c | 28 +++++++++++++++++-----------
src/interface.c | 19 +++++++++++++++++++
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])
diff --git a/doc/NEWS b/doc/NEWS
index 09780ef..5c7e190 100644
--- a/doc/NEWS
+++ b/doc/NEWS
@@ -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.
+Mon Apr 12 2004:
Version
+0.24 released, changes include: add IFF_RUNNING link check support and make it the default. This might break some setups. You may workaround this by passing -m to the daemon for selecting a different API. Please report breakages!
+
Wed Apr 7 2004:
Version
0.23 released, changes include: don't make /dev/tty1 the controlling TTY when beeping
@@ -113,11 +117,11 @@ the interface when a cable is really connected.
Supports the Linux SIOCETHTOOL (newer, aka ethtool API), SIOCGMIIREG
(older, aka mii-diag /mii-tool API) and SIOCDEVPRIVATE (oldest, aka
- mii-tool API) ioctl() s for getting link status.
+ mii-tool API) ioctl() s for getting link status. Release 0.24 introduces support for link detection with the IFF_RUNNING interface flag.
Syslog support
- Small program - the binary is just 19 KB (plus 11 KB for libdaemon ).
+ Small program - the binary is just 25 KB (plus 16 KB for libdaemon ).
Multiple ethernet interface support
@@ -289,7 +293,7 @@ compilation and make install (as root) for installation of
${sysconfdir}/init.d/ifplugd , however no /etc/rc?.d/ links are created
for it.
-Extensive installation instructions for ifplugd are available at Geoff Ericksson's web site .
+Extensive installation instructions for installation of ifplugd on Fedora Core 1 are available at Geoff Ericksson's web site .
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 @@
-m | --api-mode= MODE
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)
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 @@
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.
+
+ The APIs are tried in the following order:
+
+ First the cleanest API: IFF_RUNNING (aka ifconfig API)
+ Second the newest API: SIOCETHTOOL (aka ethtool API)
+ Third the next older API: SIOCGMIIREG (aka mii-diag API)
+ Than the WLAN API: wireless extension (aka iwconfig API)
+ Finally the oldest API: SIOCPRIV (aka mii-tool API)
+
+ 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
-v )
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
#include
#include
@@ -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
--
cgit