In the past PR[1] to add SAE wifi-station support, a commenter[2] requested
that the mac option be changed into a list. After trying to migrate my old
RADIUS setup I found myself wanting this change as well as it would simplify
my config. This patch does precisely that. Old configs that specify
`option mac ....` still work without any issues.
This change was done for both PSK and SAE. The schema was updated as well.
[1]: https://github.com/openwrt/openwrt/pull/17145
[2]: https://github.com/openwrt/openwrt/pull/17145#issuecomment-
2523507953
Signed-off-by: Rany Hany <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/17650
Signed-off-by: Hauke Mehrtens <[email protected]>
"type": "object",
"properties": {
"mac": {
- "description": "The stations MAC",
- "type": "string",
- "default": "00:00:00:00:00:00"
+ "description": "The station's MAC addresses",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "default": ["00:00:00:00:00:00"]
},
"key": {
"description": "The passphrase that shall be used",
let file = fs.open(path, 'w');
for (let k, sta in stas)
if (sta.config.mac && sta.config.key) {
- let station = `${sta.config.mac} ${sta.config.key}\n`;
- if (sta.config.vid)
- station = `vlanid=${sta.config.vid} ` + station;
- file.write(station);
+ for (let mac in sta.config.mac) {
+ let station = `${mac} ${sta.config.key}\n`;
+ if (sta.config.vid)
+ station = `vlanid=${sta.config.vid} ` + station;
+ file.write(station);
+ }
}
file.close();
let file = fs.open(path, 'w');
for (let k, sta in stas)
if (sta.config.mac && sta.config.key) {
- let mac = sta.config.mac;
- if (mac == '00:00:00:00:00:00')
- mac = 'ff:ff:ff:ff:ff:ff';
-
- let station = `${sta.config.key}|mac=${mac}`;
- if (sta.config.vid)
- station = station + `|vlanid=${sta.config.vid}`;
- station = station + '\n';
- file.write(station);
+ for (let mac in sta.config.mac) {
+ if (mac == '00:00:00:00:00:00')
+ mac = 'ff:ff:ff:ff:ff:ff';
+
+ let station = `${sta.config.key}|mac=${mac}`;
+ if (sta.config.vid)
+ station = station + `|vlanid=${sta.config.vid}`;
+ station = station + '\n';
+ file.write(station);
+ }
}
file.close();
local vlan="$2"
local vlan_id=""
- json_get_vars mac vid key
- set_default mac "00:00:00:00:00:00"
+ json_get_vars vid key
+ json_get_values mac_list mac
+ set_default mac_list "00:00:00:00:00:00"
[ -n "$vid" ] && vlan_id="vlanid=$vid "
- echo "${vlan_id} ${mac} ${key}" >> /var/run/hostapd-${ifname}.psk
+ for mac in $mac_list; do
+ echo "${vlan_id} ${mac} ${key}" >> /var/run/hostapd-${ifname}.psk
+ done
}
hostapd_set_psk() {
local vlan="$2"
local vlan_id=""
- json_get_vars mac vid key
- set_default mac "ff:ff:ff:ff:ff:ff"
- [ -n "$mac" ] && mac="|mac=$mac"
+ json_get_vars vid key
+ json_get_values mac_list mac
+ set_default mac_list "ff:ff:ff:ff:ff:ff"
[ -n "$vid" ] && vlan_id="|vlanid=$vid"
- printf '%s%s%s\n' "${key}" "${mac}" "${vlan_id}" >> /var/run/hostapd-${ifname}.sae
+ for mac in $mac_list; do
+ mac="|mac=$mac"
+ printf '%s%s%s\n' "${key}" "${mac}" "${vlan_id}" >> /var/run/hostapd-${ifname}.sae
+ done
}
hostapd_set_sae() {
}
_wdev_common_station_config() {
- config_add_string mac key vid iface
+ config_add_string key vid iface
+ config_add_array mac
}
init_wireless_driver() {