]>
git.ipfire.org Git - people/stevee/network.git/blob - src/hooks/zones/wireless
e376ab0c19e48020c3b2a4e2cb11afb52a7da071
2 ###############################################################################
4 # IPFire.org - A linux based firewall #
5 # Copyright (C) 2010 Michael Tremer & Christian Schmidt #
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 .
/usr
/lib
/network
/header-zone
24 HOOK_SETTINGS
="HOOK PHY MAC MTU SSID KEY ENCRYPTION"
27 ADDRESS
=$
(mac_generate
)
34 function hook_check
() {
37 if isset ADDRESS
; then
44 if [ -n "${ENCRYPTION_MODE}" ]; then
49 function hook_parse_cmdline
() {
50 while [ $# -gt 0 ]; do
52 --phy=*|
--parent-device=*)
53 PHY
=$
(cli_get_val
${1})
56 ENCRYPTION_MODE
=$
(cli_get_val
${1})
59 ADDRESS
=$
(cli_get_val
${1})
62 SSID
=$
(cli_get_val
${1})
65 KEY
=$
(cli_get_val
${1})
68 warning
"Unrecognized option: ${1}"
74 # Just save the MAC address of the phy.
76 PHY
=$
(phy_get_address
${PHY})
83 # Read zone configuration.
84 zone_settings_read
"${zone}" ${HOOK_SETTINGS}
86 if ! device_exists
${zone}; then
87 # Create the wireless interface.
88 wireless_create
${zone} \
91 --address="${ADDRESS}" \
95 # Start the WPA supplicant daemon.
96 wpa_supplicant_start
${zone}
98 zone_configs_up
${zone}
103 function hook_down
() {
107 if ! device_is_up
${zone}; then
108 warning
"Zone '${zone}' is not up"
112 zone_configs_down
${zone}
114 wpa_supplicant_stop
${zone}
116 wireless_remove
${zone}
121 function hook_status
() {
125 # Print the default header.
126 cli_device_headline
${zone}
128 # Exit if zone is down
129 if ! zone_is_up
${zone}; then
134 cli_headline
2 "Wireless network information"
135 cli_print_fmt1
2 "SSID" "$(wpa_cli_status_get ${zone} ssid)"
138 cli_headline
3 "Access Point"
139 local bssid
=$
(wpa_cli_status_get
${zone} bssid
)
142 cli_print_fmt1
3 "BSSID" "${bssid}"
143 cli_print_fmt1
3 "Frequency" \
144 "$(wpa_cli_bss_get_frequency ${zone} ${bssid}) MHz"
145 cli_print_fmt1
3 "Noise" \
146 "$(wpa_cli_bss_get_noise ${zone} ${bssid})"
147 cli_print_fmt1
3 "Quality" \
148 "$(wpa_cli_bss_get_quality ${zone} ${bssid})"
149 cli_print_fmt1
3 "Flags" \
150 "$(wpa_cli_bss_get_flags ${zone} ${bssid})"
153 cli_headline
3 "Encryption"
154 cli_print_fmt1
3 "Mode" \
155 "$(wpa_cli_status_get ${zone} key_mgmt)"
156 cli_print_fmt1
3 "Pairwise cipher" \
157 "$(wpa_cli_status_get ${zone} pairwise_cipher)"
158 cli_print_fmt1
3 "Group cipher" \
159 "$(wpa_cli_status_get ${zone} group_cipher)"
162 cli_headline
2 "Configurations"
163 zone_configs_cmd status
${zone}