[sr-dev] git:master: modules/ims_registrar_scscf: execute route block on async reply on REG SAR

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


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

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

modules/ims_registrar_scscf: execute route block on async reply on REG SAR
	- 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 REG SAR called from save()

---

 modules/ims_registrar_scscf/cxdx_sar.h |    8 -----
 modules/ims_registrar_scscf/reg_mod.c  |   49 ++-----------------------------
 modules/ims_registrar_scscf/save.c     |   30 +++++++++++++++----
 modules/ims_registrar_scscf/save.h     |    2 +-
 4 files changed, 29 insertions(+), 60 deletions(-)

diff --git a/modules/ims_registrar_scscf/cxdx_sar.h b/modules/ims_registrar_scscf/cxdx_sar.h
index 2f9a8a8..77b0d3d 100644
--- a/modules/ims_registrar_scscf/cxdx_sar.h
+++ b/modules/ims_registrar_scscf/cxdx_sar.h
@@ -47,14 +47,6 @@
 #define CXDX_SAR_H
 
 
-typedef struct sar_param {
-	int type;
-        udomain_t* param;
-	cfg_action_t *paction;
-} sar_param_t;
-
-
-
 extern struct cdp_binds cdpb;
 extern str cxdx_forced_peer; /**< FQDN of the Diameter peer to send requests to */
 extern str cxdx_dest_realm;
diff --git a/modules/ims_registrar_scscf/reg_mod.c b/modules/ims_registrar_scscf/reg_mod.c
index 4e2a31e..1347a07 100644
--- a/modules/ims_registrar_scscf/reg_mod.c
+++ b/modules/ims_registrar_scscf/reg_mod.c
@@ -107,16 +107,13 @@ str scscf_serviceroute_uri_str; /* Service Route URI */
 static int mod_init(void);
 static int child_init(int);
 static void mod_destroy(void);
-static int w_save(struct sip_msg* _m, char* _d, char* mode, char* _cflags);
+static int w_save(struct sip_msg* _m, char * _route, char* _d, char* mode, char* _cflags);
 static int w_assign_server_unreg(struct sip_msg* _m, char* _route, char* _d, char* _direction);
 static int w_lookup(struct sip_msg* _m, char* _d, char* _p2);
 
 /*! \brief Fixup functions */
 static int domain_fixup(void** param, int param_no);
-static int assign_save_fixup3(void** param, int param_no);
 static int assign_save_fixup3_async(void** param, int param_no);
-//static int save_fixup2(void** param, int param_no);
-//static int assign_fixup2(void** param, int param_no);
 static int unreg_fixup(void** param, int param_no);
 static int fetchc_fixup(void** param, int param_no);
 /*! \brief Functions */
@@ -187,7 +184,7 @@ static pv_export_t mod_pvs[] = {
  * Exported functions
  */
 static cmd_export_t cmds[] = {
-    {"save", (cmd_function) w_save, 1, assign_save_fixup3, 0, REQUEST_ROUTE | ONREPLY_ROUTE},
+    {"save", (cmd_function) w_save, 2, assign_save_fixup3_async, 0, REQUEST_ROUTE | ONREPLY_ROUTE},
     {"lookup", (cmd_function) w_lookup, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
     {"term_impu_registered", (cmd_function) term_impu_registered, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
     {"impu_registered", (cmd_function) impu_registered, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
@@ -511,9 +508,8 @@ static int child_init(int rank) {
 /*! \brief
  * Wrapper to save(location)
  */
-static int w_save(struct sip_msg* _m, char* _d, char* mode, char* _cflags) {
-    //return save(_m, (udomain_t*)_d);
-    return save(_m, _d);
+static int w_save(struct sip_msg* _m, char* _route, char* _d, char* mode, char* _cflags) {
+    return save(_m, _d, _route);
 }
 
 static int w_assign_server_unreg(struct sip_msg* _m, char* _route, char* _d, char* _direction) {
@@ -565,43 +561,6 @@ static int unreg_fixup(void** param, int param_no) {
 /*
  * Convert the char* parameters
  */
-static int assign_save_fixup3(void** param, int param_no) {
-
-    if (strlen((char*) *param) <= 0) {
-        LM_ERR("empty parameter %d not allowed\n", param_no);
-        return -1;
-    }
-
-    if (param_no == 1) {
-        udomain_t* d;
-
-        if (ul.register_udomain((char*) *param, &d) < 0) {
-            LM_ERR("Erroring doing fixup on assign save");
-            return -1;
-        }
-
-        *param = (void*) d;
-
-        sar_param_t *ap;
-        ap = (sar_param_t*) pkg_malloc(sizeof (sar_param_t));
-        if (ap == NULL) {
-            LM_ERR("no more pkg\n");
-            return -1;
-        }
-        memset(ap, 0, sizeof (sar_param_t));
-        ap->paction = get_action_from_param(param, param_no);
-
-        ap->param = (udomain_t*) * param;
-
-        *param = (void*) ap;
-    }
-
-    return 0;
-}
-
-/*
- * Convert the char* parameters
- */
 static int assign_save_fixup3_async(void** param, int param_no) {
 
     if (strlen((char*) *param) <= 0) {
diff --git a/modules/ims_registrar_scscf/save.c b/modules/ims_registrar_scscf/save.c
index 605fb76..7602bf9 100644
--- a/modules/ims_registrar_scscf/save.c
+++ b/modules/ims_registrar_scscf/save.c
@@ -1060,7 +1060,7 @@ error:
  */
 //int save(struct sip_msg* msg, udomain_t* _d) {
 
-int save(struct sip_msg* msg, char* str1) {
+int save(struct sip_msg* msg, char* str1, char *route) {
     int expires;
     int require_user_data = 0;
     int data_available;
@@ -1068,6 +1068,9 @@ int save(struct sip_msg* msg, char* str1) {
     int st;
     str public_identity, private_identity, realm;
     int sar_assignment_type = AVP_IMS_SAR_NO_ASSIGNMENT;
+    str route_name;
+    
+    udomain_t* _d = (udomain_t*) str1;
 
     rerrno = R_FINE;
     get_act_time();
@@ -1079,8 +1082,22 @@ int save(struct sip_msg* msg, char* str1) {
 
     contact_for_header_t* contact_header = 0;
 
-    sar_param_t* ap = (sar_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;
+    }
 
     //check which route block we are in - if not request then we fail out.
     if (!is_route_type(REQUEST_ROUTE)) {
@@ -1123,7 +1140,7 @@ int save(struct sip_msg* msg, char* str1) {
 
     expires = cscf_get_max_expires(msg, 0); //check all contacts for max expires
     if (expires != 0) { //if <0 then no expires was found in which case we treat as reg/re-reg with default expires.
-        if (is_impu_registered((udomain_t*) ap->param, &public_identity)) {
+        if (is_impu_registered(_d, &public_identity)) {
             LM_DBG("preparing for SAR assignment for RE-REGISTRATION <%.*s>\n", public_identity.len, public_identity.s);
             sar_assignment_type = AVP_IMS_SAR_RE_REGISTRATION;
         } else {
@@ -1152,7 +1169,7 @@ int save(struct sip_msg* msg, char* str1) {
             //unregister the requested contacts, if none left at the end then send a SAR, otherwise return successfully
             LM_DBG("need to unregister contacts\n");
             //lets update the contacts - we need to know if all were deleted or not for the public identity
-            int res = update_contacts_new(msg, (udomain_t*) ap->param, &public_identity, sar_assignment_type, 0, 0, 0, 0, 0, &contact_header);
+            int res = update_contacts_new(msg, _d, &public_identity, sar_assignment_type, 0, 0, 0, 0, 0, &contact_header);
             if (res <= 0) {
                 LM_ERR("Error processing REGISTER for de-registration\n");
                 free_contact_buf(contact_header);
@@ -1207,7 +1224,8 @@ int save(struct sip_msg* msg, char* str1) {
     saved_t->expires = expires;
     saved_t->require_user_data = require_user_data;
     saved_t->sar_assignment_type = sar_assignment_type;
-    saved_t->domain = (udomain_t*) ap->param;
+    
+    saved_t->domain = _d;
 
     saved_t->public_identity.s = (char*) shm_malloc(public_identity.len + 1);
     if (!saved_t->public_identity.s) {
diff --git a/modules/ims_registrar_scscf/save.h b/modules/ims_registrar_scscf/save.h
index 85ec2ce..ac064aa 100644
--- a/modules/ims_registrar_scscf/save.h
+++ b/modules/ims_registrar_scscf/save.h
@@ -58,7 +58,7 @@
  */
 int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction, char* route);
 
-int save(struct sip_msg* msg, char* str1);
+int save(struct sip_msg* msg, char* str1, char* route);
 
 int unregister(struct sip_msg* _m, char* _d, char* _uri);
 




More information about the sr-dev mailing list