From 6a7bb925cc42a2e177b6b6c129d1de327cc73e14 Mon Sep 17 00:00:00 2001 From: "Rudy (zarya)" Date: Tue, 2 Jan 2024 11:57:22 +0100 Subject: [PATCH] Added fixes for roaming --- lib/diameter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/diameter.py b/lib/diameter.py index dee7d48..476471b 100644 --- a/lib/diameter.py +++ b/lib/diameter.py @@ -1283,6 +1283,7 @@ def Answer_16777251_316(self, packet_vars, avps): mcc = decodedPlmn[0] mnc = decodedPlmn[1] subscriberIsRoaming = False + subscriberRoamingAllowed = False if str(mcc) != str(self.MCC) and str(mnc) != str(self.MNC): subscriberIsRoaming = True @@ -1290,7 +1291,7 @@ def Answer_16777251_316(self, packet_vars, avps): self.logTool.log(service='HSS', level='debug', message=f"[diameter.py] [Answer_16777251_318] [AIA] Subscriber {imsi} is roaming", redisClient=self.redisMessaging) subscriberRoamingAllowed = self.validateSubscriberRoaming(subscriber=subscriber_details, mcc=mcc, mnc=mnc) - if not subscriberRoamingAllowed: + if not subscriberRoamingAllowed and subscriberIsRoaming: avp = '' session_id = self.get_avp_data(avps, 263)[0] #Get Session-ID avp += self.generate_avp(263, 40, session_id) #Session-ID AVP set @@ -1609,6 +1610,9 @@ def Answer_16777251_318(self, packet_vars, avps): decodedPlmn = self.DecodePLMN(plmn=plmn) mcc = decodedPlmn[0] mnc = decodedPlmn[1] + subscriberIsRoaming=False + subscriberRoamingAllowed=False + if str(mcc) != str(self.MCC) and str(mnc) != str(self.MNC): subscriberIsRoaming = True @@ -1616,7 +1620,7 @@ def Answer_16777251_318(self, packet_vars, avps): self.logTool.log(service='HSS', level='debug', message=f"[diameter.py] [Answer_16777251_318] [AIA] Subscriber {imsi} is roaming", redisClient=self.redisMessaging) subscriberRoamingAllowed = self.validateSubscriberRoaming(subscriber=subscriber_details, mcc=mcc, mnc=mnc) - if not subscriberRoamingAllowed: + if not subscriberRoamingAllowed and subscriberIsRoaming: avp = '' session_id = self.get_avp_data(avps, 263)[0] #Get Session-ID avp += self.generate_avp(263, 40, session_id) #Session-ID AVP set