From a9ff02e514f73ae5e6877debc1b5bef0b4cba536 Mon Sep 17 00:00:00 2001 From: nickvsnetworking Date: Fri, 12 Jan 2024 17:00:59 +1100 Subject: [PATCH] Encode PLMN update --- lib/diameter.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/lib/diameter.py b/lib/diameter.py index db89844..3607f9c 100644 --- a/lib/diameter.py +++ b/lib/diameter.py @@ -174,15 +174,24 @@ def DecodePLMN(self, plmn): return mcc, mnc def EncodePLMN(self, mcc, mnc): - plmn = list('XXXXXX') - plmn[0] = self.Reverse(mcc)[1] - plmn[1] = self.Reverse(mcc)[2] - plmn[2] = "f" - plmn[3] = self.Reverse(mcc)[0] - plmn[4] = self.Reverse(mnc)[0] - plmn[5] = self.Reverse(mnc)[1] - plmn_list = plmn - plmn = '' + if len(mnc) == 2: + plmn[0] = self.Reverse(mcc)[1] + plmn[1] = self.Reverse(mcc)[2] + plmn[2] = "f" + plmn[3] = self.Reverse(mcc)[0] + plmn[4] = self.Reverse(mnc)[0] + plmn[5] = self.Reverse(mnc)[1] + plmn_list = plmn + plmn = '' + else: + plmn[0] = self.Reverse(mcc)[1] + plmn[1] = self.Reverse(mcc)[2] + plmn[2] = self.Reverse(mnc)[0] + plmn[3] = self.Reverse(mcc)[0] + plmn[4] = self.Reverse(mnc)[1] + plmn[5] = self.Reverse(mnc)[2] + plmn_list = plmn + plmn = '' for bits in plmn_list: plmn = plmn + bits self.logTool.log(service='HSS', level='debug', message="Encoded PLMN: " + str(plmn), redisClient=self.redisMessaging)