Browse Source

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

This package provides br-client and sets up a wireless AP interface for
clients.
Nils Schneider 8 years ago
parent
commit
84b6374970

+ 8 - 0
docs/index.rst

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

+ 11 - 0
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

+ 36 - 0
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))

+ 6 - 0
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

+ 27 - 0
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')

+ 48 - 0
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')

+ 1 - 1
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

+ 0 - 5
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$')

+ 3 - 20
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)
 

+ 0 - 22
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