Skip to content

Commit

Permalink
Dynamically set preEmption if normal or emergency call in AAA
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkneipp committed Jan 30, 2024
1 parent 6111373 commit b1c4736
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/diameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2811,7 +2811,12 @@ def Answer_16777236_265(self, packet_vars, avps):
imsi = None
msisdn = None
identifier = None
try:
serviceUrn = bytes.fromhex(self.get_avp_data(avps, 525)[0]).decode('ascii')
except:
serviceUrn = None
emergencySubscriber = False
registeredEmergencySubscriber = False

try:
ueIp = self.get_avp_data(avps, 8)[0]
Expand Down Expand Up @@ -2927,6 +2932,9 @@ def Answer_16777236_265(self, packet_vars, avps):
servingPgw = servingApn.get('serving_pgw', None)
servingPgwRealm = servingApn.get('serving_pgw_realm', None)
pcrfSessionId = servingApn.get('pcrf_session_id', None)
if serviceUrn:
if 'sos' in str(serviceUrn).lower():
registeredEmergencySubscriber = True
if not ueIp:
ueIp = servingApn.get('subscriber_routing', None)

Expand Down Expand Up @@ -3062,17 +3070,24 @@ def Answer_16777236_265(self, packet_vars, avps):
3. Send the winning rule.
"""

if emergencySubscriber or registeredEmergencySubscriber:
arpPreemptionCapability = True
arpPreemptionVulnerability = False
else:
arpPreemptionCapability = False
arpPreemptionVulnerability = True

chargingRule = {
"charging_rule_id": 1000,
"qci": 1,
"arp_preemption_capability": False,
"arp_preemption_capability": arpPreemptionCapability,
"mbr_dl": dlBandwidth,
"mbr_ul": ulBandwidth,
"gbr_ul": ulBandwidth,
"precedence": 40,
"arp_priority": 15,
"rule_name": "GBR-Voice",
"arp_preemption_vulnerability": True,
"arp_preemption_vulnerability": arpPreemptionVulnerability,
"gbr_dl": dlBandwidth,
"tft_group_id": 1,
"rating_group": None,
Expand Down

0 comments on commit b1c4736

Please sign in to comment.