add wifi channels groups

U-NII groups for 5GHz
Non-Overlapping channel groups for 2GHz
This commit is contained in:
Johannes Kimmel 2023-04-25 02:01:32 +02:00
parent 7795a0d8d0
commit 89a4687c81
1 changed files with 42 additions and 22 deletions

View File

@ -82,8 +82,8 @@ class L3Section {
if (typeof this.presetname === 'string') {
sectionname = ` '${this.presetname}'`;
} else if (this.presetname instanceof HTMLElement
&& this.presetname.tagName === 'INPUT'
&& this.presetname.value) {
&& this.presetname.tagName === 'INPUT'
&& this.presetname.value) {
sectionname = ` '${this.presetname.value}'`;
}
return `config ${this.legend}${sectionname}\n\t` + optstrs.join('\n\t');
@ -213,11 +213,19 @@ class L3Select {
}
div.appendChild(this.input);
for (const [label, value] of this.optionList) {
let option = document.createElement('option');
option.setAttribute('value', value);
option.appendChild(makeText(label));
this.input.appendChild(option);
for (const [optgrouplabel, options] of this.optionList) {
let target = this.input;
if (optgrouplabel != '') {
target = document.createElement('optgroup');
target.setAttribute('label', optgrouplabel);
this.input.appendChild(target);
}
for (const [label, value] of options) {
let option = document.createElement('option');
option.setAttribute('value', value);
option.appendChild(makeText(label));
target.appendChild(option);
}
}
return div;
@ -293,11 +301,15 @@ function initForm() {
let form = document.createElement('form');
l3configinput.appendChild(form);
const UNII1Channels = [36, 40, 44, 48];
const UNII2Channels = [52, 56, 60, 64];
const UNII2EChannels = [100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140];
const Channels5GHz = [...UNII1Channels, ...UNII2Channels, ...UNII2EChannels].map(chan => [`${chan} (${5000+chan*5}MHz)`, chan.toString()]);
const label5ghz = (chan) => [`${chan} (${5000+chan*5}MHz)`, chan.toString()]
const label2ghz = (chan) => [`${chan} (${2407+chan*5}MHz)`, chan.toString()]
const UNII1Channels = [36, 40, 44, 48].map(label5ghz);
const UNII2Channels = [52, 56, 60, 64].map(label5ghz);
const UNII2EChannels = [100, 104, 108, 112, 116, 120, 124, 128, 132, 136, 140].map(label5ghz);
const Channels5GHz = [...UNII1Channels, ...UNII2Channels, ...UNII2EChannels];
const Channels2GHz = Array(13).fill().map((_, chan) => [`${chan+1} (${2412 + chan*5}MHz)`, (chan+1).toString()]);
const Channels2GHzOFDM = [1,5,9,13].map(label2ghz);
const Channels2GHzDSSS = [1,6,11].map(label2ghz);
const l3cfg = new L3Config();
l3cfg.addSection(new L3Section('gateway', 'meta',
@ -312,9 +324,11 @@ function initForm() {
));
l3cfg.addSection(new L3Section('dns', undefined,
new L3Select('Preset','dnsAnycastSelect', 'server', {name: 'anycast'}, [
['Anycast DNS', 'fd43:5602:29bd:ffff:1:1:1:1'],
['Anycast DNS64', 'fd43:5602:29bd:ffff:1:1:1:64'],
['---', undefined],
['', [
['Anycast DNS', 'fd43:5602:29bd:ffff:1:1:1:1'],
['Anycast DNS64', 'fd43:5602:29bd:ffff:1:1:1:64'],
['---', undefined],
]],
]),
new L3MultiInput('Custom DNS Server', function(idsuffix) {
return new L3Input(undefined,'dnsOther'+idsuffix, 'server', {type: 'text', maxlength: 39, placeholder: 'Custom DNS Server'});
@ -338,12 +352,16 @@ function initForm() {
new L3Input('DHCP Number of Addresses','clientDHCPLimit', 'dhcp_limit', {type: 'number', min: 1, max: 65535}),
new L3Input('Wifi ESSID','clientESSID', 'essid', {type: 'text'}),
new L3Select('Wifi 2.4 GHz Channel','client2GHZ', 'chan2ghz', {name: 'chan2ghz'}, [
['---', undefined],
...Channels2GHz,
]),
['', [['---', undefined]]],
['Non-Overlapping Channels (OFDM)', Channels2GHzOFDM],
['Non-Overlapping Channels (DSSS)', Channels2GHzDSSS],
['All Channels', Channels2GHz],
]),
new L3Select('Wifi 5 GHz Channel','client5GHZ', 'chan5ghz', {name: 'chan5ghz'}, [
['---', undefined],
...Channels5GHz,
['', [['---', undefined]]],
['U-NII-1 Channels (Indoor)', UNII1Channels],
['U-NII-2 Channels (Indoor + DFS)', UNII2Channels],
['U-NII-2E Channels (Indoor + Outdoor + DFS)', UNII2EChannels],
]),
));
l3cfg.addSection(new L3MultiSection('VLAN', function(idsuffix) {
@ -357,9 +375,11 @@ function initForm() {
new L3Input('Use VLAN','babelpeerVLAN'+idsuffix, 'vlan', {type: 'number', min: 1, max: 4094}),
new L3Input('Use Interface directly','babelpeerIFACE'+idsuffix, 'iface', {type: 'text', placeholder: 'eth0, eth0.4, ...'}),
new L3Select('Babel Interface Type','babelpeerType'+idsuffix, 'type', {name: 'type'}, [
['Default', undefined],
['Wired', 'wired'],
['Wireless', 'wireless'],
['', [
['Default', ''],
['Wired', 'wired'],
['Wireless', 'wireless'],
]],
]),
new L3Input('rxcost','babelpeerRXCost'+idsuffix, 'rxcost', {type: 'number', min: 96, max: 65535, placeholder: 'LAN: 96, Tunnel: 4096, ...'}),
);