renderer: add ssid purpose support

This allow us to use pre-defined BSS settings

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-06-16 09:10:49 +02:00
parent 3eb43a120f
commit 0cd335a51b
5 changed files with 78 additions and 1 deletions

View File

@@ -1,4 +1,45 @@
{%
let purpose = {
"onboarding-ap": {
"name": "OpenWifi-onboarding",
"hidden_ssid": true,
"isolate_clients": true,
"wifi_bands": [
"2G"
],
"bss_mode": "ap",
"encryption": {
"proto": "wpa2",
"ieee80211w": "required"
},
"certificates": {
"use_local_certificates": true
},
"radius": {
"local": {
"server-identity": "uCentral-EAP"
}
}
},
"onboarding-sta": {
"name": "OpenWifi-onboarding",
"wifi_bands": [
"2G"
],
"bss_mode": "sta",
"encryption": {
"proto": "wpa2",
"ieee80211w": "required"
},
"certificates": {
"use_local_certificates": true
}
}
};
if (purpose[ssid.purpose])
ssid = purpose[ssid.purpose];
let phys = [];
for (let band in ssid.wifi_bands)

View File

@@ -60,7 +60,7 @@ try {
fs.symlink(ARGV[2], '/etc/ucentral/ucentral.active');
set_service_state(true);
if (split(old_config, ".")[1] == "/etc/ucentral/ucentral")
if (old_config && split(old_config, ".")[1] == "/etc/ucentral/ucentral")
fs.unlink(old_config);
} else {
error = 1;

View File

@@ -3,6 +3,16 @@ description:
These properties are described inside this object.
type: object
properties:
purpose:
description:
An SSID can have a special purpose such as the hidden on-boarding BSS.
All purposes other than "user-defined" are static pre-defined configurations.
type: string
enum:
- user-defined
- onboarding-ap
- onboarding-sta
default: user-defined
name:
description:
The broadcasted SSID of the wireless network and for for managed mode

View File

@@ -2597,6 +2597,23 @@ function instantiateInterfaceSsid(location, value, errors) {
if (type(value) == "object") {
let obj = {};
function parsePurpose(location, value, errors) {
if (type(value) != "string")
push(errors, [ location, "must be of type string" ]);
if (!(value in [ "user-defined", "onboarding-ap", "onboarding-sta" ]))
push(errors, [ location, "must be one of \"user-defined\", \"onboarding-ap\" or \"onboarding-sta\"" ]);
return value;
}
if (exists(value, "purpose")) {
obj.purpose = parsePurpose(location + "/purpose", value["purpose"], errors);
}
else {
obj.purpose = "user-defined";
}
function parseName(location, value, errors) {
if (type(value) == "string") {
if (length(value) > 32)

View File

@@ -1036,6 +1036,15 @@
"interface.ssid": {
"type": "object",
"properties": {
"purpose": {
"type": "string",
"enum": [
"user-defined",
"onboarding-ap",
"onboarding-sta"
],
"default": "user-defined"
},
"name": {
"type": "string",
"maxLength": 32,