Skip to content

Commit

Permalink
add valid-channels and allow-dfs options to radio sections
Browse files Browse the repository at this point in the history
Signed-off-by: John Crispin <[email protected]>
  • Loading branch information
blogic committed Feb 12, 2022
1 parent 9789c75 commit 35adc26
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 11 deletions.
20 changes: 13 additions & 7 deletions renderer/templates/radio.uc
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@
184, 192 ]
};

if (!length(radio.valid_channels) && radio.band == "5G")
radio.valid_channels = [ 36, 44, 52, 60, 100, 108, 116, 124, 132, 149, 157, 165, 173, 184, 192 ];

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) {
Expand Down Expand Up @@ -135,9 +140,10 @@ 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 }}.channels='36 44 52 60 100 108 116 124 132 149 157 165 173 184 192'
{% endif %}
set wireless.{{ phy.section }}.acs_exclude_dfs={{ b(!radio.allow_dfs) }}
{% for (let channel in radio.valid_channels): %}
add_list wireless.{{ phy.section }}.channels={{ channel }}
{% endfor %}
{% if (radio.he_settings && phy.he_mac_capa && match(htmode, /HE.*/)): %}
set wireless.{{ phy.section }}.he_bss_color={{ radio.he_settings.bss_color }}
set wireless.{{ phy.section }}.multiple_bssid={{ b(radio.he_settings.multiple_bssid) }}
Expand Down
15 changes: 14 additions & 1 deletion schema/radio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
49 changes: 47 additions & 2 deletions schemareader.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]);
Expand Down Expand Up @@ -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)
Expand All @@ -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" ]);
Expand Down
14 changes: 13 additions & 1 deletion ucentral.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@
"oneOf": [
{
"type": "integer",
"maximum": 171,
"maximum": 196,
"minimum": 1
},
{
Expand All @@ -383,6 +383,14 @@
}
]
},
"valid-channels": {
"type": "array",
"items": {
"type": "integer",
"maximum": 196,
"minimum": 1
}
},
"country": {
"type": "string",
"maxLength": 2,
Expand All @@ -391,6 +399,10 @@
"US"
]
},
"allow-dfs": {
"type": "boolean",
"default": false
},
"channel-mode": {
"type": "string",
"enum": [
Expand Down

0 comments on commit 35adc26

Please sign in to comment.