summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2003-08-13 16:12:15 +0000
committerLennart Poettering <lennart@poettering.net>2003-08-13 16:12:15 +0000
commit62601723f4692631105f5e05da1871dc36a795f4 (patch)
treefa2393923d831d4335561e8fb7da213190c3fe51
parentc471ab6794ad48a571f8658fa1fab6d4ab8cc358 (diff)
many fixes
git-svn-id: file:///home/lennart/svn/public/ifplugd/trunk@32 2bf48fe7-cfc1-0310-909f-d9042e1e0fef
-rwxr-xr-xconf/ifplugd.init.in2
-rw-r--r--src/ifplugd.c64
-rw-r--r--src/interface.c4
3 files changed, 38 insertions, 32 deletions
diff --git a/conf/ifplugd.init.in b/conf/ifplugd.init.in
index f28274c..e1f567c 100755
--- a/conf/ifplugd.init.in
+++ b/conf/ifplugd.init.in
@@ -55,6 +55,8 @@ fi
[ -f $CFG ] && . $CFG
+[ -n "$2" ] && INTERFACES="$2"
+
[ "$INTERFACES" = "auto" ] && INTERFACES=`cat /proc/net/dev | awk '{ print $1 }' | egrep '^(eth|wlan)' | cut -d: -f1`
case "$1" in
diff --git a/src/ifplugd.c b/src/ifplugd.c
index 0547808..18c883b 100644
--- a/src/ifplugd.c
+++ b/src/ifplugd.c
@@ -473,6 +473,8 @@ void work(void) {
goto finish;
}
+ //daemon_log(LOG_INFO, "select()");
+
d = disabled;
s = status;
@@ -485,8 +487,8 @@ void work(void) {
if (d && !disabled) {
daemon_log(LOG_INFO, "Interface enabled");
- if (welcome_iface(fd, interface) < 0)
- goto finish;
+ welcome_iface(fd, interface);
+ status = IFSTATUS_DOWN;
}
if (!d && disabled) {
@@ -495,6 +497,34 @@ void work(void) {
}
}
+
+ if (!paused && !disabled) {
+ //daemon_log(LOG_INFO, "detect");
+ if ((status = detect_beat(fd, interface)) == IFSTATUS_ERR) {
+ if (!use_ifmonitor)
+ goto finish;
+
+ status = IFSTATUS_DOWN;
+ }
+ }
+
+ if (status != s) {
+ daemon_log(LOG_INFO, "Link beat %s.", status == IFSTATUS_DOWN ? "lost" : "detected");
+ beep(status == IFSTATUS_UP ? 0 : 1);
+
+ if (t)
+ t = 0;
+ else {
+ t = time(NULL);
+
+ if (status == IFSTATUS_UP)
+ t += delay_up;
+
+ if (status == IFSTATUS_DOWN)
+ t += delay_down;
+ }
+ }
+
if (FD_ISSET(sigfd, &qfds)) {
int sig;
@@ -540,35 +570,7 @@ void work(void) {
}
}
-
- if (!paused && !disabled) {
- //daemon_log(LOG_INFO, "detect");
- if ((status = detect_beat(fd, interface)) == IFSTATUS_ERR) {
- if (!use_ifmonitor)
- break;
-
- status = IFSTATUS_DOWN;
- }
- }
-
- if (status != s) {
- daemon_log(LOG_INFO, "Link beat %s.", status == IFSTATUS_DOWN ? "lost" : "detected");
- beep(status == IFSTATUS_UP ? 0 : 1);
-
- if (t)
- t = 0;
- else {
- t = time(NULL);
-
- if (status == IFSTATUS_UP)
- t += delay_up;
-
- if (status == IFSTATUS_DOWN)
- t += delay_down;
- }
- }
-
- if (t && t < time(NULL)) {
+ if (t && t < time(NULL)) {
t = 0;
if (action(status) < 0)
diff --git a/src/interface.c b/src/interface.c
index b6f1ee6..9128c11 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -247,10 +247,10 @@ static int is_assoc_ap(uint8_t mac[ETH_ALEN]) {
}
interface_status_t interface_detect_beat_wlan(int fd, char *iface) {
+
if (interface_auto_up)
interface_up(fd, iface);
-
uint8_t mac[6];
int q;
struct iwreq req;
@@ -264,6 +264,8 @@ interface_status_t interface_detect_beat_wlan(int fd, char *iface) {
return IFSTATUS_ERR;
}
+ memcpy(mac, &(req.u.ap_addr.sa_data), ETH_ALEN);
+
if (!is_assoc_ap(mac))
return IFSTATUS_DOWN;