@@ -287,17 +287,25 @@ route[MO_indialog_aar_reply]
287287
288288# !ifdef WITH_N5
289289route[MO_N5_CALL_PCF_POLICY_AUTH] {
290+ # Send N5 PCF policy authorization only on replies.
291+ if (!is_reply()) {
292+ return;
293+ }
290294 $var(contact_uri) = $T_req($(ct{nameaddr.uri}));
291295 $var(ue_ip) = $(var(contact_uri){uri.host});
292- $var(app_session) = $null;
296+ $var(app_session) = 0;
297+ sht_lock(" ue_ip_to_call_app_session_map=>ue_ip_to_call_app_session_map_lock" );
293298 if ($sht(ue_ip_to_call_app_session_map =>$var(ue_ip)) != $null) {
294299 $var(app_session) = $sht(ue_ip_to_call_app_session_map =>$var(ue_ip));
295300 # Update again so that Hash table does not remove the entry upon session timer expiry.
296301 $sht(ue_ip_to_call_app_session_map =>$var(ue_ip)) = $var(app_session);
302+ sht_lock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
297303 $sht(mo_call_id_to_call_app_session_and_ue_ip_map =>$ci) = $var(app_session) + " ;" + $var(ue_ip);
304+ sht_unlock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
298305 }
299- # Send N5 PCF policy authorization only on replies.
300- if (!is_reply() || !has_body(" application/sdp" )) {
306+ sht_unlock(" ue_ip_to_call_app_session_map=>ue_ip_to_call_app_session_map_lock" );
307+ # Send N5 PCF policy authorization if SDP body is present.
308+ if (!has_body(" application/sdp" )) {
301309 return;
302310 }
303311 $var(req_sdp) = $T_req($sdp(body));
@@ -306,10 +314,10 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
306314 xlog(" L_INFO" ," Rep SDP: $var(rep_sdp)\n" );
307315
308316 $var(current_media) = " " ;
309- $var(req_audio_rtp_port) = $null ;
310- $var(req_audio_rtcp_port) = $null ;
311- $var(req_video_rtp_port) = $null ;
312- $var(req_video_rtcp_port) = $null ;
317+ $var(req_audio_rtp_port) = 0 ;
318+ $var(req_audio_rtcp_port) = 0 ;
319+ $var(req_video_rtp_port) = 0 ;
320+ $var(req_video_rtcp_port) = 0 ;
313321 $var(req_audio_rtcp_explicit) = 0;
314322 $var(req_video_rtcp_explicit) = 0;
315323 $var(audio_bw_as) = 0;
@@ -352,18 +360,18 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
352360 }
353361
354362 # Fallback: RTCP = RTP + 1 (RFC 3550 default) if no explicit a=rtcp.
355- if ($var(req_audio_rtcp_explicit) != 1 && $var(req_audio_rtp_port) != $null ) {
363+ if ($var(req_audio_rtcp_explicit) != 1 && $var(req_audio_rtp_port) > 0 ) {
356364 $var(req_audio_rtcp_port) = $(var(req_audio_rtp_port){s.int}) + 1;
357365 }
358- if ($var(req_video_rtcp_explicit) != 1 && $var(req_video_rtp_port) != $null ) {
366+ if ($var(req_video_rtcp_explicit) != 1 && $var(req_video_rtp_port) > 0 ) {
359367 $var(req_video_rtcp_port) = $(var(req_video_rtp_port){s.int}) + 1;
360368 }
361369
362370 $var(current_media) = " " ;
363- $var(rep_audio_rtp_port) = $null ;
364- $var(rep_audio_rtcp_port) = $null ;
365- $var(rep_video_rtp_port) = $null ;
366- $var(rep_video_rtcp_port) = $null ;
371+ $var(rep_audio_rtp_port) = 0 ;
372+ $var(rep_audio_rtcp_port) = 0 ;
373+ $var(rep_video_rtp_port) = 0 ;
374+ $var(rep_video_rtcp_port) = 0 ;
367375 $var(rep_audio_rtcp_explicit) = 0;
368376 $var(rep_video_rtcp_explicit) = 0;
369377 # Split SDP into lines and iterate.
@@ -403,10 +411,10 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
403411 }
404412
405413 # Fallback: RTCP = RTP + 1 (RFC 3550 default) if no explicit a=rtcp.
406- if ($var(rep_audio_rtcp_explicit) != 1 && $var(rep_audio_rtp_port) != $null ) {
414+ if ($var(rep_audio_rtcp_explicit) != 1 && $var(rep_audio_rtp_port) > 0 ) {
407415 $var(rep_audio_rtcp_port) = $(var(rep_audio_rtp_port){s.int}) + 1;
408416 }
409- if ($var(rep_video_rtcp_explicit) != 1 && $var(rep_video_rtp_port) != $null ) {
417+ if ($var(rep_video_rtcp_explicit) != 1 && $var(rep_video_rtp_port) > 0 ) {
410418 $var(rep_video_rtcp_port) = $(var(rep_video_rtp_port){s.int}) + 1;
411419 }
412420
@@ -415,12 +423,12 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
415423
416424 xlog(" L_INFO" , " Request SDP Parse Result from $var(req_sdp_ip) - Audio RTP: $var(req_audio_rtp_port), RTCP: $var(req_audio_rtcp_port)\n" );
417425 xlog(" L_INFO" , " Reply SDP Parse Result from $var(rep_sdp_ip) - Audio RTP: $var(rep_audio_rtp_port), RTCP: $var(rep_audio_rtcp_port)\n" );
418- if ($var(req_video_rtp_port) != $null && $var(req_video_rtp_port) > 0) {
426+ if ($var(req_video_rtp_port) > 0) {
419427 xlog(" L_INFO" , " Request SDP Parse Result from $var(req_sdp_ip) - Video RTP: $var(req_video_rtp_port), RTCP: $var(req_video_rtcp_port)\n" );
420428 } else {
421429 xlog(" L_INFO" , " Request SDP Parse Result from $var(req_sdp_ip) - Audio only (no video)\n" );
422430 }
423- if ($var(rep_video_rtp_port) != $null && $var(rep_video_rtp_port) > 0) {
431+ if ($var(rep_video_rtp_port) > 0) {
424432 xlog(" L_INFO" , " Reply SDP Parse Result from $var(rep_sdp_ip) - Video RTP: $var(rep_video_rtp_port), RTCP: $var(rep_video_rtcp_port)\n" );
425433 } else {
426434 xlog(" L_INFO" , " Reply SDP Parse Result from $var(rep_sdp_ip) - Audio only (no video)\n" );
@@ -481,7 +489,7 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
481489
482490 $var(video_media_component_body) = " " ;
483491 # NOTE: Only if both request and reply SDPs have video media, we consider video for policy authorization and include it in the media components. This is to handle the case where one side doesn't support video and hence doesn't include it in the SDP at all.
484- if ($var(req_video_rtp_port) != $null && $var(req_video_rtp_port) > 0 && $var(rep_video_rtp_port) != $null && $var(rep_video_rtp_port) > 0) {
492+ if ($var(req_video_rtp_port) > 0 && $var(rep_video_rtp_port) > 0) {
485493 $var(video_media_component_body) = ' "1": {
486494 "medCompN": 2,
487495 "qosReference": "qosVoNR",
@@ -572,7 +580,7 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
572580 xlog(" L_DBG" , " Constructed UE policy authorization body: $var(ue_policy_authorization_json_body)\n" );
573581
574582 $var(time_now)=$_s($timef(%a, %d %b %Y %H:%M:%S %Z));
575- if ($var(app_session) != $null ) {
583+ if ($var(app_session) > 0 ) {
576584 xnotice(" MT - N5 QoS Auth session already exists for UE with IP $var(ue_ip) so sending a patch request\n" );
577585
578586 # Set HTTP2 request headers.
@@ -640,9 +648,13 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
640648 $var(app_session) = $(var(response_url){s.select,-1,/});
641649
642650 # Store the AppSession Id in the hash table associated with the IP address in the last Via SIP header.
651+ sht_lock(" ue_ip_to_call_app_session_map=>ue_ip_to_call_app_session_map_lock" );
643652 $sht(ue_ip_to_call_app_session_map =>$var(ue_ip)) = $var(app_session);
653+ sht_unlock(" ue_ip_to_call_app_session_map=>ue_ip_to_call_app_session_map_lock" );
644654 # Store the AppSession Id in the hash table associated with the dialog Call-Id.
655+ sht_lock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
645656 $sht(mo_call_id_to_call_app_session_and_ue_ip_map =>$ci) = $var(app_session) + " ;" + $var(ue_ip);
657+ sht_unlock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
646658 xlog(" L_INFO" , " Stored call AppSession Id for IP $var(ue_ip) is $var(app_session)\n" );
647659 break;
648660 # Failure case.
@@ -664,11 +676,14 @@ route[MO_N5_CALL_PCF_POLICY_AUTH] {
664676
665677route[MO_N5_CALL_PCF_POLICY_AUTH_DELETE] {
666678 # Retrieve the AppSession Id from the hash table.
679+ sht_lock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
667680 if ($sht(mo_call_id_to_call_app_session_and_ue_ip_map =>$ci) == $null) {
668681 xlog(" L_WARN" , " No call AppSession found for Call-Id $ci\n" );
682+ sht_unlock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
669683 return;
670684 }
671685 $var(app_session_and_ue_ip) = $sht(mo_call_id_to_call_app_session_and_ue_ip_map =>$ci);
686+ sht_unlock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
672687 $var(app_session) = $(var(app_session_and_ue_ip){s.select,0,; });
673688 $var(ue_ip) = $(var(app_session_and_ue_ip){s.select,1,; });
674689
@@ -692,7 +707,11 @@ route[MO_N5_CALL_PCF_POLICY_AUTH_DELETE] {
692707 xlog(" L_INFO" , " Location Header: [$httprhdr(location)]\n" );
693708
694709 # Clear hashtable content irrespective of the response from PCF/IMS as the call has ended.
710+ sht_lock(" ue_ip_to_call_app_session_map=>ue_ip_to_call_app_session_map_lock" );
695711 $sht(ue_ip_to_call_app_session_map =>$var(ue_ip)) = $null;
712+ sht_unlock(" ue_ip_to_call_app_session_map=>ue_ip_to_call_app_session_map_lock" );
713+ sht_lock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
696714 $sht(mo_call_id_to_call_app_session_and_ue_ip_map =>$ci) = $null;
715+ sht_unlock(" mo_call_id_to_call_app_session_and_ue_ip_map=>mo_call_id_to_call_app_session_and_ue_ip_map_lock" );
697716}
698717# !endif
0 commit comments