. /usr/share/libubox/jshn.sh . /lib/functions/fff/wireless getWirelessHoodfile() { if [ $# != 1 ]; then echo "Usage: getWirelessHoodfile " 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 " 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 " 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 [ ]" 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 }