Developing lightweight computation at the DSG edge

Commit 003700f2 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Add backwards-compatible 802.11s+AdHoc mesh mode



This commit sets the "Ad hoc (mesh)" wireless mode as "Ad hoc (legacy
mesh)" on the web GUI.

It also introduces a backwards-compatible mode, the "802.11s (mesh) + Ad
hoc (legacy mesh)", on the web GUI and adds code to the configuration
scripts to handle it properly.

This whole thing will ease the transition from current Ad hoc mesh
networks towards 802.11s mesh networks (e.g. Guifi.net networks in
Barcelona like Sants-Les Corts-UPC).
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent cea45cfb
...@@ -33,7 +33,7 @@ configure_wifi() { ...@@ -33,7 +33,7 @@ configure_wifi() {
qmp_configure_wifi_initial qmp_configure_wifi_initial
qmp_configure_wifi qmp_configure_wifi
configure_network configure_network
/etc/init.d/network reload /etc/init.d/network restart
if /etc/init.d/gwck enabled if /etc/init.d/gwck enabled
then then
/etc/init.d/gwck restart /etc/init.d/gwck restart
......
...@@ -59,15 +59,17 @@ qmp_set_vlan() { ...@@ -59,15 +59,17 @@ qmp_set_vlan() {
[ -z "$iface" ] || [ -z "$vid" ] && return [ -z "$iface" ] || [ -z "$vid" ] && return
# Replace dots by underscores to use the interface name as part of another one # Replace dots by underscores to use the interface name as part of another one
local uiface="$(echo $iface | sed -r 's/\./_/g')" local uiface="$(echo $iface | sed -r 's/\./_/g')"
uci set network.${uiface}_${vid}=device uci set network.${uiface}_${vid}=device
if [ -e "/sys/class/net/$dev/phy80211" ]; then if [ -e "/sys/class/net/$dev/phy80211" ]; then
# 802.1q VLANs for wireless interfaces # 802.1q VLANs for wireless interfaces
uci set network.${uiface}_${vid}.type=8021q uci set network.${uiface}_${vid}.type=8021q
echo "VLAN $vid for interface $iface is of type 802.1q"
else else
# 802.1ad VLANs for wired interfaces # 802.1ad VLANs for wired interfaces
uci set network.${uiface}_${vid}.type=8021ad uci set network.${uiface}_${vid}.type=8021ad
echo "VLAN $vid for interface $iface is of type 802.1ad (QinQ)"
fi fi
uci set network.${uiface}_${vid}.name=${uiface}_${vid} uci set network.${uiface}_${vid}.name=${uiface}_${vid}
...@@ -126,9 +128,12 @@ qmp_get_virtual_iface() { ...@@ -126,9 +128,12 @@ qmp_get_virtual_iface() {
[ ! -e "/sys/class/net/$device/phy80211" ] && [ -n "$viface" ] && { echo $viface; return; } [ ! -e "/sys/class/net/$device/phy80211" ] && [ -n "$viface" ] && { echo $viface; return; }
# id is the first char and the numbers of the device [e]th[0] [w]lan[1] # id_char is the first char of the device: [e]th0 [w]lan1a
local id_num=$(echo $device | tr -d "[A-z]" | tr - _ | tr . _)
local id_char=$(echo $device | cut -c 1) local id_char=$(echo $device | cut -c 1)
# id_num is the number of the device: eth[0], wlan[1]a
local id_num=$(echo $device | tr -d "[A-z]" | tr - _ | tr . _)
# id_extra are the extra characters after the number: eth0[], wlan1[a]
local id_extra=$(echo $device | sed -e 's/^[a-z]*[0-9]*//g')
# is wan? # is wan?
for w in $(qmp_get_devices wan); do for w in $(qmp_get_devices wan); do
...@@ -142,10 +147,11 @@ qmp_get_virtual_iface() { ...@@ -142,10 +147,11 @@ qmp_get_virtual_iface() {
qmp_log "LOG: 5" qmp_log "LOG: 5"
qmp_log "Viface: $viface" qmp_log "Viface: $viface"
qmp_log $device $viface
# is mesh? # is mesh?
for w in $(qmp_get_devices mesh); do for w in $(qmp_get_devices mesh); do
if [ "$w" == "$device" ]; then if [ "$w" == "$device" ]; then
viface="mesh_${id_char}${id_num}" viface="mesh_${id_char}${id_num}${id_extra}"
break break
fi fi
done done
...@@ -162,7 +168,7 @@ qmp_get_devices() { ...@@ -162,7 +168,7 @@ qmp_get_devices() {
fi fi
# local brlan_enabled=0 # local brlan_enabled=0
# for dev in $(uci get qmp.interfaces.mesh_devices 2>/dev/null); do # for dev in $(uci get qmp.interfaces.mesh_devices 2>/dev/null); do
# #
# # Looking if device is defined as LAN, in such case dev=br-lan, but only once # # Looking if device is defined as LAN, in such case dev=br-lan, but only once
# # except eth1 for RouterStation Pro # # except eth1 for RouterStation Pro
# if ! ( [[ "$dev" == "eth1" ]] && qmp_is_routerstationpro ) ; then # if ! ( [[ "$dev" == "eth1" ]] && qmp_is_routerstationpro ) ; then
...@@ -178,7 +184,7 @@ qmp_get_devices() { ...@@ -178,7 +184,7 @@ qmp_get_devices() {
# fi # fi
# done # done
# fi # fi
# #
# [ -n "$dev" ] && devices="$devices $dev" # [ -n "$dev" ] && devices="$devices $dev"
# done # done
# fi # fi
......
...@@ -246,7 +246,7 @@ qmp_configure_lan_v6() { ...@@ -246,7 +246,7 @@ qmp_configure_lan_v6() {
echo "Publishing $ulan_net over the mesh network" echo "Publishing $ulan_net over the mesh network"
qmp_publish_hna_bmx6 $ulan_net ulan qmp_publish_hna_bmx6 $ulan_net ulan
### Deprecated ### Deprecated
# echo "Configuring radvd" # echo "Configuring radvd"
# qmp_radvd_enable_dev lan # qmp_radvd_enable_dev lan
...@@ -388,7 +388,12 @@ qmp_configure_mesh() { ...@@ -388,7 +388,12 @@ qmp_configure_mesh() {
# bring them up; otherwise the VLAN interface on top of the radio interface # bring them up; otherwise the VLAN interface on top of the radio interface
# can't be brought up # can't be brought up
if [ -e "/sys/class/net/$dev/phy80211" ]; then if [ -e "/sys/class/net/$dev/phy80211" ]; then
qmp_configure_rescue_ip_device "$dev" "$viface" local wireless_network="$(uci get wireless.${dev}.network)"
if [ -z "$wireless_network" ]; then
qmp_configure_rescue_ip_device "$dev" "$viface"
else
qmp_configure_rescue_ip_device "$dev" "$wireless_network"
fi
fi fi
counter=$(( $counter + 1 )) counter=$(( $counter + 1 ))
done done
...@@ -461,8 +466,18 @@ qmp_get_rescue_ip() { ...@@ -461,8 +466,18 @@ qmp_get_rescue_ip() {
mac=${mac:-FF:FF:FF:FF:FF:FF} mac=${mac:-FF:FF:FF:FF:FF:FF}
#local xoctet=$(printf "%d\n" 0x$(echo $mac | cut -d: -f5))
local yoctet=$(printf "%d\n" 0x$(echo $mac | cut -d: -f6)) local yoctet=$(printf "%d\n" 0x$(echo $mac | cut -d: -f6))
# A trick to avoid wlan0 and wlan0a getting the same rescue IP:
local id_extra=$(echo $device | sed -e 's/^[a-z]*[0-9]*//g')
local subdevice=$(echo $device | sed -e "s/$id_extra\$//g")
if [ $device != $subdevice ]; then
if qmp_uci_test wireless.$subdevice.device; then
yoctet=$((yoctet+1))
fi
fi
local rip="$rprefix.$yoctet.1" local rip="$rprefix.$yoctet.1"
echo "$rip" echo "$rip"
......
...@@ -130,13 +130,14 @@ qmp_configure_wifi_device() { ...@@ -130,13 +130,14 @@ qmp_configure_wifi_device() {
# clientwan => Client (WAN) # clientwan => Client (WAN)
# 80211s ====> 802.11s (mesh) # 80211s ====> 802.11s (mesh)
# 80211s_aplan ====> 802.11s (mesh) + access poin (LAN) # 80211s_aplan ====> 802.11s (mesh) + access poin (LAN)
# 80211s_adhoc ====> 802.11s (mesh) + adhoc (mesh)
local mode="$(qmp_uci_get @wireless[$id].mode)" local mode="$(qmp_uci_get @wireless[$id].mode)"
local dev_disabled="0" local dev_disabled="0"
# Remove $device and also unneeded white spaces # Remove $device and also unneeded white spaces
local allmeshdevs="$(qmp_uci_get interfaces.mesh_devices)" local allmeshdevs="$(qmp_uci_get interfaces.mesh_devices)"
local meshdevs="$(echo $allmeshdevs | sed -e s/$device//g -e 's/^[ \t]*//' -e 's/ \+/ /g' -e 's/[ \t]*$//')" local meshdevs="$(echo $allmeshdevs | sed -e s/$device[a-z]*[A-Z]*//g -e 's/^[ \t]*//' -e 's/ \+/ /g' -e 's/[ \t]*$//')"
local allwandevs="$(qmp_uci_get interfaces.wan_devices)" local allwandevs="$(qmp_uci_get interfaces.wan_devices)"
local wandevs="$(echo $allwandevs | sed -e s/$device//g -e 's/^[ \t]*//' -e 's/ \+/ /g' -e 's/[ \t]*$//')" local wandevs="$(echo $allwandevs | sed -e s/$device//g -e 's/^[ \t]*//' -e 's/ \+/ /g' -e 's/[ \t]*$//')"
local alllandevs="$(qmp_uci_get interfaces.lan_devices)" local alllandevs="$(qmp_uci_get interfaces.lan_devices)"
...@@ -163,6 +164,11 @@ qmp_configure_wifi_device() { ...@@ -163,6 +164,11 @@ qmp_configure_wifi_device() {
qmp_uci_set interfaces.lan_devices "$landevs $device" qmp_uci_set interfaces.lan_devices "$landevs $device"
qmp_uci_set interfaces.wan_devices "$wandevs" qmp_uci_set interfaces.wan_devices "$wandevs"
;; ;;
80211s_adhoc)
qmp_uci_set interfaces.mesh_devices "$meshdevs $device ${device}a"
qmp_uci_set interfaces.lan_devices "$landevs"
qmp_uci_set interfaces.wan_devices "$wandevs"
;;
ap) ap)
qmp_uci_set interfaces.mesh_devices "$meshdevs $device" qmp_uci_set interfaces.mesh_devices "$meshdevs $device"
qmp_uci_set interfaces.lan_devices "$landevs" qmp_uci_set interfaces.lan_devices "$landevs"
...@@ -276,6 +282,7 @@ qmp_configure_wifi_device() { ...@@ -276,6 +282,7 @@ qmp_configure_wifi_device() {
[ -z $mesh80211s ] && mesh80211s="qMp" [ -z $mesh80211s ] && mesh80211s="qMp"
local vap=0 local vap=0
local ahl=0
[ $mode == "adhoc_ap" ] && { [ $mode == "adhoc_ap" ] && {
mode="adhoc" mode="adhoc"
vap=1 vap=1
...@@ -286,6 +293,11 @@ qmp_configure_wifi_device() { ...@@ -286,6 +293,11 @@ qmp_configure_wifi_device() {
vap=1 vap=1
} }
[ $mode == "80211s_adhoc" ] && {
mode="80211s"
ahl=1
}
device_template="$TEMPLATE_BASE/device.$driver-$mode11" device_template="$TEMPLATE_BASE/device.$driver-$mode11"
[ ! -f "$device_template" ] && qmp_error "Device template $device_template not found" [ ! -f "$device_template" ] && qmp_error "Device template $device_template not found"
...@@ -340,6 +352,22 @@ qmp_configure_wifi_device() { ...@@ -340,6 +352,22 @@ qmp_configure_wifi_device() {
-e s/"#QMP_KEY"/"$key"/ \ -e s/"#QMP_KEY"/"$key"/ \
-e s/"#QMP_MODE"/"ap"/ >> $TMP/qmp_wifi_iface -e s/"#QMP_MODE"/"ap"/ >> $TMP/qmp_wifi_iface
} }
# If legacy Ad hoc interface has to be configured
ahl_template="$TEMPLATE_BASE/iface.adhoclegacy"
[ ! -f "$ahl_template" ] && qmp_error "Legacy Ad hoc mesh template $ahl_template not found"
[ "$ahl" == "1" ] && {
qmp_prepare_wireless_iface ${device}a
cat $ahl_template | grep -v ^# | sed \
-e s/"#QMP_RADIO"/"$radio"/ \
-e s/"#QMP_DEVICE"/"${device}a"/ \
-e s/"#QMP_IFNAME"/"${device}a"/ \
-e s/"#QMP_SSID"/"$(echo "${name:0:32}" | sed -e 's|/|\\/|g')"/ \
-e s/"#QMP_BSSID"/"$bssid"/ \
-e s/"#QMP_NETWORK"/"${network}a"/ \
-e s/"#QMP_MODE"/"adhoc"/ >> $TMP/qmp_wifi_iface
}
qmp_uci_import $TMP/qmp_wifi_iface qmp_uci_import $TMP/qmp_wifi_iface
qmp_uci_import $TMP/qmp_wifi_device qmp_uci_import $TMP/qmp_wifi_device
# List arguments (needed for HT capab) # List arguments (needed for HT capab)
......
wireless.#QMP_DEVICE.device=#QMP_RADIO
wireless.#QMP_DEVICE.mode=adhoc
wireless.#QMP_DEVICE.ssid=#QMP_SSID
wireless.#QMP_DEVICE.bssid=#QMP_BSSID
wireless.#QMP_DEVICE.network=#QMP_NETWORK
#wireless.#QMP_DEVICE.mcast_rate=#QMP_MRATE
wireless.#QMP_DEVICE.ifname=#QMP_IFNAME
...@@ -258,8 +258,9 @@ local wireless_interface_mode_help ...@@ -258,8 +258,9 @@ local wireless_interface_mode_help
wireless_interface_mode_help = m:field(DummyValue,"wireless_interface_mode_help") wireless_interface_mode_help = m:field(DummyValue,"wireless_interface_mode_help")
wireless_interface_mode_help.rawhtml = true wireless_interface_mode_help.rawhtml = true
wireless_interface_mode_help.default = translate("Select the working mode of the wireless network interfaces:") .. "<br/> <br/>" .. wireless_interface_mode_help.default = translate("Select the working mode of the wireless network interfaces:") .. "<br/> <br/>" ..
translate("· <em>Ad hoc (mesh)</em> mode is used to link with other mesh nodes operating in ad hoc mode") .. "<br/>" .. translate("· <em>802.11s (mesh)</em> mode is used to link with other mesh nodes operating in <strong>current 802.11s mesh</strong> mode") .."<br/>" ..
translate("· <em>802.11s (mesh)</em> mode is used to link with other mesh nodes operating in ad hoc mode") .."<br/>" .. translate("· <em>802.11s (mesh) + Ad hoc (legacy mesh)</em> mode is used to link with other mesh nodes operating in <strong>current 802.11s mesh</strong> or in <strong>legacy ad hoc mesh</strong> mode. Use this one for <strong>backwards compatibility</strong> with old qMp deployments.") .."<br/>" ..
translate("· <em>Ad hoc (legacy mesh)</em> mode is used to link with other mesh nodes operating in <strong>legacy ad hoc mesh</strong> mode") .. "<br/>" ..
translate("· <em>AP (mesh)</em> mode is used to create an access point for other mesh nodes to connect as clients") .. "<br/>" .. translate("· <em>AP (mesh)</em> mode is used to create an access point for other mesh nodes to connect as clients") .. "<br/>" ..
translate("· <em>Client (mesh)</em> mode is used to link with a mesh node operating in AP mode") .. "<br/>" .. translate("· <em>Client (mesh)</em> mode is used to link with a mesh node operating in AP mode") .. "<br/>" ..
translate("· <em>AP (LAN)</em> mode is used to generate an access point for end users' devices") .. "<br/>" .. translate("· <em>AP (LAN)</em> mode is used to generate an access point for end users' devices") .. "<br/>" ..
...@@ -271,8 +272,9 @@ nodedevs_wifi = {} ...@@ -271,8 +272,9 @@ nodedevs_wifi = {}
for i,v in ipairs(devices.wifi) do for i,v in ipairs(devices.wifi) do
wmode = m:field(ListValue, "_"..v.."_mode", translatef("Wireless interface <strong>%s</strong>",v)) wmode = m:field(ListValue, "_"..v.."_mode", translatef("Wireless interface <strong>%s</strong>",v))
wmode:value("adhoc","Ad hoc (mesh)")
wmode:value("80211s","802.11s (mesh)") wmode:value("80211s","802.11s (mesh)")
wmode:value("80211s_adhoc","802.11s (mesh) + Ad hoc (legacy mesh)")
wmode:value("adhoc","Ad hoc (legacy mesh)")
wmode:value("ap","Access point (mesh)") wmode:value("ap","Access point (mesh)")
wmode:value("client","Client (mesh)") wmode:value("client","Client (mesh)")
wmode:value("aplan","Access point (LAN)") wmode:value("aplan","Access point (LAN)")
...@@ -280,7 +282,7 @@ for i,v in ipairs(devices.wifi) do ...@@ -280,7 +282,7 @@ for i,v in ipairs(devices.wifi) do
wmode:value("adhoc_ap","Ad hoc (mesh) + access point (LAN)") wmode:value("adhoc_ap","Ad hoc (mesh) + access point (LAN)")
wmode:value("80211s_aplan","802.11s (mesh) + access point (LAN)") wmode:value("80211s_aplan","802.11s (mesh) + access point (LAN)")
wmode:value("none","Disabled") wmode:value("none","Disabled")
wmode.default = "adhoc_ap" wmode.default = "80211s_aplan"
wchan = m:field(ListValue, "_".. v.."_chan", translate("Channel")) wchan = m:field(ListValue, "_".. v.."_chan", translate("Channel"))
for _,ch in ipairs(qmpinfo.get_channels(v)) do for _,ch in ipairs(qmpinfo.get_channels(v)) do
......
...@@ -81,8 +81,9 @@ for _,wdev in ipairs(wdevs) do ...@@ -81,8 +81,9 @@ for _,wdev in ipairs(wdevs) do
-- Mode -- Mode
mode = s_wireless:option(ListValue,"mode","Mode") mode = s_wireless:option(ListValue,"mode","Mode")
mode:value("adhoc","Ad hoc (mesh)")
mode:value("80211s","802.11s (mesh)") mode:value("80211s","802.11s (mesh)")
mode:value("80211s_adhoc","802.11s (mesh) + Ad hoc (legacy mesh)")
mode:value("adhoc","Ad hoc (legacy mesh)")
mode:value("ap","Access point (mesh)") mode:value("ap","Access point (mesh)")
mode:value("client","Client (mesh)") mode:value("client","Client (mesh)")
mode:value("aplan","Access point (LAN)") mode:value("aplan","Access point (LAN)")
...@@ -90,6 +91,7 @@ for _,wdev in ipairs(wdevs) do ...@@ -90,6 +91,7 @@ for _,wdev in ipairs(wdevs) do
mode:value("adhoc_ap","Ad hoc (mesh) + access point (LAN)") mode:value("adhoc_ap","Ad hoc (mesh) + access point (LAN)")
mode:value("80211s_aplan","802.11s (mesh) + access point (LAN)") mode:value("80211s_aplan","802.11s (mesh) + access point (LAN)")
mode:value("none","Disabled") mode:value("none","Disabled")
mode.default = "80211s_aplan"
-- Channel -- Channel
channel = s_wireless:option(ListValue,"channel","Channel",translate("WiFi channel to be used in this device.") .. " " ..translate ("Selecting channels with + or - enables 40MHz bandwidth.")) channel = s_wireless:option(ListValue,"channel","Channel",translate("WiFi channel to be used in this device.") .. " " ..translate ("Selecting channels with + or - enables 40MHz bandwidth."))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment