summaryrefslogtreecommitdiffstats
path: root/src/waproamd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/waproamd.c')
-rw-r--r--src/waproamd.c70
1 files changed, 36 insertions, 34 deletions
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);