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 PHY_DIR
="/sys/class/ieee80211"
27 echo "${PHY_DIR}/${phy}"
34 [ -d "$(phy_dir ${phy})" ]
38 list_directory
"$(phy_dir)"
45 # As this is already a valid phy, we don't need to search on...
46 if phy_exists
"${info}"; then
51 # If this is an existing device, we can figure out the name of the
53 if device_exists
${info}; then
54 phy
="$(device_get_phy ${info})"
56 # If we just got the MAC address we need to walk though all
57 # available phys and find the right one.
58 elif mac_is_valid
${info}; then
60 for i
in $
(phy_list
); do
61 if [ "${info}" = "$(phy_get_address ${i})" ]; then
68 log DEBUG
"Searching for phy = ${info}, found ${phy:-none}"
70 if [ -z "${phy}" ]; then
82 local path
="$(phy_dir ${phy})/macaddress"
83 [ -r "${path}" ] ||
return ${EXIT_ERROR}
92 get_driver_from_path
"$(phy_dir "${phy}")/device/driver/module"
100 for device
in $
(device_list
); do
101 local p
="$(device_get_phy "${device}")"
103 if [ "${phy}" = "${p}" ]; then
112 # Check if the PHY exists
113 assert phy_exists
"${phy}"
116 for led
in $
(list_directory
/sys
/class
/leds
); do
117 # Get basename of the LED
120 if [[ ${led} =~
${phy}(:.
*)?$
]]; then
126 # This function tries to automatically configure LEDs to
128 phy_leds_autoconf
() {
133 for led
in $
(phy_list_leds
"${phy}"); do
134 # Skip some types of LEDs
136 # Pretty much everything we tested from Ralink
137 # locked up the kernel after a couple of seconds
143 # We try to set the LED into tpt mode (flashing on activity),
144 # but will fallback to tx mode if that isn't supported
146 for trigger
in "${phy}tpt" "${phy}tx"; do
147 if led_set_trigger
"${led}" "${trigger}"; then
156 phy_supports_channel
() {
161 assert isinteger channel
163 local _channel _frequency _dfs _max_tx_power
164 while read -r _channel _frequency _dfs _max_tx_power
; do
165 if [ "${channel}" = "${_channel}" ]; then
168 done <<< "$(network-phy-list-channels "${phy}")"
173 __phy_list_ht_capabilities
() {
177 local capabilities
="$(network-phy-list-ht-caps "${phy}")"
179 print
"${capabilities//[\[\]]/ }"
182 phy_supports_ht_capability
() {
186 local capability
="${2}"
187 assert isset capability
189 list_match
"${capability}" $
(__phy_list_ht_capabilities
"${phy}")