summaryrefslogtreecommitdiffstats
path: root/src/8021x
diff options
context:
space:
mode:
authorJames Rayner <james@archlinux.org>2008-12-18 06:33:31 +0100
committerJames Rayner <james@archlinux.org>2008-12-18 06:33:31 +0100
commit164df2fdcc8ac4286c7f8f04f1e7c9004ade6960 (patch)
tree50e56f8711d4c7e9db7981c3c6282a994213acca /src/8021x
parent300cd2c73b599c2a58463ce75e1aa2cb19ac2414 (diff)
downloadnetctl-164df2fdcc8ac4286c7f8f04f1e7c9004ade6960.tar.gz
netctl-164df2fdcc8ac4286c7f8f04f1e7c9004ade6960.tar.xz
fix libify
Diffstat (limited to 'src/8021x')
-rw-r--r--src/8021x32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/8021x b/src/8021x
new file mode 100644
index 0000000..cce66cd
--- /dev/null
+++ b/src/8021x
@@ -0,0 +1,32 @@
+# Uses wpa_supplicant to check for association to a network
+# wpa_check interface [timeout]
+wpa_check()
+{
+ local timeout=0 INTERFACE=$1 TIMEOUT=${2:-15}
+
+ while [[ $timeout -lt $TIMEOUT ]]; do
+ (
+ eval `wpa_cli status|grep wpa_state`
+ [[ "$wpa_state" = "COMPLETED" ]]
+ ) && return 0
+ sleep 1
+ let timeout++
+ done
+
+ wpa_cli terminate >/dev/null 2>&1
+ err_append "Authentication/association failed"
+ return 1
+}
+
+start_wpa()
+{
+ INTERFACE="$1"; WPA_CONF="$2"; WPA_OPTS="$3"
+
+ wpa_supplicant -wB -P/var/run/wpa_supplicant_${INTERFACE}.pid -i"${INTERFACE}" -c "$WPA_CONF" $WPA_OPTS
+ sleep 1
+
+ if [[ ! -f "/var/run/wpa_supplicant_${INTERFACE}.pid" ]]; then
+ err_append "wpa_supplicant did not start, possible configuration error"
+ return 1
+ fi
+}