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

Jason Penton jason.penton at gmail.com
Mon Jun 24 15:26:57 CEST 2013


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

Author: Jason Penton <jason.penton at smilecoms.com>
Committer: Jason Penton <jason.penton at smilecoms.com>
Date:   Mon Jun 24 15:24:49 2013 +0200

modules/ims_registrar_scscf: execute route block on async reply of unreg. SAR
	- changed this to make the use of saync CDP cleaner
	- fixes inconsistencies we are experienceing with async TM and not using route block

---

 modules/ims_registrar_scscf/cxdx_sar.c |    6 +++-
 modules/ims_registrar_scscf/reg_mod.c  |   37 +++++++++++++++++++++++++++----
 modules/ims_registrar_scscf/save.c     |   27 +++++++++++++++++++----
 modules/ims_registrar_scscf/save.h     |    2 +-
 4 files changed, 59 insertions(+), 13 deletions(-)

diff --git a/modules/ims_registrar_scscf/cxdx_sar.c b/modules/ims_registrar_scscf/cxdx_sar.c
index 3c67ce7..51dafdd 100644
--- a/modules/ims_registrar_scscf/cxdx_sar.c
+++ b/modules/ims_registrar_scscf/cxdx_sar.c
@@ -249,7 +249,8 @@ success:
     update_stat(accepted_registrations, 1);
 
 done:
-    reg_send_reply_transactional(t->uas.request, data->contact_header, t);
+    if (data->sar_assignment_type != AVP_IMS_SAR_UNREGISTERED_USER)
+        reg_send_reply_transactional(t->uas.request, data->contact_header, t);
     LM_DBG("DBG:SAR Async CDP callback: ... Done resuming transaction\n");
     set_avp_list(AVP_TRACK_FROM | AVP_CLASS_URI, &t->uri_avps_from);
     set_avp_list(AVP_TRACK_TO | AVP_CLASS_URI, &t->uri_avps_to);
@@ -274,7 +275,8 @@ done:
     return;
 
 error:
-    reg_send_reply_transactional(t->uas.request, data->contact_header, t);
+    if (data->sar_assignment_type != AVP_IMS_SAR_UNREGISTERED_USER)
+        reg_send_reply_transactional(t->uas.request, data->contact_header, t);
 
 error_no_send: //if we don't have the transaction then we can't send a transaction response
     update_stat(rejected_registrations, 1);
diff --git a/modules/ims_registrar_scscf/reg_mod.c b/modules/ims_registrar_scscf/reg_mod.c
index f948dcb..4e2a31e 100644
--- a/modules/ims_registrar_scscf/reg_mod.c
+++ b/modules/ims_registrar_scscf/reg_mod.c
@@ -108,12 +108,13 @@ 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_assign_server_unreg(struct sip_msg* _m, char* _d, char* _direction);
+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);
@@ -190,7 +191,7 @@ static cmd_export_t cmds[] = {
     {"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},
-    {"assign_server_unreg", (cmd_function) w_assign_server_unreg, 2, assign_save_fixup3, 0, REQUEST_ROUTE},
+    {"assign_server_unreg", (cmd_function) w_assign_server_unreg, 3, assign_save_fixup3_async, 0, REQUEST_ROUTE},
     {"add_sock_hdr", (cmd_function) add_sock_hdr, 1, fixup_str_null, 0, REQUEST_ROUTE},
     {"unregister", (cmd_function) unregister, 2, unreg_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
     {"reg_fetch_contacts", (cmd_function) pv_fetch_contacts, 3, fetchc_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
@@ -515,13 +516,12 @@ static int w_save(struct sip_msg* _m, char* _d, char* mode, char* _cflags) {
     return save(_m, _d);
 }
 
-static int w_assign_server_unreg(struct sip_msg* _m, char* _d, char* _direction) {
+static int w_assign_server_unreg(struct sip_msg* _m, char* _route, char* _d, char* _direction) {
     str direction;
 
     direction.s = _direction;
     direction.len = strlen(_direction);
-    //return assign_server_unreg(_m, (udomain_t*)_d, &direction);
-    return assign_server_unreg(_m, _d, &direction);
+    return assign_server_unreg(_m, _d, &direction, _route);
 
 }
 
@@ -599,6 +599,33 @@ static int assign_save_fixup3(void** param, int param_no) {
     return 0;
 }
 
+/*
+ * Convert the char* parameters
+ */
+static int assign_save_fixup3_async(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) {        //route name - static or dynamic string (config vars)
+        if (fixup_spve_null(param, param_no) < 0)
+            return -1;
+        return 0;
+    } else if (param_no == 2) {
+        udomain_t* d;
+
+        if (ul.register_udomain((char*) *param, &d) < 0) {
+            LM_ERR("Error doing fixup on assign save");
+            return -1;
+        }
+        *param = (void*) d;
+    }
+
+    return 0;
+}
+
 /*! \brief
  * Convert char* parameter to udomain_t* pointer
  * Convert char* parameter to pv_elem_t* pointer
diff --git a/modules/ims_registrar_scscf/save.c b/modules/ims_registrar_scscf/save.c
index 4eb8ab5..605fb76 100644
--- a/modules/ims_registrar_scscf/save.c
+++ b/modules/ims_registrar_scscf/save.c
@@ -926,20 +926,37 @@ error:
 
 }
 
-int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction) {
+int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction, char* route) {
     str private_identity = {0, 0}, public_identity = {0, 0};
     int assignment_type = AVP_IMS_SAR_NO_ASSIGNMENT;
     int data_available = AVP_IMS_SAR_USER_DATA_NOT_AVAILABLE;
     int require_user_data = 1;
     rerrno = R_FINE;
     tm_cell_t *t = 0;
+    str route_name;
 
     saved_transaction_t* saved_t;
     cfg_action_t* cfg_action;
 
-    sar_param_t* ap = (sar_param_t*) str1;
-    cfg_action = ap->paction->next;
-
+    udomain_t* _d = (udomain_t*) str1;
+    
+    if (fixup_get_svalue(_m, (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("Assigning unregistered user for direction [%.*s]\n", direction->len, direction->s);
 
     enum cscf_dialog_direction dir = cscf_get_dialog_direction(direction->s);
@@ -995,7 +1012,7 @@ int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction) {
     saved_t->expires = 1; //not a dereg as this is server_assign_unreg
     saved_t->require_user_data = require_user_data;
     saved_t->sar_assignment_type = assignment_type;
-    saved_t->domain = (udomain_t*) ap->param;
+    saved_t->domain = (udomain_t*) _d;
 
     saved_t->contact_header = 0;
 
diff --git a/modules/ims_registrar_scscf/save.h b/modules/ims_registrar_scscf/save.h
index 5ab4488..85ec2ce 100644
--- a/modules/ims_registrar_scscf/save.h
+++ b/modules/ims_registrar_scscf/save.h
@@ -56,7 +56,7 @@
 /*! \brief
  * Process REGISTER request and save it's contacts
  */
-int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction);
+int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction, char* route);
 
 int save(struct sip_msg* msg, char* str1);
 




More information about the sr-dev mailing list