Skip to content

Commit

Permalink
Hotfix for malformed AAA requests
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkneipp committed Jan 24, 2024
1 parent b083e11 commit a509e5c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/diameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2986,6 +2986,13 @@ def Answer_16777236_265(self, packet_vars, avps):
sdpDownlinkRtpPorts = f"{sdpDownlinkRtpPort}-{int(sdpDownlinkRtpPort)+1}"
sdpUplinkRtpPorts = f"{sdpUplinkRtpPort}-{int(sdpUplinkRtpPort)+1}"

# If we've got a UE that's sending a malformed request, use a fallback rule.
# Else, if all necessary variables are defined, use the correct SDP rule.
# The fallback rule will fail on some cheap handsets.
if not sdpDownlinkIpv4 or not sdpDownlinkRtpPort or not sdpUplinkRtpPort:
tftString = f"permit out 17 from {ueIp}/32 1-65535 to any 1-65535"
else:
tftString = f"permit out 17 from {sdpDownlinkIpv4}/32 {sdpDownlinkRtpPorts} to {ueIp}/32 {sdpUplinkRtpPorts}"

except Exception as e:
self.logTool.log(service='HSS', level='error', message=f"[diameter.py] [Answer_16777236_265] [AAA] Failed to extract SDP due to error: {traceback.format_exc()}", redisClient=self.redisMessaging)
Expand Down Expand Up @@ -3018,13 +3025,13 @@ def Answer_16777236_265(self, packet_vars, avps):
"tft_group_id": 1,
"direction": 1,
"tft_id": 1,
"tft_string": f"permit out 17 from {sdpDownlinkIpv4}/32 {sdpDownlinkRtpPorts} to {ueIp}/32 {sdpUplinkRtpPorts}"
"tft_string": tftString
},
{
"tft_group_id": 1,
"direction": 2,
"tft_id": 2,
"tft_string": f"permit out 17 from {sdpDownlinkIpv4}/32 {sdpDownlinkRtpPorts} to {ueIp}/32 {sdpUplinkRtpPorts}"
"tft_string": tftString
}
]
}
Expand Down

0 comments on commit a509e5c

Please sign in to comment.