gluon/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless
Matthias Schiffer 86ef9b0e97
Fix creation of IBSS interfaces on devices with two radios
Lua's tables are 1-based, so we must decrement the index by 1 to get the
desired MAC addresses. By not doing this, the second IBSS interface would
get the address with index 8, but only indices 0..7 are available.

Fixes: c73a12e0ea
2016-05-14 00:34:04 +02:00

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-1))
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')