firmware/src/packages/fff/fff-hoods/files/usr/lib/functions/fff/hoodfile
Adrian Schmutzler 3214388680 treewide: rename br-mesh to br-client
The name br-mesh is actually quite misleading, since the bridge
actually includes the "client" interfaces. In order to make this
obvious, and to prevent confusion with the properly named wXmesh
interfaces, rename them to br-client.

Note that br-mesh is also particularly disturbing for the layer 3
firmware without batman-adv.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Acked-by: Fabian Bläse <fabian@blaese.de>
Acked-by: Christian Dresel <freifunk@dresel.systems>
Reviewed-by: Robert Langhammer <rlanghammer@web.de>
2020-12-22 13:41:44 +01:00

108 lines
2.3 KiB
Plaintext

. /usr/share/libubox/jshn.sh
. /lib/functions/fff/wireless
getWirelessHoodfile() {
if [ $# != 1 ]; then
echo "Usage: getWirelessHoodfile <target-file>"
return 1
fi
file=$1
echo "Trying to get hoodfile from wireless neighbor..."
echo "All wireless interfaces will be disabled temporarily!"
# only change temporarily
# Set channel to auto, enable wXsta, disable other interfaces
for radio in $(wifiListRadio); do
freq="$(wifiGetFreq $radio)"
uci set wireless.w${freq}ap.disabled='1'
uci set wireless.w${freq}mesh.disabled='1'
uci set wireless.w${freq}configap.disabled='1'
done
uci commit wireless
reload_config
# wait for wireless interfaces to vanish
sleep 8;
for phy in $(ls /sys/class/ieee80211); do
iw phy $phy interface add configsta type managed
ip link set up configsta
iw dev configsta connect -w config.franken.freifunk.net 2>/dev/null
if /bin/busybox wget -T15 -O "$file" "http://[fe80::1%configsta]:2342/keyxchangev2data"; then
iw dev configsta del
return 0
fi
iw dev configsta del
done
return 1
}
getEthernetHoodfile() {
if [ $# != 1 ]; then
echo "Usage: getEthernetHoodfile <target-file>"
return 1
fi
file=$1
echo "Trying to get hoodfile from ethernet neighbor..."
if ! ethmesh_dev=$(uci -q get network.ethmesh.ifname); then
# no ethmesh interface
return 1
fi
neighbor_addrs=$(ping6 -c2 ff02::1%"${ethmesh_dev}" | grep seq | grep DUP | cut -d " " -f4 | sed s/:$//g | sort -u)
for addr in $neighbor_addrs; do
/bin/busybox wget -T2 -qO "$file" "http://[${addr}%${ethmesh_dev}]:2342/keyxchangev2data" && return 0
done
# got no hoodfile
return 1
}
getGatewayHoodfile() {
if [ $# != 1 ]; then
echo "Usage: getGatewayHoodfile <target-file>"
return 1
fi
file=$1
echo "Trying to get hoodfile from gateway..."
if /bin/busybox wget -T15 -O "$file" "http://[fe80::1%br-client]:2342/keyxchangev2data"; then
return 0
else
return 1
fi
}
getKeyserverHoodfile() {
if [ $# = 1 ]; then
lat=$(uci -q get fff.system.latitude)
long=$(uci -q get fff.system.longitude)
elif [ $# = 3 ]; then
lat=$2
long=$3
else
echo "Usage: getKeyserverHoodfile <target-file> [<latitude> <longitude>]"
return 1
fi
file=$1
echo "Getting hoodfile from Keyserver"
if /bin/busybox wget -T15 -O "$file" "http://keyserver.freifunk-franken.de/v2/?lat=$lat&long=$long"; then
return 0
else
return 1
fi
}