While ath9k/ath10k devices can supprt VIFs with any combination of MAC addresses, there are also adapters which have a hardware MAC filter which only allows a few bits to differ. This commit changes the addresses of all VIFs to ony differ in the last 3 bits, which is required to support many Ralink/Mediatek based WLAN adapters. Technically, the new addresses are generated by calculating an MD5 hash of the primary MAC address and using a part of this hash as a prefix for the MAC addresses. The addresses (BSSIDs) of the AP VIFs are also reused for the LAN and WAN interfaces in mesh-on-LAN/WAN mode to reduce the number of needed addresses, and thus reduce the chance of collisions. This is not a problem as the MAC addresses of the AP VIFs are never used except as BSSID, and thus not seen by routing protocols like batman-adv. Fixes #648 [Matthias Schiffer: rewrote commit message]
50 lines
1.1 KiB
Lua
Executable File
50 lines
1.1 KiB
Lua
Executable File
#!/usr/bin/lua
|
|
|
|
local site = require 'gluon.site_config'
|
|
local util = require 'gluon.util'
|
|
|
|
local uci = require('luci.model.uci').cursor()
|
|
|
|
|
|
local function is_disabled(config, name)
|
|
local disabled = config and config.disabled
|
|
if uci:get('wireless', name) then
|
|
disabled = uci:get_bool('wireless', name, 'disabled')
|
|
end
|
|
|
|
return disabled and 1 or 0
|
|
end
|
|
|
|
local function configure_client(config, radio, index, suffix)
|
|
local name = 'client_' .. radio
|
|
local disabled = is_disabled(config, name)
|
|
|
|
uci:delete('wireless', name)
|
|
|
|
macaddr = util.generate_mac(3*index)
|
|
|
|
if config and macaddr then
|
|
uci:section('wireless', 'wifi-iface', name,
|
|
{
|
|
device = radio,
|
|
network = 'client',
|
|
mode = 'ap',
|
|
ssid = config.ssid,
|
|
macaddr = macaddr,
|
|
ifname = suffix and 'client' .. suffix,
|
|
disabled = disabled,
|
|
}
|
|
)
|
|
end
|
|
end
|
|
|
|
local function configure_radio(radio, index, config)
|
|
local suffix = radio:match('^radio(%d+)$')
|
|
|
|
configure_client(config.ap, radio, index, suffix)
|
|
end
|
|
|
|
util.iterate_radios(configure_radio)
|
|
|
|
uci:save('wireless')
|