From 68b8888ac462219fdadc66d568c0a6956e878c3a Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sat, 12 Feb 2022 15:13:48 +0100 Subject: [PATCH] add valid-channels and allow-dfs options to radio sections Signed-off-by: John Crispin --- renderer/templates/radio.uc | 17 +++++++++---- schema/radio.yml | 15 +++++++++++- schemareader.uc | 49 +++++++++++++++++++++++++++++++++++-- ucentral.schema.json | 14 ++++++++++- 4 files changed, 86 insertions(+), 9 deletions(-) diff --git a/renderer/templates/radio.uc b/renderer/templates/radio.uc index 473a48f..90d671d 100644 --- a/renderer/templates/radio.uc +++ b/renderer/templates/radio.uc @@ -46,10 +46,12 @@ function allowed_channel(radio) { if (!channel_list[radio.channel_width]) - return true; - if (radio.channel in channel_list[radio.channel_width]) - return true; - return false; + return false; + if (!(radio.channel in channel_list[radio.channel_width])) + return false; + if (radio.valid_channels && !(radio.channel in radio.valid_channels)) + return false; + return true; } function match_channel(phy, radio) { @@ -135,7 +137,12 @@ set wireless.{{ phy.section }}.txpower={{ radio.tx_power }} set wireless.{{ phy.section }}.legacy_rates={{ b(radio.legacy_rates) }} set wireless.{{ phy.section }}.chan_bw={{ radio.bandwidth }} set wireless.{{ phy.section }}.maxassoc={{ radio.maximum_clients }} -{% if (index(phy.band, "5G") >= 0): %} +set wireless.{{ phy.section }}.acs_exclude_dfs={{ !radio.allow_dfs }} +{% if (length(radio.valid_channels) > 0): %} +{% for (let channel in radio.valid_channels): %} +list wireless.{{ phy.section }}.channels={ channel } +{% endfor %} +{% else if (index(phy.band, "5G") >= 0): %} set wireless.{{ phy.section }}.channels='36 44 52 60 100 108 116 124 132 149 157 165 173 184 192' {% endif %} {% if (radio.he_settings && phy.he_mac_capa && match(htmode, /HE.*/)): %} diff --git a/schema/radio.yml b/schema/radio.yml index 90d43ef..649c425 100644 --- a/schema/radio.yml +++ b/schema/radio.yml @@ -30,10 +30,18 @@ properties: algorithm. oneOf: - type: integer - maximum: 171 + maximum: 196 minimum: 1 - type: string const: auto + valid-channels: + description: + Pass a list of valid-channels that can be used during ACS. + type: array + items: + type: integer + maximum: 196 + minimum: 1 country: description: Specifies the country code, affects the available channels and @@ -43,6 +51,11 @@ properties: minLength: 2 examples: - US + allow-dfs: + description: + This property defines whether a radio may use DFS channels. + type: boolean + default: false channel-mode: description: Define the ideal channel mode that the radio shall use. This can be 802.11n, 802.11ac diff --git a/schemareader.uc b/schemareader.uc index 040ad5a..b19f787 100644 --- a/schemareader.uc +++ b/schemareader.uc @@ -731,8 +731,8 @@ function instantiateRadio(location, value, errors) { function parseChannel(location, value, errors) { function parseVariant0(location, value, errors) { if (type(value) in [ "int", "double" ]) { - if (value > 171) - push(errors, [ location, "must be lower than or equal to 171" ]); + if (value > 196) + push(errors, [ location, "must be lower than or equal to 196" ]); if (value < 1) push(errors, [ location, "must be bigger than or equal to 1" ]); @@ -802,6 +802,37 @@ function instantiateRadio(location, value, errors) { obj.channel = parseChannel(location + "/channel", value["channel"], errors); } + function parseValidChannels(location, value, errors) { + if (type(value) == "array") { + function parseItem(location, value, errors) { + if (type(value) in [ "int", "double" ]) { + if (value > 196) + push(errors, [ location, "must be lower than or equal to 196" ]); + + if (value < 1) + push(errors, [ location, "must be bigger than or equal to 1" ]); + + } + + if (type(value) != "int") + push(errors, [ location, "must be of type integer" ]); + + return value; + } + + return map(value, (item, i) => parseItem(location + "/" + i, item, errors)); + } + + if (type(value) != "array") + push(errors, [ location, "must be of type array" ]); + + return value; + } + + if (exists(value, "valid-channels")) { + obj.valid_channels = parseValidChannels(location + "/valid-channels", value["valid-channels"], errors); + } + function parseCountry(location, value, errors) { if (type(value) == "string") { if (length(value) > 2) @@ -822,6 +853,20 @@ function instantiateRadio(location, value, errors) { obj.country = parseCountry(location + "/country", value["country"], errors); } + function parseAllowDfs(location, value, errors) { + if (type(value) != "bool") + push(errors, [ location, "must be of type boolean" ]); + + return value; + } + + if (exists(value, "allow-dfs")) { + obj.allow_dfs = parseAllowDfs(location + "/allow-dfs", value["allow-dfs"], errors); + } + else { + obj.allow_dfs = false; + } + function parseChannelMode(location, value, errors) { if (type(value) != "string") push(errors, [ location, "must be of type string" ]); diff --git a/ucentral.schema.json b/ucentral.schema.json index 1572004..21414e1 100644 --- a/ucentral.schema.json +++ b/ucentral.schema.json @@ -374,7 +374,7 @@ "oneOf": [ { "type": "integer", - "maximum": 171, + "maximum": 196, "minimum": 1 }, { @@ -383,6 +383,14 @@ } ] }, + "valid-channels": { + "type": "array", + "items": { + "type": "integer", + "maximum": 196, + "minimum": 1 + } + }, "country": { "type": "string", "maxLength": 2, @@ -391,6 +399,10 @@ "US" ] }, + "allow-dfs": { + "type": "boolean", + "default": false + }, "channel-mode": { "type": "string", "enum": [