2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2012 IPFire Network Development Team #
7 # This program is free software: you can redistribute it and/or modify #
8 # it under the terms of the GNU General Public License as published by #
9 # the Free Software Foundation, either version 3 of the License, or #
10 # (at your option) any later version. #
12 # This program is distributed in the hope that it will be useful, #
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
15 # GNU General Public License for more details. #
17 # You should have received a copy of the GNU General Public License #
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. #
20 ###############################################################################
22 WPA_SUPPLICANT_SOCKET_DIR
="${RUN_DIR}/wpa_supplicant/ctrl"
24 wpa_supplicant_config_header
() {
25 config_header
"WPA supplicant configuration file"
27 # Set control socket directory.
28 print
"ctrl_interface=${WPA_SUPPLICANT_SOCKET_DIR}"
31 local country
="$(wireless_get_reg_domain)"
32 if isset country
; then
33 print
"country=${country}"
39 wpa_supplicant_config_destroy
() {
43 file_delete
"${WPA_SUPPLICANT_CONF_DIR}/${device}.conf"
46 wpa_supplicant_start
() {
50 service_start
"wpa_supplicant@${device}.service"
53 wpa_supplicant_stop
() {
57 service_stop
"wpa_supplicant@${device}.service"
60 wpa_supplicant_client
() {
68 # Run the command and return the output.
69 cmd wpa_cli
-p${WPA_SUPPLICANT_SOCKET_DIR} -i${device} ${cmd}
76 wpa_supplicant_client
${device} status verbose
79 wpa_cli_status_get
() {
87 while read -r line
; do
88 key
=$
(cli_get_key
${line})
90 if [ "${key}" = "${arg}" ]; then
94 done <<< "$(wpa_cli_status ${device})"
106 wpa_supplicant_client
${device} bss
${bss}
120 while read -r line
; do
121 key
=$
(cli_get_key
${line})
123 if [ "${key}" = "${arg}" ]; then
124 cli_get_val
"${line}"
127 done <<< "$(wpa_cli_bss ${device} ${bss})"
132 wpa_cli_bss_get_frequency
() {
139 wpa_cli_bss_get
${device} ${bssid} freq
142 wpa_cli_bss_get_noise
() {
149 wpa_cli_bss_get
${device} ${bssid} noise
152 wpa_cli_bss_get_quality
() {
159 local quality
=$
(wpa_cli_bss_get
${device} ${bssid} qual
)
162 print $
(( ${quality} * 100 / 70 ))
165 wpa_cli_bss_get_flags
() {
172 wpa_cli_bss_get
${device} ${bssid} flags