[02/11] fff-wireless: new package to configure wifi

Submitted by Tim Niemeyer on June 8, 2016, 4:29 p.m.

Details

Message ID 1465403387-3241-2-git-send-email-tim@tn-x.org
State Superseded, archived
Headers show

Commit Message

Tim Niemeyer June 8, 2016, 4:29 p.m.
Signed-off-by: Tim Niemeyer <tim@tn-x.org>
---

 bsp/ar71xx/.config                                 |   2 -
 bsp/default/root_file_system/etc/config/network    |   5 -
 .../root_file_system/etc/config/wireless.tpl       |  25 -----
 bsp/wdr4300/.config                                |   2 -
 bsp/wdr4300/root_file_system/etc/config/network    |  30 ------
 .../root_file_system/etc/config/wireless.tpl       |  51 ----------
 bsp/wdr4900/.config                                |   2 -
 bsp/wdr4900/root_file_system/etc/config/network    |  30 ------
 .../root_file_system/etc/config/wireless.tpl       |  51 ----------
 src/packages/fff/fff-wireless/Makefile             |  39 +++++++
 .../fff/fff-wireless/files/etc/config/wireless     |   0
 .../files/etc/uci-defaults/60-fff-wireless         |  43 ++++++++
 .../fff-wireless/files/lib/functions/fff/wireless  | 113 +++++++++++++++++++++
 src/packages/fff/fff/Makefile                      |   5 +-
 14 files changed, 198 insertions(+), 200 deletions(-)
 delete mode 100644 bsp/default/root_file_system/etc/config/wireless.tpl
 delete mode 100644 bsp/wdr4300/root_file_system/etc/config/network
 delete mode 100644 bsp/wdr4300/root_file_system/etc/config/wireless.tpl
 delete mode 100644 bsp/wdr4900/root_file_system/etc/config/network
 delete mode 100644 bsp/wdr4900/root_file_system/etc/config/wireless.tpl
 create mode 100644 src/packages/fff/fff-wireless/Makefile
 create mode 100644 src/packages/fff/fff-wireless/files/etc/config/wireless
 create mode 100644 src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
 create mode 100644 src/packages/fff/fff-wireless/files/lib/functions/fff/wireless

Patch hide | download patch | download mbox

diff --git a/bsp/ar71xx/.config b/bsp/ar71xx/.config
index f7b0097..e827685 100644
--- a/bsp/ar71xx/.config
+++ b/bsp/ar71xx/.config
@@ -5,7 +5,6 @@  CONFIG_TARGET_ar71xx=y
 CONFIG_TARGET_ar71xx_generic=y
 CONFIG_TARGET_ar71xx_generic_Default=y
 CONFIG_BUSYBOX_CUSTOM=y
-CONFIG_ATH_USER_REGD=y
 # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
 # CONFIG_BUSYBOX_CONFIG_CROND is not set
 # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
@@ -33,4 +32,3 @@  CONFIG_PACKAGE_libugpio=y
 # CONFIG_PACKAGE_ppp is not set
 CONFIG_PACKAGE_qos-scripts=y
 CONFIG_PACKAGE_tc=y
-CONFIG_PACKAGE_wireless-tools=y
diff --git a/bsp/default/root_file_system/etc/config/network b/bsp/default/root_file_system/etc/config/network
index b658385..1bab57f 100644
--- a/bsp/default/root_file_system/etc/config/network
+++ b/bsp/default/root_file_system/etc/config/network
@@ -4,11 +4,6 @@  config interface 'loopback'
         option ipaddr '127.0.0.1'
         option netmask '255.0.0.0'
 
-config interface 'w2mesh'
-        option mtu '1532'
-        option proto 'batadv'
-        option mesh 'bat0'
-
 config interface 'mesh'
         option type 'bridge'
         option auto '1'
diff --git a/bsp/default/root_file_system/etc/config/wireless.tpl b/bsp/default/root_file_system/etc/config/wireless.tpl
deleted file mode 100644
index 291eed1..0000000
--- a/bsp/default/root_file_system/etc/config/wireless.tpl
+++ /dev/null
@@ -1,25 +0,0 @@ 
-config wifi-device radio0
-    option type    mac80211
-    option channel ${BATMAN_CHANNEL}
-    option phy     phy0
-    option hwmode  11g
-    option htmode  HT20
-    option country DE
-
-config wifi-iface
-    option device     radio0
-    option network    w2mesh
-    option ifname     w2mesh
-    option mode       adhoc
-    option bssid      ${BSSID_MESH}
-    option ssid       '${ESSID_MESH}'
-    option mcast_rate 6000
-    option encryption none
-
-config wifi-iface
-    option device     radio0
-    option network    mesh
-    option ifname     w2ap
-    option mode       ap
-    option ssid       '${ESSID_AP}'
-    option encryption none
\ No newline at end of file
diff --git a/bsp/wdr4300/.config b/bsp/wdr4300/.config
index bd55104..a827ffb 100644
--- a/bsp/wdr4300/.config
+++ b/bsp/wdr4300/.config
@@ -5,7 +5,6 @@  CONFIG_TARGET_ar71xx=y
 CONFIG_TARGET_ar71xx_generic=y
 CONFIG_TARGET_ar71xx_generic_TLWDR4300=y
 CONFIG_BUSYBOX_CUSTOM=y
-CONFIG_ATH_USER_REGD=y
 # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
 # CONFIG_BUSYBOX_CONFIG_CROND is not set
 # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
@@ -33,4 +32,3 @@  CONFIG_PACKAGE_libugpio=y
 # CONFIG_PACKAGE_ppp is not set
 CONFIG_PACKAGE_qos-scripts=y
 CONFIG_PACKAGE_tc=y
-CONFIG_PACKAGE_wireless-tools=y
diff --git a/bsp/wdr4300/root_file_system/etc/config/network b/bsp/wdr4300/root_file_system/etc/config/network
deleted file mode 100644
index 9301678..0000000
--- a/bsp/wdr4300/root_file_system/etc/config/network
+++ /dev/null
@@ -1,30 +0,0 @@ 
-config 'interface' 'loopback'
-	option 'ifname'   'lo'
-	option 'proto'    'static'
-	option 'ipaddr'   '127.0.0.1'
-	option 'netmask'  '255.0.0.0'
-
-config interface 'w2mesh'
-	option mtu '1528'
-	option proto 'batadv'
-	option mesh 'bat0'
-
-config interface 'w5mesh'
-	option mtu '1528'
-	option proto 'batadv'
-	option mesh 'bat0'
-
-config 'interface' 'mesh'
-	option 'type' 'bridge'
-	option 'auto' '1'
-
-config 'interface' 'wan'
-	option 'ifname' 'eth0.2'
-	option 'proto' 'dhcp'
-
-config 'interface' 'ethmesh'
-	option 'mtu' '1528'
-	option proto 'batadv'
-	option mesh 'bat0'
-
-# vim: noexpandtab
\ No newline at end of file
diff --git a/bsp/wdr4300/root_file_system/etc/config/wireless.tpl b/bsp/wdr4300/root_file_system/etc/config/wireless.tpl
deleted file mode 100644
index c45073f..0000000
--- a/bsp/wdr4300/root_file_system/etc/config/wireless.tpl
+++ /dev/null
@@ -1,51 +0,0 @@ 
-config wifi-device radio0
-    option type    mac80211
-    option channel ${BATMAN_CHANNEL}
-    option phy     phy0
-    option hwmode  11g
-    option htmode  HT20
-    option country DE
-
-config wifi-iface w2mesh
-    option device     radio0
-    option network    w2mesh
-    option ifname     w2mesh
-    option mode       adhoc
-    option bssid      ${BSSID_MESH}
-    option ssid       '${ESSID_MESH}'
-    option mcast_rate 6000
-    option encryption none
-
-config wifi-iface w2ap
-    option device     radio0
-    option network    mesh
-    option ifname     w2ap
-    option mode       ap
-    option ssid       '${ESSID_AP}'
-    option encryption none
-
-config wifi-device radio1
-    option type    mac80211
-    option channel ${BATMAN_CHANNEL_5GHZ}
-    option phy     phy1
-    option hwmode  11a
-    option htmode  HT40+
-    option country DE
-
-config wifi-iface w5mesh
-    option device     radio1
-    option network    w5mesh
-    option ifname     w5mesh
-    option mode       adhoc
-    option bssid      ${BSSID_MESH}
-    option ssid       '${ESSID_MESH}'
-    option mcast_rate 6000
-    option encryption none
-
-config wifi-iface w5ap
-    option device     radio1
-    option network    mesh
-    option ifname     w5ap
-    option mode       ap
-    option ssid       '${ESSID_AP}'
-    option encryption none
\ No newline at end of file
diff --git a/bsp/wdr4900/.config b/bsp/wdr4900/.config
index 930ebe2..0bc72e4 100644
--- a/bsp/wdr4900/.config
+++ b/bsp/wdr4900/.config
@@ -5,7 +5,6 @@  CONFIG_TARGET_mpc85xx=y
 CONFIG_TARGET_mpc85xx_generic=y
 CONFIG_TARGET_mpc85xx_generic_Default=y
 CONFIG_BUSYBOX_CUSTOM=y
-CONFIG_ATH_USER_REGD=y
 # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
 # CONFIG_BUSYBOX_CONFIG_CROND is not set
 # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
@@ -33,4 +32,3 @@  CONFIG_PACKAGE_libugpio=y
 # CONFIG_PACKAGE_ppp is not set
 CONFIG_PACKAGE_qos-scripts=y
 CONFIG_PACKAGE_tc=y
-CONFIG_PACKAGE_wireless-tools=y
diff --git a/bsp/wdr4900/root_file_system/etc/config/network b/bsp/wdr4900/root_file_system/etc/config/network
deleted file mode 100644
index 9301678..0000000
--- a/bsp/wdr4900/root_file_system/etc/config/network
+++ /dev/null
@@ -1,30 +0,0 @@ 
-config 'interface' 'loopback'
-	option 'ifname'   'lo'
-	option 'proto'    'static'
-	option 'ipaddr'   '127.0.0.1'
-	option 'netmask'  '255.0.0.0'
-
-config interface 'w2mesh'
-	option mtu '1528'
-	option proto 'batadv'
-	option mesh 'bat0'
-
-config interface 'w5mesh'
-	option mtu '1528'
-	option proto 'batadv'
-	option mesh 'bat0'
-
-config 'interface' 'mesh'
-	option 'type' 'bridge'
-	option 'auto' '1'
-
-config 'interface' 'wan'
-	option 'ifname' 'eth0.2'
-	option 'proto' 'dhcp'
-
-config 'interface' 'ethmesh'
-	option 'mtu' '1528'
-	option proto 'batadv'
-	option mesh 'bat0'
-
-# vim: noexpandtab
\ No newline at end of file
diff --git a/bsp/wdr4900/root_file_system/etc/config/wireless.tpl b/bsp/wdr4900/root_file_system/etc/config/wireless.tpl
deleted file mode 100644
index 5be28f2..0000000
--- a/bsp/wdr4900/root_file_system/etc/config/wireless.tpl
+++ /dev/null
@@ -1,51 +0,0 @@ 
-config wifi-device radio0
-    option type    mac80211
-    option channel ${BATMAN_CHANNEL_5GHZ}
-    option phy     phy0
-    option hwmode  11a
-    option htmode  HT40+
-    option country DE
-
-config wifi-iface w5mesh
-    option device     radio0
-    option network    w5mesh
-    option ifname     w5mesh
-    option mode       adhoc
-    option bssid      ${BSSID_MESH}
-    option ssid       '${ESSID_MESH}'
-    option mcast_rate 6000
-    option encryption none
-
-config wifi-iface w5ap
-    option device     radio0
-    option network    mesh
-    option ifname     w5ap
-    option mode       ap
-    option ssid       '${ESSID_AP}'
-    option encryption none
-
-config wifi-device radio1
-    option type    mac80211
-    option channel ${BATMAN_CHANNEL}
-    option phy     phy1
-    option hwmode  11g
-    option htmode  HT20
-    option country DE
-
-config wifi-iface w2mesh
-    option device     radio1
-    option network    w2mesh
-    option ifname     w2mesh
-    option mode       adhoc
-    option bssid      ${BSSID_MESH}
-    option ssid       '${ESSID_MESH}'
-    option mcast_rate 6000
-    option encryption none
-
-config wifi-iface w2ap
-    option device     radio1
-    option network    mesh
-    option ifname     w2ap
-    option mode       ap
-    option ssid       '${ESSID_AP}'
-    option encryption none
\ No newline at end of file
diff --git a/src/packages/fff/fff-wireless/Makefile b/src/packages/fff/fff-wireless/Makefile
new file mode 100644
index 0000000..12456e5
--- /dev/null
+++ b/src/packages/fff/fff-wireless/Makefile
@@ -0,0 +1,39 @@ 
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=fff-wireless
+PKG_VERSION:=0.0.1
+PKG_RELEASE:=1
+
+PKG_BUILD_DIR:=$(BUILD_DIR)/fff-wireless
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/fff-wireless
+    SECTION:=base
+    CATEGORY:=Freifunk
+    TITLE:= Freifunk-Franken wireless configuration
+    URL:=http://www.freifunk-franken.de
+    DEPENDS:=+@ATH_USER_REGD +wireless-tools
+endef
+
+define Package/fff-wireless/description
+    This package configures the wireless interfaces.
+endef
+
+define Build/Prepare
+    echo "all: " > $(PKG_BUILD_DIR)/Makefile
+endef
+
+define Build/Configure
+    # nothing
+endef
+
+define Build/Compile
+    # nothing
+endef
+
+define Package/fff-wireless/install
+    $(CP) ./files/* $(1)/
+endef
+
+$(eval $(call BuildPackage,fff-wireless))
diff --git a/src/packages/fff/fff-wireless/files/etc/config/wireless b/src/packages/fff/fff-wireless/files/etc/config/wireless
new file mode 100644
index 0000000..e69de29
diff --git a/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless b/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
new file mode 100644
index 0000000..59239b3
--- /dev/null
+++ b/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
@@ -0,0 +1,43 @@ 
+#!/bin/sh
+# Copyright 2016 Tim Niemeyer
+# License GPLv3
+
+. /lib/functions/fff/wireless
+
+. /etc/community.cfg
+
+if ! wifiDelAll; then
+	echo "Can't delete current wifi setup"
+	exit 1
+fi
+
+for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
+	if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
+		echo "$phy is 2.4 GHz"
+		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
+		if [ -z "$radio" ]; then
+			echo "Can't create radio for $phy"
+			exit 1
+		fi
+	fi
+	if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
+		echo "$phy is 5 GHz"
+		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
+		if [ -z "$radio" ]; then
+			echo "Can't create radio for $phy"
+			exit 1
+		fi
+	fi
+
+	if ! wifiAddAP "$radio" "$ESSID_AP"; then
+		echo "Can't add AP interface on $radio0."
+		exit 1
+	fi
+
+	if ! wifiAddAdHocMesh "$radio" "$ESSID_MESH" "$BSSID_MESH"; then
+		echo "Can't add AP interface on $radio0."
+		exit 1
+	fi
+done
+
+# vim: set noexpandtab:tabstop=4
diff --git a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
new file mode 100644
index 0000000..63a07ba
--- /dev/null
+++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
@@ -0,0 +1,113 @@ 
+#!/bin/sh
+# Copyright 2016 Tim Niemeyer
+# License GPLv3
+
+wifiDelAll() {
+	if [ $# -ne "0" ]
+	then
+		echo "Usage: wifiDelAll"
+		return 1
+	fi
+
+	> /etc/config/wireless
+
+	return 0
+}
+
+wifiAddPhy() {
+	if [ $# -ne "2" ]
+	then
+		echo "Usage: wifiAddPhy <phy> <channel>"
+		return 1
+	fi
+
+	local phy=$1
+	local channel=$2
+	local radio="radio$(echo $phy | tr -d -C [0-9])"
+
+	uci batch <<-__EOF__
+		set wireless.${radio}='wifi-device'
+		set wireless.${radio}.type='mac80211'
+		set wireless.${radio}.channel='${channel}'
+		set wireless.${radio}.phy='${phy}'
+		set wireless.${radio}.hwmode='11g'
+		set wireless.${radio}.htmode='HT20'
+		set wireless.${radio}.country='DE'
+		commit wireless
+	__EOF__
+
+	echo "${radio}"
+	return 0
+}
+
+wifiAddAdHocMesh() {
+	if [ $# -ne "3" ]
+	then
+		echo "Usage: wifiAddAdHocMesh <radio> <essid> <bssid>"
+		return 1
+	fi
+
+	local radio=$1
+	local essid=$2
+	local bssid=$3
+
+	local channel=$(uci get "wireless.${radio}.channel")
+	local iface="w2mesh"
+	if [ "$channel" -gt "14" ]; then
+		iface="w5mesh"
+	fi
+
+	uci batch <<-__EOF__
+		set wireless.${iface}='wifi-iface'
+		set wireless.${iface}.device='${radio}'
+		set wireless.${iface}.network='${iface}'
+		set wireless.${iface}.ifname='${iface}'
+		set wireless.${iface}.mode='adhoc'
+		set wireless.${iface}.bssid='${bssid}'
+		set wireless.${iface}.ssid='${essid}'
+		set wireless.${iface}.mcast_rate='6000'
+		set wireless.${iface}.encryption='none'
+		commit wireless
+
+		set network.${iface}='interface'
+		set network.${iface}.mtu='1528'
+		set network.${iface}.proto='batadv'
+		set network.${iface}.mesh='bat0'
+		commit network
+	__EOF__
+
+	echo "${iface}"
+	return 0
+}
+
+wifiAddAP() {
+	if [ $# -ne "2" ]
+	then
+		echo "Usage: wifiAddAP <radio> <essid>"
+		return 1
+	fi
+
+	local radio=$1
+	local essid=$2
+
+	local channel=$(uci get "wireless.${radio}.channel")
+	local iface="w2ap"
+	if [ "$channel" -gt "14" ]; then
+		iface="w5ap"
+	fi
+	uci batch <<-__EOF__
+		set wireless.${iface}='wifi-iface'
+		set wireless.${iface}.device='${radio}'
+		set wireless.${iface}.network='mesh'
+		set wireless.${iface}.ifname='${iface}'
+		set wireless.${iface}.mode='ap'
+		set wireless.${iface}.ssid='${essid}'
+		set wireless.${iface}.encryption='none'
+
+		commit wireless
+	__EOF__
+
+	echo "${iface}"
+}
+
+# vim: set noexpandtab:tabstop=4
diff --git a/src/packages/fff/fff/Makefile b/src/packages/fff/fff/Makefile
index 52ccc14..366e828 100644
--- a/src/packages/fff/fff/Makefile
+++ b/src/packages/fff/fff/Makefile
@@ -2,7 +2,7 @@  include $(TOPDIR)/rules.mk
 
 PKG_NAME:=fff
 PKG_VERSION:=0.0.2
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_BUILD_DIR:=$(BUILD_DIR)/fff
 
@@ -22,7 +22,8 @@  define Package/fff-base
              +fff-fastd \
              +fff-firewall \
              +fff-support \
-             +fff-network
+             +fff-network \
+             +fff-wireless
 endef
 
 define Package/fff-base/description

Comments

Jan Kraus June 9, 2016, 11:21 a.m.
Hi Tim,
Am Mittwoch, den 08.06.2016, 18:29 +0200 schrieb Tim Niemeyer:
> Signed-off-by: Tim Niemeyer <tim@tn-x.org>
> ---
> 
>  bsp/ar71xx/.config                                 |   2 -
>  bsp/default/root_file_system/etc/config/network    |   5 -
>  .../root_file_system/etc/config/wireless.tpl       |  25 -----
>  bsp/wdr4300/.config                                |   2 -
>  bsp/wdr4300/root_file_system/etc/config/network    |  30 ------
>  .../root_file_system/etc/config/wireless.tpl       |  51 ----------
>  bsp/wdr4900/.config                                |   2 -
>  bsp/wdr4900/root_file_system/etc/config/network    |  30 ------
>  .../root_file_system/etc/config/wireless.tpl       |  51 ----------
>  src/packages/fff/fff-wireless/Makefile             |  39 +++++++
>  .../fff/fff-wireless/files/etc/config/wireless     |   0
>  .../files/etc/uci-defaults/60-fff-wireless         |  43 ++++++++
>  .../fff-wireless/files/lib/functions/fff/wireless  | 113 +++++++++++++++++++++
>  src/packages/fff/fff/Makefile                      |   5 +-
>  14 files changed, 198 insertions(+), 200 deletions(-)
>  delete mode 100644 bsp/default/root_file_system/etc/config/wireless.tpl
>  delete mode 100644 bsp/wdr4300/root_file_system/etc/config/network
>  delete mode 100644 bsp/wdr4300/root_file_system/etc/config/wireless.tpl
>  delete mode 100644 bsp/wdr4900/root_file_system/etc/config/network
>  delete mode 100644 bsp/wdr4900/root_file_system/etc/config/wireless.tpl
>  create mode 100644 src/packages/fff/fff-wireless/Makefile
>  create mode 100644 src/packages/fff/fff-wireless/files/etc/config/wireless
>  create mode 100644 src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
>  create mode 100644 src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
> 
> diff --git a/bsp/ar71xx/.config b/bsp/ar71xx/.config
> index f7b0097..e827685 100644
> --- a/bsp/ar71xx/.config
> +++ b/bsp/ar71xx/.config
> @@ -5,7 +5,6 @@ CONFIG_TARGET_ar71xx=y
>  CONFIG_TARGET_ar71xx_generic=y
>  CONFIG_TARGET_ar71xx_generic_Default=y
>  CONFIG_BUSYBOX_CUSTOM=y
> -CONFIG_ATH_USER_REGD=y
>  # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
>  # CONFIG_BUSYBOX_CONFIG_CROND is not set
>  # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
> @@ -33,4 +32,3 @@ CONFIG_PACKAGE_libugpio=y
>  # CONFIG_PACKAGE_ppp is not set
>  CONFIG_PACKAGE_qos-scripts=y
>  CONFIG_PACKAGE_tc=y
> -CONFIG_PACKAGE_wireless-tools=y
> diff --git a/bsp/default/root_file_system/etc/config/network b/bsp/default/root_file_system/etc/config/network
> index b658385..1bab57f 100644
> --- a/bsp/default/root_file_system/etc/config/network
> +++ b/bsp/default/root_file_system/etc/config/network
> @@ -4,11 +4,6 @@ config interface 'loopback'
>          option ipaddr '127.0.0.1'
>          option netmask '255.0.0.0'
>  
> -config interface 'w2mesh'
> -        option mtu '1532'
> -        option proto 'batadv'
> -        option mesh 'bat0'
> -
>  config interface 'mesh'
>          option type 'bridge'
>          option auto '1'
> diff --git a/bsp/default/root_file_system/etc/config/wireless.tpl b/bsp/default/root_file_system/etc/config/wireless.tpl
> deleted file mode 100644
> index 291eed1..0000000
> --- a/bsp/default/root_file_system/etc/config/wireless.tpl
> +++ /dev/null
> @@ -1,25 +0,0 @@
> -config wifi-device radio0
> -    option type    mac80211
> -    option channel ${BATMAN_CHANNEL}
> -    option phy     phy0
> -    option hwmode  11g
> -    option htmode  HT20
> -    option country DE
> -
> -config wifi-iface
> -    option device     radio0
> -    option network    w2mesh
> -    option ifname     w2mesh
> -    option mode       adhoc
> -    option bssid      ${BSSID_MESH}
> -    option ssid       '${ESSID_MESH}'
> -    option mcast_rate 6000
> -    option encryption none
> -
> -config wifi-iface
> -    option device     radio0
> -    option network    mesh
> -    option ifname     w2ap
> -    option mode       ap
> -    option ssid       '${ESSID_AP}'
> -    option encryption none
> \ No newline at end of file
> diff --git a/bsp/wdr4300/.config b/bsp/wdr4300/.config
> index bd55104..a827ffb 100644
> --- a/bsp/wdr4300/.config
> +++ b/bsp/wdr4300/.config
> @@ -5,7 +5,6 @@ CONFIG_TARGET_ar71xx=y
>  CONFIG_TARGET_ar71xx_generic=y
>  CONFIG_TARGET_ar71xx_generic_TLWDR4300=y
>  CONFIG_BUSYBOX_CUSTOM=y
> -CONFIG_ATH_USER_REGD=y
>  # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
>  # CONFIG_BUSYBOX_CONFIG_CROND is not set
>  # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
> @@ -33,4 +32,3 @@ CONFIG_PACKAGE_libugpio=y
>  # CONFIG_PACKAGE_ppp is not set
>  CONFIG_PACKAGE_qos-scripts=y
>  CONFIG_PACKAGE_tc=y
> -CONFIG_PACKAGE_wireless-tools=y
> diff --git a/bsp/wdr4300/root_file_system/etc/config/network b/bsp/wdr4300/root_file_system/etc/config/network
> deleted file mode 100644
> index 9301678..0000000
> --- a/bsp/wdr4300/root_file_system/etc/config/network
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -config 'interface' 'loopback'
> -	option 'ifname'   'lo'
> -	option 'proto'    'static'
> -	option 'ipaddr'   '127.0.0.1'
> -	option 'netmask'  '255.0.0.0'
> -
> -config interface 'w2mesh'
> -	option mtu '1528'
> -	option proto 'batadv'
> -	option mesh 'bat0'
> -
> -config interface 'w5mesh'
> -	option mtu '1528'
> -	option proto 'batadv'
> -	option mesh 'bat0'
> -
> -config 'interface' 'mesh'
> -	option 'type' 'bridge'
> -	option 'auto' '1'
> -
> -config 'interface' 'wan'
> -	option 'ifname' 'eth0.2'
> -	option 'proto' 'dhcp'
> -
> -config 'interface' 'ethmesh'
> -	option 'mtu' '1528'
> -	option proto 'batadv'
> -	option mesh 'bat0'
> -
> -# vim: noexpandtab
> \ No newline at end of file
> diff --git a/bsp/wdr4300/root_file_system/etc/config/wireless.tpl b/bsp/wdr4300/root_file_system/etc/config/wireless.tpl
> deleted file mode 100644
> index c45073f..0000000
> --- a/bsp/wdr4300/root_file_system/etc/config/wireless.tpl
> +++ /dev/null
> @@ -1,51 +0,0 @@
> -config wifi-device radio0
> -    option type    mac80211
> -    option channel ${BATMAN_CHANNEL}
> -    option phy     phy0
> -    option hwmode  11g
> -    option htmode  HT20
> -    option country DE
> -
> -config wifi-iface w2mesh
> -    option device     radio0
> -    option network    w2mesh
> -    option ifname     w2mesh
> -    option mode       adhoc
> -    option bssid      ${BSSID_MESH}
> -    option ssid       '${ESSID_MESH}'
> -    option mcast_rate 6000
> -    option encryption none
> -
> -config wifi-iface w2ap
> -    option device     radio0
> -    option network    mesh
> -    option ifname     w2ap
> -    option mode       ap
> -    option ssid       '${ESSID_AP}'
> -    option encryption none
> -
> -config wifi-device radio1
> -    option type    mac80211
> -    option channel ${BATMAN_CHANNEL_5GHZ}
> -    option phy     phy1
> -    option hwmode  11a
> -    option htmode  HT40+
> -    option country DE
> -
> -config wifi-iface w5mesh
> -    option device     radio1
> -    option network    w5mesh
> -    option ifname     w5mesh
> -    option mode       adhoc
> -    option bssid      ${BSSID_MESH}
> -    option ssid       '${ESSID_MESH}'
> -    option mcast_rate 6000
> -    option encryption none
> -
> -config wifi-iface w5ap
> -    option device     radio1
> -    option network    mesh
> -    option ifname     w5ap
> -    option mode       ap
> -    option ssid       '${ESSID_AP}'
> -    option encryption none
> \ No newline at end of file
> diff --git a/bsp/wdr4900/.config b/bsp/wdr4900/.config
> index 930ebe2..0bc72e4 100644
> --- a/bsp/wdr4900/.config
> +++ b/bsp/wdr4900/.config
> @@ -5,7 +5,6 @@ CONFIG_TARGET_mpc85xx=y
>  CONFIG_TARGET_mpc85xx_generic=y
>  CONFIG_TARGET_mpc85xx_generic_Default=y
>  CONFIG_BUSYBOX_CUSTOM=y
> -CONFIG_ATH_USER_REGD=y
>  # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
>  # CONFIG_BUSYBOX_CONFIG_CROND is not set
>  # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
> @@ -33,4 +32,3 @@ CONFIG_PACKAGE_libugpio=y
>  # CONFIG_PACKAGE_ppp is not set
>  CONFIG_PACKAGE_qos-scripts=y
>  CONFIG_PACKAGE_tc=y
> -CONFIG_PACKAGE_wireless-tools=y
> diff --git a/bsp/wdr4900/root_file_system/etc/config/network b/bsp/wdr4900/root_file_system/etc/config/network
> deleted file mode 100644
> index 9301678..0000000
> --- a/bsp/wdr4900/root_file_system/etc/config/network
> +++ /dev/null
> @@ -1,30 +0,0 @@
> -config 'interface' 'loopback'
> -	option 'ifname'   'lo'
> -	option 'proto'    'static'
> -	option 'ipaddr'   '127.0.0.1'
> -	option 'netmask'  '255.0.0.0'
> -
> -config interface 'w2mesh'
> -	option mtu '1528'
> -	option proto 'batadv'
> -	option mesh 'bat0'
> -
> -config interface 'w5mesh'
> -	option mtu '1528'
> -	option proto 'batadv'
> -	option mesh 'bat0'
> -
> -config 'interface' 'mesh'
> -	option 'type' 'bridge'
> -	option 'auto' '1'
> -
> -config 'interface' 'wan'
> -	option 'ifname' 'eth0.2'
> -	option 'proto' 'dhcp'
> -
> -config 'interface' 'ethmesh'
> -	option 'mtu' '1528'
> -	option proto 'batadv'
> -	option mesh 'bat0'
> -
> -# vim: noexpandtab
> \ No newline at end of file
> diff --git a/bsp/wdr4900/root_file_system/etc/config/wireless.tpl b/bsp/wdr4900/root_file_system/etc/config/wireless.tpl
> deleted file mode 100644
> index 5be28f2..0000000
> --- a/bsp/wdr4900/root_file_system/etc/config/wireless.tpl
> +++ /dev/null
> @@ -1,51 +0,0 @@
> -config wifi-device radio0
> -    option type    mac80211
> -    option channel ${BATMAN_CHANNEL_5GHZ}
> -    option phy     phy0
> -    option hwmode  11a
> -    option htmode  HT40+
> -    option country DE
> -
> -config wifi-iface w5mesh
> -    option device     radio0
> -    option network    w5mesh
> -    option ifname     w5mesh
> -    option mode       adhoc
> -    option bssid      ${BSSID_MESH}
> -    option ssid       '${ESSID_MESH}'
> -    option mcast_rate 6000
> -    option encryption none
> -
> -config wifi-iface w5ap
> -    option device     radio0
> -    option network    mesh
> -    option ifname     w5ap
> -    option mode       ap
> -    option ssid       '${ESSID_AP}'
> -    option encryption none
> -
> -config wifi-device radio1
> -    option type    mac80211
> -    option channel ${BATMAN_CHANNEL}
> -    option phy     phy1
> -    option hwmode  11g
> -    option htmode  HT20
> -    option country DE
> -
> -config wifi-iface w2mesh
> -    option device     radio1
> -    option network    w2mesh
> -    option ifname     w2mesh
> -    option mode       adhoc
> -    option bssid      ${BSSID_MESH}
> -    option ssid       '${ESSID_MESH}'
> -    option mcast_rate 6000
> -    option encryption none
> -
> -config wifi-iface w2ap
> -    option device     radio1
> -    option network    mesh
> -    option ifname     w2ap
> -    option mode       ap
> -    option ssid       '${ESSID_AP}'
> -    option encryption none
> \ No newline at end of file
> diff --git a/src/packages/fff/fff-wireless/Makefile b/src/packages/fff/fff-wireless/Makefile
> new file mode 100644
> index 0000000..12456e5
> --- /dev/null
> +++ b/src/packages/fff/fff-wireless/Makefile
> @@ -0,0 +1,39 @@
> +include $(TOPDIR)/rules.mk
> +
> +PKG_NAME:=fff-wireless
> +PKG_VERSION:=0.0.1
> +PKG_RELEASE:=1
> +
> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-wireless
> +
> +include $(INCLUDE_DIR)/package.mk
> +
> +define Package/fff-wireless
> +    SECTION:=base
> +    CATEGORY:=Freifunk
> +    TITLE:= Freifunk-Franken wireless configuration
> +    URL:=http://www.freifunk-franken.de
> +    DEPENDS:=+@ATH_USER_REGD +wireless-tools
> +endef
> +
> +define Package/fff-wireless/description
> +    This package configures the wireless interfaces.
> +endef
> +
> +define Build/Prepare
> +    echo "all: " > $(PKG_BUILD_DIR)/Makefile
> +endef
> +
> +define Build/Configure
> +    # nothing
> +endef
> +
> +define Build/Compile
> +    # nothing
> +endef
> +
> +define Package/fff-wireless/install
> +    $(CP) ./files/* $(1)/
> +endef
> +
> +$(eval $(call BuildPackage,fff-wireless))
> diff --git a/src/packages/fff/fff-wireless/files/etc/config/wireless b/src/packages/fff/fff-wireless/files/etc/config/wireless
> new file mode 100644
> index 0000000..e69de29
> diff --git a/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless b/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
> new file mode 100644
> index 0000000..59239b3
> --- /dev/null
> +++ b/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
> @@ -0,0 +1,43 @@
> +#!/bin/sh
> +# Copyright 2016 Tim Niemeyer
> +# License GPLv3
> +
> +. /lib/functions/fff/wireless
> +
> +. /etc/community.cfg
> +
> +if ! wifiDelAll; then
> +	echo "Can't delete current wifi setup"
> +	exit 1
> +fi
> +
> +for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
> +	if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
> +		echo "$phy is 2.4 GHz"
> +		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
> +		if [ -z "$radio" ]; then
> +			echo "Can't create radio for $phy"
> +			exit 1
> +		fi
> +	fi
> +	if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
> +		echo "$phy is 5 GHz"
> +		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
> +		if [ -z "$radio" ]; then
> +			echo "Can't create radio for $phy"
> +			exit 1
> +		fi
> +	fi
> +
> +	if ! wifiAddAP "$radio" "$ESSID_AP"; then
> +		echo "Can't add AP interface on $radio0."
> +		exit 1
> +	fi
> +
> +	if ! wifiAddAdHocMesh "$radio" "$ESSID_MESH" "$BSSID_MESH"; then
> +		echo "Can't add AP interface on $radio0."
> +		exit 1
> +	fi
> +done
> +
> +# vim: set noexpandtab:tabstop=4
> diff --git a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
> new file mode 100644
> index 0000000..63a07ba
> --- /dev/null
> +++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
> @@ -0,0 +1,113 @@
> +#!/bin/sh
> +# Copyright 2016 Tim Niemeyer
> +# License GPLv3
> +
> +wifiDelAll() {
> +	if [ $# -ne "0" ]
> +	then
> +		echo "Usage: wifiDelAll"
> +		return 1
> +	fi
> +
> +	> /etc/config/wireless
> +
> +	return 0
> +}
> +
> +wifiAddPhy() {
> +	if [ $# -ne "2" ]
> +	then
> +		echo "Usage: wifiAddPhy <phy> <channel>"
> +		return 1
> +	fi
> +
> +	local phy=$1
> +	local channel=$2
> +	local radio="radio$(echo $phy | tr -d -C [0-9])"
> +
> +	uci batch <<-__EOF__
> +		set wireless.${radio}='wifi-device'
> +		set wireless.${radio}.type='mac80211'
> +		set wireless.${radio}.channel='${channel}'
> +		set wireless.${radio}.phy='${phy}'
> +		set wireless.${radio}.hwmode='11g'
> +		set wireless.${radio}.htmode='HT20'
Funktioniert das hier für 5Ghz? 11g ist ja eigentlich ein 2,4Ghz
Standard. Hab leider grad kein Gerät zum testen da.

Grüße Jan
> +		set wireless.${radio}.country='DE'
> +		commit wireless
> +	__EOF__
> +
> +	echo "${radio}"
> +	return 0
> +}
> +
> +wifiAddAdHocMesh() {
> +	if [ $# -ne "3" ]
> +	then
> +		echo "Usage: wifiAddAdHocMesh <radio> <essid> <bssid>"
> +		return 1
> +	fi
> +
> +	local radio=$1
> +	local essid=$2
> +	local bssid=$3
> +
> +	local channel=$(uci get "wireless.${radio}.channel")
> +	local iface="w2mesh"
> +	if [ "$channel" -gt "14" ]; then
> +		iface="w5mesh"
> +	fi
> +
> +	uci batch <<-__EOF__
> +		set wireless.${iface}='wifi-iface'
> +		set wireless.${iface}.device='${radio}'
> +		set wireless.${iface}.network='${iface}'
> +		set wireless.${iface}.ifname='${iface}'
> +		set wireless.${iface}.mode='adhoc'
> +		set wireless.${iface}.bssid='${bssid}'
> +		set wireless.${iface}.ssid='${essid}'
> +		set wireless.${iface}.mcast_rate='6000'
> +		set wireless.${iface}.encryption='none'
> +		commit wireless
> +
> +		set network.${iface}='interface'
> +		set network.${iface}.mtu='1528'
> +		set network.${iface}.proto='batadv'
> +		set network.${iface}.mesh='bat0'
> +		commit network
> +	__EOF__
> +
> +	echo "${iface}"
> +	return 0
> +}
> +
> +wifiAddAP() {
> +	if [ $# -ne "2" ]
> +	then
> +		echo "Usage: wifiAddAP <radio> <essid>"
> +		return 1
> +	fi
> +
> +	local radio=$1
> +	local essid=$2
> +
> +	local channel=$(uci get "wireless.${radio}.channel")
> +	local iface="w2ap"
> +	if [ "$channel" -gt "14" ]; then
> +		iface="w5ap"
> +	fi
> +	uci batch <<-__EOF__
> +		set wireless.${iface}='wifi-iface'
> +		set wireless.${iface}.device='${radio}'
> +		set wireless.${iface}.network='mesh'
> +		set wireless.${iface}.ifname='${iface}'
> +		set wireless.${iface}.mode='ap'
> +		set wireless.${iface}.ssid='${essid}'
> +		set wireless.${iface}.encryption='none'
> +
> +		commit wireless
> +	__EOF__
> +
> +	echo "${iface}"
> +}
> +
> +# vim: set noexpandtab:tabstop=4
> diff --git a/src/packages/fff/fff/Makefile b/src/packages/fff/fff/Makefile
> index 52ccc14..366e828 100644
> --- a/src/packages/fff/fff/Makefile
> +++ b/src/packages/fff/fff/Makefile
> @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
>  
>  PKG_NAME:=fff
>  PKG_VERSION:=0.0.2
> -PKG_RELEASE:=1
> +PKG_RELEASE:=2
>  
>  PKG_BUILD_DIR:=$(BUILD_DIR)/fff
>  
> @@ -22,7 +22,8 @@ define Package/fff-base
>               +fff-fastd \
>               +fff-firewall \
>               +fff-support \
> -             +fff-network
> +             +fff-network \
> +             +fff-wireless
>  endef
>  
>  define Package/fff-base/description
> -- 
> 2.1.4
>
Tim Niemeyer June 9, 2016, 11:27 a.m.
Hi

Am 9. Juni 2016 13:21:15 MESZ, schrieb mayosemmel <mayosemmel@googlemail.com>:
>Hi Tim,
>Am Mittwoch, den 08.06.2016, 18:29 +0200 schrieb Tim Niemeyer:
>> Signed-off-by: Tim Niemeyer <tim@tn-x.org>
>> ---
>> 
>>  bsp/ar71xx/.config                                 |   2 -
>>  bsp/default/root_file_system/etc/config/network    |   5 -
>>  .../root_file_system/etc/config/wireless.tpl       |  25 -----
>>  bsp/wdr4300/.config                                |   2 -
>>  bsp/wdr4300/root_file_system/etc/config/network    |  30 ------
>>  .../root_file_system/etc/config/wireless.tpl       |  51 ----------
>>  bsp/wdr4900/.config                                |   2 -
>>  bsp/wdr4900/root_file_system/etc/config/network    |  30 ------
>>  .../root_file_system/etc/config/wireless.tpl       |  51 ----------
>>  src/packages/fff/fff-wireless/Makefile             |  39 +++++++
>>  .../fff/fff-wireless/files/etc/config/wireless     |   0
>>  .../files/etc/uci-defaults/60-fff-wireless         |  43 ++++++++
>>  .../fff-wireless/files/lib/functions/fff/wireless  | 113
>+++++++++++++++++++++
>>  src/packages/fff/fff/Makefile                      |   5 +-
>>  14 files changed, 198 insertions(+), 200 deletions(-)
>>  delete mode 100644
>bsp/default/root_file_system/etc/config/wireless.tpl
>>  delete mode 100644 bsp/wdr4300/root_file_system/etc/config/network
>>  delete mode 100644
>bsp/wdr4300/root_file_system/etc/config/wireless.tpl
>>  delete mode 100644 bsp/wdr4900/root_file_system/etc/config/network
>>  delete mode 100644
>bsp/wdr4900/root_file_system/etc/config/wireless.tpl
>>  create mode 100644 src/packages/fff/fff-wireless/Makefile
>>  create mode 100644
>src/packages/fff/fff-wireless/files/etc/config/wireless
>>  create mode 100644
>src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
>>  create mode 100644
>src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
>> 
>> diff --git a/bsp/ar71xx/.config b/bsp/ar71xx/.config
>> index f7b0097..e827685 100644
>> --- a/bsp/ar71xx/.config
>> +++ b/bsp/ar71xx/.config
>> @@ -5,7 +5,6 @@ CONFIG_TARGET_ar71xx=y
>>  CONFIG_TARGET_ar71xx_generic=y
>>  CONFIG_TARGET_ar71xx_generic_Default=y
>>  CONFIG_BUSYBOX_CUSTOM=y
>> -CONFIG_ATH_USER_REGD=y
>>  # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
>>  # CONFIG_BUSYBOX_CONFIG_CROND is not set
>>  # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
>> @@ -33,4 +32,3 @@ CONFIG_PACKAGE_libugpio=y
>>  # CONFIG_PACKAGE_ppp is not set
>>  CONFIG_PACKAGE_qos-scripts=y
>>  CONFIG_PACKAGE_tc=y
>> -CONFIG_PACKAGE_wireless-tools=y
>> diff --git a/bsp/default/root_file_system/etc/config/network
>b/bsp/default/root_file_system/etc/config/network
>> index b658385..1bab57f 100644
>> --- a/bsp/default/root_file_system/etc/config/network
>> +++ b/bsp/default/root_file_system/etc/config/network
>> @@ -4,11 +4,6 @@ config interface 'loopback'
>>          option ipaddr '127.0.0.1'
>>          option netmask '255.0.0.0'
>>  
>> -config interface 'w2mesh'
>> -        option mtu '1532'
>> -        option proto 'batadv'
>> -        option mesh 'bat0'
>> -
>>  config interface 'mesh'
>>          option type 'bridge'
>>          option auto '1'
>> diff --git a/bsp/default/root_file_system/etc/config/wireless.tpl
>b/bsp/default/root_file_system/etc/config/wireless.tpl
>> deleted file mode 100644
>> index 291eed1..0000000
>> --- a/bsp/default/root_file_system/etc/config/wireless.tpl
>> +++ /dev/null
>> @@ -1,25 +0,0 @@
>> -config wifi-device radio0
>> -    option type    mac80211
>> -    option channel ${BATMAN_CHANNEL}
>> -    option phy     phy0
>> -    option hwmode  11g
>> -    option htmode  HT20
>> -    option country DE
>> -
>> -config wifi-iface
>> -    option device     radio0
>> -    option network    w2mesh
>> -    option ifname     w2mesh
>> -    option mode       adhoc
>> -    option bssid      ${BSSID_MESH}
>> -    option ssid       '${ESSID_MESH}'
>> -    option mcast_rate 6000
>> -    option encryption none
>> -
>> -config wifi-iface
>> -    option device     radio0
>> -    option network    mesh
>> -    option ifname     w2ap
>> -    option mode       ap
>> -    option ssid       '${ESSID_AP}'
>> -    option encryption none
>> \ No newline at end of file
>> diff --git a/bsp/wdr4300/.config b/bsp/wdr4300/.config
>> index bd55104..a827ffb 100644
>> --- a/bsp/wdr4300/.config
>> +++ b/bsp/wdr4300/.config
>> @@ -5,7 +5,6 @@ CONFIG_TARGET_ar71xx=y
>>  CONFIG_TARGET_ar71xx_generic=y
>>  CONFIG_TARGET_ar71xx_generic_TLWDR4300=y
>>  CONFIG_BUSYBOX_CUSTOM=y
>> -CONFIG_ATH_USER_REGD=y
>>  # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
>>  # CONFIG_BUSYBOX_CONFIG_CROND is not set
>>  # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
>> @@ -33,4 +32,3 @@ CONFIG_PACKAGE_libugpio=y
>>  # CONFIG_PACKAGE_ppp is not set
>>  CONFIG_PACKAGE_qos-scripts=y
>>  CONFIG_PACKAGE_tc=y
>> -CONFIG_PACKAGE_wireless-tools=y
>> diff --git a/bsp/wdr4300/root_file_system/etc/config/network
>b/bsp/wdr4300/root_file_system/etc/config/network
>> deleted file mode 100644
>> index 9301678..0000000
>> --- a/bsp/wdr4300/root_file_system/etc/config/network
>> +++ /dev/null
>> @@ -1,30 +0,0 @@
>> -config 'interface' 'loopback'
>> -	option 'ifname'   'lo'
>> -	option 'proto'    'static'
>> -	option 'ipaddr'   '127.0.0.1'
>> -	option 'netmask'  '255.0.0.0'
>> -
>> -config interface 'w2mesh'
>> -	option mtu '1528'
>> -	option proto 'batadv'
>> -	option mesh 'bat0'
>> -
>> -config interface 'w5mesh'
>> -	option mtu '1528'
>> -	option proto 'batadv'
>> -	option mesh 'bat0'
>> -
>> -config 'interface' 'mesh'
>> -	option 'type' 'bridge'
>> -	option 'auto' '1'
>> -
>> -config 'interface' 'wan'
>> -	option 'ifname' 'eth0.2'
>> -	option 'proto' 'dhcp'
>> -
>> -config 'interface' 'ethmesh'
>> -	option 'mtu' '1528'
>> -	option proto 'batadv'
>> -	option mesh 'bat0'
>> -
>> -# vim: noexpandtab
>> \ No newline at end of file
>> diff --git a/bsp/wdr4300/root_file_system/etc/config/wireless.tpl
>b/bsp/wdr4300/root_file_system/etc/config/wireless.tpl
>> deleted file mode 100644
>> index c45073f..0000000
>> --- a/bsp/wdr4300/root_file_system/etc/config/wireless.tpl
>> +++ /dev/null
>> @@ -1,51 +0,0 @@
>> -config wifi-device radio0
>> -    option type    mac80211
>> -    option channel ${BATMAN_CHANNEL}
>> -    option phy     phy0
>> -    option hwmode  11g
>> -    option htmode  HT20
>> -    option country DE
>> -
>> -config wifi-iface w2mesh
>> -    option device     radio0
>> -    option network    w2mesh
>> -    option ifname     w2mesh
>> -    option mode       adhoc
>> -    option bssid      ${BSSID_MESH}
>> -    option ssid       '${ESSID_MESH}'
>> -    option mcast_rate 6000
>> -    option encryption none
>> -
>> -config wifi-iface w2ap
>> -    option device     radio0
>> -    option network    mesh
>> -    option ifname     w2ap
>> -    option mode       ap
>> -    option ssid       '${ESSID_AP}'
>> -    option encryption none
>> -
>> -config wifi-device radio1
>> -    option type    mac80211
>> -    option channel ${BATMAN_CHANNEL_5GHZ}
>> -    option phy     phy1
>> -    option hwmode  11a
>> -    option htmode  HT40+
>> -    option country DE
>> -
>> -config wifi-iface w5mesh
>> -    option device     radio1
>> -    option network    w5mesh
>> -    option ifname     w5mesh
>> -    option mode       adhoc
>> -    option bssid      ${BSSID_MESH}
>> -    option ssid       '${ESSID_MESH}'
>> -    option mcast_rate 6000
>> -    option encryption none
>> -
>> -config wifi-iface w5ap
>> -    option device     radio1
>> -    option network    mesh
>> -    option ifname     w5ap
>> -    option mode       ap
>> -    option ssid       '${ESSID_AP}'
>> -    option encryption none
>> \ No newline at end of file
>> diff --git a/bsp/wdr4900/.config b/bsp/wdr4900/.config
>> index 930ebe2..0bc72e4 100644
>> --- a/bsp/wdr4900/.config
>> +++ b/bsp/wdr4900/.config
>> @@ -5,7 +5,6 @@ CONFIG_TARGET_mpc85xx=y
>>  CONFIG_TARGET_mpc85xx_generic=y
>>  CONFIG_TARGET_mpc85xx_generic_Default=y
>>  CONFIG_BUSYBOX_CUSTOM=y
>> -CONFIG_ATH_USER_REGD=y
>>  # CONFIG_BUSYBOX_CONFIG_BRCTL is not set
>>  # CONFIG_BUSYBOX_CONFIG_CROND is not set
>>  # CONFIG_BUSYBOX_CONFIG_CRONTAB is not set
>> @@ -33,4 +32,3 @@ CONFIG_PACKAGE_libugpio=y
>>  # CONFIG_PACKAGE_ppp is not set
>>  CONFIG_PACKAGE_qos-scripts=y
>>  CONFIG_PACKAGE_tc=y
>> -CONFIG_PACKAGE_wireless-tools=y
>> diff --git a/bsp/wdr4900/root_file_system/etc/config/network
>b/bsp/wdr4900/root_file_system/etc/config/network
>> deleted file mode 100644
>> index 9301678..0000000
>> --- a/bsp/wdr4900/root_file_system/etc/config/network
>> +++ /dev/null
>> @@ -1,30 +0,0 @@
>> -config 'interface' 'loopback'
>> -	option 'ifname'   'lo'
>> -	option 'proto'    'static'
>> -	option 'ipaddr'   '127.0.0.1'
>> -	option 'netmask'  '255.0.0.0'
>> -
>> -config interface 'w2mesh'
>> -	option mtu '1528'
>> -	option proto 'batadv'
>> -	option mesh 'bat0'
>> -
>> -config interface 'w5mesh'
>> -	option mtu '1528'
>> -	option proto 'batadv'
>> -	option mesh 'bat0'
>> -
>> -config 'interface' 'mesh'
>> -	option 'type' 'bridge'
>> -	option 'auto' '1'
>> -
>> -config 'interface' 'wan'
>> -	option 'ifname' 'eth0.2'
>> -	option 'proto' 'dhcp'
>> -
>> -config 'interface' 'ethmesh'
>> -	option 'mtu' '1528'
>> -	option proto 'batadv'
>> -	option mesh 'bat0'
>> -
>> -# vim: noexpandtab
>> \ No newline at end of file
>> diff --git a/bsp/wdr4900/root_file_system/etc/config/wireless.tpl
>b/bsp/wdr4900/root_file_system/etc/config/wireless.tpl
>> deleted file mode 100644
>> index 5be28f2..0000000
>> --- a/bsp/wdr4900/root_file_system/etc/config/wireless.tpl
>> +++ /dev/null
>> @@ -1,51 +0,0 @@
>> -config wifi-device radio0
>> -    option type    mac80211
>> -    option channel ${BATMAN_CHANNEL_5GHZ}
>> -    option phy     phy0
>> -    option hwmode  11a
>> -    option htmode  HT40+
>> -    option country DE
>> -
>> -config wifi-iface w5mesh
>> -    option device     radio0
>> -    option network    w5mesh
>> -    option ifname     w5mesh
>> -    option mode       adhoc
>> -    option bssid      ${BSSID_MESH}
>> -    option ssid       '${ESSID_MESH}'
>> -    option mcast_rate 6000
>> -    option encryption none
>> -
>> -config wifi-iface w5ap
>> -    option device     radio0
>> -    option network    mesh
>> -    option ifname     w5ap
>> -    option mode       ap
>> -    option ssid       '${ESSID_AP}'
>> -    option encryption none
>> -
>> -config wifi-device radio1
>> -    option type    mac80211
>> -    option channel ${BATMAN_CHANNEL}
>> -    option phy     phy1
>> -    option hwmode  11g
>> -    option htmode  HT20
>> -    option country DE
>> -
>> -config wifi-iface w2mesh
>> -    option device     radio1
>> -    option network    w2mesh
>> -    option ifname     w2mesh
>> -    option mode       adhoc
>> -    option bssid      ${BSSID_MESH}
>> -    option ssid       '${ESSID_MESH}'
>> -    option mcast_rate 6000
>> -    option encryption none
>> -
>> -config wifi-iface w2ap
>> -    option device     radio1
>> -    option network    mesh
>> -    option ifname     w2ap
>> -    option mode       ap
>> -    option ssid       '${ESSID_AP}'
>> -    option encryption none
>> \ No newline at end of file
>> diff --git a/src/packages/fff/fff-wireless/Makefile
>b/src/packages/fff/fff-wireless/Makefile
>> new file mode 100644
>> index 0000000..12456e5
>> --- /dev/null
>> +++ b/src/packages/fff/fff-wireless/Makefile
>> @@ -0,0 +1,39 @@
>> +include $(TOPDIR)/rules.mk
>> +
>> +PKG_NAME:=fff-wireless
>> +PKG_VERSION:=0.0.1
>> +PKG_RELEASE:=1
>> +
>> +PKG_BUILD_DIR:=$(BUILD_DIR)/fff-wireless
>> +
>> +include $(INCLUDE_DIR)/package.mk
>> +
>> +define Package/fff-wireless
>> +    SECTION:=base
>> +    CATEGORY:=Freifunk
>> +    TITLE:= Freifunk-Franken wireless configuration
>> +    URL:=http://www.freifunk-franken.de
>> +    DEPENDS:=+@ATH_USER_REGD +wireless-tools
>> +endef
>> +
>> +define Package/fff-wireless/description
>> +    This package configures the wireless interfaces.
>> +endef
>> +
>> +define Build/Prepare
>> +    echo "all: " > $(PKG_BUILD_DIR)/Makefile
>> +endef
>> +
>> +define Build/Configure
>> +    # nothing
>> +endef
>> +
>> +define Build/Compile
>> +    # nothing
>> +endef
>> +
>> +define Package/fff-wireless/install
>> +    $(CP) ./files/* $(1)/
>> +endef
>> +
>> +$(eval $(call BuildPackage,fff-wireless))
>> diff --git a/src/packages/fff/fff-wireless/files/etc/config/wireless
>b/src/packages/fff/fff-wireless/files/etc/config/wireless
>> new file mode 100644
>> index 0000000..e69de29
>> diff --git
>a/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
>b/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
>> new file mode 100644
>> index 0000000..59239b3
>> --- /dev/null
>> +++
>b/src/packages/fff/fff-wireless/files/etc/uci-defaults/60-fff-wireless
>> @@ -0,0 +1,43 @@
>> +#!/bin/sh
>> +# Copyright 2016 Tim Niemeyer
>> +# License GPLv3
>> +
>> +. /lib/functions/fff/wireless
>> +
>> +. /etc/community.cfg
>> +
>> +if ! wifiDelAll; then
>> +	echo "Can't delete current wifi setup"
>> +	exit 1
>> +fi
>> +
>> +for phy in $(iw phy | awk '/^Wiphy/{ print $2 }'); do
>> +	if iw phy "$phy" info | grep -q -m1 "2... MHz"; then
>> +		echo "$phy is 2.4 GHz"
>> +		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL")
>> +		if [ -z "$radio" ]; then
>> +			echo "Can't create radio for $phy"
>> +			exit 1
>> +		fi
>> +	fi
>> +	if iw phy "$phy" info | grep -q -m1 "5... MHz"; then
>> +		echo "$phy is 5 GHz"
>> +		radio=$(wifiAddPhy "$phy" "$BATMAN_CHANNEL_5GHZ")
>> +		if [ -z "$radio" ]; then
>> +			echo "Can't create radio for $phy"
>> +			exit 1
>> +		fi
>> +	fi
>> +
>> +	if ! wifiAddAP "$radio" "$ESSID_AP"; then
>> +		echo "Can't add AP interface on $radio0."
>> +		exit 1
>> +	fi
>> +
>> +	if ! wifiAddAdHocMesh "$radio" "$ESSID_MESH" "$BSSID_MESH"; then
>> +		echo "Can't add AP interface on $radio0."
>> +		exit 1
>> +	fi
>> +done
>> +
>> +# vim: set noexpandtab:tabstop=4
>> diff --git
>a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
>b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
>> new file mode 100644
>> index 0000000..63a07ba
>> --- /dev/null
>> +++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
>> @@ -0,0 +1,113 @@
>> +#!/bin/sh
>> +# Copyright 2016 Tim Niemeyer
>> +# License GPLv3
>> +
>> +wifiDelAll() {
>> +	if [ $# -ne "0" ]
>> +	then
>> +		echo "Usage: wifiDelAll"
>> +		return 1
>> +	fi
>> +
>> +	> /etc/config/wireless
>> +
>> +	return 0
>> +}
>> +
>> +wifiAddPhy() {
>> +	if [ $# -ne "2" ]
>> +	then
>> +		echo "Usage: wifiAddPhy <phy> <channel>"
>> +		return 1
>> +	fi
>> +
>> +	local phy=$1
>> +	local channel=$2
>> +	local radio="radio$(echo $phy | tr -d -C [0-9])"
>> +
>> +	uci batch <<-__EOF__
>> +		set wireless.${radio}='wifi-device'
>> +		set wireless.${radio}.type='mac80211'
>> +		set wireless.${radio}.channel='${channel}'
>> +		set wireless.${radio}.phy='${phy}'
>> +		set wireless.${radio}.hwmode='11g'
>> +		set wireless.${radio}.htmode='HT20'
>Funktioniert das hier für 5Ghz? 11g ist ja eigentlich ein 2,4Ghz
>Standard. Hab leider grad kein Gerät zum testen da.


Good catch..

Vermutlich nicht..

Tim
>
>Grüße Jan
>> +		set wireless.${radio}.country='DE'
>> +		commit wireless
>> +	__EOF__
>> +
>> +	echo "${radio}"
>> +	return 0
>> +}
>> +
>> +wifiAddAdHocMesh() {
>> +	if [ $# -ne "3" ]
>> +	then
>> +		echo "Usage: wifiAddAdHocMesh <radio> <essid> <bssid>"
>> +		return 1
>> +	fi
>> +
>> +	local radio=$1
>> +	local essid=$2
>> +	local bssid=$3
>> +
>> +	local channel=$(uci get "wireless.${radio}.channel")
>> +	local iface="w2mesh"
>> +	if [ "$channel" -gt "14" ]; then
>> +		iface="w5mesh"
>> +	fi
>> +
>> +	uci batch <<-__EOF__
>> +		set wireless.${iface}='wifi-iface'
>> +		set wireless.${iface}.device='${radio}'
>> +		set wireless.${iface}.network='${iface}'
>> +		set wireless.${iface}.ifname='${iface}'
>> +		set wireless.${iface}.mode='adhoc'
>> +		set wireless.${iface}.bssid='${bssid}'
>> +		set wireless.${iface}.ssid='${essid}'
>> +		set wireless.${iface}.mcast_rate='6000'
>> +		set wireless.${iface}.encryption='none'
>> +		commit wireless
>> +
>> +		set network.${iface}='interface'
>> +		set network.${iface}.mtu='1528'
>> +		set network.${iface}.proto='batadv'
>> +		set network.${iface}.mesh='bat0'
>> +		commit network
>> +	__EOF__
>> +
>> +	echo "${iface}"
>> +	return 0
>> +}
>> +
>> +wifiAddAP() {
>> +	if [ $# -ne "2" ]
>> +	then
>> +		echo "Usage: wifiAddAP <radio> <essid>"
>> +		return 1
>> +	fi
>> +
>> +	local radio=$1
>> +	local essid=$2
>> +
>> +	local channel=$(uci get "wireless.${radio}.channel")
>> +	local iface="w2ap"
>> +	if [ "$channel" -gt "14" ]; then
>> +		iface="w5ap"
>> +	fi
>> +	uci batch <<-__EOF__
>> +		set wireless.${iface}='wifi-iface'
>> +		set wireless.${iface}.device='${radio}'
>> +		set wireless.${iface}.network='mesh'
>> +		set wireless.${iface}.ifname='${iface}'
>> +		set wireless.${iface}.mode='ap'
>> +		set wireless.${iface}.ssid='${essid}'
>> +		set wireless.${iface}.encryption='none'
>> +
>> +		commit wireless
>> +	__EOF__
>> +
>> +	echo "${iface}"
>> +}
>> +
>> +# vim: set noexpandtab:tabstop=4
>> diff --git a/src/packages/fff/fff/Makefile
>b/src/packages/fff/fff/Makefile
>> index 52ccc14..366e828 100644
>> --- a/src/packages/fff/fff/Makefile
>> +++ b/src/packages/fff/fff/Makefile
>> @@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
>>  
>>  PKG_NAME:=fff
>>  PKG_VERSION:=0.0.2
>> -PKG_RELEASE:=1
>> +PKG_RELEASE:=2
>>  
>>  PKG_BUILD_DIR:=$(BUILD_DIR)/fff
>>  
>> @@ -22,7 +22,8 @@ define Package/fff-base
>>               +fff-fastd \
>>               +fff-firewall \
>>               +fff-support \
>> -             +fff-network
>> +             +fff-network \
>> +             +fff-wireless
>>  endef
>>  
>>  define Package/fff-base/description
>> -- 
>> 2.1.4
>> 
>
>
>
>------------------------------------------------------------------------