diff options
author | Jim Pryor <profjim@jimpryor.net> | 2009-08-11 14:05:10 +0200 |
---|---|---|
committer | James Rayner <james@archlinux.org> | 2009-08-15 04:28:29 +0200 |
commit | 9578dda45b86acf3bd25def5de8f1d51f2ec22b2 (patch) | |
tree | 214394f032dc086c0c63befc8e22fffc80d16403 /src/wireless | |
parent | c37f2081157b15be719ce8afb0e8e15afbf24253 (diff) | |
download | netctl-9578dda45b86acf3bd25def5de8f1d51f2ec22b2.tar.gz netctl-9578dda45b86acf3bd25def5de8f1d51f2ec22b2.tar.xz |
Add AP argument to profile, also let ESSID arguments be regexps
* AP= arguments in profiles take precedence over ESSID= arguments
* ESSID= arguments regexps instead of literals. To avoid screwing up
any currently working profiles, I restricted the interpretation as a
regexp to just the new wireless-dbus connection types.
* But a global change involved in implementing this is that the
connection up/down calls will be passed a literal ESSID (which of the
local networks matches the regexp) as an additional argument.
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
Diffstat (limited to 'src/wireless')
-rw-r--r-- | src/wireless | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/src/wireless b/src/wireless index 883ea0b..99c146d 100644 --- a/src/wireless +++ b/src/wireless @@ -14,24 +14,35 @@ wep_check() } # Check if a particular network is within range -# find_essid interface essid +# find_essid interface essid connection (we treat ESSID as regexp when CONNECTION=wireless-dbus) find_essid() { - local INTERFACE="$1" ESSID="$2" RETRIES=20 try=0 res scanned + local INTERFACE="$1" ESSID="$2" CONNECTION="$3" RETRIES=20 try=0 res scanned while [[ "$try" -lt "$RETRIES" ]]; do sleep 0.5 let try++ - found=$( - res=$(iwlist "$INTERFACE" scan 2>/dev/null) - [[ -z "$res" ]] && exit 1 - # if results were non-null, process them and exit 0 - echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | fgrep -xm1 "$ESSID" - ) && { + if [[ "$CONNECTION" == wireless-dbus ]]; then + # JP: ESSID is a regexp + found=$( + res=$(iwlist "$INTERFACE" scan 2>/dev/null) + [[ -z "$res" ]] && exit 1 + # if results were non-null, process them and exit 0 + echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | egrep -xm1 "$ESSID" + ) + else + found=$( + res=$(iwlist "$INTERFACE" scan 2>/dev/null) + [[ -z "$res" ]] && exit 1 + # if results were non-null, process them and exit 0 + echo "$res" | sed -nr 's/^\s+ESSID:"([^"]*)"$/\1/p' | fgrep -xm1 "$ESSID" + ) + fi && { scanned=1 report_debug find_essid "\"$found\"" # we only bother with at most 5 successful scans if (( try < RETRIES-4 )); then try=$((RETRIES-4)); fi } if [[ -n "$found" ]]; then + echo "$found" # JP: echo literal ESSID return 0 # network found fi done |