fff-wireless: new package to configure wifi

Signed-off-by: Tim Niemeyer <tim@tn-x.org>
Reviewed-by: Jan Kraus <mayosemmel@gmail.com>
Reviewed-by: Christian Dresel <fff@chrisi01.de>
This commit is contained in:
Tim Niemeyer 2016-06-10 23:58:09 +02:00
parent d901f7c442
commit 2bd50f3b87
14 changed files with 202 additions and 200 deletions

View File

@ -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

View File

@ -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'

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -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

View File

@ -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

View File

@ -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