[sr-dev] git:master: modules/ims_icscf: execute route block on async reply to UAR and LIR

Richard Good richard.good at smilecoms.com
Tue Jun 25 14:12:49 CEST 2013


Module: sip-router
Branch: master
Commit: 0d5622531d71d0b0ab3fb25a13c3ea1f46581512
URL:    http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=0d5622531d71d0b0ab3fb25a13c3ea1f46581512

Author: Richard Good <richard.good at smilecoms.com>
Committer: Richard Good <richard.good at smilecoms.com>
Date:   Tue Jun 25 14:09:00 2013 +0200

modules/ims_icscf: execute route block on async reply to UAR and LIR
	- Changed this to make the use of async CDP cleaner
	- Fixes inconsistencies we are experiencing with async TM and not using route blocks
	- Note this fix is for UAR replies called from I_perform_user_authorization_request() and LIR replies called from I_perform_location_information_request()

---

 modules/ims_icscf/cxdx_lir.h     |    5 ---
 modules/ims_icscf/cxdx_uar.h     |    6 ----
 modules/ims_icscf/location.c     |   23 +++++++++++++--
 modules/ims_icscf/location.h     |    2 +-
 modules/ims_icscf/mod.c          |   59 ++++++++++++++++++--------------------
 modules/ims_icscf/registration.c |   28 ++++++++++++++----
 modules/ims_icscf/registration.h |    2 +-
 7 files changed, 72 insertions(+), 53 deletions(-)

diff --git a/modules/ims_icscf/cxdx_lir.h b/modules/ims_icscf/cxdx_lir.h
index 6e43923..6389d46 100644
--- a/modules/ims_icscf/cxdx_lir.h
+++ b/modules/ims_icscf/cxdx_lir.h
@@ -57,11 +57,6 @@ extern str cxdx_dest_realm;
 struct sip_msg;
 
 
-typedef struct lir_param {
-	int type;
-	cfg_action_t *paction;
-} lir_param_t;
-
 typedef struct saved_lir_transaction {
 	unsigned int tindex;
 	unsigned int tlabel;
diff --git a/modules/ims_icscf/cxdx_uar.h b/modules/ims_icscf/cxdx_uar.h
index c2f20f4..1a00557 100644
--- a/modules/ims_icscf/cxdx_uar.h
+++ b/modules/ims_icscf/cxdx_uar.h
@@ -52,12 +52,6 @@ extern struct cdp_binds cdpb; /**< Structure with pointers to cdp funcs 		*/
 extern str cxdx_forced_peer; /**< FQDN of the Diameter peer to send requests to */
 extern str cxdx_dest_realm;
 
-typedef struct uar_param {
-	int type;
-	gparam_t *ivalue;
-	cfg_action_t *paction;
-} uar_param_t;
-
 typedef struct saved_transaction {
 	unsigned int tindex;
 	unsigned int tlabel;
diff --git a/modules/ims_icscf/location.c b/modules/ims_icscf/location.c
index 92d50cb..3d0f09a 100644
--- a/modules/ims_icscf/location.c
+++ b/modules/ims_icscf/location.c
@@ -45,6 +45,7 @@
 
 #include "location.h"
 #include "../../action.h" /* run_actions */
+#include "../../mod_fix.h"
 #include "cxdx_lir.h"
 
 extern int route_lir_user_unknown_no; 
@@ -54,17 +55,33 @@ extern int route_lir_user_unknown_no;
  * @param msg - sip message
  * @returns 1 on success or 0 on failure
  */
-int I_perform_location_information_request(struct sip_msg* msg, char* str1, char* str2) {
+int I_perform_location_information_request(struct sip_msg* msg, char* route, char* str1, char* str2) {
     str public_identity = {0, 0};
     int orig = 0;
     
     tm_cell_t *t = 0;
     saved_lir_transaction_t* saved_t;
     
+    str route_name;
+    
      cfg_action_t* cfg_action;
 
-    lir_param_t* ap = (lir_param_t*) str1;
-    cfg_action = ap->paction->next;
+     if (fixup_get_svalue(msg, (gparam_t*) route, &route_name) != 0) {
+        LM_ERR("no async route block for assign_server_unreg\n");
+        return -1;
+    }
+    
+    LM_DBG("Looking for route block [%.*s]\n", route_name.len, route_name.s);
+    int ri = route_get(&main_rt, route_name.s);
+    if (ri < 0) {
+        LM_ERR("unable to find route block [%.*s]\n", route_name.len, route_name.s);
+        return -1;
+    }
+    cfg_action = main_rt.rlist[ri];
+    if (cfg_action == NULL) {
+        LM_ERR("empty action lists in route block [%.*s]\n", route_name.len, route_name.s);
+        return -1;
+    }
     
     LM_DBG("DBG:I_LIR: Starting ...\n");
     /* check if we received what we should */
diff --git a/modules/ims_icscf/location.h b/modules/ims_icscf/location.h
index 8ccc7bc..eccd734 100644
--- a/modules/ims_icscf/location.h
+++ b/modules/ims_icscf/location.h
@@ -60,7 +60,7 @@ extern struct cdp_binds cdpb;//cdp binds functions
  * @param msg - sip message
  * @returns 1 on success or 0 on failure
  */
-int I_perform_location_information_request(struct sip_msg* msg, char* str1, char* str2);
+int I_perform_location_information_request(struct sip_msg* msg, char* route, char* str1, char* str2);
 
 
 #endif
diff --git a/modules/ims_icscf/mod.c b/modules/ims_icscf/mod.c
index 6066741..f9d0fe8 100644
--- a/modules/ims_icscf/mod.c
+++ b/modules/ims_icscf/mod.c
@@ -106,8 +106,8 @@ static int fixup_uar(void** param, int param_no);
 static int fixup_lir(void** param, int param_no);
 
 static cmd_export_t cmds[] = {
-    {"I_perform_user_authorization_request", (cmd_function) I_perform_user_authorization_request, 1, fixup_uar, 0, REQUEST_ROUTE},
-    {"I_perform_location_information_request", (cmd_function) I_perform_location_information_request, 1, fixup_lir, 0, REQUEST_ROUTE},
+    {"I_perform_user_authorization_request", (cmd_function) I_perform_user_authorization_request, 2, fixup_uar, 0, REQUEST_ROUTE},
+    {"I_perform_location_information_request", (cmd_function) I_perform_location_information_request, 2, fixup_lir, 0, REQUEST_ROUTE},
     {"I_scscf_select", (cmd_function) I_scscf_select, 1, 0, 0, REQUEST_ROUTE | FAILURE_ROUTE},
     {"I_scscf_drop", (cmd_function) I_scscf_drop, 0, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE},
     { 0, 0, 0, 0, 0, 0}
@@ -274,38 +274,35 @@ static int mod_init(void) {
 
 static int fixup_uar(void** param, int param_no)
 {
-	uar_param_t *ap;
-	if(param_no!=1)
-		return 0;
-	ap = (uar_param_t*)pkg_malloc(sizeof(uar_param_t));
-	if(ap==NULL)
-	{
-		LM_ERR("no more pkg\n");
-		return -1;
-	}
-	memset(ap, 0, sizeof(uar_param_t));
-	ap->paction = get_action_from_param(param, param_no);
-	if(fixup_igp_null(param, param_no)<0)
-		return -1;
-	ap->ivalue = (gparam_t*)(*param);
-	*param = (void*)ap;
-	return 0;
+    if (strlen((char*) *param) <= 0) {
+        LM_ERR("empty parameter %d not allowed\n", param_no);
+        return -1;
+    }
+
+    if (param_no == 1) {        //route name - static or dynamic string (config vars)
+        if (fixup_spve_null(param, param_no) < 0){
+            LM_ERR("fixup spve failed on %d\n", param_no);
+            return -1;
+        }
+        return 0;
+    }
+    return 0;
+    
 }
 
 static int fixup_lir(void** param, int param_no)
 {
-	lir_param_t *ap;
-	if(param_no!=1)
-		return 0;
-	ap = (lir_param_t*)pkg_malloc(sizeof(lir_param_t));
-	if(ap==NULL)
-	{
-		LM_ERR("no more pkg\n");
-		return -1;
-	}
-	memset(ap, 0, sizeof(lir_param_t));
-	ap->paction = get_action_from_param(param, param_no);
-	*param = (void*)ap;
-	return 0;
+	if (strlen((char*) *param) <= 0) {
+        LM_ERR("empty parameter %d not allowed\n", param_no);
+        return -1;
+        }
+
+        if (param_no == 1) {        //route name - static or dynamic string (config vars)
+            if (fixup_spve_null(param, param_no) < 0)
+                return -1;
+            return 0;
+        } 
+        return 0;
+    
 }
 
diff --git a/modules/ims_icscf/registration.c b/modules/ims_icscf/registration.c
index 6a6fe57..9412511 100644
--- a/modules/ims_icscf/registration.c
+++ b/modules/ims_icscf/registration.c
@@ -46,6 +46,7 @@
 
 #include "registration.h"
 #include "../../action.h" /* run_actions */
+#include "../../mod_fix.h"
 #include "cxdx_uar.h"
 
 extern int route_uar_user_unknown_no;
@@ -54,11 +55,9 @@ extern int route_uar_user_unknown_no;
  * Perform User Authorization Request.
  * creates and send the user authorization query
  * @param msg - the SIP message
- * @param str1 - the realm
- * @param str2 - if to do capabilities
  * @returns true if OK, false if not
  */
-int I_perform_user_authorization_request(struct sip_msg* msg, char* str1, char* str2) {
+int I_perform_user_authorization_request(struct sip_msg* msg, char* route, char* str1, char* str2) {
     str private_identity, public_identity, visited_network_id;
     int authorization_type = AVP_IMS_UAR_REGISTRATION;
     int expires = 3600;
@@ -72,13 +71,30 @@ int I_perform_user_authorization_request(struct sip_msg* msg, char* str1, char*
     tm_cell_t *t = 0;
     int intvalue_param;
     cfg_action_t* cfg_action;
+    
+    str route_name;
 
-    uar_param_t* ap = (uar_param_t*) str1;
-    if (fixup_get_ivalue(msg, ap->ivalue, &intvalue_param) != 0) {
+    if (fixup_get_ivalue(msg, (gparam_t*) str1, &intvalue_param) != 0) {
         LM_ERR("no int value param passed\n");
         return CSCF_RETURN_ERROR;
     }
-    cfg_action = ap->paction->next;
+    if (fixup_get_svalue(msg, (gparam_t*) route, &route_name) != 0) {
+        LM_ERR("no async route block for assign_server_unreg\n");
+        return -1;
+    }
+    
+    LM_DBG("Looking for route block [%.*s]\n", route_name.len, route_name.s);
+    int ri = route_get(&main_rt, route_name.s);
+    if (ri < 0) {
+        LM_ERR("unable to find route block [%.*s]\n", route_name.len, route_name.s);
+        return -1;
+    }
+    cfg_action = main_rt.rlist[ri];
+    if (cfg_action == NULL) {
+        LM_ERR("empty action lists in route block [%.*s]\n", route_name.len, route_name.s);
+        return -1;
+    }
+
 
     realm = cscf_get_realm_from_ruri(msg);
 
diff --git a/modules/ims_icscf/registration.h b/modules/ims_icscf/registration.h
index 6cf52cd..b7ebbc6 100644
--- a/modules/ims_icscf/registration.h
+++ b/modules/ims_icscf/registration.h
@@ -61,7 +61,7 @@ extern struct cdp_binds cdpb;
  * @param str2 - if to do capabilities
  * @returns true if OK, false if not
  */
-int I_perform_user_authorization_request(struct sip_msg* msg, char* str1, char* str2);
+int I_perform_user_authorization_request(struct sip_msg* msg, char* route, char* str1, char* str2);
 
 
 




More information about the sr-dev mailing list