From 486e72a79bfcfc9000ae0b4ed4d847522b5ce04e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 13 Aug 2003 16:11:55 +0000 Subject: Serveral fixes git-svn-id: file:///home/lennart/svn/public/aeswepd/trunk@6 022f378f-78c4-0310-b860-d162c87e6274 --- conf/waproamd.init.in | 2 ++ doc/README | 20 ++++++++++++++- src/waproamd.c | 70 ++++++++++++++++++++++++++------------------------- 3 files changed, 57 insertions(+), 35 deletions(-) diff --git a/conf/waproamd.init.in b/conf/waproamd.init.in index 467ce9a..ab77fa3 100755 --- a/conf/waproamd.init.in +++ b/conf/waproamd.init.in @@ -27,6 +27,8 @@ if [ `id -u` != "0" ] && [ "$1" = "start" -o "$1" = "stop" ] ; then exit 1 fi +[ -n "$2" ] && INTERFACES="$2" + [ -f $CFG ] && . $CFG case "$1" in diff --git a/doc/README b/doc/README index e9cfad8..9c61633 100644 --- a/doc/README +++ b/doc/README @@ -1 +1,19 @@ -Sorry, no README yet. +Sorry, no real README yet. + +Just a short intro: + +waproamd is to be used together with ifplugd. + +waproamd: when not associated waproamd does periodic scans and tries to associate to a sensible AP by running a script in /etc/waproamd/scripts + +aeswepd: A daemon for doing AES based WEP rekeying, is called by /etc/waproamd/scripts/default if /etc/waproamd/keys/foo.aes exists + +ifplugd: if an associating succeeded runs ifup for the device + +waproamd will not issue scans while associated. + +The algorithm to select an AP if multiple are available is rather simple: Just take the first one having a script in /etc/waproamd/scripts. + +If a script named after the MAC address of the AP is available in /etc/waproamd/scripts/ it is run if an AP is selected. If not /etc/waproamd/scripts/default is run. Have a look on that script to see its arguments. + +$Id$ diff --git a/src/waproamd.c b/src/waproamd.c index 7c8d7d8..f96288a 100644 --- a/src/waproamd.c +++ b/src/waproamd.c @@ -69,8 +69,8 @@ int issue_scan(struct interface *i) { if (iw_set_mode(i, IW_MODE_INFRA) < 0) return -1; - if (iw_set_ap(i, &null_ap) < 0) - return -1; +/* if (iw_set_ap(i, &null_ap) < 0) */ +/* return -1; */ if (iw_set_essid(i, NULL) < 0) return -1; @@ -327,7 +327,7 @@ int go(struct interface *i) { if (nlapi_work(0) < 0) goto finish; - if (!use_assocwatch) { + if (!disabled && !use_assocwatch) { if ((associated = interface_is_assoc(i, &associated_ap)) < 0) { if (!use_ifmonitor) goto finish; @@ -341,51 +341,51 @@ int go(struct interface *i) { daemon_log(LOG_INFO, "Interface disabled\n"); if (associated) - if (set_current_ap(&null_ap) < 0) + if (set_current_ap(NULL) < 0) goto finish; - associated = 0; + associated = scanning = 0; } /* Changed: disabled -> enabled */ if (d && !disabled) { daemon_log(LOG_INFO, "Interface enabled\n"); - associated = 0; + associated = scanning = 0; } - if (!disabled) { - /* Changed: associated -> not associated */ - if (a && !associated) - daemon_log(LOG_INFO, "No longer associated.\n"); + /* Changed: associated -> not associated */ + if (a && !associated) { + daemon_log(LOG_INFO, "No longer associated.\n"); + scanning = 0; + } - /* Changed: not associated -> associated */ - if (!a && associated) { - if (set_current_ap(&associated_ap) < 0) - goto finish; + /* Changed: not associated -> associated */ + if (!a && associated) { + if (set_current_ap(&associated_ap) < 0) + goto finish; - daemon_log(LOG_INFO, "Associated.\n"); - next_scan = (time_t) -1; - } + daemon_log(LOG_INFO, "Associated.\n"); + scanning = 0; + } - if (scanning) { - int r; - struct ap_info *ai = NULL; + if (scanning) { + int r; + struct ap_info *ai = NULL; - if ((r = read_scan(i, &ai)) < 0) { - if (!use_ifmonitor) - goto finish; - - scanning = 0; - - } else if (!r) { - - scanning = 0; + if ((r = read_scan(i, &ai)) < 0) { + if (!use_ifmonitor) + goto finish; + + scanning = 0; + + } else if (!r) { + + scanning = 0; + + if (!associated) { - if (!associated) { - - if (set_current_ap(ai ? &ai->ap : NULL) < 0) - goto finish; - } + if (set_current_ap(ai ? &ai->ap : NULL) < 0) + goto finish; } } } @@ -432,6 +432,8 @@ int go(struct interface *i) { finish: + set_current_ap(NULL); + if (send_retval && daemonize && wait_on_fork) daemon_retval_send(1); -- cgit