Skip to content

Commit

Permalink
renderer: add ssid purpose support
Browse files Browse the repository at this point in the history
This allow us to use pre-defined BSS settings

Signed-off-by: John Crispin <[email protected]>
  • Loading branch information
blogic committed Jun 16, 2021
1 parent 3eb43a1 commit 8c1b9fa
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 1 deletion.
41 changes: 41 additions & 0 deletions renderer/templates/interface/ssid.uc
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion renderer/ucentral.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 10 additions & 0 deletions schema/interface.ssid.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions schemareader.uc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions ucentral.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8c1b9fa

Please sign in to comment.