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 <john@phrozen.org>
  • Loading branch information
blogic committed Feb 12, 2022
1 parent 9789c75 commit 68b8888
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 9 deletions.
17 changes: 12 additions & 5 deletions renderer/templates/radio.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.*/)): %}
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 68b8888

Please sign in to comment.