summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJouke Witteveen <j.witteveen@gmail.com>2012-08-08 12:35:02 +0200
committerJouke Witteveen <j.witteveen@gmail.com>2012-08-08 13:16:31 +0200
commit11ba258a774f72818b4c79fbc61596fe5880e837 (patch)
tree643ae47fe1a9ed2504d861164195f95e02f85842
parent0b35da2fde29d7cafceb205523df130903645b72 (diff)
downloadnetctl-11ba258a774f72818b4c79fbc61596fe5880e837.tar.gz
netctl-11ba258a774f72818b4c79fbc61596fe5880e837.tar.xz
Small code review
-rwxr-xr-xscripts/netcfg1
-rwxr-xr-xscripts/wifi-menu2
-rw-r--r--src/8021x17
3 files changed, 6 insertions, 14 deletions
diff --git a/scripts/netcfg b/scripts/netcfg
index 65e4d62..f591641 100755
--- a/scripts/netcfg
+++ b/scripts/netcfg
@@ -82,6 +82,7 @@ case "$1" in
rm "$STATE_DIR/interfaces"/* 2> /dev/null
rm "$STATE_DIR/profiles"/* 2> /dev/null
rm "$STATE_DIR/suspend"/* 2> /dev/null
+ rm "$STATE_DIR/netcfg-daemon" 2> /dev/null
killall wpa_supplicant 2> /dev/null
killall dhcpcd 2> /dev/null
;;
diff --git a/scripts/wifi-menu b/scripts/wifi-menu
index 10353f8..08268a1 100755
--- a/scripts/wifi-menu
+++ b/scripts/wifi-menu
@@ -210,7 +210,7 @@ fi
report_try "Scanning for networks"
CONNECTION=$(wpa_call "$INTERFACE" status 2> /dev/null | grep -m 1 "^ssid=")
CONNECTION=${CONNECTION#ssid=}
-NETWORKS=$(wpa_supplicant_scan_info "$INTERFACE" 3,4,5)
+NETWORKS=$(wpa_supplicant_scan "$INTERFACE" 3,4,5)
if [[ $? -eq 0 ]]; then
trap 'rm -f "$NETWORKS"' EXIT
report_success
diff --git a/src/8021x b/src/8021x
index fcde131..608d683 100644
--- a/src/8021x
+++ b/src/8021x
@@ -124,11 +124,10 @@ wpa_supplicant_scan_and_find() {
#usage: wpa_supplicant_scan_and_find $INTERFACE $FIELD $ITEM
# field = 1 for bssid, 5 for essid
# item = string to lookup
- local INTERFACE="$1" FIELD="$2" ITEM="$3" RETRIES=5 try scan_ok
- scan_ok=0
- wpa_call "$INTERFACE" scan > /dev/null
+ local INTERFACE="$1" FIELD="$2" ITEM="$3" RETRIES=5 scan_ok=0 try
for ((try=0; try < $RETRIES; try++)); do
local found
+ wpa_call "$INTERFACE" scan > /dev/null
sleep 2
found=$(wpa_call "$INTERFACE" scan_results | tail -n+2 | cut -f ${FIELD} | grep -F -x -m 1 "${ITEM}")
(( $? == 0 )) && scan_ok=1
@@ -138,7 +137,6 @@ wpa_supplicant_scan_and_find() {
echo "$found"
return 0
fi
- wpa_call "$INTERFACE" scan > /dev/null
done
if (( $scan_ok != 1 )); then
report_debug wpa_supplicant_scan_and_find "unable to retrieve scan results"
@@ -146,13 +144,7 @@ wpa_supplicant_scan_and_find() {
return 1
}
-# Return a filename containing a list of network APs and ESSIDs found (sorted by decreasing signal strength)
-# list_networks interface
-list_networks() {
- wpa_supplicant_scan_info "$1" 1,5
-}
-
-wpa_supplicant_scan_info() {
+wpa_supplicant_scan() {
local INTERFACE="$1" fields="$2" spawned_wpa=0 essids
# temp file used, as keeping ESSID's with spaces in their name in arrays
# is hard, obscure and kinda nasty. This is simpler and clearer.
@@ -171,8 +163,7 @@ wpa_supplicant_scan_info() {
# Sometimes, that is not enough (FS#29946)
timeout_wait 7 '! wpa_call "$INTERFACE" status | grep -F -q "wpa_state=SCANNING"'
wpa_call "$INTERFACE" scan_results |
- grep -v "^Selected" |
- grep -v "^bssid" |
+ tail -n+2 |
sort -rn -k3 |
sort -u -k5 |
sort -rn -k3 |