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
|
||||
|
||||
PKG_NAME:=fff-network
|
||||
PKG_RELEASE:=29
|
||||
PKG_RELEASE:=30
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="5 4 3 2 1"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
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
|
||||
|
||||
PORTORDER="5 4"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
PORTORDER="5 4"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="0t"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
PORTORDER="1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
WAN_PORTS=
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="4 3 2 1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="4 3 2 1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="4 3 2 1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="1 2 3 4 5"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth1
|
||||
CLIENT_PORTS="4 5 0t"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
PORTORDER="1 2 3 4 5"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="4 5 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="5 4 3 2 1"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="5 4 3 2 1"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="4 3 2 1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="4 3 2 1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="4 3 2 1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 2 0t"
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
PORTORDER="2 3 4 1"
|
||||
|
||||
WANDEV=eth1
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="1 4 0t"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
PORTORDER="4 3 2 1 0"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="6t 0 1"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
. /lib/functions/system.sh
|
||||
|
||||
PORTORDER="0 1 2 3 4"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="6t 3 4"
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
. /lib/functions/fff/network
|
||||
|
||||
PORTORDER="0 1 2 3 4"
|
||||
|
||||
WANDEV=eth0
|
||||
SWITCHDEV=eth0
|
||||
CLIENT_PORTS="6t 3 4"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-support
|
||||
PKG_RELEASE:=6
|
||||
PKG_RELEASE:=7
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
. /etc/firmware_release
|
||||
. /lib/functions/fff/evalhoodinfo
|
||||
. /lib/functions/fff/evalbytes
|
||||
. /lib/functions/fff/portorder
|
||||
. /lib/functions.sh # required for config_load and config_foreach
|
||||
|
||||
board_name=$(uci -q get board.model.name)
|
||||
|
@ -171,9 +172,7 @@ else
|
|||
echo "simple-tc nicht installiert."
|
||||
fi
|
||||
|
||||
if grep -q 'PORTORDER=' /etc/network.$board_name ; then
|
||||
portorder=$(awk -F= '/PORTORDER=/ { print $2 }' /etc/network.$board_name | sed "s/\"//g")
|
||||
fi
|
||||
portorder=$(get_port_order)
|
||||
|
||||
echo ""
|
||||
if swconfig list | grep -q switch0 ; then
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=fff-web-ui
|
||||
PKG_RELEASE:=17
|
||||
PKG_RELEASE:=18
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
|
|
|
@ -108,9 +108,8 @@ format_port() {
|
|||
echo "</td>"
|
||||
fi
|
||||
|
||||
if grep -q 'PORTORDER=' /etc/network.$board_name ; then
|
||||
portorder=$(awk -F= '/PORTORDER=/ { print $2 }' /etc/network.$board_name | sed "s/\"//g")
|
||||
fi
|
||||
. /lib/functions/fff/portorder
|
||||
portorder=$(get_port_order)
|
||||
for internalport in $portorder
|
||||
do
|
||||
line=$(swconfig dev switch0 port "$internalport" show | tr -d '\n' | tr -d '\t')
|
||||
|
|
Loading…
Reference in New Issue
Block a user