Quellcode durchsuchen

IMS example config files: update icscf and scscf config files to correctly use async route blocks
- This fix updates the example ICSCF and SCSCF config files to correctly use route blocks for the replies of any asynchronous Diameter messages

Richard Good vor 12 Jahren
Ursprung
Commit
bf08aa1a38
2 geänderte Dateien mit 133 neuen und 50 gelöschten Zeilen
  1. 34 19
      examples/icscf/kamailio.cfg
  2. 99 31
      examples/scscf/kamailio.cfg

+ 34 - 19
examples/icscf/kamailio.cfg

@@ -312,29 +312,44 @@ route[register]
 		#free this from the failed I_scscf_select call
 		#free this from the failed I_scscf_select call
 		I_scscf_drop();
 		I_scscf_drop();
 		# Do an asynchronous UAR:
 		# Do an asynchronous UAR:
-		I_perform_user_authorization_request("0");
-		if ($avp(uaa_return_code) == 1) {
-			if (I_scscf_select("0")) {
-				t_on_reply("register_reply");
-				t_on_failure("register_failure");
-				if (!t_relay()) {
-					t_reply("500","Error forwarding towards S-CSCF");
-					break;
-				}
-				break;
-			} else {
-				I_scscf_drop();
-				t_reply("500", "Server error on UAR select S-CSCF");
-				break;
-			}
-		} else {
-			t_reply("500", "Server error on UAR select S-CSCF");
-			break;
-		}    
+                I_perform_user_authorization_request("REG_UAR_REPLY","0"); #0=REG/DEREG; 1=REG+Capabilities
+                exit;    
 	}
 	}
 	break;
 	break;
 }
 }
 
 
+route[REG_UAR_REPLY]
+{
+    #this is async so to know status we have to check the reply avp
+    switch ($avp(s:uaa_return_code)){
+            case 1: #success
+                    if (I_scscf_select("0")){
+                            t_on_failure("register_failure");
+                            t_on_reply("register_reply");
+                            #now relay to appropriate SCSCF
+                            if (!t_relay()) {
+                                    t_reply("500", "Error forwarding to SCSCF");
+                            }
+                    } else {#select failed
+                            I_scscf_drop();
+                            t_reply("500", "Server error on SCSCF Select (UAR)");
+                    }
+                    break;
+            case -1: #failure
+                    xlog("L_ERR", "UAR failure - error response sent from module\n");
+                    break;
+            case -2: #error
+                    xlog("L_ERR", "UAR error - sending error response now\n");
+                    t_reply("500", "UAR failed");
+                    break;
+            default:
+                    xlog("L_ERR", "Unknown return code from UAR, value is [$avp(s:uaa_return_code)]\n");
+                    t_reply("500", "Unknown response code from UAR");
+                    break;
+    }
+}
+
+
 ######################################################################
 ######################################################################
 # Replies to REGISTER requests, 
 # Replies to REGISTER requests, 
 ######################################################################
 ######################################################################

+ 99 - 31
examples/scscf/kamailio.cfg

@@ -353,7 +353,8 @@ route {
 		if (uri=~"sip:(.*)@"+NETWORKNAME_ESC +"(.*)" || uri=~"tel:.*") {
 		if (uri=~"sip:(.*)@"+NETWORKNAME_ESC +"(.*)" || uri=~"tel:.*") {
 			if (!term_impu_registered("location")) {
 			if (!term_impu_registered("location")) {
 				xlog("L_ERR", "We need to do an UNREG server SAR assignemnt");
 				xlog("L_ERR", "We need to do an UNREG server SAR assignemnt");
-		                assign_server_unreg("location", "term");
+                                assign_server_unreg("UNREG_SAR_REPLY", "location", "term");
+                                exit;
 		        }
 		        }
 		} else {
 		} else {
 			sl_send_reply("403","Forbidden - Dialog not found on S-CSCF or Terminating user not suitable for unregistered services");
 			sl_send_reply("403","Forbidden - Dialog not found on S-CSCF or Terminating user not suitable for unregistered services");
@@ -364,6 +365,28 @@ route {
 	}
 	}
 }
 }
 
 
+route[UNREG_SAR_REPLY]
+{
+        xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
+        switch ($avp(s:saa_return_code)){
+            case 1: #success
+                    xlog("L_DBG", "SAR success - will route message\n");
+                route(term);
+                break;
+            case -1: #failure
+                    xlog("L_ERR", "SAR failure - error response sent from module\n");
+                break;
+            case -2: #error
+                    xlog("L_ERR", "SAR error - error response sent from module\n");
+                break;
+            default:
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:saa_return_code)]\n");
+                break;
+        }
+        exit;
+}
+
+
 ######################################################################
 ######################################################################
 # Helper routes (Basic-Checks, NAT-Handling/RTP-Control, XML-RPC)
 # Helper routes (Basic-Checks, NAT-Handling/RTP-Control, XML-RPC)
 ######################################################################
 ######################################################################
@@ -458,26 +481,7 @@ route[REGISTER] {
                 } else {
                 } else {
                         #user has not been authenticated. Lets send a challenge via 401 Unauthorized
                         #user has not been authenticated. Lets send a challenge via 401 Unauthorized
                         xlog("L_DBG","About to challenge! auth_ims\n");
                         xlog("L_DBG","About to challenge! auth_ims\n");
-                        ims_www_challenge("$td");
-                        #this is async so to know status we have to check the reply avp
-                        xlog("L_DBG","maa_return code is $avp(s:maa_return_code)\n");
-
-                        switch ($avp(s:maa_return_code)){
-                                case 1: #success
-                                        xlog("L_DBG", "MAR success - 401/407 response sent from module");
-                                        break;
-                                case -1: #failure
-                                        xlog("L_ERR", "MAR failure - error response sent from module");
-                                        break;
-                                case -2: #error
-                                        xlog("L_ERR", "MAR error - sending error response now");
-                                        t_reply("500", "MAR failed");
-                                        break;
-                                default:
-                                        xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:uaa_return_code)]");
-                                        t_reply("500", "Unknown response code from MAR");
-                                        break;
-                        }
+                        ims_www_challenge("REG_MAR_REPLY", "$td");
                         exit;
                         exit;
                 }
                 }
 	} else {
 	} else {
@@ -485,21 +489,85 @@ route[REGISTER] {
 		# We need to check if this user is registered or not
 		# We need to check if this user is registered or not
 		if (!impu_registered("location")) {
 		if (!impu_registered("location")) {
 			xlog("L_ERR", "Not REGISTERED\n");
 			xlog("L_ERR", "Not REGISTERED\n");
-			save("location");
-			if ($avp(saa_return_code) == 1) {
-				isc_match_filter_reg("0","location");
-				exit;
-			}
+			save("PRE_REG_SAR_REPLY","location");
+                        exit;
 		} else {
 		} else {
-			save("location");
-			if($avp(saa_return_code) == 1) {
-				isc_match_filter_reg("1","location");
-				exit;
-			}
+			isc_match_filter_reg("1","location");
+                        save("REG_SAR_REPLY","location");
+                        exit;
 		}
 		}
 	}
 	}
 }
 }
 
 
+route[REG_MAR_REPLY]
+{
+     #this is async so to know status we have to check the reply avp
+     xlog("L_DBG","maa_return code is $avp(s:maa_return_code)\n");   
+
+     switch ($avp(s:maa_return_code)){
+             case 1: #success
+                     xlog("L_DBG", "MAR success - 401/407 response sent from module\n");
+                     break;
+             case -1: #failure
+                     xlog("L_ERR", "MAR failure - error response sent from module\n");
+                     break;
+             case -2: #error
+                     xlog("L_ERR", "MAR error - sending error response now\n");
+                     t_reply("500", "MAR failed");
+                     break;
+             default:
+                     xlog("L_ERR", "Unknown return code from MAR, value is [$avp(s:uaa_return_code)]\n");
+                     t_reply("500", "Unknown response code from MAR");
+                     break;
+     }
+     exit;
+}
+
+route[PRE_REG_SAR_REPLY]
+{
+    xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
+        #this is async so to know status we have to check the reply avp
+    xlog("L_DBG","saa_return code (for scscf_save on register) is $avp(s:saa_return_code)\n");
+    switch ($avp(s:saa_return_code)){
+            case 1: #success
+                   xlog("L_DBG", "SAR success - 200 response sent from module\n");
+                    isc_match_filter_reg("0","location");
+                    exit;
+            case -1: #failure
+                    xlog("L_ERR", "SAR failure - error response sent from module\n");
+                    break;
+            case -2: #error
+                    xlog("L_ERR", "SAR error - error response sent from module\n");
+                    break;
+            default:
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]\n");
+                    break;
+    }
+    exit;
+}
+
+route[REG_SAR_REPLY]
+{
+    xlog("L_DBG","saa_return code is $avp(s:saa_return_code)\n");
+    #this is async so to know status we have to check the reply avp
+    xlog("L_DBG","saa_return code (for scscf_save on register) is $avp(s:saa_return_code)\n");
+    switch ($avp(s:saa_return_code)){
+            case 1: #success
+                   xlog("L_DBG", "SAR success - 200 response sent from module\n");
+                    exit;
+            case -1: #failure
+                    xlog("L_ERR", "SAR failure - error response sent from module\n");
+                    break;
+            case -2: #error
+                    xlog("L_ERR", "SAR error - error response sent from module\n");
+                    break;
+            default:
+                    xlog("L_ERR", "Unknown return code from SAR, value is [$avp(s:uaa_return_code)]\n");
+                    break;
+    }
+    exit;
+}
+
 ######################################################################
 ######################################################################
 # Apply privacy, if requested
 # Apply privacy, if requested
 ######################################################################
 ######################################################################