From 363c2ff15550baaab822e09dd664dfec084f6d45 Mon Sep 17 00:00:00 2001 From: Markus Gothe Date: Mon, 17 Mar 2025 13:15:38 +0100 Subject: [PATCH] ponmngr: Add support for PLOAM password. --- ponmngr/files/airoha/lib/xpon/airoha.sh | 11 +++++++++++ ponmngr/files/broadcom/lib/xpon/broadcom.sh | 11 +++++++++++ ponmngr/files/common/etc/init.d/xpon | 12 ++++++++++++ .../common/etc/uci-defaults/60-xpon-generate | 15 +++++++++++++++ 4 files changed, 49 insertions(+) diff --git a/ponmngr/files/airoha/lib/xpon/airoha.sh b/ponmngr/files/airoha/lib/xpon/airoha.sh index 57615642f..6bb32f9fa 100644 --- a/ponmngr/files/airoha/lib/xpon/airoha.sh +++ b/ponmngr/files/airoha/lib/xpon/airoha.sh @@ -53,6 +53,17 @@ set_serial_number() { /userfs/bin/omcicfgCmd set sn "${vendor_id}${vssn}" } +set_ploam_password() { + local passwd="$1" + local hex="$2" + + if [ -z "$hex" -o "$hex" = "0" ]; then + /userfs/bin/omcicfgCmd set passwdAscii "${passwd}" + else + /userfs/bin/omcicfgCmd set passwdHex "${passwd}" + fi +} + set_equipment_id() { local eqid="$1" diff --git a/ponmngr/files/broadcom/lib/xpon/broadcom.sh b/ponmngr/files/broadcom/lib/xpon/broadcom.sh index c7eee5fda..74a7e9bf0 100644 --- a/ponmngr/files/broadcom/lib/xpon/broadcom.sh +++ b/ponmngr/files/broadcom/lib/xpon/broadcom.sh @@ -16,6 +16,17 @@ set_serial_number() { bs /b/c gpon onu_sn={vendor_id=$vendor_id,vendor_specific=$vssn} } +set_ploam_password() { + local passwd="$1" + local hex="$2" + + if [ -z "$hex" -o "$hex" = "0" ]; then + passwd="$(echo -n "${passwd}" | hexdump -e '"%02X"' -v)" + fi + + bs /b/c gpon password=${passwd} +} + set_equipment_id() { local equipment_id="$1" [ -z "$equipment_id" ] && return diff --git a/ponmngr/files/common/etc/init.d/xpon b/ponmngr/files/common/etc/init.d/xpon index 73f047349..b6596c852 100755 --- a/ponmngr/files/common/etc/init.d/xpon +++ b/ponmngr/files/common/etc/init.d/xpon @@ -24,9 +24,21 @@ configure_serial_number() { set_serial_number "${vendor_id}" "${vssn}" } +configure_ploam_password() { + local passwd="$(uci -q get xpon.ani.ploam_password)" + local hex="$(uci -q get xpon.ani.ploam_hexadecimalpassword)" + + if [ -z "${passwd}" ]; then + return + fi + + set_ploam_password "${passwd}" "${hex}" +} + start_service() { if [ "$(uci -q get xpon.ani.enable)" = "1" ]; then configure_serial_number + configure_ploam_password apply_xpon_uci_config init_xpon else diff --git a/ponmngr/files/common/etc/uci-defaults/60-xpon-generate b/ponmngr/files/common/etc/uci-defaults/60-xpon-generate index e7144be5f..3583ec662 100755 --- a/ponmngr/files/common/etc/uci-defaults/60-xpon-generate +++ b/ponmngr/files/common/etc/uci-defaults/60-xpon-generate @@ -15,6 +15,19 @@ configure_serial_number() { fi } +configure_ploam_password() { + # check if PLOAM password is present in the production data + local passwd="$(uci -q get xpon.ani.ploam_password)" + + if [ -z "${passwd}" ]; then + local production_passwd="$(fw_printenv -n gponpswd)" + if [ -n ${#production_passwd} ]; then + uci set xpon.ani.ploam_password="${production_passwd}" + uci set xpon.ani.ploam_hexadecimalpassword=0 + fi + fi +} + configure_loid_authentication() { local production_loid local production_loidpwd @@ -45,6 +58,7 @@ if [ -s "/etc/config/xpon" ]; then if [ ${#SERIAL_NUMBER} -ne 12 ]; then configure_serial_number fi + configure_ploam_password configure_loid_authentication exit else @@ -56,5 +70,6 @@ touch /etc/config/xpon uci set xpon.ani=ani uci set xpon.ani.enable="1" configure_serial_number +configure_ploam_password configure_loid_authentication