gluon-mesh-batman-adv-core: move config not specific to batman-adv to gluon-core
This commit is contained in:
parent
f8f8a9ce00
commit
74cbd2939c
@ -1,10 +1,12 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local mesh = require 'gluon.mesh'
|
||||
local util = require 'gluon.util'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
local site = require 'gluon.site_config'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
-- Initial
|
||||
if not sysconfig.gluon_version then
|
||||
uci:delete_all('wireless', 'wifi-iface')
|
||||
@ -18,8 +20,135 @@ local function get_channel(radio, config)
|
||||
end
|
||||
end
|
||||
|
||||
local function is_disabled(name)
|
||||
if uci:get('wireless', name) then
|
||||
return uci:get_bool('wireless', name, 'disabled')
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns the first argument that is not nil; don't call without any non-nil arguments!
|
||||
local function first_non_nil(first, ...)
|
||||
if first ~= nil then
|
||||
return first
|
||||
else
|
||||
return first_non_nil(...)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function configure_ibss(config, radio, index, suffix, disabled)
|
||||
local name = 'ibss_' .. radio
|
||||
local ifname = 'ibss' .. suffix
|
||||
|
||||
uci:delete('network', name)
|
||||
uci:delete('network', name .. '_vlan')
|
||||
uci:delete('wireless', name)
|
||||
|
||||
if not config then
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 3)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
|
||||
if config.vlan then
|
||||
uci:section('network', 'interface', name,
|
||||
{
|
||||
proto = 'none',
|
||||
}
|
||||
)
|
||||
|
||||
uci:section('network', 'interface', name .. '_vlan',
|
||||
{
|
||||
ifname = '@' .. name .. '.' .. config.vlan,
|
||||
proto = 'none',
|
||||
auto = 1,
|
||||
}
|
||||
)
|
||||
|
||||
mesh.register_interface(ifname .. '.' .. config.vlan)
|
||||
else
|
||||
uci:section('network', 'interface', name,
|
||||
{
|
||||
proto = 'none',
|
||||
auto = 1,
|
||||
}
|
||||
)
|
||||
|
||||
mesh.register_interface(ifname)
|
||||
end
|
||||
|
||||
uci:section('wireless', 'wifi-iface', name,
|
||||
{
|
||||
device = radio,
|
||||
network = name,
|
||||
mode = 'adhoc',
|
||||
ssid = config.ssid,
|
||||
bssid = config.bssid,
|
||||
macaddr = macaddr,
|
||||
mcast_rate = config.mcast_rate,
|
||||
ifname = ifname,
|
||||
disabled = disabled and 1 or 0,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function configure_mesh(config, radio, index, suffix, disabled)
|
||||
local name = 'mesh_' .. radio
|
||||
local ifname = 'mesh' .. suffix
|
||||
local macfilter = uci:get('wireless', name, 'macfilter')
|
||||
local maclist = uci:get('wireless', name, 'maclist')
|
||||
|
||||
uci:delete('network', name)
|
||||
uci:delete('wireless', name)
|
||||
|
||||
if not config then
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 2)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
|
||||
mesh.register_interface(ifname)
|
||||
|
||||
uci:section('network', 'interface', name,
|
||||
{
|
||||
proto = 'none',
|
||||
auto = 1,
|
||||
}
|
||||
)
|
||||
|
||||
uci:section('wireless', 'wifi-iface', name,
|
||||
{
|
||||
device = radio,
|
||||
network = name,
|
||||
mode = 'mesh',
|
||||
mesh_id = config.id,
|
||||
mesh_fwding = 0,
|
||||
macaddr = macaddr,
|
||||
mcast_rate = config.mcast_rate,
|
||||
ifname = ifname,
|
||||
disabled = disabled and 1 or 0,
|
||||
macfilter = macfilter,
|
||||
maclist = maclist,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function configure_radio(radio, index, config)
|
||||
if config then
|
||||
if not config then
|
||||
return
|
||||
end
|
||||
|
||||
local suffix = radio:match('^radio(%d+)$')
|
||||
if not suffix then
|
||||
return
|
||||
end
|
||||
|
||||
local channel = get_channel(radio, config)
|
||||
|
||||
uci:delete('wireless', radio, 'disabled')
|
||||
@ -39,9 +168,41 @@ local function configure_radio(radio, index, config)
|
||||
else
|
||||
uci:delete('wireless', radio, 'basic_rate')
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local ibss_disabled = is_disabled('ibss_' .. radio)
|
||||
local mesh_disabled = is_disabled('mesh_' .. radio)
|
||||
|
||||
configure_ibss(config.ibss, radio, index, suffix,
|
||||
first_non_nil(
|
||||
ibss_disabled,
|
||||
mesh_disabled,
|
||||
(config.ibss or {}).disabled, -- will be nil if config.ibss or config.ibss.disabled is unset
|
||||
false
|
||||
)
|
||||
)
|
||||
configure_mesh(config.mesh, radio, index, suffix,
|
||||
first_non_nil(
|
||||
mesh_disabled,
|
||||
ibss_disabled,
|
||||
(config.mesh or {}).disabled, -- will be nil if config.mesh or config.mesh.disabled is unset
|
||||
false
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
util.iterate_radios(configure_radio)
|
||||
|
||||
|
||||
if uci:get('system', 'rssid_wlan0') then
|
||||
if uci:get('wireless', 'mesh_radio0') then
|
||||
uci:set('system', 'rssid_wlan0', 'dev', 'mesh0')
|
||||
else
|
||||
uci:set('system', 'rssid_wlan0', 'dev', 'ibss0')
|
||||
end
|
||||
|
||||
uci:save('system')
|
||||
end
|
||||
|
||||
uci:save('wireless')
|
||||
uci:save('network')
|
||||
|
17
package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan
Executable file
17
package/gluon-core/luasrc/lib/gluon/upgrade/210-interface-wan
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local network = require 'gluon.network'
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
if not uci:get('network', 'mesh_wan') then
|
||||
uci:section('network', 'interface', 'mesh_wan', {
|
||||
ifname = 'br-wan',
|
||||
proto = 'none',
|
||||
auto = site.mesh_on_wan and 1 or 0,
|
||||
})
|
||||
end
|
||||
|
||||
c:save('network')
|
||||
|
||||
network.update_mesh_on_wan()
|
@ -2,7 +2,6 @@
|
||||
|
||||
local mesh = require 'gluon.mesh'
|
||||
local site = require 'gluon.site_config'
|
||||
local util = require 'gluon.util'
|
||||
local sysconfig = require 'gluon.sysconfig'
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
@ -17,7 +16,6 @@ uci:section('network', 'interface', 'mesh_lan', {
|
||||
type = 'bridge',
|
||||
igmp_snooping = 0,
|
||||
proto = 'none',
|
||||
macaddr = util.get_mac(3),
|
||||
})
|
||||
|
||||
if uci:get('network', 'mesh_lan', 'auto') == nil then
|
@ -1,159 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local mesh = require 'gluon.mesh'
|
||||
local site = require 'gluon.site_config'
|
||||
local util = require 'gluon.util'
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
|
||||
local function is_disabled(name)
|
||||
if uci:get('wireless', name) then
|
||||
return uci:get_bool('wireless', name, 'disabled')
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns the first argument that is not nil; don't call without any non-nil arguments!
|
||||
local function first_non_nil(first, ...)
|
||||
if first ~= nil then
|
||||
return first
|
||||
else
|
||||
return first_non_nil(...)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
local function configure_ibss(config, radio, index, suffix, disabled)
|
||||
local name = 'ibss_' .. radio
|
||||
local ifname = 'ibss' .. suffix
|
||||
|
||||
uci:delete('network', name)
|
||||
uci:delete('network', name .. '_vlan')
|
||||
uci:delete('wireless', name)
|
||||
|
||||
if not config then
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 3)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
|
||||
if config.vlan then
|
||||
uci:section('network', 'interface', name,
|
||||
{
|
||||
proto = 'none',
|
||||
}
|
||||
)
|
||||
|
||||
uci:section('network', 'interface', name .. '_vlan',
|
||||
{
|
||||
ifname = '@' .. name .. '.' .. config.vlan,
|
||||
proto = 'none',
|
||||
auto = 1,
|
||||
}
|
||||
)
|
||||
|
||||
mesh.register_interface(ifname .. '.' .. config.vlan)
|
||||
else
|
||||
uci:section('network', 'interface', name,
|
||||
{
|
||||
proto = 'none',
|
||||
auto = 1,
|
||||
}
|
||||
)
|
||||
|
||||
mesh.register_interface(ifname)
|
||||
end
|
||||
|
||||
uci:section('wireless', 'wifi-iface', name,
|
||||
{
|
||||
device = radio,
|
||||
network = name,
|
||||
mode = 'adhoc',
|
||||
ssid = config.ssid,
|
||||
bssid = config.bssid,
|
||||
macaddr = macaddr,
|
||||
mcast_rate = config.mcast_rate,
|
||||
ifname = ifname,
|
||||
disabled = disabled and 1 or 0,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function configure_mesh(config, radio, index, suffix, disabled)
|
||||
local name = 'mesh_' .. radio
|
||||
local ifname = 'mesh' .. suffix
|
||||
local macfilter = uci:get('wireless', name, 'macfilter')
|
||||
local maclist = uci:get('wireless', name, 'maclist')
|
||||
|
||||
uci:delete('network', name)
|
||||
uci:delete('wireless', name)
|
||||
|
||||
if not config then
|
||||
return
|
||||
end
|
||||
|
||||
local macaddr = util.get_wlan_mac(radio, index, 2)
|
||||
if not macaddr then
|
||||
return
|
||||
end
|
||||
|
||||
mesh.register_interface(ifname)
|
||||
|
||||
uci:section('network', 'interface', name,
|
||||
{
|
||||
proto = 'none',
|
||||
auto = 1,
|
||||
}
|
||||
)
|
||||
|
||||
uci:section('wireless', 'wifi-iface', name,
|
||||
{
|
||||
device = radio,
|
||||
network = name,
|
||||
mode = 'mesh',
|
||||
mesh_id = config.id,
|
||||
mesh_fwding = 0,
|
||||
macaddr = macaddr,
|
||||
mcast_rate = config.mcast_rate,
|
||||
ifname = ifname,
|
||||
disabled = disabled and 1 or 0,
|
||||
macfilter = macfilter,
|
||||
maclist = maclist,
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
local function configure_radio(radio, index, config)
|
||||
local suffix = radio:match('^radio(%d+)$')
|
||||
if not suffix then
|
||||
return
|
||||
end
|
||||
|
||||
local ibss_disabled = is_disabled('ibss_' .. radio)
|
||||
local mesh_disabled = is_disabled('mesh_' .. radio)
|
||||
|
||||
configure_ibss(config.ibss, radio, index, suffix,
|
||||
first_non_nil(
|
||||
ibss_disabled,
|
||||
mesh_disabled,
|
||||
(config.ibss or {}).disabled, -- will be nil if config.ibss or config.ibss.disabled is unset
|
||||
false
|
||||
)
|
||||
)
|
||||
configure_mesh(config.mesh, radio, index, suffix,
|
||||
first_non_nil(
|
||||
mesh_disabled,
|
||||
ibss_disabled,
|
||||
(config.mesh or {}).disabled, -- will be nil if config.mesh or config.mesh.disabled is unset
|
||||
false
|
||||
)
|
||||
)
|
||||
end
|
||||
|
||||
util.iterate_radios(configure_radio)
|
||||
|
||||
uci:save('wireless')
|
||||
uci:save('network')
|
@ -1,19 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local network = require 'gluon.network'
|
||||
local site = require 'gluon.site_config'
|
||||
local uci = require 'luci.model.uci'
|
||||
|
||||
local c = uci.cursor()
|
||||
|
||||
if not c:get('network', 'mesh_wan') then
|
||||
c:section('network', 'interface', 'mesh_wan',
|
||||
{ ifname = 'br-wan'
|
||||
, proto = 'none'
|
||||
, auto = site.mesh_on_wan and 1 or 0
|
||||
})
|
||||
end
|
||||
|
||||
c:save('network')
|
||||
|
||||
network.update_mesh_on_wan()
|
@ -1,13 +0,0 @@
|
||||
#!/usr/bin/lua
|
||||
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
if uci:get('system', 'rssid_wlan0') then
|
||||
if uci:get('wireless', 'mesh_radio0') then
|
||||
uci:set('system', 'rssid_wlan0', 'dev', 'mesh0')
|
||||
else
|
||||
uci:set('system', 'rssid_wlan0', 'dev', 'ibss0')
|
||||
end
|
||||
|
||||
uci:save('system')
|
||||
end
|
@ -3,7 +3,7 @@
|
||||
local util = require 'gluon.util'
|
||||
local uci = require('luci.model.uci').cursor()
|
||||
|
||||
|
||||
-- fix up duplicate mac addresses (for mesh-on-WAN)
|
||||
-- fix up duplicate mac addresses (for meshing)
|
||||
uci:set('network', 'wan', 'macaddr', util.get_mac(2))
|
||||
uci:set('network', 'mesh_lan', 'macaddr', util.get_mac(3))
|
||||
uci:save('network')
|
Loading…
Reference in New Issue
Block a user