Module: sip-router
Branch: master
Commit: bf08aa1a3859766caf0842fdd30b9fc2f4a4ff43
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=bf08aa1…
Author: Richard Good <richard.good(a)smilecoms.com>
Committer: Richard Good <richard.good(a)smilecoms.com>
Date: Tue Jun 25 14:11:13 2013 +0200
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
---
examples/icscf/kamailio.cfg | 53 +++++++++++------
examples/scscf/kamailio.cfg | 130 ++++++++++++++++++++++++++++++++----------
2 files changed, 133 insertions(+), 50 deletions(-)
diff --git a/examples/icscf/kamailio.cfg b/examples/icscf/kamailio.cfg
index c66cb25..6a0de63 100644
--- a/examples/icscf/kamailio.cfg
+++ b/examples/icscf/kamailio.cfg
@@ -312,29 +312,44 @@ route[register]
#free this from the failed I_scscf_select call
I_scscf_drop();
# 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;
}
+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,
######################################################################
diff --git a/examples/scscf/kamailio.cfg b/examples/scscf/kamailio.cfg
index f3b3cac..b8c9f1b 100644
--- a/examples/scscf/kamailio.cfg
+++ b/examples/scscf/kamailio.cfg
@@ -353,7 +353,8 @@ route {
if (uri=~"sip:(.*)@"+NETWORKNAME_ESC +"(.*)" ||
uri=~"tel:.*") {
if (!term_impu_registered("location")) {
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 {
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)
######################################################################
@@ -458,26 +481,7 @@ route[REGISTER] {
} else {
#user has not been authenticated. Lets send a challenge via 401
Unauthorized
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;
}
} else {
@@ -485,21 +489,85 @@ route[REGISTER] {
# We need to check if this user is registered or not
if (!impu_registered("location")) {
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 {
- 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
######################################################################