From patchwork Sat Oct 14 17:19:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [SQUASHED,v17,2/8] Reconfigure fff-wireless for keyxchangev2 From: Tim Niemeyer X-Patchwork-Id: 570 Message-Id: <20171014171959.25099-3-tim@tn-x.org> To: franken-dev@freifunk.net Cc: Adrian Schmutzler Date: Sat, 14 Oct 2017 19:19:53 +0200 From: Christian Dresel Need more parameters in wifiAddAP to add hidden AP Need new function wifiAddSta to add a station and download hoodfile Signed-off-by: Christian Dresel Signed-off-by: Adrian Schmutzler Signed-off-by: Tim Niemeyer --- Changes in v17: - Reintroduce initial setup of wireless interfaces. This is required as configurenetwork reads the MAC addresses from the WiFi interfaces. Changes in v16: None Changes in v15: None Changes in v14: - Removed single quotes in iface Changes in v13: None Changes in v12: None Changes in v11: None Changes in v10: None Changes in v9: - rebase onto 20170918-beta Changes in v8: - rebase onto 20170918-beta Changes in v7: None Changes in v6: None Changes in v5: - wXSta to wXsta Changes in v4: None Changes in v3: None Changes in v2: None .../files/etc/uci-defaults/60-fff-wireless | 27 ++++--------- .../fff-wireless/files/lib/functions/fff/wireless | 44 +++++++++++++++++++--- 2 files changed, 47 insertions(+), 24 deletions(-) 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 index 8e207a4..8070cb4 100644 --- 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 @@ -4,37 +4,26 @@ . /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 + radio="$(wifiAddPhyCond "$phy" "2" "1")" + radio5="$(wifiAddPhyCond "$phy" "5" "36")" + [ -n "$radio5" ] && radio="$radio5" + if [ -z "$radio" ]; then + echo "Can't create radio for $phy" + exit 1 fi - if ! wifiAddAP "$radio" "$ESSID_AP"; then + if ! wifiAddAP "$radio" "do.not.use" "mesh" "ap" "0"; then echo "Can't add AP interface on $radio." exit 1 fi - if ! wifiAddAdHocMesh "$radio" "$ESSID_MESH" "$BSSID_MESH"; then + if ! wifiAddAdHocMesh "$radio" "batman.do.not.use" "02:CA:FF:EE:BA:BE"; then echo "Can't add AdHocMesh interface on $radio." exit 1 fi diff --git a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless index 76424be..8ba9463 100644 --- a/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless +++ b/src/packages/fff/fff-wireless/files/lib/functions/fff/wireless @@ -91,28 +91,32 @@ wifiAddAdHocMesh() { } wifiAddAP() { - if [ $# -ne "2" ] + if [ $# -ne "5" ] then - echo "Usage: wifiAddAP " + echo "Usage: wifiAddAP " return 1 fi local radio=$1 local essid=$2 + local network=$3 + local inface=$4 + local hidden=$5 local channel=$(uci get "wireless.${radio}.channel") - local iface="w2ap" + local iface="w2${inface}" if [ "$channel" -gt "14" ]; then - iface="w5ap" + iface="w5${inface}" fi uci batch <<-__EOF__ set wireless.${iface}='wifi-iface' set wireless.${iface}.device='${radio}' - set wireless.${iface}.network='mesh' + set wireless.${iface}.network='${network}' set wireless.${iface}.ifname='${iface}' set wireless.${iface}.mode='ap' set wireless.${iface}.ssid='${essid}' set wireless.${iface}.encryption='none' + set wireless.${iface}.hidden='${hidden}' commit wireless __EOF__ @@ -120,4 +124,34 @@ wifiAddAP() { echo "${iface}" } +wifiAddSta() { + if [ $# -ne "3" ] + then + echo "Usage: wifiAddSta " + return 1 + fi + + local radio=$1 + local essid=$2 + local network=$3 + + local channel=$(uci get "wireless.${radio}.channel") + local iface="w2sta" + if [ "$channel" -gt "14" ]; then + iface="w5sta" + fi + uci batch <<-__EOF__ + set wireless.${iface}='wifi-iface' + set wireless.${iface}.device='${radio}' + set wireless.${iface}.network='${network}' + set wireless.${iface}.ifname='${iface}' + set wireless.${iface}.mode='sta' + set wireless.${iface}.ssid='${essid}' + + commit wireless + __EOF__ + + echo "${iface}" +} + # vim: set noexpandtab:tabstop=4