]> git.ipfire.org Git - people/ms/network.git/blobdiff - src/functions/functions.phy
libnetwork: Add function to check if a PHY supports a specific channel
[people/ms/network.git] / src / functions / functions.phy
index a4067d4ebd8a9bfc252343b1c05275231fa98a31..76974fa860c46c2fc0766ad49f8436d5ea9842f9 100644 (file)
@@ -152,3 +152,20 @@ phy_leds_autoconf() {
 
        return ${EXIT_OK}
 }
+
+phy_supports_channel() {
+       local phy="${1}"
+       assert isset phy
+
+       local channel="${2}"
+       assert isinteger channel
+
+       local _channel _frequency _dfs _max_tx_power
+       while read -r _channel _frequency _dfs _max_tx_power; do
+               if [ "${channel}" = "${_channel}" ]; then
+                       return ${EXIT_TRUE}
+               fi
+       done <<< "$(network-phy-list-channels "${phy}")"
+
+       return ${EXIT_FALSE}
+}