summaryrefslogtreecommitdiffstats
path: root/usr/lib/autowifi/lib/plugin_core
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2014-12-20 22:02:08 +0100
committermakefu <github@syntax-fehler.de>2014-12-20 22:02:08 +0100
commit16e1373ddd9050dd06cd699b2874cf178375574b (patch)
tree0352a0f39f4426327ffd4aa16dad8e0e15a6a8c4 /usr/lib/autowifi/lib/plugin_core
parent120114ad12a212331e9e790305a4ab3afdc15857 (diff)
parent6a9beb12dad44b5e1efa984b112c7a6b8c13a118 (diff)
Merge remote-tracking branch 'inspector_wifi/wifi_scanner'
Conflicts: .gitignore
Diffstat (limited to 'usr/lib/autowifi/lib/plugin_core')
-rw-r--r--usr/lib/autowifi/lib/plugin_core41
1 files changed, 41 insertions, 0 deletions
diff --git a/usr/lib/autowifi/lib/plugin_core b/usr/lib/autowifi/lib/plugin_core
new file mode 100644
index 00000000..e79a3c05
--- /dev/null
+++ b/usr/lib/autowifi/lib/plugin_core
@@ -0,0 +1,41 @@
+#!/bin/sh
+parse_plugin_args(){
+ [ $# -ne 4 ] && plugin_usage && exit 1
+ # convenience function to put args in ENV variables
+ ESSID="$1"
+
+ # mac is returned without colon
+ MAC=$(printf "%s" "$2" | sed 's/://g')
+ # split up the mac address to vendor and private part
+ VENDOR_MAC=${MAC:0:6}
+ PRIVATE_MAC=${MAC:6:12}
+ CHANNEL="$3"
+ ENC="$4"
+ if [ ${#MAC} -ne 12 ] ;then
+ echo "MAC malformed"
+ exit 1
+ fi
+}
+plugin_usage(){
+ cat << EOF
+usage: $0 ESSID MAC CHANNEL ENC"
+
+ ESSID - string
+ MAC - 00:11:22:33:44:55
+ CHANNEL - 4
+ ENC - wpa
+EOF
+
+}
+
+check_vendor_mac(){
+ needle="$(printf $1 | tr '[A-Z]' '[a-z]')"
+ shift
+ for i in "$@";do
+ [ "$needle" == "$(printf $i | tr '[A-Z]' '[a-z]')" ] && return 0
+ done
+ return 1
+}
+check_painmode(){
+ test -z "${painmode:-}" && echo "painmode required" && exit 1
+}