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 ADDRESS PHY"
26 hook_check_settings
() {
31 hook_parse_cmdline
() {
32 while [ $# -gt 0 ]; do
35 ADDRESS
=$
(cli_get_val
"${1}")
38 PHY
=$
(cli_get_val
"${1}")
41 warning
"Unrecognized option: ${1}"
47 # Just save the MAC address of the phy.
49 PHY
=$
(phy_get_address
${PHY})
51 # Generate a random MAC address if none given
52 if ! isset ADDRESS
; then
53 ADDRESS
="$(mac_generate)"
61 # Read zone configuration.
62 zone_settings_read
"${zone}"
64 # Create the wireless interface
65 if ! device_exists
"${zone}"; then
66 wireless_create
"${zone}" \
69 --address="${ADDRESS}" \
73 # Write WPA supplicant configuration
74 if ! wireless_networks_write_wpa_supplicant_configuration
"${zone}"; then
75 log ERROR
"Could not write WPA supplicant configuration for ${zone}"
79 # Start the WPA supplicant daemon.
80 wpa_supplicant_start
${zone}
82 zone_configs_up
${zone}
91 if ! device_is_up
${zone}; then
92 warning
"Zone '${zone}' is not up"
96 zone_configs_down
${zone}
98 wpa_supplicant_stop
${zone}
100 # Remove WPA supplicant configuration
101 wpa_supplicant_config_destroy
"${zone}"
103 wireless_remove
${zone}
112 # Print the default header.
113 cli_device_headline
${zone}
115 # Exit if zone is down
116 if ! zone_is_up
${zone}; then
121 cli_headline
2 "Wireless network information"
122 cli_print_fmt1
2 "SSID" "$(wpa_cli_status_get ${zone} ssid)"
125 cli_headline
3 "Access Point"
126 local bssid
=$
(wpa_cli_status_get
${zone} bssid
)
129 local frequency
=$
(wpa_cli_bss_get_frequency
"${zone}" "${bssid}")
130 cli_print_fmt1
3 "Channel" "$(wireless_frequency_to_channel ${frequency}) (${frequency} MHz)"
131 cli_print_fmt1
3 "BSSID" "${bssid}"
132 cli_print_fmt1
3 "Noise" \
133 "$(wpa_cli_bss_get_noise ${zone} ${bssid})"
134 cli_print_fmt1
3 "Quality" \
135 "$(wpa_cli_bss_get_quality ${zone} ${bssid})%%"
136 cli_print_fmt1
3 "Flags" \
137 "$(wpa_cli_bss_get_flags ${zone} ${bssid})"
140 cli_headline
3 "Encryption"
141 cli_print_fmt1
3 "Mode" \
142 "$(wpa_cli_status_get ${zone} key_mgmt)"
143 cli_print_fmt1
3 "Pairwise cipher" \
144 "$(wpa_cli_status_get ${zone} pairwise_cipher)"
145 cli_print_fmt1
3 "Group cipher" \
146 "$(wpa_cli_status_get ${zone} group_cipher)"
149 cli_headline
2 "Configurations"
150 zone_configs_cmd status
${zone}