[PATCH v2 1/7] fff-wireless: new package to configure wifi
mayosemmel
mayosemmel at googlemail.com
Sa Jun 11 09:22:51 CEST 2016
Sollte jetzt passen. Hier wäre ich froh, wenn ein zweiter noch drüber
schaut.
Reviewed-by: Jan Kraus <mayosemmel at gmail.com>
Am Freitag, den 10.06.2016, 23:58 +0200 schrieb Tim Niemeyer:
> Signed-off-by: Tim Niemeyer <tim at tn-x.org>
> ---
>
> Changes in v2:
> - fix wifi hwmode
>
> 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 | 117 +++++++++++++++++++++
> src/packages/fff/fff/Makefile | 5 +-
> 14 files changed, 202 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 18263f9..08a897b 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:=+ at 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..59c8ce2
> --- /dev/null
> +++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless
> @@ -0,0 +1,117 @@
> +#!/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])"
> + local hwmode="11g"
> + if [ "$channel" -gt "14" ]; then
> + hwmode="11a"
> + fi
> +
> + 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='${hwmode}'
> + 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 9f91b31..614eba1 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:=2
> +PKG_RELEASE:=3
>
> PKG_BUILD_DIR:=$(BUILD_DIR)/fff
>
> @@ -23,7 +23,8 @@ define Package/fff-base
> +fff-firewall \
> +fff-support \
> +fff-network \
> - +fff-sysupgrade
> + +fff-sysupgrade \
> + +fff-wireless
> endef
>
> define Package/fff-base/description
> --
> 2.1.4
>
-------------- nächster Teil --------------
Ein Dateianhang mit Binärdaten wurde abgetrennt...
Dateiname : signature.asc
Dateityp : application/pgp-signature
Dateigröße : 473 bytes
Beschreibung: This is a digitally signed message part
URL : <http://lists.freifunk.net/pipermail/franken-dev-freifunk.net/attachments/20160611/c392ccc3/attachment.sig>
Mehr Informationen über die Mailingliste franken-dev