[OpenWrt-Devel] [PATCH] lantiq: add dsl line_state mapping

Florian Eckert fe at dev.tdt.de
Tue Jun 16 04:26:13 EDT 2020


The line_state of the DSL connection is described in the system via a
hexadecimal variable. With this change the hexadecimal is mapped to a decimal
value. With this change it is now possible to store this value in a database,
so that it can be easily evaluated.

This is especially relevant for the collectd and gravana backend.

Signed-off-by: Florian Eckert <fe at dev.tdt.de>
---
 .../base-files/lib/functions/lantiq_dsl.sh    | 82 +++++++++++++------
 1 file changed, 55 insertions(+), 27 deletions(-)

diff --git a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
index 11b02fc4aa..4827d10bc5 100755
--- a/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
+++ b/target/linux/lantiq/base-files/lib/functions/lantiq_dsl.sh
@@ -650,40 +650,68 @@ line_data() {
 line_state() {
 	local lsg=$(dsl_cmd lsg)
 	local ls=$(dsl_val "$lsg" nLineState);
-	local s;
+	local s n;
 
 	case "$ls" in
-		"0x0")		s="not initialized" ;;
-		"0x1")		s="exception" ;;
-		"0x10")		s="not updated" ;;
-		"0xff")		s="idle request" ;;
-		"0x100")	s="idle" ;;
-		"0x1ff")	s="silent request" ;;
-		"0x200")	s="silent" ;;
-		"0x300")	s="handshake" ;;
-		"0x380")	s="full_init" ;;
-		"0x400")	s="discovery" ;;
-		"0x500")	s="training" ;;
-		"0x600")	s="analysis" ;;
-		"0x700")	s="exchange" ;;
-		"0x800")	s="showtime_no_sync" ;;
-		"0x801")	s="showtime_tc_sync" ;;
-		"0x900")	s="fastretrain" ;;
-		"0xa00")	s="lowpower_l2" ;;
-		"0xb00")	s="loopdiagnostic active" ;;
-		"0xb10")	s="loopdiagnostic data exchange" ;;
-		"0xb20")	s="loopdiagnostic data request" ;;
-		"0xc00")	s="loopdiagnostic complete" ;;
-		"0x1000000")	s="test" ;;
-		"0xd00")	s="resync" ;;
-		"0x3c0")	s="short init entry" ;;
-		"")		s="not running daemon"; ls="0xfff" ;;
-		*)		s="unknown" ;;
+		"0x0")		s="not initialized"
+				n=1 ;;
+		"0x1")		s="exception"
+				n=2 ;;
+		"0x10")		s="not updated"
+				n=3 ;;
+		"0xff")		s="idle request"
+				n=4 ;;
+		"0x100")	s="idle"
+				n=5 ;;
+		"0x1ff")	s="silent request"
+				n=6 ;;
+		"0x200")	s="silent"
+				n=7 ;;
+		"0x300")	s="handshake"
+				n=8 ;;
+		"0x380")	s="full_init"
+				n=9 ;;
+		"0x400")	s="discovery"
+				n=10 ;;
+		"0x500")	s="training"
+				n=11 ;;
+		"0x600")	s="analysis"
+				n=12 ;;
+		"0x700")	s="exchange"
+				n=13 ;;
+		"0x800")	s="showtime_no_sync"
+				n=14 ;;
+		"0x801")	s="showtime_tc_sync"
+				n=15 ;;
+		"0x900")	s="fastretrain"
+				n=16 ;;
+		"0xa00")	s="lowpower_l2"
+				n=17 ;;
+		"0xb00")	s="loopdiagnostic active"
+				n=18 ;;
+		"0xb10")	s="loopdiagnostic data exchange"
+				n=19 ;;
+		"0xb20")	s="loopdiagnostic data request"
+				n=20 ;;
+		"0xc00")	s="loopdiagnostic complete"
+				n=21 ;;
+		"0x1000000")	s="test"
+				n=22 ;;
+		"0xd00")	s="resync"
+				n=23 ;;
+		"0x3c0")	s="short init entry"
+				n=24 ;;
+		"")		s="not running daemon"
+				ls="0xfff"
+				n=25 ;;
+		*)		s="unknown"
+				n=26 ;;
 	esac
 
 	if [ "$action" = "lucistat" ]; then
 		echo "dsl.line_state_num=$ls"
 		echo "dsl.line_state_detail=\"$s\""
+		echo "dsl.line_state_mapping=$n"
 		if [ "$ls" = "0x801" ]; then
 			echo "dsl.line_state=\"UP\""
 		else
-- 
2.20.1


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list