forked from freifunk-franken/firmware
fff-network: move PORTORDER to function/library
So far, we define PORTORDER individually in each network.* file. This creates a lot of duplications, and makes the code to parse those values very ugly (and it's only used outside of configurenetwork anyway). Therefore, move the assignment to a library file, and wrap it into a function for tidyness. This gives us more overview and nicer implementation of the retrieval. Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Acked-by: Christian Dresel <freifunk@dresel.systems> Reviewed-by: Robert Langhammer <rlanghammer@web.de>
This commit is contained in:
parent
37695a1cfc
commit
cb4bce7cc2
|
@ -1,7 +1,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=fff-network
|
PKG_NAME:=fff-network
|
||||||
PKG_RELEASE:=29
|
PKG_RELEASE:=30
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="5 4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="0t 1 2"
|
CLIENT_PORTS="0t 1 2"
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
# Copyright 2019 Adrian Schmutzler
|
||||||
|
# License GPLv3
|
||||||
|
|
||||||
|
get_port_order() {
|
||||||
|
local BOARD=$(uci get board.model.name)
|
||||||
|
local PORTORDER
|
||||||
|
|
||||||
|
case "$BOARD" in
|
||||||
|
glinet,gl-ar150)
|
||||||
|
PORTORDER="1"
|
||||||
|
;;
|
||||||
|
r6220)
|
||||||
|
PORTORDER="4 3 2 1 0"
|
||||||
|
;;
|
||||||
|
tplink,archer-c25-v1|\
|
||||||
|
tplink,archer-c60-v1|\
|
||||||
|
tplink,archer-c60-v2|\
|
||||||
|
tplink,tl-wr841-v10|\
|
||||||
|
tplink,tl-wr841-v11|\
|
||||||
|
tplink,tl-wr841-v12)
|
||||||
|
PORTORDER="4 3 2 1"
|
||||||
|
;;
|
||||||
|
tplink,c50-v4|\
|
||||||
|
tl-wr841n-v13)
|
||||||
|
PORTORDER="0 1 2 3 4"
|
||||||
|
;;
|
||||||
|
tplink,archer-c7-v2|\
|
||||||
|
tplink,archer-c7-v5|\
|
||||||
|
tplink,tl-wdr4300-v1)
|
||||||
|
PORTORDER="1 2 3 4 5"
|
||||||
|
;;
|
||||||
|
tplink,c2600|\
|
||||||
|
tplink,tl-wr1043nd-v4|\
|
||||||
|
tplink,tl-wr1043n-v5)
|
||||||
|
PORTORDER="5 4 3 2 1"
|
||||||
|
;;
|
||||||
|
cpe210|\
|
||||||
|
cpe510)
|
||||||
|
PORTORDER="5 4"
|
||||||
|
;;
|
||||||
|
tplink,tl-wr841-v8)
|
||||||
|
PORTORDER="2 3 4 1"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
echo "$PORTORDER"
|
||||||
|
}
|
|
@ -1,7 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
. /lib/functions/fff/network
|
||||||
|
|
||||||
PORTORDER="5 4"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="0t"
|
CLIENT_PORTS="0t"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
. /lib/functions/fff/network
|
||||||
|
|
||||||
PORTORDER="5 4"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="0t"
|
CLIENT_PORTS="0t"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
. /lib/functions/fff/network
|
||||||
|
|
||||||
PORTORDER="1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
WAN_PORTS=
|
WAN_PORTS=
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="1 2 3 4 5"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth1
|
SWITCHDEV=eth1
|
||||||
CLIENT_PORTS="4 5 0t"
|
CLIENT_PORTS="4 5 0t"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
. /lib/functions/fff/network
|
||||||
|
|
||||||
PORTORDER="1 2 3 4 5"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="4 5 0t"
|
CLIENT_PORTS="4 5 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="5 4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="5 4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="4 3 2 1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 2 0t"
|
CLIENT_PORTS="1 2 0t"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
PORTORDER="2 3 4 1"
|
|
||||||
|
|
||||||
WANDEV=eth1
|
WANDEV=eth1
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="1 4 0t"
|
CLIENT_PORTS="1 4 0t"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
. /lib/functions/fff/network
|
||||||
|
|
||||||
PORTORDER="4 3 2 1 0"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="6t 0 1"
|
CLIENT_PORTS="6t 0 1"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
. /lib/functions/system.sh
|
. /lib/functions/system.sh
|
||||||
|
|
||||||
PORTORDER="0 1 2 3 4"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="6t 3 4"
|
CLIENT_PORTS="6t 3 4"
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
. /lib/functions/fff/network
|
. /lib/functions/fff/network
|
||||||
|
|
||||||
PORTORDER="0 1 2 3 4"
|
|
||||||
|
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth0
|
SWITCHDEV=eth0
|
||||||
CLIENT_PORTS="6t 3 4"
|
CLIENT_PORTS="6t 3 4"
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=fff-support
|
PKG_NAME:=fff-support
|
||||||
PKG_RELEASE:=6
|
PKG_RELEASE:=7
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
. /etc/firmware_release
|
. /etc/firmware_release
|
||||||
. /lib/functions/fff/evalhoodinfo
|
. /lib/functions/fff/evalhoodinfo
|
||||||
. /lib/functions/fff/evalbytes
|
. /lib/functions/fff/evalbytes
|
||||||
|
. /lib/functions/fff/portorder
|
||||||
. /lib/functions.sh # required for config_load and config_foreach
|
. /lib/functions.sh # required for config_load and config_foreach
|
||||||
|
|
||||||
board_name=$(uci -q get board.model.name)
|
board_name=$(uci -q get board.model.name)
|
||||||
|
@ -171,9 +172,7 @@ else
|
||||||
echo "simple-tc nicht installiert."
|
echo "simple-tc nicht installiert."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q 'PORTORDER=' /etc/network.$board_name ; then
|
portorder=$(get_port_order)
|
||||||
portorder=$(awk -F= '/PORTORDER=/ { print $2 }' /etc/network.$board_name | sed "s/\"//g")
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
if swconfig list | grep -q switch0 ; then
|
if swconfig list | grep -q switch0 ; then
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=fff-web-ui
|
PKG_NAME:=fff-web-ui
|
||||||
PKG_RELEASE:=17
|
PKG_RELEASE:=18
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
|
|
@ -107,10 +107,9 @@ format_port() {
|
||||||
echo "<span class=\"stat\">$speed</span>"
|
echo "<span class=\"stat\">$speed</span>"
|
||||||
echo "</td>"
|
echo "</td>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -q 'PORTORDER=' /etc/network.$board_name ; then
|
. /lib/functions/fff/portorder
|
||||||
portorder=$(awk -F= '/PORTORDER=/ { print $2 }' /etc/network.$board_name | sed "s/\"//g")
|
portorder=$(get_port_order)
|
||||||
fi
|
|
||||||
for internalport in $portorder
|
for internalport in $portorder
|
||||||
do
|
do
|
||||||
line=$(swconfig dev switch0 port "$internalport" show | tr -d '\n' | tr -d '\t')
|
line=$(swconfig dev switch0 port "$internalport" show | tr -d '\n' | tr -d '\t')
|
||||||
|
@ -123,7 +122,7 @@ format_port() {
|
||||||
if [ -n "$portorder" ] ; then
|
if [ -n "$portorder" ] ; then
|
||||||
echo "<td class=\"swport\" style=\"width:4em\"></td>"
|
echo "<td class=\"swport\" style=\"width:4em\"></td>"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
swconfig dev switch0 show | grep "\t*link:" | while read line ; do
|
swconfig dev switch0 show | grep "\t*link:" | while read line ; do
|
||||||
line=$(echo "$line" | tr -d '\n' | tr -d '\t')
|
line=$(echo "$line" | tr -d '\n' | tr -d '\t')
|
||||||
port=$(echo "$line" | sed 's/.* port:\([^ ]*\) .*/\1/')
|
port=$(echo "$line" | sed 's/.* port:\([^ ]*\) .*/\1/')
|
||||||
|
|
Loading…
Reference in New Issue