[sr-dev] git:master:a84392d4: misc: update ims pcscf register example

Daniel-Constantin Mierla miconda at gmail.com
Mon Nov 22 19:32:53 CET 2021


Module: kamailio
Branch: master
Commit: a84392d49551dcc98378e9fe2feee5f6c3fb81a4
URL: https://github.com/kamailio/kamailio/commit/a84392d49551dcc98378e9fe2feee5f6c3fb81a4

Author: Aleksandar Yosifov <alexyosifov at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2021-11-22T19:32:49+01:00

misc: update ims pcscf register example

- Updated ims pcscf register script file
with removing of ck/ik in 401 Challenge reply.

---

Modified: misc/examples/ims/pcscf/route/register.cfg

---

Diff:  https://github.com/kamailio/kamailio/commit/a84392d49551dcc98378e9fe2feee5f6c3fb81a4.diff
Patch: https://github.com/kamailio/kamailio/commit/a84392d49551dcc98378e9fe2feee5f6c3fb81a4.patch

---

diff --git a/misc/examples/ims/pcscf/route/register.cfg b/misc/examples/ims/pcscf/route/register.cfg
index c10979d84a4..e90b7fa300b 100644
--- a/misc/examples/ims/pcscf/route/register.cfg
+++ b/misc/examples/ims/pcscf/route/register.cfg
@@ -3,9 +3,9 @@
 ######################################################################
 route[REGISTER] {
 	# Provide some statistics
-        if ($sht(a=>$ci::start_time) == $null || $sht(a=>$ci::start_time) == 0) {
-            $sht(a=>$ci::start_time) = $TV(Sn);
-        } 
+		if ($sht(a=>$ci::start_time) == $null || $sht(a=>$ci::start_time) == 0) {
+			$sht(a=>$ci::start_time) = $TV(Sn);
+		} 
 
 	# Strip Transport from RURI:
 	$ru = $(ru{re.subst,/;transport=[A-Za-z]*//g});
@@ -146,23 +146,31 @@ onreply_route[REGISTER_reply]
 #!endif
 #!endif
 		#update stats for register reply on success
-        	$var(start_secs) = $(sht(a=>$ci::start_time){s.select,0,.});
-        	$var(start_usecs) = $(sht(a=>$ci::start_time){s.select,1,.});
-        	$var(diff_secs) = $TV(s) - $var(start_secs);
-        	$var(diff_usecs) = $TV(u) - $var(start_usecs);
-        	$var(diff_ms) = $var(diff_secs)*1000 + ($var(diff_usecs)/1000);
-        	$sht(a=>$ci::start_time)=0;
-        	$var(stat_add) = "+" + $var(diff_ms);
-        	xlog("L_DBG", "REGISTER SUCCESS[$ci] took $var(stat_add)ms\n"); 
-        	update_stat("register_success", "+1");
-        	update_stat("register_time", "$var(stat_add)");
+		$var(start_secs) = $(sht(a=>$ci::start_time){s.select,0,.});
+		$var(start_usecs) = $(sht(a=>$ci::start_time){s.select,1,.});
+		$var(diff_secs) = $TV(s) - $var(start_secs);
+		$var(diff_usecs) = $TV(u) - $var(start_usecs);
+		$var(diff_ms) = $var(diff_secs)*1000 + ($var(diff_usecs)/1000);
+		$sht(a=>$ci::start_time)=0;
+		$var(stat_add) = "+" + $var(diff_ms);
+		xlog("L_DBG", "REGISTER SUCCESS[$ci] took $var(stat_add)ms\n"); 
+		update_stat("register_success", "+1");
+		update_stat("register_time", "$var(stat_add)");
 #!ifdef WITH_IPSEC
-            ipsec_forward("location");
-   	}
-	else {  
+		ipsec_forward("location");
+	}
+	else {
 		if (t_check_status("401")) {
-			ipsec_create("location");
-        }
+			#Remove ck and ik from Authentication header
+			$var(rem_ck) = $(hdr(WWW-Authenticate){re.subst,/ck="[a-zA-Z0-9]*", //g});
+			$var(rem_ik) = $(var(rem_ck){re.subst,/ik="[a-zA-Z0-9]*", //g});
+			remove_hf("WWW-Authenticate");
+			append_hf("WWW-Authenticate: $var(rem_ik)\r\n");
+
+			if(ipsec_create("location")!=1) {
+				send_reply("503", "Service Unavailable (Create ipsec failed)");
+			}
+		}
 #!endif
     }
 	exit;
@@ -183,12 +191,12 @@ failure_route[REGISTER_failure]
 			xlog("Blocking traffic from $si\n");
 			$sht(ipban=>$si) = 1;
 		}
-                update_stat("register_failed", "+1");
+		update_stat("register_failed", "+1");
 	}
 #!endif
 	if (t_check_status("408")) {
 		send_reply("504","Server Time-Out");
-                update_stat("register_failed", "+1");
+		update_stat("register_failed", "+1");
 		exit;
 	}
 }




More information about the sr-dev mailing list