Browse code

ims_charging: fix charging reply route with kemi

Riccardo Villa authored on 27/08/2021 08:33:11 • Daniel-Constantin Mierla committed on 14/09/2021 08:10:49
Showing 3 changed files
... ...
@@ -498,7 +498,7 @@ static int ki_ro_ccr(sip_msg_t *msg, str* s_route_name, str* s_direction, int re
498 498
     contact = {0, 0};
499 499
     struct hdr_field *h=0;
500 500
     
501
-    cfg_action_t* cfg_action;
501
+    void* cfg_action;
502 502
     tm_cell_t *t;
503 503
     unsigned int tindex = 0,
504 504
                  tlabel = 0;
... ...
@@ -573,18 +573,22 @@ send_ccr:
573 573
     
574 574
     LM_DBG("Looking for route block [%.*s]\n", s_route_name->len, s_route_name->s);
575 575
 
576
-    int ri = route_get(&main_rt, s_route_name->s);
577
-    if (ri < 0) {
578
-        LM_ERR("unable to find route block [%.*s]\n", s_route_name->len, s_route_name->s);
579
-        ret = RO_RETURN_ERROR;
580
-        goto done;
581
-    }
582
-    
583
-    cfg_action = main_rt.rlist[ri];
584
-    if (!cfg_action) {
585
-        LM_ERR("empty action lists in route block [%.*s]\n", s_route_name->len, s_route_name->s);
586
-        ret = RO_RETURN_ERROR;
587
-        goto done;
576
+    if (!sr_kemi_eng_get()) {
577
+        int ri = route_get(&main_rt, s_route_name->s);
578
+        if (ri < 0) {
579
+            LM_ERR("unable to find route block [%.*s]\n", s_route_name->len, s_route_name->s);
580
+            ret = RO_RETURN_ERROR;
581
+            goto done;
582
+        }
583
+        
584
+        cfg_action = main_rt.rlist[ri];
585
+        if (!cfg_action) {
586
+            LM_ERR("empty action lists in route block [%.*s]\n", s_route_name->len, s_route_name->s);
587
+            ret = RO_RETURN_ERROR;
588
+            goto done;
589
+        }
590
+    } else {
591
+        cfg_action = s_route_name;
588 592
     }
589 593
 
590 594
     //before we send lets suspend the transaction
... ...
@@ -33,6 +33,7 @@
33 33
 #include "ro_avp.h"
34 34
 #include "ro_db_handler.h"
35 35
 #include "ims_charging_stats.h"
36
+#include "../../core/str.h"
36 37
 
37 38
 static pv_spec_t *custom_user_avp;		/*!< AVP for custom_user setting */
38 39
 static pv_spec_t *app_provided_party_avp;	/*!< AVP for app_provided_party setting */
... ...
@@ -50,7 +51,7 @@ extern int vendor_specific_chargeinfo;
50 51
 
51 52
 struct session_setup_data {
52 53
     struct ro_session *ro_session;
53
-    cfg_action_t* action;
54
+    void* action;
54 55
     unsigned int tindex;
55 56
     unsigned int tlabel;
56 57
 };
... ...
@@ -1077,7 +1078,7 @@ error:
1077 1078
  * @returns #CSCF_RETURN_BREAK if OK, #CSCF_RETURN_ERROR on error
1078 1079
  */
1079 1080
 int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservation_units, str* incoming_trunk_id, str* outgoing_trunk_id,
1080
-        str* pani, cfg_action_t* action, unsigned int tindex, unsigned int tlabel) {
1081
+        str* pani, void* action, unsigned int tindex, unsigned int tlabel) {
1081 1082
     str session_id = {0, 0},
1082 1083
     called_asserted_identity = {0, 0},
1083 1084
     subscription_id = {0, 0},
... ...
@@ -1217,7 +1218,24 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1217 1218
     }
1218 1219
     LM_DBG("new session created\n");
1219 1220
 
1220
-    ssd->action = action;
1221
+    if (sr_kemi_eng_get())
1222
+    {
1223
+        str *tmp = shm_malloc(sizeof(str));
1224
+        if (tmp == NULL) {
1225
+            SHM_MEM_ERROR;
1226
+            goto error;
1227
+        }
1228
+        if (shm_str_dup(tmp, (str *) action) != 0) {
1229
+            SHM_MEM_ERROR;
1230
+            shm_free(tmp);
1231
+            goto error;
1232
+        } else {
1233
+            ssd->action = tmp;
1234
+        }
1235
+    } else {
1236
+        ssd->action = action;
1237
+    }
1238
+
1221 1239
     ssd->tindex = tindex;
1222 1240
     ssd->tlabel = tlabel;
1223 1241
     ssd->ro_session = new_session;
... ...
@@ -1464,7 +1482,16 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
1464 1482
     if (t)
1465 1483
         tmb.unref_cell(t);
1466 1484
 
1467
-    tmb.t_continue(ssd->tindex, ssd->tlabel, ssd->action);
1485
+    if (sr_kemi_eng_get())
1486
+    {
1487
+        str cb_param = str_init("ccr:continue");
1488
+        tmb.t_continue_cb(ssd->tindex, ssd->tlabel, ssd->action, &cb_param);
1489
+        str_free(*((str *)ssd->action), shm);
1490
+        shm_free(ssd->action);
1491
+    } else {
1492
+        tmb.t_continue(ssd->tindex, ssd->tlabel, ssd->action);
1493
+    }
1494
+
1468 1495
     shm_free(ssd);
1469 1496
 
1470 1497
     counter_inc(ims_charging_cnts_h.successful_initial_ccrs);
... ...
@@ -21,7 +21,7 @@ struct interim_ccr {
21 21
 void credit_control_session_callback(int event, void* session);
22 22
 void remove_aaa_session(str *session_id);
23 23
 int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservation_units, 
24
-	    str *incoming_trunk_id, str *outgoing_trunk_id, str *enb_cell_id, cfg_action_t* action, unsigned int tindex, unsigned int tlabel);
24
+	    str *incoming_trunk_id, str *outgoing_trunk_id, str *enb_cell_id, void* action, unsigned int tindex, unsigned int tlabel);
25 25
 long get_current_time_micro();
26 26
 void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned int reserve);
27 27
 void send_ccr_stop_with_param(struct ro_session *ro_session, unsigned int code, str* reason);