Browse code

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()

Richard Good authored on 25/06/2013 12:09:00
Showing 7 changed files
... ...
@@ -57,11 +57,6 @@ extern str cxdx_dest_realm;
57 57
 struct sip_msg;
58 58
 
59 59
 
60
-typedef struct lir_param {
61
-	int type;
62
-	cfg_action_t *paction;
63
-} lir_param_t;
64
-
65 60
 typedef struct saved_lir_transaction {
66 61
 	unsigned int tindex;
67 62
 	unsigned int tlabel;
... ...
@@ -52,12 +52,6 @@ extern struct cdp_binds cdpb; /**< Structure with pointers to cdp funcs 		*/
52 52
 extern str cxdx_forced_peer; /**< FQDN of the Diameter peer to send requests to */
53 53
 extern str cxdx_dest_realm;
54 54
 
55
-typedef struct uar_param {
56
-	int type;
57
-	gparam_t *ivalue;
58
-	cfg_action_t *paction;
59
-} uar_param_t;
60
-
61 55
 typedef struct saved_transaction {
62 56
 	unsigned int tindex;
63 57
 	unsigned int tlabel;
... ...
@@ -45,6 +45,7 @@
45 45
 
46 46
 #include "location.h"
47 47
 #include "../../action.h" /* run_actions */
48
+#include "../../mod_fix.h"
48 49
 #include "cxdx_lir.h"
49 50
 
50 51
 extern int route_lir_user_unknown_no; 
... ...
@@ -54,17 +55,33 @@ extern int route_lir_user_unknown_no;
54 55
  * @param msg - sip message
55 56
  * @returns 1 on success or 0 on failure
56 57
  */
57
-int I_perform_location_information_request(struct sip_msg* msg, char* str1, char* str2) {
58
+int I_perform_location_information_request(struct sip_msg* msg, char* route, char* str1, char* str2) {
58 59
     str public_identity = {0, 0};
59 60
     int orig = 0;
60 61
     
61 62
     tm_cell_t *t = 0;
62 63
     saved_lir_transaction_t* saved_t;
63 64
     
65
+    str route_name;
66
+    
64 67
      cfg_action_t* cfg_action;
65 68
 
66
-    lir_param_t* ap = (lir_param_t*) str1;
67
-    cfg_action = ap->paction->next;
69
+     if (fixup_get_svalue(msg, (gparam_t*) route, &route_name) != 0) {
70
+        LM_ERR("no async route block for assign_server_unreg\n");
71
+        return -1;
72
+    }
73
+    
74
+    LM_DBG("Looking for route block [%.*s]\n", route_name.len, route_name.s);
75
+    int ri = route_get(&main_rt, route_name.s);
76
+    if (ri < 0) {
77
+        LM_ERR("unable to find route block [%.*s]\n", route_name.len, route_name.s);
78
+        return -1;
79
+    }
80
+    cfg_action = main_rt.rlist[ri];
81
+    if (cfg_action == NULL) {
82
+        LM_ERR("empty action lists in route block [%.*s]\n", route_name.len, route_name.s);
83
+        return -1;
84
+    }
68 85
     
69 86
     LM_DBG("DBG:I_LIR: Starting ...\n");
70 87
     /* check if we received what we should */
... ...
@@ -60,7 +60,7 @@ extern struct cdp_binds cdpb;//cdp binds functions
60 60
  * @param msg - sip message
61 61
  * @returns 1 on success or 0 on failure
62 62
  */
63
-int I_perform_location_information_request(struct sip_msg* msg, char* str1, char* str2);
63
+int I_perform_location_information_request(struct sip_msg* msg, char* route, char* str1, char* str2);
64 64
 
65 65
 
66 66
 #endif
... ...
@@ -106,8 +106,8 @@ static int fixup_uar(void** param, int param_no);
106 106
 static int fixup_lir(void** param, int param_no);
107 107
 
108 108
 static cmd_export_t cmds[] = {
109
-    {"I_perform_user_authorization_request", (cmd_function) I_perform_user_authorization_request, 1, fixup_uar, 0, REQUEST_ROUTE},
110
-    {"I_perform_location_information_request", (cmd_function) I_perform_location_information_request, 1, fixup_lir, 0, REQUEST_ROUTE},
109
+    {"I_perform_user_authorization_request", (cmd_function) I_perform_user_authorization_request, 2, fixup_uar, 0, REQUEST_ROUTE},
110
+    {"I_perform_location_information_request", (cmd_function) I_perform_location_information_request, 2, fixup_lir, 0, REQUEST_ROUTE},
111 111
     {"I_scscf_select", (cmd_function) I_scscf_select, 1, 0, 0, REQUEST_ROUTE | FAILURE_ROUTE},
112 112
     {"I_scscf_drop", (cmd_function) I_scscf_drop, 0, 0, 0, REQUEST_ROUTE | ONREPLY_ROUTE | FAILURE_ROUTE},
113 113
     { 0, 0, 0, 0, 0, 0}
... ...
@@ -274,38 +274,35 @@ static int mod_init(void) {
274 274
 
275 275
 static int fixup_uar(void** param, int param_no)
276 276
 {
277
-	uar_param_t *ap;
278
-	if(param_no!=1)
279
-		return 0;
280
-	ap = (uar_param_t*)pkg_malloc(sizeof(uar_param_t));
281
-	if(ap==NULL)
282
-	{
283
-		LM_ERR("no more pkg\n");
284
-		return -1;
285
-	}
286
-	memset(ap, 0, sizeof(uar_param_t));
287
-	ap->paction = get_action_from_param(param, param_no);
288
-	if(fixup_igp_null(param, param_no)<0)
289
-		return -1;
290
-	ap->ivalue = (gparam_t*)(*param);
291
-	*param = (void*)ap;
292
-	return 0;
277
+    if (strlen((char*) *param) <= 0) {
278
+        LM_ERR("empty parameter %d not allowed\n", param_no);
279
+        return -1;
280
+    }
281
+
282
+    if (param_no == 1) {        //route name - static or dynamic string (config vars)
283
+        if (fixup_spve_null(param, param_no) < 0){
284
+            LM_ERR("fixup spve failed on %d\n", param_no);
285
+            return -1;
286
+        }
287
+        return 0;
288
+    }
289
+    return 0;
290
+    
293 291
 }
294 292
 
295 293
 static int fixup_lir(void** param, int param_no)
296 294
 {
297
-	lir_param_t *ap;
298
-	if(param_no!=1)
299
-		return 0;
300
-	ap = (lir_param_t*)pkg_malloc(sizeof(lir_param_t));
301
-	if(ap==NULL)
302
-	{
303
-		LM_ERR("no more pkg\n");
304
-		return -1;
305
-	}
306
-	memset(ap, 0, sizeof(lir_param_t));
307
-	ap->paction = get_action_from_param(param, param_no);
308
-	*param = (void*)ap;
309
-	return 0;
295
+	if (strlen((char*) *param) <= 0) {
296
+        LM_ERR("empty parameter %d not allowed\n", param_no);
297
+        return -1;
298
+        }
299
+
300
+        if (param_no == 1) {        //route name - static or dynamic string (config vars)
301
+            if (fixup_spve_null(param, param_no) < 0)
302
+                return -1;
303
+            return 0;
304
+        } 
305
+        return 0;
306
+    
310 307
 }
311 308
 
... ...
@@ -46,6 +46,7 @@
46 46
 
47 47
 #include "registration.h"
48 48
 #include "../../action.h" /* run_actions */
49
+#include "../../mod_fix.h"
49 50
 #include "cxdx_uar.h"
50 51
 
51 52
 extern int route_uar_user_unknown_no;
... ...
@@ -54,11 +55,9 @@ extern int route_uar_user_unknown_no;
54 55
  * Perform User Authorization Request.
55 56
  * creates and send the user authorization query
56 57
  * @param msg - the SIP message
57
- * @param str1 - the realm
58
- * @param str2 - if to do capabilities
59 58
  * @returns true if OK, false if not
60 59
  */
61
-int I_perform_user_authorization_request(struct sip_msg* msg, char* str1, char* str2) {
60
+int I_perform_user_authorization_request(struct sip_msg* msg, char* route, char* str1, char* str2) {
62 61
     str private_identity, public_identity, visited_network_id;
63 62
     int authorization_type = AVP_IMS_UAR_REGISTRATION;
64 63
     int expires = 3600;
... ...
@@ -72,13 +71,30 @@ int I_perform_user_authorization_request(struct sip_msg* msg, char* str1, char*
72 71
     tm_cell_t *t = 0;
73 72
     int intvalue_param;
74 73
     cfg_action_t* cfg_action;
74
+    
75
+    str route_name;
75 76
 
76
-    uar_param_t* ap = (uar_param_t*) str1;
77
-    if (fixup_get_ivalue(msg, ap->ivalue, &intvalue_param) != 0) {
77
+    if (fixup_get_ivalue(msg, (gparam_t*) str1, &intvalue_param) != 0) {
78 78
         LM_ERR("no int value param passed\n");
79 79
         return CSCF_RETURN_ERROR;
80 80
     }
81
-    cfg_action = ap->paction->next;
81
+    if (fixup_get_svalue(msg, (gparam_t*) route, &route_name) != 0) {
82
+        LM_ERR("no async route block for assign_server_unreg\n");
83
+        return -1;
84
+    }
85
+    
86
+    LM_DBG("Looking for route block [%.*s]\n", route_name.len, route_name.s);
87
+    int ri = route_get(&main_rt, route_name.s);
88
+    if (ri < 0) {
89
+        LM_ERR("unable to find route block [%.*s]\n", route_name.len, route_name.s);
90
+        return -1;
91
+    }
92
+    cfg_action = main_rt.rlist[ri];
93
+    if (cfg_action == NULL) {
94
+        LM_ERR("empty action lists in route block [%.*s]\n", route_name.len, route_name.s);
95
+        return -1;
96
+    }
97
+
82 98
 
83 99
     realm = cscf_get_realm_from_ruri(msg);
84 100
 
... ...
@@ -61,7 +61,7 @@ extern struct cdp_binds cdpb;
61 61
  * @param str2 - if to do capabilities
62 62
  * @returns true if OK, false if not
63 63
  */
64
-int I_perform_user_authorization_request(struct sip_msg* msg, char* str1, char* str2);
64
+int I_perform_user_authorization_request(struct sip_msg* msg, char* route, char* str1, char* str2);
65 65
 
66 66
 
67 67