wps-ap-cli revision 252190
1#!/bin/sh 2 3CLI=wpa_cli 4 5pbc() 6{ 7 echo "Starting PBC mode" 8 echo "Push button on the station within two minutes" 9 if ! $CLI wps_pbc | grep -q OK; then 10 echo "Failed to enable PBC mode" 11 fi 12} 13 14enter_pin() 15{ 16 echo "Enter a PIN from a station to be enrolled to the network." 17 read -p "Enrollee PIN: " pin 18 cpin=`$CLI wps_check_pin "$pin" | tail -1` 19 if [ "$cpin" = "FAIL-CHECKSUM" ]; then 20 echo "Checksum digit is not valid" 21 read -p "Do you want to use this PIN (y/n)? " resp 22 case "$resp" in 23 y*) 24 cpin=`echo "$pin" | sed "s/[^1234567890]//g"` 25 ;; 26 *) 27 return 1 28 ;; 29 esac 30 fi 31 if [ "$cpin" = "FAIL" ]; then 32 echo "Invalid PIN: $pin" 33 return 1 34 fi 35 echo "Enabling Enrollee PIN: $cpin" 36 $CLI wps_pin any "$cpin" 37} 38 39show_config() 40{ 41 $CLI status wps 42} 43 44main_menu() 45{ 46 echo "WPS AP" 47 echo "------" 48 echo "1: Push button (activate PBC)" 49 echo "2: Enter Enrollee PIN" 50 echo "3: Show current configuration" 51 echo "0: Exit wps-ap-cli" 52 53 read -p "Command: " cmd 54 55 case "$cmd" in 56 1) 57 pbc 58 ;; 59 2) 60 enter_pin 61 ;; 62 3) 63 show_config 64 ;; 65 0) 66 exit 0 67 ;; 68 *) 69 echo "Unknown command: $cmd" 70 ;; 71 esac 72 73 echo 74 main_menu 75} 76 77 78main_menu 79