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 3 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)
... ...
@@ -196,11 +196,11 @@ void destroy_dlg_table(void) {
196 196
 
197 197
 struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_session_type, str *session_id, str *callid, str *asserted_identity, 
198 198
 	str* called_asserted_identity, str* mac, unsigned int dlg_h_entry, unsigned int dlg_h_id, unsigned int requested_secs, unsigned int validity_timeout,
199
-	int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id, str *pani){
199
+	int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id, str *pani, str *app_provided_party){
200 200
     LM_DBG("Building Ro Session **********\n");
201 201
     char *p;
202 202
     unsigned int len = /*session_id->len + */callid->len + asserted_identity->len + called_asserted_identity->len + mac->len + 
203
-        incoming_trunk_id->len + outgoing_trunk_id->len + pani->len + sizeof (struct ro_session);
203
+        incoming_trunk_id->len + outgoing_trunk_id->len + pani->len + app_provided_party->len + sizeof (struct ro_session);
204 204
     struct ro_session *new_ro_session = (struct ro_session*) shm_malloc(len);
205 205
 
206 206
     if (!new_ro_session) {
... ...
@@ -276,6 +276,11 @@ struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_
276 276
     new_ro_session->pani.len = pani->len;
277 277
     p += pani->len;
278 278
 
279
+    new_ro_session->app_provided_party.s = p;
280
+    memcpy(p, app_provided_party->s, app_provided_party->len);
281
+    new_ro_session->app_provided_party.len = app_provided_party->len;
282
+    p += app_provided_party->len;
283
+
279 284
     if (p != (((char*) new_ro_session) + len)) {
280 285
         LM_ERR("buffer overflow\n");
281 286
         shm_free(new_ro_session);
... ...
@@ -208,7 +208,7 @@ void remove_aaa_session(str *session_id);
208 208
 
209 209
 struct ro_session* build_new_ro_session(int direction, int auth_appid, int auth_session_type, str *session_id, str *callid, str *asserted_identity, str* called_asserted_identity,
210 210
         str* mac, unsigned int dlg_h_entry, unsigned int dlg_h_id, unsigned int requested_secs, unsigned int validity_timeout,
211
-        int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id, str *pani);
211
+        int active_rating_group, int active_service_identifier, str *incoming_trunk_id, str *outgoing_trunk_id, str *pani, str *app_provided_party);
212 212
 
213 213
 /*!
214 214
  * \brief Refefence a ro_session with locking