diff options
-rw-r--r-- | src-wireless/netcfg-auto-wireless | 1 | ||||
-rw-r--r-- | src/8021x | 44 | ||||
-rw-r--r-- | src/wireless | 44 |
3 files changed, 45 insertions, 44 deletions
diff --git a/src-wireless/netcfg-auto-wireless b/src-wireless/netcfg-auto-wireless index 3215d5c..2bec32f 100644 --- a/src-wireless/netcfg-auto-wireless +++ b/src-wireless/netcfg-auto-wireless @@ -3,6 +3,7 @@ . /usr/lib/network/network . /usr/lib/network/wireless +. /usr/lib/network/8021x # wifi_auto # autoconnect wireless interface @@ -50,6 +50,50 @@ stop_wpa() fi } +# 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() { + local INTERFACE="$1" fields="$2" 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. + + [[ -z "$INTERFACE" ]] && return 1 + essids=$(mktemp --tmpdir essid.XXXXXXXX) + + wpa_supplicant -B -i"$INTERFACE" -Dnl80211,wext -C/run/wpa_supplicant -P/run/wpa_supplicant.pid || return 1 + $WPA_CLI -i "$INTERFACE" scan &> /dev/null + sleep 2.5 + $WPA_CLI -i "$INTERFACE" scan_results | + grep -v "^Selected" | + grep -v "^bssid" | + sort -rn -k3 | + sort -u -k5 | + sort -rn -k3 | + cut -f"$fields" > "$essids" + + # Fields are tab delimited + # Remove extraneous output from wpa_cli + # Sort by strength + # Remove duplicates + # Re-sort by strength as the removal disorders the list + # Cut to the AP/essid fields only + + kill "$(cat /run/wpa_supplicant.pid)" + + # File of 0 length, ie. no ssid's. + if [[ ! -s "$essids" ]]; then + rm -f "$essids" + return 1 + fi + + echo $essids + return 0 +} + # Requires already loaded profile make_wpa_config_file() { local interface=$1 diff --git a/src/wireless b/src/wireless index 71713e7..b5ae141 100644 --- a/src/wireless +++ b/src/wireless @@ -72,50 +72,6 @@ find_ap() { 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() { - local INTERFACE="$1" fields="$2" 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. - - [[ -z "$INTERFACE" ]] && return 1 - essids=$(mktemp --tmpdir essid.XXXXXXXX) - - wpa_supplicant -B -i"$INTERFACE" -Dnl80211,wext -C/run/wpa_supplicant -P/run/wpa_supplicant.pid || return 1 - wpa_cli -p /run/wpa_supplicant -i "$INTERFACE" scan &> /dev/null - sleep 2.5 - wpa_cli -p /run/wpa_supplicant -i "$INTERFACE" scan_results | - grep -v "^Selected" | - grep -v "^bssid" | - sort -rn -k3 | - sort -u -k5 | - sort -rn -k3 | - cut -f"$fields" > "$essids" - - # Fields are tab delimited - # Remove extraneous output from wpa_cli - # Sort by strength - # Remove duplicates - # Re-sort by strength as the removal disorders the list - # Cut to the AP/essid fields only - - kill "$(cat /run/wpa_supplicant.pid)" - - # File of 0 length, ie. no ssid's. - if [[ ! -s "$essids" ]]; then - rm -f "$essids" - return 1 - fi - - echo $essids - return 0 -} - set_rf_state() { local INTERFACE="$1" state="$2" RFKILL_NAME="$3" |