Browse code

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

Jason Penton authored on 24/06/2013 13:24:49
Showing 4 changed files
... ...
@@ -249,7 +249,8 @@ success:
249 249
     update_stat(accepted_registrations, 1);
250 250
 
251 251
 done:
252
-    reg_send_reply_transactional(t->uas.request, data->contact_header, t);
252
+    if (data->sar_assignment_type != AVP_IMS_SAR_UNREGISTERED_USER)
253
+        reg_send_reply_transactional(t->uas.request, data->contact_header, t);
253 254
     LM_DBG("DBG:SAR Async CDP callback: ... Done resuming transaction\n");
254 255
     set_avp_list(AVP_TRACK_FROM | AVP_CLASS_URI, &t->uri_avps_from);
255 256
     set_avp_list(AVP_TRACK_TO | AVP_CLASS_URI, &t->uri_avps_to);
... ...
@@ -274,7 +275,8 @@ done:
274 275
     return;
275 276
 
276 277
 error:
277
-    reg_send_reply_transactional(t->uas.request, data->contact_header, t);
278
+    if (data->sar_assignment_type != AVP_IMS_SAR_UNREGISTERED_USER)
279
+        reg_send_reply_transactional(t->uas.request, data->contact_header, t);
278 280
 
279 281
 error_no_send: //if we don't have the transaction then we can't send a transaction response
280 282
     update_stat(rejected_registrations, 1);
... ...
@@ -108,12 +108,13 @@ static int mod_init(void);
108 108
 static int child_init(int);
109 109
 static void mod_destroy(void);
110 110
 static int w_save(struct sip_msg* _m, char* _d, char* mode, char* _cflags);
111
-static int w_assign_server_unreg(struct sip_msg* _m, char* _d, char* _direction);
111
+static int w_assign_server_unreg(struct sip_msg* _m, char* _route, char* _d, char* _direction);
112 112
 static int w_lookup(struct sip_msg* _m, char* _d, char* _p2);
113 113
 
114 114
 /*! \brief Fixup functions */
115 115
 static int domain_fixup(void** param, int param_no);
116 116
 static int assign_save_fixup3(void** param, int param_no);
117
+static int assign_save_fixup3_async(void** param, int param_no);
117 118
 //static int save_fixup2(void** param, int param_no);
118 119
 //static int assign_fixup2(void** param, int param_no);
119 120
 static int unreg_fixup(void** param, int param_no);
... ...
@@ -190,7 +191,7 @@ static cmd_export_t cmds[] = {
190 191
     {"lookup", (cmd_function) w_lookup, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
191 192
     {"term_impu_registered", (cmd_function) term_impu_registered, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
192 193
     {"impu_registered", (cmd_function) impu_registered, 1, domain_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
193
-    {"assign_server_unreg", (cmd_function) w_assign_server_unreg, 2, assign_save_fixup3, 0, REQUEST_ROUTE},
194
+    {"assign_server_unreg", (cmd_function) w_assign_server_unreg, 3, assign_save_fixup3_async, 0, REQUEST_ROUTE},
194 195
     {"add_sock_hdr", (cmd_function) add_sock_hdr, 1, fixup_str_null, 0, REQUEST_ROUTE},
195 196
     {"unregister", (cmd_function) unregister, 2, unreg_fixup, 0, REQUEST_ROUTE | FAILURE_ROUTE},
196 197
     {"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) {
515 516
     return save(_m, _d);
516 517
 }
517 518
 
518
-static int w_assign_server_unreg(struct sip_msg* _m, char* _d, char* _direction) {
519
+static int w_assign_server_unreg(struct sip_msg* _m, char* _route, char* _d, char* _direction) {
519 520
     str direction;
520 521
 
521 522
     direction.s = _direction;
522 523
     direction.len = strlen(_direction);
523
-    //return assign_server_unreg(_m, (udomain_t*)_d, &direction);
524
-    return assign_server_unreg(_m, _d, &direction);
524
+    return assign_server_unreg(_m, _d, &direction, _route);
525 525
 
526 526
 }
527 527
 
... ...
@@ -599,6 +599,33 @@ static int assign_save_fixup3(void** param, int param_no) {
599 599
     return 0;
600 600
 }
601 601
 
602
+/*
603
+ * Convert the char* parameters
604
+ */
605
+static int assign_save_fixup3_async(void** param, int param_no) {
606
+
607
+    if (strlen((char*) *param) <= 0) {
608
+        LM_ERR("empty parameter %d not allowed\n", param_no);
609
+        return -1;
610
+    }
611
+
612
+    if (param_no == 1) {        //route name - static or dynamic string (config vars)
613
+        if (fixup_spve_null(param, param_no) < 0)
614
+            return -1;
615
+        return 0;
616
+    } else if (param_no == 2) {
617
+        udomain_t* d;
618
+
619
+        if (ul.register_udomain((char*) *param, &d) < 0) {
620
+            LM_ERR("Error doing fixup on assign save");
621
+            return -1;
622
+        }
623
+        *param = (void*) d;
624
+    }
625
+
626
+    return 0;
627
+}
628
+
602 629
 /*! \brief
603 630
  * Convert char* parameter to udomain_t* pointer
604 631
  * Convert char* parameter to pv_elem_t* pointer
... ...
@@ -926,20 +926,37 @@ error:
926 926
 
927 927
 }
928 928
 
929
-int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction) {
929
+int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction, char* route) {
930 930
     str private_identity = {0, 0}, public_identity = {0, 0};
931 931
     int assignment_type = AVP_IMS_SAR_NO_ASSIGNMENT;
932 932
     int data_available = AVP_IMS_SAR_USER_DATA_NOT_AVAILABLE;
933 933
     int require_user_data = 1;
934 934
     rerrno = R_FINE;
935 935
     tm_cell_t *t = 0;
936
+    str route_name;
936 937
 
937 938
     saved_transaction_t* saved_t;
938 939
     cfg_action_t* cfg_action;
939 940
 
940
-    sar_param_t* ap = (sar_param_t*) str1;
941
-    cfg_action = ap->paction->next;
942
-
941
+    udomain_t* _d = (udomain_t*) str1;
942
+    
943
+    if (fixup_get_svalue(_m, (gparam_t*) route, &route_name) != 0) {
944
+        LM_ERR("no async route block for assign_server_unreg\n");
945
+        return -1;
946
+    }
947
+    
948
+    LM_DBG("Looking for route block [%.*s]\n", route_name.len, route_name.s);
949
+    int ri = route_get(&main_rt, route_name.s);
950
+    if (ri < 0) {
951
+        LM_ERR("unable to find route block [%.*s]\n", route_name.len, route_name.s);
952
+        return -1;
953
+    }
954
+    cfg_action = main_rt.rlist[ri];
955
+    if (cfg_action == NULL) {
956
+        LM_ERR("empty action lists in route block [%.*s]\n", route_name.len, route_name.s);
957
+        return -1;
958
+    }
959
+    
943 960
     LM_DBG("Assigning unregistered user for direction [%.*s]\n", direction->len, direction->s);
944 961
 
945 962
     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) {
995 1012
     saved_t->expires = 1; //not a dereg as this is server_assign_unreg
996 1013
     saved_t->require_user_data = require_user_data;
997 1014
     saved_t->sar_assignment_type = assignment_type;
998
-    saved_t->domain = (udomain_t*) ap->param;
1015
+    saved_t->domain = (udomain_t*) _d;
999 1016
 
1000 1017
     saved_t->contact_header = 0;
1001 1018
 
... ...
@@ -56,7 +56,7 @@
56 56
 /*! \brief
57 57
  * Process REGISTER request and save it's contacts
58 58
  */
59
-int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction);
59
+int assign_server_unreg(struct sip_msg* _m, char* str1, str* direction, char* route);
60 60
 
61 61
 int save(struct sip_msg* msg, char* str1);
62 62