Browse code

ims_charging: fixed misleading-indentation warning GH #3012

Sergey Safarov authored on 04/02/2022 08:46:31 • Daniel-Constantin Mierla committed on 07/02/2022 20:45:43
Showing 1 changed files
... ...
@@ -1604,23 +1604,23 @@ static int create_cca_result_code(int result) {
1604 1604
 
1605 1605
 static int create_cca_fui_avps(int action, str* redirecturi) {
1606 1606
 	int_str action_avp_val, action_avp_name, redirecturi_avp_val, redirecturi_avp_name;
1607
-    action_avp_name.s.s = RO_AVP_CCA_FUI_ACTION;
1608
-    action_avp_name.s.len = RO_AVP_CCA_FUI_ACTION_LENGTH;
1607
+	action_avp_name.s.s = RO_AVP_CCA_FUI_ACTION;
1608
+	action_avp_name.s.len = RO_AVP_CCA_FUI_ACTION_LENGTH;
1609 1609
 	redirecturi_avp_name.s.s = RO_AVP_CCA_FUI_REDIRECT_URI;
1610
-    redirecturi_avp_name.s.len = RO_AVP_CCA_FUI_REDIRECT_URI_LENGTH;
1611
-    char buf[10];
1610
+	redirecturi_avp_name.s.len = RO_AVP_CCA_FUI_REDIRECT_URI_LENGTH;
1611
+	char buf[10];
1612 1612
 	int rc;
1613 1613
 
1614
-    action_avp_val.n = action;
1615
-    action_avp_val.s.len = snprintf(buf, 10, "%i", action);
1616
-    action_avp_val.s.s = buf;
1614
+	action_avp_val.n = action;
1615
+	action_avp_val.s.len = snprintf(buf, 10, "%i", action);
1616
+	action_avp_val.s.s = buf;
1617 1617
 
1618
-    rc = add_avp(AVP_NAME_STR|AVP_VAL_STR, action_avp_name, action_avp_val);
1618
+	rc = add_avp(AVP_NAME_STR|AVP_VAL_STR, action_avp_name, action_avp_val);
1619 1619
 
1620
-    if (rc < 0)
1621
-        LM_ERR("Couldn't create ["RO_AVP_CCA_FUI_ACTION"] AVP\n");
1622
-    else
1623
-        LM_DBG("Created AVP ["RO_AVP_CCA_FUI_ACTION"] successfully: value=[%d]\n", action);
1620
+	if (rc < 0)
1621
+		LM_ERR("Couldn't create ["RO_AVP_CCA_FUI_ACTION"] AVP\n");
1622
+	else
1623
+		LM_DBG("Created AVP ["RO_AVP_CCA_FUI_ACTION"] successfully: value=[%d]\n", action);
1624 1624
 
1625 1625
 	if (redirecturi && redirecturi->len >0 && redirecturi->s) {
1626 1626
 		redirecturi_avp_val.s.len = redirecturi->len;
... ...
@@ -1634,7 +1634,7 @@ static int create_cca_fui_avps(int action, str* redirecturi) {
1634 1634
 			LM_DBG("Created AVP ["RO_AVP_CCA_FUI_REDIRECT_URI"] successfully: value=[%.*s]\n", redirecturi->len, redirecturi->s);
1635 1635
 	}
1636 1636
 
1637
-    return 1;
1637
+	return 1;
1638 1638
 }
1639 1639
 
1640 1640
 static int get_mac_avp_value(struct sip_msg *msg, str *value) {
Browse code

ims_charging: use TIME_T_FMT

Signed-off-by: Sebastian Kemper <sebastian_ml@gmx.net>

Sebastian Kemper authored on 31/10/2021 20:49:45 • Daniel-Constantin Mierla committed on 03/11/2021 12:03:34
Showing 1 changed files
... ...
@@ -858,7 +858,8 @@ void send_ccr_stop_with_param(struct ro_session *ro_session, unsigned int code,
858 858
         LM_DBG("Final used number of seconds for session is %ld\n", used);
859 859
     }
860 860
 
861
-    LM_DBG("Call started at %ld and ended at %ld and lasted %d seconds and so far we have billed for %ld seconds\n", ro_session->start_time, stop_time,
861
+    LM_DBG("Call started at %" TIME_T_FMT " and ended at %" TIME_T_FMT " and lasted %d seconds and so far we have billed for %ld seconds\n",
862
+            TIME_T_CAST(ro_session->start_time), TIME_T_CAST(stop_time),
862 863
             actual_time_seconds, ro_session->billed + used);
863 864
     if (ro_session->billed + used < actual_time_seconds) {
864 865
         LM_DBG("Making adjustment by adding %ld seconds\n", actual_time_seconds - (ro_session->billed + used));
Browse code

ims_charging: include kemi.h to fix compile warning

Daniel-Constantin Mierla authored on 28/10/2021 18:25:48
Showing 1 changed files
... ...
@@ -7,6 +7,7 @@
7 7
 #include "../../core/socket_info.h"
8 8
 #include "../../core/timer.h"
9 9
 #include "../../core/locking.h"
10
+#include "../../core/kemi.h"
10 11
 #include "../../modules/tm/tm_load.h"
11 12
 
12 13
 #include "../../modules/ims_dialog/dlg_hash.h"
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 1 changed files
... ...
@@ -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);
Browse code

ims_charging: fix wrong default User-Equipment-Info-Type AVP format

- fix User-Equipment-Info-Type AVP format
According to the RFC 8506 it should be like this: The 48-bit Media Access
Control (MAC) address is formatted as described in Section 3.21 of [RFC3580]
- use strlen instead of sizeof

(cherry picked from commit 1a8f54147063560f6016634152b17293394b8497)

Henning Westerholt authored on 11/07/2020 11:03:26
Showing 1 changed files
... ...
@@ -1615,9 +1615,8 @@ static int get_mac_avp_value(struct sip_msg *msg, str *value) {
1615 1615
 
1616 1616
     pv_parse_spec2(&mac_avp_name_str, &avp_spec, 1);
1617 1617
     if (pv_get_spec_value(msg, &avp_spec, &val) != 0 || val.rs.len == 0) {
1618
-
1619
-        value->s = "00:00:00:00:00:00";
1620
-        value->len = sizeof ("00:00:00:00:00:00") - 1;
1618
+        value->s = "00-00-00-00-00-00";
1619
+        value->len = strlen(value->s);
1621 1620
         return -1;
1622 1621
     }
1623 1622
 
Browse code

ims_charging: fix for app_provided_party functionality, also support interim/stop reqs

Henning Westerholt authored on 09/07/2020 19:24:49
Showing 1 changed files
... ...
@@ -469,16 +469,15 @@ int get_timestamps(struct sip_msg * req, struct sip_msg * reply, time_t * req_ti
469 469
  */
470 470
 
471 471
 Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, AAASession ** authp, int dir, str asserted_identity,
472
-        str called_asserted_identity, str subscription_id, int subscription_id_type, str* incoming_trunk_id, str *outgoing_trunk_id, str* pani) {
472
+        str called_asserted_identity, str subscription_id, int subscription_id_type, str* incoming_trunk_id, str *outgoing_trunk_id,
473
+        str* pani, str* app_provided_party) {
473 474
 
474 475
     Ro_CCR_t * ro_ccr_data = 0;
475 476
     AAASession * auth = NULL;
476 477
     str user_name/* ={0,0}*/, sip_method = {0, 0}, event = {0, 0};
477 478
     uint32_t expires = 0;
478 479
     str callid = {0, 0}, to_uri = {0, 0}, from_uri = {0, 0},
479
-    icid = {0, 0}, orig_ioi = {0, 0}, term_ioi = {0, 0},
480
-    app_provided_party = {0, 0};
481
-
480
+    icid = {0, 0}, orig_ioi = {0, 0}, term_ioi = {0, 0};
482 481
     event_type_t * event_type = 0;
483 482
     ims_information_t * ims_info = 0;
484 483
     time_stamps_t * time_stamps = 0;
... ...
@@ -508,12 +507,8 @@ Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, A
508 507
     if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, &reply_timestamp, NULL)))
509 508
         goto error;
510 509
 
511
-    if (get_app_provided_party(req, &app_provided_party) == -1) {
512
-        LM_DBG("no valid Application-Provided-Called-Party-Address AVP provided\n");
513
-    }
514
-
515 510
     if (!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &asserted_identity, &called_asserted_identity, &icid,
516
-            &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id, pani, &app_provided_party)))
511
+            &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id, pani, app_provided_party)))
517 512
         goto error;
518 513
     LM_DBG("created IMS information\n");
519 514
     event_type = 0;
... ...
@@ -561,13 +556,13 @@ out_of_memory:
561 556
 }
562 557
 
563 558
 int sip_create_ro_ccr_data(struct sip_msg * msg, int dir, Ro_CCR_t ** ro_ccr_data, AAASession ** auth, str asserted_identity, str called_asserted_identity,
564
-        str subscription_id, int subscription_id_type, str* incoming_trunk_id, str* outgoing_trunk_id, str* pani) {
559
+        str subscription_id, int subscription_id_type, str* incoming_trunk_id, str* outgoing_trunk_id, str* pani, str* app_provided_party) {
565 560
 
566 561
     if (msg->first_line.type == SIP_REQUEST) {
567 562
         /*end of session*/
568 563
         if (strncmp(msg->first_line.u.request.method.s, "INVITE", 6) == 0) {
569 564
             if (!(*ro_ccr_data = dlg_create_ro_session(msg, NULL, auth, dir, asserted_identity, called_asserted_identity, subscription_id,
570
-                    subscription_id_type, incoming_trunk_id, outgoing_trunk_id, pani)))
565
+                    subscription_id_type, incoming_trunk_id, outgoing_trunk_id, pani, app_provided_party)))
571 566
                 goto error;
572 567
         }
573 568
     } else {
... ...
@@ -1086,7 +1081,8 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1086 1081
     str session_id = {0, 0},
1087 1082
     called_asserted_identity = {0, 0},
1088 1083
     subscription_id = {0, 0},
1089
-    asserted_identity = {0, 0};
1084
+    asserted_identity = {0, 0},
1085
+    app_provided_party = {0, 0};
1090 1086
     int subscription_id_type = AVP_EPC_Subscription_Id_Type_End_User_SIP_URI;
1091 1087
     AAASession* cc_acc_session = NULL;
1092 1088
     Ro_CCR_t * ro_ccr_data = 0;
... ...
@@ -1205,10 +1201,15 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1205 1201
 
1206 1202
     free_sdp((sdp_info_t**) (void*) &msg->body);
1207 1203
 
1204
+    if (get_app_provided_party(msg, &app_provided_party) == -1) {
1205
+        LM_DBG("no valid Application-Provided-Called-Party-Address AVP provided\n");
1206
+    }
1207
+
1208 1208
     //create a session object without auth and diameter session id - we will add this later.
1209 1209
     new_session = build_new_ro_session(dir, 0, 0, &session_id, &dlg->callid,
1210 1210
             &asserted_identity, &called_asserted_identity, &mac, dlg->h_entry, dlg->h_id,
1211
-            reservation_units, 0, active_rating_group, active_service_identifier, incoming_trunk_id, outgoing_trunk_id, pani);
1211
+            reservation_units, 0, active_rating_group, active_service_identifier, incoming_trunk_id,
1212
+            outgoing_trunk_id, pani, &app_provided_party);
1212 1213
 
1213 1214
     if (!new_session) {
1214 1215
         LM_ERR("Couldn't create new Ro Session - this is BAD!\n");
... ...
@@ -1221,7 +1222,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1221 1222
     ssd->tlabel = tlabel;
1222 1223
     ssd->ro_session = new_session;
1223 1224
 
1224
-    if (!sip_create_ro_ccr_data(msg, dir, &ro_ccr_data, &cc_acc_session, asserted_identity, called_asserted_identity, subscription_id, subscription_id_type, incoming_trunk_id, outgoing_trunk_id, pani))
1225
+    if (!sip_create_ro_ccr_data(msg, dir, &ro_ccr_data, &cc_acc_session, asserted_identity, called_asserted_identity, subscription_id, subscription_id_type, incoming_trunk_id, outgoing_trunk_id, pani, &app_provided_party))
1225 1226
         goto error;
1226 1227
 
1227 1228
     if (!ro_ccr_data)
Browse code

ims_charging: bugfix for tel URIs, need the same logic in stop as in start requests

Henning Westerholt authored on 02/07/2020 16:05:51
Showing 1 changed files
... ...
@@ -914,6 +914,8 @@ void send_ccr_stop_with_param(struct ro_session *ro_session, unsigned int code,
914 914
     //getting subscription id type
915 915
     if (strncasecmp(subscr.id.s, "tel:", 4) == 0) {
916 916
         subscr.type = Subscription_Type_MSISDN;
917
+        subscr.id.s += 4;
918
+        subscr.id.len -= 4;
917 919
     } else {
918 920
         subscr.type = Subscription_Type_IMPU; //default is END_USER_SIP_URI
919 921
     }
Browse code

ims_charging: add support for Application-Provided-Called-Party-Address AVP

Henning Westerholt authored on 16/06/2020 19:49:17
Showing 1 changed files
... ...
@@ -35,6 +35,7 @@
35 35
 #include "ims_charging_stats.h"
36 36
 
37 37
 static pv_spec_t *custom_user_avp;		/*!< AVP for custom_user setting */
38
+static pv_spec_t *app_provided_party_avp;	/*!< AVP for app_provided_party setting */
38 39
 
39 40
 extern struct tm_binds tmb;
40 41
 extern struct cdp_binds cdpb;
... ...
@@ -77,6 +78,11 @@ void init_custom_user(pv_spec_t *custom_user_avp_p)
77 78
     custom_user_avp = custom_user_avp_p;
78 79
 }
79 80
 
81
+void init_app_provided_party(pv_spec_t *app_provided_party_avp_p)
82
+{
83
+    app_provided_party_avp = app_provided_party_avp_p;
84
+}
85
+
80 86
 /*!
81 87
  * \brief Return the custom_user for a record route
82 88
  * \param req SIP message
... ...
@@ -99,6 +105,29 @@ static int get_custom_user(struct sip_msg *req, str *custom_user) {
99 105
 	return -1;
100 106
 }
101 107
 
108
+/*!
109
+ * \brief Return the Application-Provided-Called-Party-Address
110
+ * \param req SIP message
111
+ * \param address to be returned
112
+ * \return <0 for failure
113
+ */
114
+static int get_app_provided_party(struct sip_msg *req, str *address) {
115
+	pv_value_t pv_val;
116
+
117
+	if (app_provided_party_avp) {
118
+		if ((pv_get_spec_value(req, app_provided_party_avp, &pv_val) == 0)
119
+				&& (pv_val.flags & PV_VAL_STR) && (pv_val.rs.len > 0)) {
120
+			address->s = pv_val.rs.s;
121
+			address->len = pv_val.rs.len;
122
+			return 0;
123
+		}
124
+		LM_DBG("invalid AVP value, no Application-Provided-Called-Party-Address\n");
125
+	}
126
+
127
+	return -1;
128
+}
129
+
130
+
102 131
 void credit_control_session_callback(int event, void* session) {
103 132
     switch (event) {
104 133
         case AUTH_EV_SESSION_DROP:
... ...
@@ -447,7 +476,8 @@ Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, A
447 476
     str user_name/* ={0,0}*/, sip_method = {0, 0}, event = {0, 0};
448 477
     uint32_t expires = 0;
449 478
     str callid = {0, 0}, to_uri = {0, 0}, from_uri = {0, 0},
450
-    icid = {0, 0}, orig_ioi = {0, 0}, term_ioi = {0, 0};
479
+    icid = {0, 0}, orig_ioi = {0, 0}, term_ioi = {0, 0},
480
+    app_provided_party = {0, 0};
451 481
 
452 482
     event_type_t * event_type = 0;
453 483
     ims_information_t * ims_info = 0;
... ...
@@ -478,8 +508,12 @@ Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, A
478 508
     if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, &reply_timestamp, NULL)))
479 509
         goto error;
480 510
 
511
+    if (get_app_provided_party(req, &app_provided_party) == -1) {
512
+        LM_DBG("no valid Application-Provided-Called-Party-Address AVP provided\n");
513
+    }
514
+
481 515
     if (!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &asserted_identity, &called_asserted_identity, &icid,
482
-            &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id, pani)))
516
+            &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id, pani, &app_provided_party)))
483 517
         goto error;
484 518
     LM_DBG("created IMS information\n");
485 519
     event_type = 0;
... ...
@@ -586,7 +620,8 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned
586 620
         goto error;
587 621
 
588 622
     if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity,
589
-            &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id, &ro_session->pani)))
623
+            &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id,
624
+            &ro_session->pani, &ro_session->app_provided_party)))
590 625
         goto error;
591 626
 
592 627
     LM_DBG("created IMS information\n");
... ...
@@ -859,7 +894,8 @@ void send_ccr_stop_with_param(struct ro_session *ro_session, unsigned int code,
859 894
         goto error0;
860 895
 
861 896
     if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity,
862
-            &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id, &ro_session->pani)))
897
+            &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id,
898
+            &ro_session->pani, &ro_session->app_provided_party)))
863 899
         goto error0;
864 900
 
865 901
     event_type = 0;
Browse code

ims_charging: add structured debug logging for key functions

Henning Westerholt authored on 10/06/2020 19:25:20
Showing 1 changed files
... ...
@@ -147,6 +147,7 @@ int Ro_add_avp_list(AAA_AVP_LIST *list, char *d, int len, int avp_code,
147 147
 
148 148
 int Ro_add_cc_request(AAAMessage *msg, unsigned int cc_request_type, unsigned int cc_request_number) {
149 149
     char x[4];
150
+    LM_DBG("add cc request %d\n", cc_request_type);
150 151
     set_4bytes(x, cc_request_type);
151 152
     int success = Ro_add_avp(msg, x, 4, AVP_CC_Request_Type, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
152 153
 
... ...
@@ -160,6 +161,7 @@ int Ro_add_cc_request(AAAMessage *msg, unsigned int cc_request_type, unsigned in
160 161
 int Ro_add_event_timestamp(AAAMessage *msg, time_t now) {
161 162
     char x[4];
162 163
     str s = {x, 4};
164
+    LM_DBG("add Event-Timestamp\n");
163 165
     uint32_t ntime = htonl(now + EPOCH_UNIX_TO_EPOCH_NTP);
164 166
     memcpy(x, &ntime, sizeof (uint32_t));
165 167
 
... ...
@@ -190,6 +192,7 @@ int Ro_add_user_equipment_info(AAAMessage *msg, unsigned int type, str value) {
190 192
 int Ro_add_termination_cause(AAAMessage *msg, unsigned int term_code) {
191 193
     char x[4];
192 194
     str s = {x, 4};
195
+    LM_DBG("add termination cause %d\n", term_code);
193 196
     uint32_t code = htonl(term_code);
194 197
     memcpy(x, &code, sizeof (uint32_t));
195 198
 
... ...
@@ -199,6 +202,7 @@ int Ro_add_termination_cause(AAAMessage *msg, unsigned int term_code) {
199 202
 int Ro_add_vendor_specific_termination_cause(AAAMessage *msg, unsigned int term_code) {
200 203
     char x[4];
201 204
     str s = {x, 4};
205
+    LM_DBG("add vendor specific termination cause %d\n", term_code);
202 206
     uint32_t code = htonl(term_code);
203 207
     memcpy(x, &code, sizeof (uint32_t));
204 208
 
... ...
@@ -206,6 +210,7 @@ int Ro_add_vendor_specific_termination_cause(AAAMessage *msg, unsigned int term_
206 210
 }
207 211
 
208 212
 int Ro_add_vendor_specific_termination_reason(AAAMessage *msg, str* reason) {
213
+    LM_DBG("add vendor specific termination reason: %.*s\n", reason->len, reason->s);
209 214
     return Ro_add_avp(msg, reason->s, reason->len, VS_TERMREASON, AAA_AVP_FLAG_VENDOR_SPECIFIC, 10, AVP_DUPLICATE_DATA, __FUNCTION__);
210 215
 }
211 216
 
... ...
@@ -217,6 +222,7 @@ int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used_unit,
217 222
     AAA_AVP_LIST used_list, mscc_list;
218 223
     str used_group;
219 224
 
225
+    LM_DBG("add multiple service credit control stop, used unit %d\n", used_unit);
220 226
     // Add Multiple-Services AVP Indicator
221 227
     set_4bytes(x, 1);
222 228
     Ro_add_avp(msg, x, 4, AVP_Multiple_Services_Indicator, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
... ...
@@ -270,6 +276,7 @@ int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int request
270 276
     mscc_list.head = 0;
271 277
     mscc_list.tail = 0;
272 278
 
279
+    LM_DBG("add multiple service credit control, requested unit %d\n", requested_unit);
273 280
     set_4bytes(x, requested_unit);
274 281
     Ro_add_avp_list(&list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
275 282
     group = cdpb.AAAGroupAVPS(list);
... ...
@@ -310,6 +317,8 @@ int Ro_add_subscription_id(AAAMessage *msg, unsigned int type, str *subscription
310 317
     list.head = 0;
311 318
     list.tail = 0;
312 319
 
320
+    LM_DBG("add Subscription-Id type %d, id %.*s\n", type, subscription_id->len, subscription_id->s);
321
+
313 322
     set_4bytes(x, type);
314 323
     Ro_add_avp_list(&list, x, 4, AVP_Subscription_Id_Type, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
315 324
 
... ...
@@ -338,14 +347,18 @@ int Ro_add_vendor_specific_appid(AAAMessage *msg, unsigned int vendor_id, unsign
338 347
     list.head = 0;
339 348
     list.tail = 0;
340 349
 
350
+    LM_DBG("add Vendor-Specific-Application-Id %d\n", vendor_id);
351
+
341 352
     set_4bytes(x, vendor_id);
342 353
     Ro_add_avp_list(&list, x, 4, AVP_Vendor_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
343 354
 
344 355
     if (auth_id) {
356
+        LM_DBG("adding Auth-Application-Id %d\n", auth_id);
345 357
         set_4bytes(x, auth_id);
346 358
         Ro_add_avp_list(&list, x, 4, AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
347 359
     }
348 360
     if (acct_id) {
361
+        LM_DBG("adding Acct-Application-Id %d\n", acct_id);
349 362
         set_4bytes(x, acct_id);
350 363
         Ro_add_avp_list(&list, x, 4, AVP_Acct_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
351 364
     }
... ...
@@ -468,10 +481,10 @@ Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, A
468 481
     if (!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &asserted_identity, &called_asserted_identity, &icid,
469 482
             &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id, pani)))
470 483
         goto error;
484
+    LM_DBG("created IMS information\n");
471 485
     event_type = 0;
472 486
     time_stamps = 0;
473 487
 
474
-
475 488
     subscr.id.s = subscription_id.s;
476 489
     subscr.id.len = subscription_id.len;
477 490
     subscr.type = subscription_id_type;
... ...
@@ -576,7 +589,7 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned
576 589
             &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id, &ro_session->pani)))
577 590
         goto error;
578 591
 
579
-    LM_DBG("Created IMS information\n");
592
+    LM_DBG("created IMS information\n");
580 593
 
581 594
     event_type = 0;
582 595
 
... ...
@@ -1163,6 +1176,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1163 1176
         LM_ERR("Couldn't create new Ro Session - this is BAD!\n");
1164 1177
         goto error;
1165 1178
     }
1179
+    LM_DBG("new session created\n");
1166 1180
 
1167 1181
     ssd->action = action;
1168 1182
     ssd->tindex = tindex;
Browse code

ims_charging: fix missing line-breaks for log messages

Henning Westerholt authored on 10/06/2020 11:50:51
Showing 1 changed files
... ...
@@ -380,10 +380,10 @@ int get_sip_header_info(struct sip_msg * req,
380 380
 
381 381
     if (get_custom_user(req, asserted_id_uri) == -1) {
382 382
 	    if ((*asserted_id_uri = cscf_get_asserted_identity(req, 0)).len == 0) {
383
-		LM_DBG("No P-Asserted-Identity hdr found. Using From hdr");
383
+		LM_DBG("No P-Asserted-Identity hdr found. Using From hdr\n");
384 384
 
385 385
 		if (!cscf_get_from_uri(req, asserted_id_uri)) {
386
-		    LM_ERR("Error assigning P-Asserted-Identity using From hdr");
386
+		    LM_ERR("Error assigning P-Asserted-Identity using From hdr\n");
387 387
 		    goto error;
388 388
 		}
389 389
 	    }
... ...
@@ -739,7 +739,7 @@ static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca,
739 739
     }
740 740
 
741 741
     if (ro_cca_data->resultcode != 2001) {
742
-        LM_ERR("Got bad CCA result code [%d] - reservation failed", ro_cca_data->resultcode);
742
+        LM_ERR("Got bad CCA result code [%d] - reservation failed\n", ro_cca_data->resultcode);
743 743
         error_or_timeout = 1;
744 744
         goto error;
745 745
     } else {
... ...
@@ -1073,7 +1073,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1073 1073
     //getting asserted identity
1074 1074
     if (get_custom_user(msg, &asserted_identity) == -1) {
1075 1075
       if ((asserted_identity = cscf_get_asserted_identity(msg, 0)).len == 0) {
1076
-          LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity");
1076
+          LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity\n");
1077 1077
           asserted_identity = dlg->from_uri;
1078 1078
           if (asserted_identity.len > 0 && asserted_identity.s) {
1079 1079
               p=(char*)memchr(asserted_identity.s, ';',asserted_identity.len);
... ...
@@ -1085,7 +1085,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1085 1085
 
1086 1086
     //getting called asserted identity
1087 1087
     if ((called_asserted_identity = cscf_get_public_identity_from_called_party_id(msg, &h)).len == 0) {
1088
-        LM_DBG("No P-Called-Identity hdr found. Using request URI for called_asserted_identity");
1088
+        LM_DBG("No P-Called-Identity hdr found. Using request URI for called_asserted_identity\n");
1089 1089
         called_asserted_identity = cscf_get_public_identity_from_requri(msg);
1090 1090
         free_called_asserted_identity = 1;
1091 1091
     }
... ...
@@ -1113,11 +1113,11 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1113 1113
 
1114 1114
     str mac = {0, 0};
1115 1115
     if (get_mac_avp_value(msg, &mac) != 0)
1116
-        LM_DBG(RO_MAC_AVP_NAME" was not set. Using default.");
1116
+        LM_DBG(RO_MAC_AVP_NAME" was not set. Using default.\n");
1117 1117
 
1118 1118
     //by default we use voice service id and rate group
1119 1119
     //then we check SDP - if we find video then we use video service id and rate group
1120
-    LM_DBG("Setting default SID to %d and RG to %d for voice",
1120
+    LM_DBG("Setting default SID to %d and RG to %d for voice\n",
1121 1121
             voice_service_identifier, voice_rating_group);
1122 1122
     active_service_identifier = voice_service_identifier;
1123 1123
     active_rating_group = voice_rating_group;
... ...
@@ -1141,7 +1141,7 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1141 1141
 
1142 1142
             int intportA = atoi(msg_sdp_stream->port.s);
1143 1143
             if (intportA != 0 && strncasecmp(msg_sdp_stream->media.s, "video", 5) == 0) {
1144
-                LM_DBG("This SDP has a video component and src ports not equal to 0 - so we set default SID to %d and RG to %d for video",
1144
+                LM_DBG("This SDP has a video component and src ports not equal to 0 - so we set default SID to %d and RG to %d for video\n",
1145 1145
                         video_service_identifier, video_rating_group);
1146 1146
                 active_service_identifier = video_service_identifier;
1147 1147
                 active_rating_group = video_rating_group;
... ...
@@ -1342,7 +1342,7 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
1342 1342
 
1343 1343
 		if (fui_action == AVP_Final_Unit_Action_Redirect) {
1344 1344
 			if (ro_cca_data->mscc->final_unit_action->redirect_server) {
1345
-				LM_DBG("FUI with action: [%d]", ro_cca_data->mscc->final_unit_action->action);
1345
+				LM_DBG("FUI with action: [%d]\n", ro_cca_data->mscc->final_unit_action->action);
1346 1346
 
1347 1347
 				if (ro_cca_data->mscc->final_unit_action->action == AVP_Final_Unit_Action_Redirect) {
1348 1348
 					LM_DBG("Have REDIRECT action with address type of [%d]\n", ro_cca_data->mscc->final_unit_action->redirect_server->address_type);
... ...
@@ -1376,7 +1376,7 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
1376 1376
             ro_cca_data->mscc->validity_time);
1377 1377
 
1378 1378
     if (ro_cca_data->mscc->granted_service_unit->cc_time <= 0) {
1379
-        LM_DBG("got zero GSU.... reservation failed");
1379
+        LM_DBG("got zero GSU.... reservation failed\n");
1380 1380
         error_code = RO_RETURN_FALSE;
1381 1381
         goto error1;
1382 1382
     }
... ...
@@ -1482,7 +1482,7 @@ static int create_cca_return_code(int result) {
1482 1482
             if (result >= 0)
1483 1483
                 break;
1484 1484
 
1485
-            LM_ERR("Unknown result code: %d", result);
1485
+            LM_ERR("Unknown result code: %d\n", result);
1486 1486
             avp_val.s.s = "??";
1487 1487
     }
1488 1488
 
Browse code

ims_charging: use extern to avoid double declaration of globals

Daniel-Constantin Mierla authored on 05/03/2020 12:45:36
Showing 1 changed files
... ...
@@ -54,10 +54,10 @@ struct session_setup_data {
54 54
     unsigned int tlabel;
55 55
 };
56 56
 
57
-struct dlg_binds* dlgb_p;
57
+extern struct dlg_binds* dlgb_p;
58 58
 extern struct tm_binds tmb;
59 59
 
60
-int interim_request_credits;
60
+extern int interim_request_credits;
61 61
 
62 62
 extern int voice_service_identifier;
63 63
 extern int voice_rating_group;
Browse code

ims_charging: In case of tel: URI => type MSISDN, skip the "tel:" from the URI

Carsten Bock authored on 18/09/2018 08:31:57
Showing 1 changed files
... ...
@@ -1105,6 +1105,8 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1105 1105
     //getting subscription id type
1106 1106
     if (strncasecmp(subscription_id.s, "tel:", 4) == 0) {
1107 1107
         subscription_id_type = Subscription_Type_MSISDN;
1108
+        subscription_id.s += 4;
1109
+        subscription_id.len -= 4;
1108 1110
     } else {
1109 1111
         subscription_id_type = Subscription_Type_IMPU; //default is END_USER_SIP_URI
1110 1112
     }
Browse code

ims_charging: Use the "custom_user_avp" also in other places, where the user is retrieved (aligning request with the docs)

Carsten Bock authored on 26/04/2018 09:38:44
Showing 1 changed files
... ...
@@ -660,7 +660,7 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned
660 660
     LM_DBG("Sending CCR Diameter message.\n");
661 661
     ro_session->last_event_timestamp_backup = ro_session->last_event_timestamp;
662 662
     ro_session->last_event_timestamp = get_current_time_micro(); /*this is to make sure that if we get a term request now that we don't double bill for this time we are about to bill for in the interim */
663
-    
663
+
664 664
     cdpb.AAASessionsUnlock(auth->hash);
665 665
 
666 666
     if (ro_forced_peer.len > 0) {
... ...
@@ -760,7 +760,7 @@ static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca,
760 760
     goto success;
761 761
 
762 762
 error:
763
-    counter_inc(ims_charging_cnts_h.failed_interim_ccr);  
763
+    counter_inc(ims_charging_cnts_h.failed_interim_ccr);
764 764
     if (ro_cca_data)
765 765
         Ro_free_CCA(ro_cca_data);
766 766
 
... ...
@@ -985,7 +985,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
985 985
 
986 986
     if (!cca) {
987 987
         LM_ERR("Error in termination CCR.\n");
988
-        counter_inc(ims_charging_cnts_h.failed_final_ccrs); 
988
+        counter_inc(ims_charging_cnts_h.failed_final_ccrs);
989 989
         return;
990 990
     }
991 991
 
... ...
@@ -993,7 +993,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
993 993
 
994 994
     if (ro_cca_data == NULL) {
995 995
         LM_DBG("Could not parse CCA message response.\n");
996
-        counter_inc(ims_charging_cnts_h.failed_final_ccrs); 
996
+        counter_inc(ims_charging_cnts_h.failed_final_ccrs);
997 997
         return;
998 998
     }
999 999
 
... ...
@@ -1012,7 +1012,7 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
1012 1012
     return;
1013 1013
 
1014 1014
 error:
1015
-    counter_inc(ims_charging_cnts_h.failed_final_ccrs);      
1015
+    counter_inc(ims_charging_cnts_h.failed_final_ccrs);
1016 1016
     Ro_free_CCA(ro_cca_data);
1017 1017
     if (!is_timeout && cca) {
1018 1018
         cdpb.AAAFreeMessage(&cca);
... ...
@@ -1071,14 +1071,16 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1071 1071
     }
1072 1072
 
1073 1073
     //getting asserted identity
1074
-    if ((asserted_identity = cscf_get_asserted_identity(msg, 0)).len == 0) {
1075
-        LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity");
1076
-        asserted_identity = dlg->from_uri;
1077
-        if (asserted_identity.len > 0 && asserted_identity.s) {
1078
-            p=(char*)memchr(asserted_identity.s, ';',asserted_identity.len);
1079
-            if (p) 
1080
-                asserted_identity.len = (p-asserted_identity.s);
1081
-        }
1074
+    if (get_custom_user(msg, &asserted_identity) == -1) {
1075
+      if ((asserted_identity = cscf_get_asserted_identity(msg, 0)).len == 0) {
1076
+          LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity");
1077
+          asserted_identity = dlg->from_uri;
1078
+          if (asserted_identity.len > 0 && asserted_identity.s) {
1079
+              p=(char*)memchr(asserted_identity.s, ';',asserted_identity.len);
1080
+              if (p)
1081
+                  asserted_identity.len = (p-asserted_identity.s);
1082
+          }
1083
+      }
1082 1084
     }
1083 1085
 
1084 1086
     //getting called asserted identity
... ...
@@ -1251,13 +1253,13 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
1251 1253
     counter_inc(ims_charging_cnts_h.initial_ccrs);
1252 1254
     counter_inc(ims_charging_cnts_h.active_ro_sessions);
1253 1255
 
1254
-    if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri	
1256
+    if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri
1255 1257
     return RO_RETURN_BREAK;
1256 1258
 
1257 1259
 error:
1258 1260
     LM_DBG("Trying to reserve credit on initial INVITE failed.\n");
1259 1261
 
1260
-    if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri	
1262
+    if (free_called_asserted_identity) shm_free(called_asserted_identity.s); // shm_malloc in cscf_get_public_identity_from_requri
1261 1263
     Ro_free_CCR(ro_ccr_data);
1262 1264
     if (cc_acc_session) {
1263 1265
         cdpb.AAASessionsUnlock(cc_acc_session->hash);
... ...
@@ -1323,7 +1325,7 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
1323 1325
 		create_cca_result_code(0);
1324 1326
         goto error0;
1325 1327
     }
1326
-    
1328
+
1327 1329
     LM_DBG("Ro result code is [%d]\n", (int)ro_cca_data->resultcode);
1328 1330
     create_cca_result_code((int)ro_cca_data->resultcode);
1329 1331
     if (ro_cca_data->resultcode != 2001) {
... ...
@@ -1356,10 +1358,10 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
1356 1358
 			}
1357 1359
 		}
1358 1360
 	}
1359
-	
1361
+
1360 1362
 	/* create the AVPs cca_redirect_uri and cca_fui_action  for export to cfg file */
1361 1363
 	create_cca_fui_avps(fui_action, redirecturi);
1362
-	
1364
+
1363 1365
 	/* check result code at mscc level */
1364 1366
 	if (ro_cca_data->mscc->resultcode && ro_cca_data->mscc->resultcode != 2001) {
1365 1367
 		LM_DBG("CCA failure at MSCC level with resultcode [%d]\n", ro_cca_data->mscc->resultcode);
... ...
@@ -1391,7 +1393,7 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
1391 1393
     LM_DBG("Freeing CCA message\n");
1392 1394
     cdpb.AAAFreeMessage(&cca);
1393 1395
 
1394
-    link_ro_session(ssd->ro_session, 0); 
1396
+    link_ro_session(ssd->ro_session, 0);
1395 1397
 
1396 1398
     if (ro_db_mode == DB_MODE_REALTIME) {
1397 1399
         ssd->ro_session->flags |= RO_SESSION_FLAG_NEW;
... ...
@@ -1524,7 +1526,7 @@ static int create_cca_fui_avps(int action, str* redirecturi) {
1524 1526
     redirecturi_avp_name.s.len = RO_AVP_CCA_FUI_REDIRECT_URI_LENGTH;
1525 1527
     char buf[10];
1526 1528
 	int rc;
1527
-	
1529
+
1528 1530
     action_avp_val.n = action;
1529 1531
     action_avp_val.s.len = snprintf(buf, 10, "%i", action);
1530 1532
     action_avp_val.s.s = buf;
... ...
@@ -1535,7 +1537,7 @@ static int create_cca_fui_avps(int action, str* redirecturi) {
1535 1537
         LM_ERR("Couldn't create ["RO_AVP_CCA_FUI_ACTION"] AVP\n");
1536 1538
     else
1537 1539
         LM_DBG("Created AVP ["RO_AVP_CCA_FUI_ACTION"] successfully: value=[%d]\n", action);
1538
-	
1540
+
1539 1541
 	if (redirecturi && redirecturi->len >0 && redirecturi->s) {
1540 1542
 		redirecturi_avp_val.s.len = redirecturi->len;
1541 1543
 		redirecturi_avp_val.s.s = redirecturi->s;
... ...
@@ -1547,7 +1549,7 @@ static int create_cca_fui_avps(int action, str* redirecturi) {
1547 1549
 		else
1548 1550
 			LM_DBG("Created AVP ["RO_AVP_CCA_FUI_REDIRECT_URI"] successfully: value=[%.*s]\n", redirecturi->len, redirecturi->s);
1549 1551
 	}
1550
-	
1552
+
1551 1553
     return 1;
1552 1554
 }
1553 1555
 
Browse code

ims_charging: fixed check result code at mscc level (#1504)

* ims_charging: fixed check result code at mscc level

according to RFC 4006 the Result-Code in Multiple-Services-Credit-Control AVP is optional.
resume_on_initial_ccr() stops proceeding CCA if no Result-Code in MSCC and goes to error1 even though
the Result-Code on CCR itself is 2001 (SUCCESSFUL)

* ims_charging: fixed check result code at mscc level

according to RFC 4006 the Result-Code in Multiple-Services-Credit-Control AVP is optional.
resume_on_initial_ccr() stops proceeding CCA if no Result-Code in MSCC and goes to error1 even though
the Result-Code on CCR itself is 2001 (SUCCESSFUL)

yuri-r authored on 24/04/2018 10:39:07 • Daniel-Constantin Mierla committed on 24/04/2018 10:39:07
Showing 1 changed files
... ...
@@ -1361,7 +1361,7 @@ static void resume_on_initial_ccr(int is_timeout, void *param, AAAMessage *cca,
1361 1361
 	create_cca_fui_avps(fui_action, redirecturi);
1362 1362
 	
1363 1363
 	/* check result code at mscc level */
1364
-	if (ro_cca_data->mscc->resultcode != 2001) {
1364
+	if (ro_cca_data->mscc->resultcode && ro_cca_data->mscc->resultcode != 2001) {
1365 1365
 		LM_DBG("CCA failure at MSCC level with resultcode [%d]\n", ro_cca_data->mscc->resultcode);
1366 1366
 		error_code = RO_RETURN_FALSE;
1367 1367
         goto error1;
Browse code

ims_charging: remove inline to functions that break the symbol linking

Daniel-Constantin Mierla authored on 09/12/2017 12:49:35
Showing 1 changed files
... ...
@@ -83,7 +83,7 @@ void init_custom_user(pv_spec_t *custom_user_avp_p)
83 83
  * \param custom_user to be returned
84 84
  * \return <0 for failure
85 85
  */
86
-inline static int get_custom_user(struct sip_msg *req, str *custom_user) {
86
+static int get_custom_user(struct sip_msg *req, str *custom_user) {
87 87
 	pv_value_t pv_val;
88 88
 
89 89
 	if (custom_user_avp) {
... ...
@@ -121,7 +121,7 @@ void credit_control_session_callback(int event, void* session) {
121 121
  * @param func - the name of the calling function, for debugging purposes
122 122
  * @returns 1 on success or 0 on failure
123 123
  */
124
-inline int Ro_add_avp_list(AAA_AVP_LIST *list, char *d, int len, int avp_code,
124
+int Ro_add_avp_list(AAA_AVP_LIST *list, char *d, int len, int avp_code,
125 125
         int flags, int vendorid, int data_do, const char *func) {
126 126
     AAA_AVP *avp;
127 127
     if (vendorid != 0) flags |= AAA_AVP_FLAG_VENDOR_SPECIFIC;
... ...
@@ -145,7 +145,7 @@ inline int Ro_add_avp_list(AAA_AVP_LIST *list, char *d, int len, int avp_code,
145 145
     return 1;
146 146
 }
147 147
 
148
-inline int Ro_add_cc_request(AAAMessage *msg, unsigned int cc_request_type, unsigned int cc_request_number) {
148
+int Ro_add_cc_request(AAAMessage *msg, unsigned int cc_request_type, unsigned int cc_request_number) {
149 149
     char x[4];
150 150
     set_4bytes(x, cc_request_type);
151 151
     int success = Ro_add_avp(msg, x, 4, AVP_CC_Request_Type, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
... ...
@@ -157,7 +157,7 @@ inline int Ro_add_cc_request(AAAMessage *msg, unsigned int cc_request_type, unsi
157 157
 
158 158
 }
159 159
 
160
-inline int Ro_add_event_timestamp(AAAMessage *msg, time_t now) {
160
+int Ro_add_event_timestamp(AAAMessage *msg, time_t now) {
161 161
     char x[4];
162 162
     str s = {x, 4};
163 163
     uint32_t ntime = htonl(now + EPOCH_UNIX_TO_EPOCH_NTP);
... ...
@@ -167,7 +167,7 @@ inline int Ro_add_event_timestamp(AAAMessage *msg, time_t now) {
167 167
 
168 168
 }
169 169
 
170
-inline int Ro_add_user_equipment_info(AAAMessage *msg, unsigned int type, str value) {
170
+int Ro_add_user_equipment_info(AAAMessage *msg, unsigned int type, str value) {
171 171
     AAA_AVP_LIST list;
172 172
     str group;
173 173
     char x[4];
... ...
@@ -187,7 +187,7 @@ inline int Ro_add_user_equipment_info(AAAMessage *msg, unsigned int type, str va
187 187
     return Ro_add_avp(msg, group.s, group.len, AVP_User_Equipment_Info, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
188 188
 }
189 189
 
190
-inline int Ro_add_termination_cause(AAAMessage *msg, unsigned int term_code) {
190
+int Ro_add_termination_cause(AAAMessage *msg, unsigned int term_code) {
191 191
     char x[4];
192 192
     str s = {x, 4};
193 193
     uint32_t code = htonl(term_code);
... ...
@@ -196,7 +196,7 @@ inline int Ro_add_termination_cause(AAAMessage *msg, unsigned int term_code) {
196 196
     return Ro_add_avp(msg, s.s, s.len, AVP_Termination_Cause, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
197 197
 }
198 198
 
199
-inline int Ro_add_vendor_specific_termination_cause(AAAMessage *msg, unsigned int term_code) {
199
+int Ro_add_vendor_specific_termination_cause(AAAMessage *msg, unsigned int term_code) {
200 200
     char x[4];
201 201
     str s = {x, 4};
202 202
     uint32_t code = htonl(term_code);
... ...
@@ -205,14 +205,14 @@ inline int Ro_add_vendor_specific_termination_cause(AAAMessage *msg, unsigned in
205 205
     return Ro_add_avp(msg, s.s, s.len, VS_TERMCODE, AAA_AVP_FLAG_VENDOR_SPECIFIC, 10, AVP_DUPLICATE_DATA, __FUNCTION__);
206 206
 }
207 207
 
208
-inline int Ro_add_vendor_specific_termination_reason(AAAMessage *msg, str* reason) {
208
+int Ro_add_vendor_specific_termination_reason(AAAMessage *msg, str* reason) {
209 209
     return Ro_add_avp(msg, reason->s, reason->len, VS_TERMREASON, AAA_AVP_FLAG_VENDOR_SPECIFIC, 10, AVP_DUPLICATE_DATA, __FUNCTION__);
210 210
 }
211 211
 
212 212
 
213 213
 
214 214
 /* called only when building stop record AVPS */
215
-inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used_unit, int active_rating_group, int active_service_identifier) {
215
+int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used_unit, int active_rating_group, int active_service_identifier) {
216 216
     char x[4];
217 217
     AAA_AVP_LIST used_list, mscc_list;
218 218
     str used_group;
... ...
@@ -254,7 +254,7 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used
254 254
     return Ro_add_avp(msg, used_group.s, used_group.len, AVP_Multiple_Services_Credit_Control, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
255 255
 }
256 256
 
257
-inline int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int requested_unit, int used_unit, int active_rating_group, int active_service_identifier) {
257
+int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int requested_unit, int used_unit, int active_rating_group, int active_service_identifier) {
258 258
     // Add Multiple-Services AVP Indicator
259 259
     char x[4];
260 260
     set_4bytes(x, 1);
... ...
@@ -301,7 +301,7 @@ inline int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int
301 301
     return Ro_add_avp(msg, group.s, group.len, AVP_Multiple_Services_Credit_Control, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
302 302
 }
303 303
 
304
-inline int Ro_add_subscription_id(AAAMessage *msg, unsigned int type, str *subscription_id)//, struct sip_msg* sip_msg)
304
+int Ro_add_subscription_id(AAAMessage *msg, unsigned int type, str *subscription_id)//, struct sip_msg* sip_msg)
305 305
 {
306 306
     AAA_AVP_LIST list;
307 307
     str group;
... ...
@@ -330,7 +330,7 @@ inline int Ro_add_subscription_id(AAAMessage *msg, unsigned int type, str *subsc
330 330
  * @param acct_id - the accounting application id
331 331
  * @returns 1 on success or 0 on error
332 332
  */
333
-inline int Ro_add_vendor_specific_appid(AAAMessage *msg, unsigned int vendor_id, unsigned int auth_id, unsigned int acct_id) {
333
+int Ro_add_vendor_specific_appid(AAAMessage *msg, unsigned int vendor_id, unsigned int auth_id, unsigned int acct_id) {
334 334
     AAA_AVP_LIST list;
335 335
     str group;
336 336
     char x[4];
Browse code

ims_charging: Add a custom_user_avp parameter, to allow a custom from user in Diameter rather than PAI/From

Carsten Bock authored on 09/03/2017 08:40:53
Showing 1 changed files
... ...
@@ -34,6 +34,8 @@
34 34
 #include "ro_db_handler.h"
35 35
 #include "ims_charging_stats.h"
36 36
 
37
+static pv_spec_t *custom_user_avp;		/*!< AVP for custom_user setting */
38
+
37 39
 extern struct tm_binds tmb;
38 40
 extern struct cdp_binds cdpb;
39 41
 extern client_ro_cfg cfg;
... ...
@@ -70,6 +72,33 @@ static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca,
70 72
 static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *cca, long elapsed_msecs);
71 73
 static int get_mac_avp_value(struct sip_msg *msg, str *value);
72 74
 
75
+void init_custom_user(pv_spec_t *custom_user_avp_p)
76
+{
77
+    custom_user_avp = custom_user_avp_p;
78
+}
79
+
80
+/*!
81
+ * \brief Return the custom_user for a record route
82
+ * \param req SIP message
83
+ * \param custom_user to be returned
84
+ * \return <0 for failure
85
+ */
86
+inline static int get_custom_user(struct sip_msg *req, str *custom_user) {
87
+	pv_value_t pv_val;
88
+
89
+	if (custom_user_avp) {
90
+		if ((pv_get_spec_value(req, custom_user_avp, &pv_val) == 0)
91
+				&& (pv_val.flags & PV_VAL_STR) && (pv_val.rs.len > 0)) {
92
+			custom_user->s = pv_val.rs.s;
93
+			custom_user->len = pv_val.rs.len;
94
+			return 0;
95
+		}
96
+		LM_DBG("invalid AVP value, using default user from P-Asserted-Identity/From-Header\n");
97
+	}
98
+
99
+	return -1;
100
+}
101
+
73 102
 void credit_control_session_callback(int event, void* session) {
74 103
     switch (event) {
75 104
         case AUTH_EV_SESSION_DROP:
... ...
@@ -349,13 +378,15 @@ int get_sip_header_info(struct sip_msg * req,
349 378
     *expires = cscf_get_expires_hdr(req, 0);
350 379
     *callid = cscf_get_call_id(req, NULL);
351 380
 
352
-    if ((*asserted_id_uri = cscf_get_asserted_identity(req, 0)).len == 0) {
353
-        LM_DBG("No P-Asserted-Identity hdr found. Using From hdr");
381
+    if (get_custom_user(req, asserted_id_uri) == -1) {
382
+	    if ((*asserted_id_uri = cscf_get_asserted_identity(req, 0)).len == 0) {
383
+		LM_DBG("No P-Asserted-Identity hdr found. Using From hdr");
354 384
 
355
-        if (!cscf_get_from_uri(req, asserted_id_uri)) {
356
-            LM_ERR("Error assigning P-Asserted-Identity using From hdr");
357
-            goto error;
358
-        }
385
+		if (!cscf_get_from_uri(req, asserted_id_uri)) {
386
+		    LM_ERR("Error assigning P-Asserted-Identity using From hdr");
387
+		    goto error;
388
+		}
389
+	    }
359 390
     }
360 391
 
361 392
     *to_uri = req->first_line.u.request.uri;
Browse code

ims_charging: Rename module interface file #82

Victor Seva authored on 13/02/2017 14:27:40
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-#include "mod.h"
1
+#include "ims_charging_mod.h"
2 2
 
3 3
 #include <math.h>
4 4
 #include "../../core/parser/msg_parser.h"
Browse code

core, lib, modules: updated include paths for header files

Daniel-Constantin Mierla authored on 07/12/2016 11:07:22
Showing 1 changed files
... ...
@@ -1,12 +1,12 @@
1 1
 #include "mod.h"
2 2
 
3 3
 #include <math.h>
4
-#include "../../parser/msg_parser.h"
5
-#include "../../parser/parse_uri.h"
6