From 9578dda45b86acf3bd25def5de8f1d51f2ec22b2 Mon Sep 17 00:00:00 2001 From: Jim Pryor Date: Tue, 11 Aug 2009 08:05:10 -0400 Subject: 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 --- src/wireless | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src/wireless') 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 -- cgit v1.2.3-24-g4f1b