Skip to content
This repository has been archived by the owner on Sep 30, 2021. It is now read-only.

Add WPS support #452

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,14 @@
### Client Isolation:
create_ap --isolate-clients wlan0 eth0 MyAccessPoint MyPassPhrase

### WPS
create_ap wlan0 eth0 MyAccessPoint MyPassPhrase --wps

For Push Button Configuration (PBC), use `hostapd_cli` to press the virtual WPS button
(see create_ap's output for exact command):

hostapd_cli -p/path/to/hostapd_ctrl wps_pbc

## Systemd service
Using the persistent [systemd](https://wiki.archlinux.org/index.php/systemd#Basic_systemctl_usage) service
### Start service immediately:
Expand Down
30 changes: 28 additions & 2 deletions create_ap
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ usage() {
echo " back to managed"
echo " --mac <MAC> Set MAC address"
echo " --dhcp-dns <IP1[,IP2]> Set DNS returned by DHCP"
echo " --wps Enable WPS"
echo " --daemon Run create_ap in the background"
echo " --pidfile <pidfile> Save daemon PID to file"
echo " --logfile <logfile> Save daemon messages to file"
Expand Down Expand Up @@ -645,14 +646,15 @@ DAEMON_PIDFILE=
DAEMON_LOGFILE=/dev/null
NO_HAVEGED=0
USE_PSK=0
WPS=0

HOSTAPD_DEBUG_ARGS=
REDIRECT_TO_LOCALHOST=0

CONFIG_OPTS=(CHANNEL GATEWAY WPA_VERSION ETC_HOSTS DHCP_DNS NO_DNS NO_DNSMASQ HIDDEN MAC_FILTER MAC_FILTER_ACCEPT ISOLATE_CLIENTS
SHARE_METHOD IEEE80211N IEEE80211AC HT_CAPAB VHT_CAPAB DRIVER NO_VIRT COUNTRY FREQ_BAND
NEW_MACADDR DAEMONIZE DAEMON_PIDFILE DAEMON_LOGFILE NO_HAVEGED WIFI_IFACE INTERNET_IFACE
SSID PASSPHRASE USE_PSK)
SSID PASSPHRASE USE_PSK WPS)

FIX_UNMANAGED=0
LIST_RUNNING=0
Expand Down Expand Up @@ -1047,7 +1049,7 @@ for ((i=0; i<$#; i++)); do
fi
done

GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","redirect-to-localhost","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","pidfile:","logfile:","stop:","list","list-running","list-clients:","version","psk","no-haveged","no-dns","no-dnsmasq","mkconfig:","config:" -n "$PROGNAME" -- "$@")
GETOPT_ARGS=$(getopt -o hc:w:g:de:nm: -l "help","hidden","hostapd-debug:","redirect-to-localhost","mac-filter","mac-filter-accept:","isolate-clients","ieee80211n","ieee80211ac","ht_capab:","vht_capab:","driver:","no-virt","fix-unmanaged","country:","freq-band:","mac:","dhcp-dns:","daemon","pidfile:","logfile:","stop:","list","list-running","list-clients:","version","psk","wps","no-haveged","no-dns","no-dnsmasq","mkconfig:","config:" -n "$PROGNAME" -- "$@")
[[ $? -ne 0 ]] && exit 1
eval set -- "$GETOPT_ARGS"

Expand Down Expand Up @@ -1204,6 +1206,10 @@ while :; do
shift
USE_PSK=1
;;
--wps)
shift
WPS=1
;;
--no-dns)
shift
NO_DNS=1
Expand Down Expand Up @@ -1729,6 +1735,26 @@ EOF
fi
fi

if [[ $WPS -eq 1 ]]; then
echo "To press the virtual WPS button, run:"
echo "hostapd_cli -p$CONFDIR/hostapd_ctrl wps_pbc"
cat << EOF >> $CONFDIR/hostapd.conf
eap_server=1
wps_state=2
ap_setup_locked=1
wps_pin_requests=$CONFDIR/hostapd.pin-req
device_name=Wireless AP
manufacturer=create_ap
model_name=WAP
model_number=123
serial_number=12345
device_type=6-0050F204-1
os_version=01020300
config_methods=label display push_button keypad
EOF
fi


# initialize WiFi interface
if [[ $NO_VIRT -eq 0 && -n "$NEW_MACADDR" ]]; then
ip link set dev ${WIFI_IFACE} address ${NEW_MACADDR} || die "$VIRTDIEMSG"
Expand Down