Skip to content
Snippets Groups Projects
Commit 18035257 authored by Matthias Schiffer's avatar Matthias Schiffer
Browse files

Configure unique MAC addresses for all WLAN interfaces

parent b51e1063
No related branches found
No related tags found
No related merge requests found
...@@ -66,8 +66,8 @@ end ...@@ -66,8 +66,8 @@ end
-- Functions and IDs defined so far: -- Functions and IDs defined so far:
-- (1, 0): WAN (for mesh-on-WAN) -- (1, 0): WAN (for mesh-on-WAN)
-- (1, 1): LAN (for mesh-on-LAN) -- (1, 1): LAN (for mesh-on-LAN)
-- (2, X): client interface for radioX -- (2, n): client interface for the n'th radio
-- (3, X): adhoc interface for radioX -- (3, n): adhoc interface for n'th radio
-- (4, 0): mesh VPN -- (4, 0): mesh VPN
function generate_mac(f, i) function generate_mac(f, i)
local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)') local m1, m2, m3, m4, m5, m6 = string.match(sysconfig.primary_mac, '(%x%x):(%x%x):(%x%x):(%x%x):(%x%x):(%x%x)')
......
#!/usr/bin/lua #!/usr/bin/lua
local site = require 'gluon.site_config' local site = require 'gluon.site_config'
local uci = require 'luci.model.uci' local util = require 'gluon.util'
local c = uci.cursor() local uci = require('luci.model.uci').cursor()
local function configure_radio(device) local function configure_radio(radio, index, config)
local radio = device['.name'] uci:delete('wireless', radio, 'disabled')
local hwmode = c:get('wireless', radio, 'hwmode')
local config uci:set('wireless', radio, 'channel', config.channel)
if hwmode == '11g' or hwmode == '11ng' then uci:set('wireless', radio, 'htmode', config.htmode)
config = site.wifi24 uci:set('wireless', radio, 'country', site.regdom)
elseif hwmode == '11a' or hwmode == '11na' then
config = site.wifi5 local client = 'client_' .. radio
else uci:delete('wireless', client)
return true uci:section('wireless', 'wifi-iface', client,
end {
device = radio,
network = 'client',
mode = 'ap',
ssid = config.ssid,
macaddr = util.generate_mac(2, index),
}
)
c:delete('wireless', radio, 'disabled') local mesh = 'mesh_' .. radio
uci:delete('network', mesh)
uci:section('network', 'interface', mesh,
{
proto = 'batadv',
mtu = '1528',
mesh = 'bat0',
}
)
c:set('wireless', radio, 'channel', config.channel) uci:delete('wireless', mesh)
c:set('wireless', radio, 'htmode', config.htmode) uci:section('wireless', 'wifi-iface', mesh,
c:set('wireless', radio, 'country', site.regdom) {
device = radio,
network = mesh,
mode = 'adhoc',
ssid = config.mesh_ssid,
bssid = config.mesh_bssid,
macaddr = util.generate_mac(3, index),
mcast_rate = config.mesh_mcast_rate,
}
)
end
local client = 'client_' .. radio
c:delete('wireless', client)
c:section('wireless', 'wifi-iface', client,
{
device = radio,
network = 'client',
mode = 'ap',
ssid = config.ssid,
}
)
local mesh = 'mesh_' .. radio local radios = {}
c:delete('network', mesh)
c:section('network', 'interface', mesh,
{
proto = 'batadv',
mtu = '1528',
mesh = 'bat0',
}
)
c:delete('wireless', mesh) uci:foreach('wireless', 'wifi-device',
c:section('wireless', 'wifi-iface', mesh, function(s)
{ table.insert(radios, s['.name'])
device = radio, end
network = mesh, )
mode = 'adhoc',
ssid = config.mesh_ssid,
bssid = config.mesh_bssid,
mcast_rate = config.mesh_mcast_rate,
}
)
return true for index, radio in ipairs(radios) do
local hwmode = uci:get('wireless', radio, 'hwmode')
local config
if hwmode == '11g' or hwmode == '11ng' then
configure_radio(radio, index, site.wifi24)
elseif hwmode == '11a' or hwmode == '11na' then
configure_radio(radio, index, site.wifi5)
end
end end
c:foreach('wireless', 'wifi-device', configure_radio)
c:save('wireless') uci:save('wireless')
c:save('network') uci:save('network')
c:commit('wireless') uci:commit('wireless')
c:commit('network') uci:commit('network')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment