Configure unique MAC addresses for all WLAN interfaces
This commit is contained in:
parent
b51e1063b7
commit
1803525745
@ -66,8 +66,8 @@ end
|
||||
-- Functions and IDs defined so far:
|
||||
-- (1, 0): WAN (for mesh-on-WAN)
|
||||
-- (1, 1): LAN (for mesh-on-LAN)
|
||||
-- (2, X): client interface for radioX
|
||||
-- (3, X): adhoc interface for radioX
|
||||
-- (2, n): client interface for the n'th radio
|
||||
-- (3, n): adhoc interface for n'th radio
|
||||
-- (4, 0): mesh VPN
|
||||
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)')
|
||||
|
@ -1,69 +1,76 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
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 radio = device['.name']
|
||||
local hwmode = c:get('wireless', radio, 'hwmode')
|
||||
local function configure_radio(radio, index, config)
|
||||
uci:delete('wireless', radio, 'disabled')
|
||||
|
||||
uci:set('wireless', radio, 'channel', config.channel)
|
||||
uci:set('wireless', radio, 'htmode', config.htmode)
|
||||
uci:set('wireless', radio, 'country', site.regdom)
|
||||
|
||||
local client = 'client_' .. radio
|
||||
uci:delete('wireless', client)
|
||||
uci:section('wireless', 'wifi-iface', client,
|
||||
{
|
||||
device = radio,
|
||||
network = 'client',
|
||||
mode = 'ap',
|
||||
ssid = config.ssid,
|
||||
macaddr = util.generate_mac(2, index),
|
||||
}
|
||||
)
|
||||
|
||||
local mesh = 'mesh_' .. radio
|
||||
uci:delete('network', mesh)
|
||||
uci:section('network', 'interface', mesh,
|
||||
{
|
||||
proto = 'batadv',
|
||||
mtu = '1528',
|
||||
mesh = 'bat0',
|
||||
}
|
||||
)
|
||||
|
||||
uci:delete('wireless', mesh)
|
||||
uci:section('wireless', 'wifi-iface', mesh,
|
||||
{
|
||||
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 radios = {}
|
||||
|
||||
uci:foreach('wireless', 'wifi-device',
|
||||
function(s)
|
||||
table.insert(radios, s['.name'])
|
||||
end
|
||||
)
|
||||
|
||||
for index, radio in ipairs(radios) do
|
||||
local hwmode = uci:get('wireless', radio, 'hwmode')
|
||||
|
||||
local config
|
||||
if hwmode == '11g' or hwmode == '11ng' then
|
||||
config = site.wifi24
|
||||
configure_radio(radio, index, site.wifi24)
|
||||
elseif hwmode == '11a' or hwmode == '11na' then
|
||||
config = site.wifi5
|
||||
else
|
||||
return true
|
||||
configure_radio(radio, index, site.wifi5)
|
||||
end
|
||||
|
||||
c:delete('wireless', radio, 'disabled')
|
||||
|
||||
c:set('wireless', radio, 'channel', config.channel)
|
||||
c:set('wireless', radio, 'htmode', config.htmode)
|
||||
c:set('wireless', radio, 'country', site.regdom)
|
||||
|
||||
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
|
||||
c:delete('network', mesh)
|
||||
c:section('network', 'interface', mesh,
|
||||
{
|
||||
proto = 'batadv',
|
||||
mtu = '1528',
|
||||
mesh = 'bat0',
|
||||
}
|
||||
)
|
||||
|
||||
c:delete('wireless', mesh)
|
||||
c:section('wireless', 'wifi-iface', mesh,
|
||||
{
|
||||
device = radio,
|
||||
network = mesh,
|
||||
mode = 'adhoc',
|
||||
ssid = config.mesh_ssid,
|
||||
bssid = config.mesh_bssid,
|
||||
mcast_rate = config.mesh_mcast_rate,
|
||||
}
|
||||
)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
c:foreach('wireless', 'wifi-device', configure_radio)
|
||||
|
||||
c:save('wireless')
|
||||
c:save('network')
|
||||
c:commit('wireless')
|
||||
c:commit('network')
|
||||
uci:save('wireless')
|
||||
uci:save('network')
|
||||
uci:commit('wireless')
|
||||
uci:commit('network')
|
||||
|
Loading…
Reference in New Issue
Block a user