lantiq_dsl.sh 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749
  1. #!/bin/sh /etc/rc.common
  2. # Copyright (C) 2012-2014 OpenWrt.org
  3. if [ "$( which vdsl_cpe_control )" ]; then
  4. XDSL_CTRL=vdsl_cpe_control
  5. else
  6. XDSL_CTRL=dsl_cpe_control
  7. fi
  8. #
  9. # Basic functions to send CLI commands to the vdsl_cpe_control daemon
  10. #
  11. dsl_cmd() {
  12. killall -q -0 ${XDSL_CTRL} && (
  13. lock /var/lock/dsl_pipe
  14. echo "$@" > /tmp/pipe/dsl_cpe0_cmd
  15. cat /tmp/pipe/dsl_cpe0_ack
  16. lock -u /var/lock/dsl_pipe
  17. )
  18. }
  19. dsl_val() {
  20. echo $(expr "$1" : '.*'$2'=\([-\.[:alnum:]]*\).*')
  21. }
  22. dsl_string() {
  23. echo $(expr "$1" : '.*'$2'=(\([A-Z0-9,]*\))')
  24. }
  25. #
  26. # Simple divide by 10 routine to cope with one decimal place
  27. #
  28. dbt() {
  29. local a=$(expr $1 / 10)
  30. local b=$(expr $1 % 10)
  31. echo "${a}.${b#-}"
  32. }
  33. #
  34. # Take a number and convert to k or meg
  35. #
  36. scale() {
  37. local val=$1
  38. local a
  39. local b
  40. if [ "$val" -gt 1000000 ]; then
  41. a=$(expr $val / 1000)
  42. b=$(expr $a % 1000)
  43. a=$(expr $a / 1000)
  44. printf "%d.%03d Mb" ${a} ${b}
  45. elif [ "$val" -gt 1000 ]; then
  46. a=$(expr $val / 1000)
  47. printf "%d Kb" ${a}
  48. else
  49. echo "${val} b"
  50. fi
  51. }
  52. scale_latency() {
  53. local val=$1
  54. local a
  55. local b
  56. a=$(expr $val / 100)
  57. b=$(expr $val % 100)
  58. printf "%d.%d ms" ${a} ${b}
  59. }
  60. #
  61. # convert vendorid into human readable form
  62. #
  63. parse_vendorid() {
  64. local val=$1
  65. local name
  66. local version
  67. case "$val" in
  68. B5,00,41,4C,43,42*)
  69. name="Alcatel"
  70. version=${val##*B5,00,41,4C,43,42,}
  71. ;;
  72. B5,00,41,4E,44,56*)
  73. name="Analog Devices"
  74. version=${val##*B5,00,41,4E,44,56,}
  75. ;;
  76. B5,00,42,44,43,4D*)
  77. name="Broadcom"
  78. version=${val##*B5,00,42,44,43,4D,}
  79. ;;
  80. B5,00,43,45,4E,54*)
  81. name="Centillium"
  82. version=${val##*B5,00,43,45,4E,54,}
  83. ;;
  84. B5,00,47,53,50,4E*)
  85. name="Globespan"
  86. version=${val##*B5,00,47,53,50,4E,}
  87. ;;
  88. B5,00,49,4B,4E,53*)
  89. name="Ikanos"
  90. version=${val##*B5,00,49,4B,4E,53,}
  91. ;;
  92. B5,00,49,46,54,4E*)
  93. name="Infineon"
  94. version=${val##*B5,00,49,46,54,4E,}
  95. ;;
  96. B5,00,54,53,54,43*)
  97. name="Texas Instruments"
  98. version=${val##*B5,00,54,53,54,43,}
  99. ;;
  100. B5,00,54,4D,4D,42*)
  101. name="Thomson MultiMedia Broadband"
  102. version=${val##*B5,00,54,4D,4D,42,}
  103. ;;
  104. B5,00,54,43,54,4E*)
  105. name="Trend Chip Technologies"
  106. version=${val##*B5,00,54,43,54,4E,}
  107. ;;
  108. B5,00,53,54,4D,49*)
  109. name="ST Micro"
  110. version=${val##*B5,00,53,54,4D,49,}
  111. ;;
  112. esac
  113. [ -n "$name" ] && {
  114. val="$name"
  115. [ "$version" != "00,00" ] && val="$(printf "%s %d.%d" "$val" 0x${version//,/ 0x})"
  116. }
  117. echo "$val"
  118. }
  119. #
  120. # Read the data rates for both directions
  121. #
  122. data_rates() {
  123. local csg
  124. local dru
  125. local drd
  126. local sdru
  127. local sdrd
  128. csg=$(dsl_cmd g997csg 0 1)
  129. drd=$(dsl_val "$csg" ActualDataRate)
  130. csg=$(dsl_cmd g997csg 0 0)
  131. dru=$(dsl_val "$csg" ActualDataRate)
  132. [ -z "$drd" ] && drd=0
  133. [ -z "$dru" ] && dru=0
  134. sdrd=$(scale $drd)
  135. sdru=$(scale $dru)
  136. if [ "$action" = "lucistat" ]; then
  137. echo "dsl.data_rate_down=$drd"
  138. echo "dsl.data_rate_up=$dru"
  139. echo "dsl.data_rate_down_s=\"$sdrd\""
  140. echo "dsl.data_rate_up_s=\"$sdru\""
  141. else
  142. echo "Data Rate: Down: ${sdrd}/s / Up: ${sdru}/s"
  143. fi
  144. }
  145. #
  146. # Chipset
  147. #
  148. chipset() {
  149. local vig
  150. local cs
  151. local csv
  152. vig=$(dsl_cmd vig)
  153. cs=$(dsl_val "$vig" DSL_ChipSetType)
  154. csv=$(dsl_val "$vig" DSL_ChipSetHWVersion)
  155. csfw=$(dsl_val "$vig" DSL_ChipSetFWVersion)
  156. csapi=$(dsl_val "$vig" DSL_DriverVersionApi)
  157. if [ "$action" = "lucistat" ]; then
  158. echo "dsl.chipset=\"${cs} ${csv}\""
  159. echo "dsl.firmware_version=\"${csfw}\""
  160. echo "dsl.api_version=\"${csapi}\""
  161. else
  162. echo "Chipset: ${cs} ${csv}"
  163. echo "Firmware Version: ${csfw}"
  164. echo "API Version: ${csapi}"
  165. fi
  166. }
  167. #
  168. # Vendor information
  169. #
  170. vendor() {
  171. local lig
  172. local vid
  173. local svid
  174. lig=$(dsl_cmd g997lig 1)
  175. vid=$(dsl_string "$lig" G994VendorID)
  176. svid=$(dsl_string "$lig" SystemVendorID)
  177. vid=$(parse_vendorid $vid)
  178. svid=$(parse_vendorid $svid)
  179. if [ "$action" = "lucistat" ]; then
  180. echo "dsl.atuc_vendor_id=\"${vid}\""
  181. echo "dsl.atuc_system_vendor_id=\"${svid}\""
  182. else
  183. echo "ATU-C Vendor ID: ${vid}"
  184. echo "ATU-C System Vendor ID: ${svid}"
  185. fi
  186. }
  187. #
  188. # XTSE capabilities
  189. #
  190. xtse() {
  191. local xtusesg
  192. local xtse1
  193. local xtse2
  194. local xtse3
  195. local xtse4
  196. local xtse5
  197. local xtse6
  198. local xtse7
  199. local xtse8
  200. local xtse_s=""
  201. local annex_s=""
  202. local line_mode_s=""
  203. local vector_s=""
  204. local dsmsg=""
  205. local cmd=""
  206. xtusesg=$(dsl_cmd g997xtusesg)
  207. xtse1=$(dsl_val "$xtusesg" XTSE1)
  208. xtse2=$(dsl_val "$xtusesg" XTSE2)
  209. xtse3=$(dsl_val "$xtusesg" XTSE3)
  210. xtse4=$(dsl_val "$xtusesg" XTSE4)
  211. xtse5=$(dsl_val "$xtusesg" XTSE5)
  212. xtse6=$(dsl_val "$xtusesg" XTSE6)
  213. xtse7=$(dsl_val "$xtusesg" XTSE7)
  214. xtse8=$(dsl_val "$xtusesg" XTSE8)
  215. # Evaluate Annex (according to G.997.1, 7.3.1.1.1)
  216. if [ $((xtse1 & 13)) != 0 \
  217. -o $((xtse2 & 1)) != 0 \
  218. -o $((xtse3 & 12)) != 0 \
  219. -o $((xtse4 & 3)) != 0 \
  220. -o $((xtse6 & 3)) != 0 \
  221. -o $((xtse8 & 1)) != 0 ]; then
  222. annex_s=" A,"
  223. fi
  224. if [ $((xtse1 & 48)) != 0 \
  225. -o $((xtse2 & 2)) != 0 \
  226. -o $((xtse3 & 48)) != 0 \
  227. -o $((xtse6 & 12)) != 0 \
  228. -o $((xtse8 & 2)) != 0 ]; then
  229. annex_s="$annex_s B,"
  230. fi
  231. if [ $((xtse1 & 194)) != 0 \
  232. -o $((xtse2 & 12)) != 0 \
  233. -o $((xtse8 & 4)) != 0 ]; then
  234. annex_s="$annex_s C,"
  235. fi
  236. if [ $((xtse4 & 48)) != 0 \
  237. -o $((xtse5 & 3)) != 0 \
  238. -o $((xtse6 & 192)) != 0 ]; then
  239. annex_s="$annex_s I,"
  240. fi
  241. if [ $((xtse4 & 192)) != 0 \
  242. -o $((xtse7 & 3)) != 0 ]; then
  243. annex_s="$annex_s J,"
  244. fi
  245. if [ $((xtse5 & 60)) != 0 ]; then
  246. annex_s="$annex_s L,"
  247. fi
  248. if [ $((xtse5 & 192)) != 0 \
  249. -o $((xtse7 & 12)) != 0 ]; then
  250. annex_s="$annex_s M,"
  251. fi
  252. annex_s=`echo ${annex_s:1}`
  253. annex_s=`echo ${annex_s%?}`
  254. # Evaluate Line Mode (according to G.997.1, 7.3.1.1.1)
  255. # Regional standard: ANSI T1.413
  256. if [ $((xtse1 & 1)) != 0 ]; then
  257. line_mode_s=" T1.413,"
  258. fi
  259. # Regional standard: TS 101 388
  260. if [ $((xtse1 & 1)) != 0 ]; then
  261. line_mode_s="$line_mode_s TS 101 388,"
  262. fi
  263. if [ $((xtse1 & 252)) != 0 ]; then
  264. line_mode_s="$line_mode_s G.992.1 (ADSL),"
  265. fi
  266. if [ $((xtse2 & 15)) != 0 ]; then
  267. line_mode_s="$line_mode_s G.992.2 (ADSL lite),"
  268. fi
  269. if [ $((xtse3 & 60)) != 0 \
  270. -o $((xtse4 & 240)) != 0 \
  271. -o $((xtse5 & 252)) != 0 ]; then
  272. line_mode_s="$line_mode_s G.992.3 (ADSL2),"
  273. fi
  274. if [ $((xtse4 & 3)) != 0 \
  275. -o $((xtse5 & 3)) != 0 ]; then
  276. line_mode_s="$line_mode_s G.992.4 (ADSL2 lite),"
  277. fi
  278. if [ $((xtse6 & 199)) != 0 \
  279. -o $((xtse7 & 15)) != 0 ]; then
  280. line_mode_s="$line_mode_s G.992.5 (ADSL2+),"
  281. fi
  282. if [ $((xtse8 & 7)) != 0 ]; then
  283. dsmsg=$(dsl_cmd dsmsg)
  284. vector_s=$(dsl_val "$dsmsg" eVectorStatus)
  285. case "$vector_s" in
  286. "0") line_mode_s="$line_mode_s G.993.2 (VDSL2)," ;;
  287. "1") line_mode_s="$line_mode_s G.993.5 (VDSL2 with downstream vectoring)," ;;
  288. "2") line_mode_s="$line_mode_s G.993.5 (VDSL2 with down- and upstream vectoring)," ;;
  289. *) line_mode_s="$line_mode_s unknown," ;;
  290. esac
  291. fi
  292. #!!! PROPRIETARY & INTERMEDIATE USE !!!
  293. if [ $((xtse8 & 128)) != 0 ]; then
  294. line_mode_s="$line_mode_s G.993.1 (VDSL),"
  295. fi
  296. line_mode_s=`echo ${line_mode_s:1}`
  297. line_mode_s=`echo ${line_mode_s%?}`
  298. xtse_s="${xtse1}, ${xtse2}, ${xtse3}, ${xtse4}, ${xtse5}, ${xtse6}, ${xtse7}, ${xtse8}"
  299. if [ "$action" = "lucistat" ]; then
  300. echo "dsl.xtse1=${xtse1:-nil}"
  301. echo "dsl.xtse2=${xtse2:-nil}"
  302. echo "dsl.xtse3=${xtse3:-nil}"
  303. echo "dsl.xtse4=${xtse4:-nil}"
  304. echo "dsl.xtse5=${xtse5:-nil}"
  305. echo "dsl.xtse6=${xtse6:-nil}"
  306. echo "dsl.xtse7=${xtse7:-nil}"
  307. echo "dsl.xtse8=${xtse8:-nil}"
  308. echo "dsl.xtse_s=\"$xtse_s\""
  309. echo "dsl.annex_s=\"${annex_s}\""
  310. echo "dsl.line_mode_s=\"${line_mode_s}\""
  311. else
  312. echo "XTSE Capabilities: ${xtse_s}"
  313. echo "Annex: ${annex_s}"
  314. echo "Line Mode: ${line_mode_s}"
  315. fi
  316. }
  317. #
  318. # Power Management Mode
  319. #
  320. power_mode() {
  321. local pmsg=$(dsl_cmd g997pmsg)
  322. local pm=$(dsl_val "$pmsg" nPowerManagementStatus);
  323. local s;
  324. case "$pm" in
  325. "-1") s="Power management state is not available" ;;
  326. "0") s="L0 - Synchronized" ;;
  327. "1") s="L1 - Power Down Data transmission (G.992.2)" ;;
  328. "2") s="L2 - Power Down Data transmission (G.992.3 and G.992.4)" ;;
  329. "3") s="L3 - No power" ;;
  330. *) s="unknown" ;;
  331. esac
  332. if [ "$action" = "lucistat" ]; then
  333. echo "dsl.power_mode_num=${pm:-nil}"
  334. echo "dsl.power_mode_s=\"$s\""
  335. else
  336. echo "Power Management Mode: $s"
  337. fi
  338. }
  339. #
  340. # Latency type (interleave delay)
  341. #
  342. latency_delay() {
  343. local csg
  344. local idu
  345. local idu_s;
  346. local sidu
  347. local idd
  348. local idd_s;
  349. local sidd
  350. csg=$(dsl_cmd g997csg 0 1)
  351. idd=$(dsl_val "$csg" ActualInterleaveDelay)
  352. csg=$(dsl_cmd g997csg 0 0)
  353. idu=$(dsl_val "$csg" ActualInterleaveDelay)
  354. [ -z "$idd" ] && idd=0
  355. [ -z "$idu" ] && idu=0
  356. if [ "$idd" -gt 100 ]; then
  357. idd_s="Interleave"
  358. else
  359. idd_s="Fast"
  360. fi
  361. if [ "$idu" -gt 100 ]; then
  362. idu_s="Interleave"
  363. else
  364. idu_s="Fast"
  365. fi
  366. sidu=$(scale_latency $idu)
  367. sidd=$(scale_latency $idd)
  368. if [ "$action" = "lucistat" ]; then
  369. echo "dsl.latency_num_down=\"$sidd\""
  370. echo "dsl.latency_num_up=\"$sidu\""
  371. echo "dsl.latency_s_down=\"$idd_s\""
  372. echo "dsl.latency_s_up=\"$idu_s\""
  373. else
  374. echo "Latency / Interleave Delay: Down: ${idd_s} (${sidd}) / Up: ${idu_s} (${sidu})"
  375. fi
  376. }
  377. #
  378. # Errors
  379. #
  380. errors() {
  381. local lsctg
  382. local dpctg
  383. local ccsg
  384. local esf
  385. local esn
  386. local sesf
  387. local sesn
  388. local lossf
  389. local lossn
  390. local uasf
  391. local uasn
  392. local crc_pf
  393. local crc_pn
  394. local crcp_pf
  395. local crcp_pn
  396. local hecf
  397. local hecn
  398. local fecn
  399. local fecf
  400. lsctg=$(dsl_cmd pmlsctg 1)
  401. esf=$(dsl_val "$lsctg" nES)
  402. sesf=$(dsl_val "$lsctg" nSES)
  403. lossf=$(dsl_val "$lsctg" nLOSS)
  404. uasf=$(dsl_val "$lsctg" nUAS)
  405. lsctg=$(dsl_cmd pmlsctg 0)
  406. esn=$(dsl_val "$lsctg" nES)
  407. sesn=$(dsl_val "$lsctg" nSES)
  408. lossn=$(dsl_val "$lsctg" nLOSS)
  409. uasn=$(dsl_val "$lsctg" nUAS)
  410. dpctg=$(dsl_cmd pmdpctg 0 1)
  411. hecf=$(dsl_val "$dpctg" nHEC)
  412. crc_pf=$(dsl_val "$dpctg" nCRC_P)
  413. crcp_pf=$(dsl_val "$dpctg" nCRCP_P)
  414. dpctg=$(dsl_cmd pmdpctg 0 0)
  415. hecn=$(dsl_val "$dpctg" nHEC)
  416. crc_pn=$(dsl_val "$dpctg" nCRC_P)
  417. crcp_pn=$(dsl_val "$dpctg" nCRCP_P)
  418. ccsg=$(dsl_cmd pmccsg 0 1 0)
  419. fecf=$(dsl_val "$ccsg" nFEC)
  420. ccsg=$(dsl_cmd pmccsg 0 0 0)
  421. fecn=$(dsl_val "$ccsg" nFEC)
  422. if [ "$action" = "lucistat" ]; then
  423. echo "dsl.errors_fec_near=${fecn:-nil}"
  424. echo "dsl.errors_fec_far=${fecf:-nil}"
  425. echo "dsl.errors_es_near=${esn:-nil}"
  426. echo "dsl.errors_es_far=${esf:-nil}"
  427. echo "dsl.errors_ses_near=${sesn:-nil}"
  428. echo "dsl.errors_ses_far=${sesf:-nil}"
  429. echo "dsl.errors_loss_near=${lossn:-nil}"
  430. echo "dsl.errors_loss_far=${lossf:-nil}"
  431. echo "dsl.errors_uas_near=${uasn:-nil}"
  432. echo "dsl.errors_uas_far=${uasf:-nil}"
  433. echo "dsl.errors_hec_near=${hecn:-nil}"
  434. echo "dsl.errors_hec_far=${hecf:-nil}"
  435. echo "dsl.errors_crc_p_near=${crc_pn:-nil}"
  436. echo "dsl.errors_crc_p_far=${crc_pf:-nil}"
  437. echo "dsl.errors_crcp_p_near=${crcp_pn:-nil}"
  438. echo "dsl.errors_crcp_p_far=${crcp_pf:-nil}"
  439. else
  440. echo "Forward Error Correction Seconds (FECS): Near: ${fecn} / Far: ${fecf}"
  441. echo "Errored seconds (ES): Near: ${esn} / Far: ${esf}"
  442. echo "Severely Errored Seconds (SES): Near: ${sesn} / Far: ${sesf}"
  443. echo "Loss of Signal Seconds (LOSS): Near: ${lossn} / Far: ${lossf}"
  444. echo "Unavailable Seconds (UAS): Near: ${uasn} / Far: ${uasf}"
  445. echo "Header Error Code Errors (HEC): Near: ${hecn} / Far: ${hecf}"
  446. echo "Non Pre-emtive CRC errors (CRC_P): Near: ${crc_pn} / Far: ${crc_pf}"
  447. echo "Pre-emtive CRC errors (CRCP_P): Near: ${crcp_pn} / Far: ${crcp_pf}"
  448. fi
  449. }
  450. #
  451. # Work out how long the line has been up
  452. #
  453. line_uptime() {
  454. local ccsg
  455. local et
  456. local etr
  457. local d
  458. local h
  459. local m
  460. local s
  461. local rc=""
  462. ccsg=$(dsl_cmd pmccsg 0 0 0)
  463. et=$(dsl_val "$ccsg" nElapsedTime)
  464. [ -z "$et" ] && et=0
  465. d=$(expr $et / 86400)
  466. etr=$(expr $et % 86400)
  467. h=$(expr $etr / 3600)
  468. etr=$(expr $etr % 3600)
  469. m=$(expr $etr / 60)
  470. s=$(expr $etr % 60)
  471. [ "${d}${h}${m}${s}" -ne 0 ] && rc="${s}s"
  472. [ "${d}${h}${m}" -ne 0 ] && rc="${m}m ${rc}"
  473. [ "${d}${h}" -ne 0 ] && rc="${h}h ${rc}"
  474. [ "${d}" -ne 0 ] && rc="${d}d ${rc}"
  475. [ -z "$rc" ] && rc="down"
  476. if [ "$action" = "lucistat" ]; then
  477. echo "dsl.line_uptime=${et}"
  478. echo "dsl.line_uptime_s=\"${rc}\""
  479. else
  480. echo "Line Uptime Seconds: ${et}"
  481. echo "Line Uptime: ${rc}"
  482. fi
  483. }
  484. #
  485. # Get noise and attenuation figures
  486. #
  487. line_data() {
  488. local lsg
  489. local latnu
  490. local latnd
  491. local satnu
  492. local satnd
  493. local snru
  494. local snrd
  495. local attndru
  496. local attndrd
  497. local sattndru
  498. local sattndrd
  499. local actatpu
  500. local actatpd
  501. lsg=$(dsl_cmd g997lsg 1 1)
  502. latnd=$(dsl_val "$lsg" LATN)
  503. satnd=$(dsl_val "$lsg" SATN)
  504. snrd=$(dsl_val "$lsg" SNR)
  505. attndrd=$(dsl_val "$lsg" ATTNDR)
  506. actatpd=$(dsl_val "$lsg" ACTATP)
  507. lsg=$(dsl_cmd g997lsg 0 1)
  508. latnu=$(dsl_val "$lsg" LATN)
  509. satnu=$(dsl_val "$lsg" SATN)
  510. snru=$(dsl_val "$lsg" SNR)
  511. attndru=$(dsl_val "$lsg" ATTNDR)
  512. actatpu=$(dsl_val "$lsg" ACTATP)
  513. [ -z "$latnd" ] && latnd=0
  514. [ -z "$latnu" ] && latnu=0
  515. [ -z "$satnd" ] && satnd=0
  516. [ -z "$satnu" ] && satnu=0
  517. [ -z "$snrd" ] && snrd=0
  518. [ -z "$snru" ] && snru=0
  519. [ -z "$actatpd" ] && actatpd=0
  520. [ -z "$actatpu" ] && actatpu=0
  521. latnd=$(dbt $latnd)
  522. latnu=$(dbt $latnu)
  523. satnd=$(dbt $satnd)
  524. satnu=$(dbt $satnu)
  525. snrd=$(dbt $snrd)
  526. snru=$(dbt $snru)
  527. actatpd=$(dbt $actatpd)
  528. actatpu=$(dbt $actatpu)
  529. [ -z "$attndrd" ] && attndrd=0
  530. [ -z "$attndru" ] && attndru=0
  531. sattndrd=$(scale $attndrd)
  532. sattndru=$(scale $attndru)
  533. if [ "$action" = "lucistat" ]; then
  534. echo "dsl.line_attenuation_down=$latnd"
  535. echo "dsl.line_attenuation_up=$latnu"
  536. echo "dsl.noise_margin_down=$snrd"
  537. echo "dsl.noise_margin_up=$snru"
  538. echo "dsl.signal_attenuation_down=$satnd"
  539. echo "dsl.signal_attenuation_up=$satnu"
  540. echo "dsl.actatp_down=$actatpd"
  541. echo "dsl.actatp_up=$actatpu"
  542. echo "dsl.max_data_rate_down=$attndrd"
  543. echo "dsl.max_data_rate_up=$attndru"
  544. echo "dsl.max_data_rate_down_s=\"$sattndrd\""
  545. echo "dsl.max_data_rate_up_s=\"$sattndru\""
  546. else
  547. echo "Line Attenuation (LATN): Down: ${latnd}dB / Up: ${latnu}dB"
  548. echo "Signal Attenuation (SATN): Down: ${satnd}dB / Up: ${satnu}dB"
  549. echo "Noise Margin (SNR): Down: ${snrd}dB / Up: ${snru}dB"
  550. echo "Aggregate Transmit Power (ACTATP): Down: ${actatpd}dB / Up: ${actatpu}dB"
  551. echo "Max. Attainable Data Rate (ATTNDR): Down: ${sattndrd}/s / Up: ${sattndru}/s"
  552. fi
  553. }
  554. #
  555. # Is the line up? Or what state is it in?
  556. #
  557. line_state() {
  558. local lsg=$(dsl_cmd lsg)
  559. local ls=$(dsl_val "$lsg" nLineState);
  560. local s;
  561. case "$ls" in
  562. "0x0") s="not initialized" ;;
  563. "0x1") s="exception" ;;
  564. "0x10") s="not updated" ;;
  565. "0xff") s="idle request" ;;
  566. "0x100") s="idle" ;;
  567. "0x1ff") s="silent request" ;;
  568. "0x200") s="silent" ;;
  569. "0x300") s="handshake" ;;
  570. "0x380") s="full_init" ;;
  571. "0x400") s="discovery" ;;
  572. "0x500") s="training" ;;
  573. "0x600") s="analysis" ;;
  574. "0x700") s="exchange" ;;
  575. "0x800") s="showtime_no_sync" ;;
  576. "0x801") s="showtime_tc_sync" ;;
  577. "0x900") s="fastretrain" ;;
  578. "0xa00") s="lowpower_l2" ;;
  579. "0xb00") s="loopdiagnostic active" ;;
  580. "0xb10") s="loopdiagnostic data exchange" ;;
  581. "0xb20") s="loopdiagnostic data request" ;;
  582. "0xc00") s="loopdiagnostic complete" ;;
  583. "0x1000000") s="test" ;;
  584. "0xd00") s="resync" ;;
  585. "0x3c0") s="short init entry" ;;
  586. "") s="not running daemon"; ls="0xfff" ;;
  587. *) s="unknown" ;;
  588. esac
  589. if [ "$action" = "lucistat" ]; then
  590. echo "dsl.line_state_num=$ls"
  591. echo "dsl.line_state_detail=\"$s\""
  592. if [ "$ls" = "0x801" ]; then
  593. echo "dsl.line_state=\"UP\""
  594. else
  595. echo "dsl.line_state=\"DOWN\""
  596. fi
  597. else
  598. if [ "$ls" = "0x801" ]; then
  599. echo "Line State: UP [$ls: $s]"
  600. else
  601. echo "Line State: DOWN [$ls: $s]"
  602. fi
  603. fi
  604. }
  605. #
  606. # Which profile is used?
  607. #
  608. profile() {
  609. local bpstg=$(dsl_cmd bpstg)
  610. local profile=$(dsl_val "$bpstg" nProfile);
  611. local s;
  612. case "$profile" in
  613. "0") s="8a" ;;
  614. "1") s="8b" ;;
  615. "2") s="8c" ;;
  616. "3") s="8d" ;;
  617. "4") s="12a" ;;
  618. "5") s="12b" ;;
  619. "6") s="17a" ;;
  620. "7") s="30a" ;;
  621. "8") s="17b" ;;
  622. "") s="";;
  623. *) s="unknown" ;;
  624. esac
  625. if [ "$action" = "lucistat" ]; then
  626. echo "dsl.profile=${profile:-nil}"
  627. echo "dsl.profile_s=\"${s}\""
  628. else
  629. echo "Profile: $s"
  630. fi
  631. }
  632. status() {
  633. vendor
  634. chipset
  635. xtse
  636. profile
  637. line_state
  638. errors
  639. power_mode
  640. latency_delay
  641. data_rates
  642. line_data
  643. line_uptime
  644. }
  645. lucistat() {
  646. echo "local dsl={}"
  647. status
  648. echo "return dsl"
  649. }