diff --git a/docs/index.rst b/docs/index.rst index 8af06f4fb0cd447a10b6f571e60712e35876c588..1719c23908258bd943039df62620050dde242e3e 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -43,6 +43,14 @@ Developer Documentation dev/wan dev/i18n +Packages +-------- + +.. toctree:: + :maxdepth: 1 + + package/gluon-client-bridge + Releases -------- diff --git a/docs/package/gluon-client-bridge.rst b/docs/package/gluon-client-bridge.rst new file mode 100644 index 0000000000000000000000000000000000000000..131072f65f33c3a6d6e493a665e7684ef6bce5f0 --- /dev/null +++ b/docs/package/gluon-client-bridge.rst @@ -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 diff --git a/package/gluon-client-bridge/Makefile b/package/gluon-client-bridge/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..6bbfed643dd4ff0c03b8219ea056d2f0bb927125 --- /dev/null +++ b/package/gluon-client-bridge/Makefile @@ -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)) diff --git a/package/gluon-client-bridge/check_site.lua b/package/gluon-client-bridge/check_site.lua new file mode 100644 index 0000000000000000000000000000000000000000..3a7d81ee8cb74d13de7b58c1826b301365c643f2 --- /dev/null +++ b/package/gluon-client-bridge/check_site.lua @@ -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 diff --git a/package/gluon-client-bridge/files/lib/gluon/upgrade/300-gluon-client-bridge-network b/package/gluon-client-bridge/files/lib/gluon/upgrade/300-gluon-client-bridge-network new file mode 100755 index 0000000000000000000000000000000000000000..5ee558cf7413b235a9ea2a25fe6aeed7b76bb902 --- /dev/null +++ b/package/gluon-client-bridge/files/lib/gluon/upgrade/300-gluon-client-bridge-network @@ -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') diff --git a/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless b/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless new file mode 100755 index 0000000000000000000000000000000000000000..4eaccacb58175b95afed932ae9e4e8f7a915504a --- /dev/null +++ b/package/gluon-client-bridge/files/lib/gluon/upgrade/320-gluon-client-bridge-wireless @@ -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') diff --git a/package/gluon-mesh-batman-adv-core/Makefile b/package/gluon-mesh-batman-adv-core/Makefile index 8358089cdfaf8191e89cdd08943a998ae0c84394..c256ac935488456d652bf37e1206ab835f47da7d 100644 --- a/package/gluon-mesh-batman-adv-core/Makefile +++ b/package/gluon-mesh-batman-adv-core/Makefile @@ -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 diff --git a/package/gluon-mesh-batman-adv-core/check_site.lua b/package/gluon-mesh-batman-adv-core/check_site.lua index 49fff159bda5d741eca63617ab0f562194f871dd..1977487181ff777d845b6d1c35477c20fd862984 100644 --- a/package/gluon-mesh-batman-adv-core/check_site.lua +++ b/package/gluon-mesh-batman-adv-core/check_site.lua @@ -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$') diff --git a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh index fe576e332252940e0646319605c1e2f195faf6ed..9fd5b4b08b8a0fdaec63bbbc3b8181d16c1d0bfc 100755 --- a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh +++ b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/310-gluon-mesh-batman-adv-core-mesh @@ -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) diff --git a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless index b1423f468a99c5d9fbf8dd79ab719c18b4061b12..66b438d809f7389f02e58a92b71580e88ccf3b5c 100755 --- a/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless +++ b/package/gluon-mesh-batman-adv-core/files/lib/gluon/upgrade/320-gluon-mesh-batman-adv-core-wireless @@ -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