gluon-client-bridge: basic br-client config and wireless AP

This package provides br-client and sets up a wireless AP interface for
clients.
This commit is contained in:
Nils Schneider 2015-08-18 00:53:40 +02:00 committed by Matthias Schiffer
parent 22130e84e8
commit 84b6374970
10 changed files with 140 additions and 48 deletions

View File

@ -43,6 +43,14 @@ Developer Documentation
dev/wan
dev/i18n
Packages
--------
.. toctree::
:maxdepth: 1
package/gluon-client-bridge
Releases
--------

View File

@ -0,0 +1,11 @@
gluon-client-bridge
===================
This package provides a bridge (*br-client*) for connecting clients. It will
also setup a wireless interface, provided it is configured in *site.conf*.
site.conf
---------
wifi24.ap.ssid / wifi5.ap.ssid
SSID for the client network

View File

@ -0,0 +1,36 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=gluon-client-bridge
PKG_VERSION:=1
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
include $(GLUONDIR)/include/package.mk
define Package/gluon-client-bridge
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Provides a bridge and a wireless interface for clients to connect to
DEPENDS:=+gluon-core
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
endef
define Build/Configure
endef
define Build/Compile
endef
define Package/gluon-client-bridge/install
$(CP) ./files/* $(1)/
endef
define Package/gluon-client-bridge/postinst
#!/bin/sh
$(call GluonCheckSite,check_site.lua)
endef
$(eval $(call BuildPackage,gluon-client-bridge))

View File

@ -0,0 +1,6 @@
for _, config in ipairs({'wifi24', 'wifi5'}) do
if need_table(config .. '.ap', nil, false) then
need_string(config .. '.ap.ssid')
need_boolean(config .. '.ap.disabled', false)
end
end

View File

@ -0,0 +1,27 @@
#!/usr/bin/lua
local sysconfig = require 'gluon.sysconfig'
local uci = require('luci.model.uci').cursor()
if not uci:get('network', 'client') then
uci:section('network', 'interface', 'client',
{
type = 'bridge',
}
)
end
local ifname = uci:get('network', 'client', 'ifname')
if type(ifname) == 'string' then
uci:delete('network', 'client', 'ifname')
for x in ifname:gmatch("[^%s]+") do
uci:add_to_set('network', 'client', 'ifname', x)
end
end
uci:set('network', 'client', 'macaddr', sysconfig.primary_mac)
uci:save('network')
uci:commit('network')

View File

@ -0,0 +1,48 @@
#!/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)
if config then
uci:section('wireless', 'wifi-iface', name,
{
device = radio,
network = 'client',
mode = 'ap',
ssid = config.ssid,
macaddr = util.generate_mac(2, index),
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')
uci:commit('wireless')

View File

@ -11,7 +11,7 @@ define Package/gluon-mesh-batman-adv-core
SECTION:=gluon
CATEGORY:=Gluon
TITLE:=Support for batman-adv meshing (core)
DEPENDS:=+gluon-core +firewall +libiwinfo-lua
DEPENDS:=+gluon-core +gluon-client-bridge +firewall +libiwinfo-lua
endef
define Build/Prepare

View File

@ -1,9 +1,4 @@
for _, config in ipairs({'wifi24', 'wifi5'}) do
if need_table(config .. '.ap', nil, false) then
need_string(config .. '.ap.ssid')
need_boolean(config .. '.ap.disabled', false)
end
if need_table(config .. '.ibss', nil, false) then
need_string(config .. '.ibss.ssid')
need_string_match(config .. '.ibss.bssid', '^%x[02468aAcCeE]:%x%x:%x%x:%x%x:%x%x:%x%x$')

View File

@ -24,16 +24,7 @@ uci:section('batman-adv', 'mesh', 'bat0',
uci:save('batman-adv')
uci:commit('batman-adv')
if not uci:get('network', 'client') then
uci:section('network', 'interface', 'client',
{
type = 'bridge',
proto = 'dhcpv6',
reqprefix = 'no',
}
)
if not uci:get('network', 'client', 'ifname') then
uci:add_to_set('network', 'client', 'ifname', 'bat0')
if sysconfig.lan_ifname and not site.mesh_on_lan then
@ -41,17 +32,9 @@ if not uci:get('network', 'client') then
end
end
local ifname = uci:get('network', 'client', 'ifname')
if type(ifname) == 'string' then
uci:delete('network', 'client', 'ifname')
for x in ifname:gmatch("[^%s]+") do
uci:add_to_set('network', 'client', 'ifname', x)
end
end
uci:set('network', 'client', 'proto', 'dhcpv6')
uci:set('network', 'client', 'reqprefix', 'no')
uci:set('network', 'client', 'igmp_snooping', 0)
uci:set('network', 'client', 'macaddr', sysconfig.primary_mac)
uci:set('network', 'client', 'peerdns', 1)
uci:set('network', 'client', 'sourcefilter', 0)

View File

@ -15,27 +15,6 @@ local function is_disabled(config, name)
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)
if config then
uci:section('wireless', 'wifi-iface', name,
{
device = radio,
network = 'client',
mode = 'ap',
ssid = config.ssid,
macaddr = util.generate_mac(2, index),
ifname = suffix and 'client' .. suffix,
disabled = disabled,
}
)
end
end
local function configure_ibss(config, radio, index, suffix)
local name = 'ibss_' .. radio
local disabled = is_disabled(config, name)
@ -122,7 +101,6 @@ end
local function configure_radio(radio, index, config)
local suffix = radio:match('^radio(%d+)$')
configure_client(config.ap, radio, index, suffix)
configure_ibss(config.ibss, radio, index, suffix)
configure_mesh(config.mesh, radio, index, suffix)
end