Skip to content

Commit

Permalink
Fix PLMN Decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
nickvsnetworking committed Jan 12, 2024
1 parent e37e323 commit becbc85
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/diameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,18 @@ def Reverse(self, str):
return (slicedString)

def DecodePLMN(self, plmn):
self.logTool.log(service='HSS', level='debug', message="Decoded PLMN: " + str(plmn), redisClient=self.redisMessaging)
mcc = self.Reverse(plmn[0:2]) + self.Reverse(plmn[2:4]).replace('f', '')

self.logTool.log(service='HSS', level='debug', message="Decoding PLMN: " + str(plmn), redisClient=self.redisMessaging)
if "f" in plmn:
mcc = self.Reverse(plmn[0:2]) + self.Reverse(plmn[2:4]).replace('f', '')
mnc = self.Reverse(plmn[4:6])
else:
mcc = self.Reverse(plmn[0:2]) + self.Reverse(plmn[2:4][1])
mnc = self.Reverse(plmn[4:6]) + str(self.Reverse(plmn[2:4][0]))
self.logTool.log(service='HSS', level='debug', message="Decoded MCC: " + mcc, redisClient=self.redisMessaging)

mnc = self.Reverse(plmn[4:6])
self.logTool.log(service='HSS', level='debug', message="Decoded MNC: " + mnc, redisClient=self.redisMessaging)
return mcc, mnc

def EncodePLMN(self, mcc, mnc):
plmn = list('XXXXXX')
plmn[0] = self.Reverse(mcc)[1]
Expand Down

0 comments on commit becbc85

Please sign in to comment.