diff options
Diffstat (limited to 'src/waproamd.c')
-rw-r--r-- | src/waproamd.c | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/src/waproamd.c b/src/waproamd.c index b269def..b37b38d 100644 --- a/src/waproamd.c +++ b/src/waproamd.c @@ -70,8 +70,9 @@ int poll_interval = 5, char log_ident[32], pid_ident[32]; int issue_scan(struct interface *i) { + static int count = 0; - /* daemon_log(LOG_ERR, "Scanning...\n"); */ + daemon_log(LOG_ERR, "Scanning... %i\n", count++); /* Due to driver issues, the return codes of these function calls are no longer evaluated */ iw_set_mode(i, IW_MODE_INFRA); @@ -372,40 +373,50 @@ int go(struct interface *i) { daemon_log(LOG_INFO, "Interface enabled\n"); associated = scanning = 0; } - - /* 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; - - daemon_log(LOG_INFO, "Associated.\n"); - scanning = 0; - } - - if (scanning) { - int r; - struct ap_info *ai = NULL; + + if (!disabled) { + /* Changed: associated -> not associated */ + if (a && !associated) { + daemon_log(LOG_INFO, "No longer associated.\n"); + scanning = 0; + } - if ((r = read_scan(i, &ai)) < 0) { - if (!use_ifmonitor) + /* Changed: not associated -> associated */ + if (!a && associated) { + if (set_current_ap(&associated_ap) < 0) goto finish; + daemon_log(LOG_INFO, "Associated.\n"); scanning = 0; + } + + if (scanning) { + int r; + struct ap_info *ai = NULL; - } else if (!r) { + if ((r = read_scan(i, &ai)) < 0) { + if (!use_ifmonitor) + goto finish; + + scanning = 0; + + } else if (!r) { - scanning = 0; + scanning = 0; - if (!associated) { - - if (set_current_ap(ai ? &ai->ap : NULL) < 0) - goto finish; + if (!associated) { + + if (ai) { + if (iw_tune(i, ai) < 0) + goto finish; + + if (set_current_ap(&ai->ap) < 0) + goto finish; + } else { + if (set_current_ap(NULL) < 0) + goto finish; + } + } } } } @@ -459,14 +470,11 @@ int go(struct interface *i) { } } - if (next_scan == (time_t) -1 && !scanning) - if (!disabled && !associated && !paused) - next_scan = time(NULL) + scan_interval; - if (disabled || associated || paused) { scanning = 0; next_scan = (time_t) -1; - } + } else if (next_scan == (time_t) -1 && !scanning) + next_scan = time(NULL) + scan_interval; } r = 0; |