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