Browse code

modules/ims_charging: changed stats to use counters instead

Jason Penton authored on 25/02/2015 09:05:08
Showing 7 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,66 @@
0
+#include "ims_charging_stats.h"
1
+
2
+struct ims_charging_counters_h ims_charging_cnts_h;
3
+enum sctp_info_req { IMS_CHARGING_AVG_RSP, IMS_CHARGING_FAILED_INITIAL, IMS_CHARGING_FAILED_FINAL, IMS_CHARGING_FAILED_INTERIM };
4
+
5
+static counter_val_t ims_charging_internal_stats(counter_handle_t h, void* what);
6
+
7
+counter_def_t ims_charging_cnt_defs[] = {
8
+    {&ims_charging_cnts_h.active_ro_sessions,	    "active_ro_sessions",	0, 0, 0,			    "number of currently active Ro sessions"},
9
+    {&ims_charging_cnts_h.billed_secs,		    "billed_secs",		0, 0, 0,			    "total number of seconds billed since start or reset"},
10
+    {&ims_charging_cnts_h.ccr_avg_response_time,    "ccr_avg_response_time",	0, ims_charging_internal_stats, (void*) (long) IMS_CHARGING_AVG_RSP,	"avg response time for CCRs"},
11
+    {&ims_charging_cnts_h.ccr_response_time,	    "ccr_response_time",	0, 0, 0,			    "total number of seconds waiting for CCR responses"},
12
+    {&ims_charging_cnts_h.ccr_timeouts,		    "ccr_timeouts",		0, 0, 0,			    "total number of CCR timeouts"},
13
+    {&ims_charging_cnts_h.failed_final_ccrs,	    "failed_final_ccrs",	0, 0, 0,			    "total number of failed final CCRs"},
14
+    {&ims_charging_cnts_h.failed_initial_ccrs,	    "failed_initial_ccrs",	0, 0, 0,			    "total number of failed initial CCRs"},
15
+    {&ims_charging_cnts_h.failed_interim_ccr,	    "failed_interim_ccrs",	0, 0, 0,			    "total number of failed interim CCRs"},
16
+    {&ims_charging_cnts_h.final_ccrs,		    "final_ccrs",		0, 0, 0,			    "total number of final (terminating) CCRs"},
17
+    {&ims_charging_cnts_h.initial_ccrs,		    "initial_ccrs",		0, 0, 0,			    "total number of initial CCRs"},
18
+    {&ims_charging_cnts_h.interim_ccrs,		    "interim_ccrs",		0, 0, 0,			    "total number of interim CCRs"},
19
+    {&ims_charging_cnts_h.killed_calls,		    "killed_calls",		0, 0, 0,			    "total number of killed calls"},
20
+    {&ims_charging_cnts_h.successful_final_ccrs,    "successful_final_ccrs",	0, 0, 0,			    "total number of successful final CCRs"},
21
+    {&ims_charging_cnts_h.successful_initial_ccrs,  "successful_initial_ccrs",	0, 0, 0,			    "total number of successful initial CCRs"},
22
+    {&ims_charging_cnts_h.successful_interim_ccrs,   "successful_interim_ccrs",	0, 0, 0,			    "total number of successful interim CCRs"},
23
+    {0, 0, 0, 0, 0, 0}
24
+};
25
+
26
+int ims_charging_init_counters() {
27
+    if (counter_register_array("ims_charging", ims_charging_cnt_defs) < 0)
28
+	goto error;
29
+    return 0;
30
+error:
31
+    return -1;
32
+}
33
+
34
+void ims_charging_destroy_counters() {
35
+    
36
+}
37
+
38
+/** helper function for some stats (which are kept internally).
39
+ */
40
+static counter_val_t ims_charging_internal_stats(counter_handle_t h, void* what) {
41
+    enum sctp_info_req w;
42
+
43
+    w = (int) (long) what;
44
+    switch (w) {
45
+	case IMS_CHARGING_AVG_RSP:
46
+	    if ((counter_get_val(ims_charging_cnts_h.initial_ccrs) + counter_get_val(ims_charging_cnts_h.interim_ccrs) + counter_get_val(ims_charging_cnts_h.final_ccrs)) == 0) 
47
+		return 0;
48
+	    else
49
+		return counter_get_val(ims_charging_cnts_h.ccr_response_time)/
50
+			(counter_get_val(ims_charging_cnts_h.initial_ccrs) + counter_get_val(ims_charging_cnts_h.interim_ccrs) + counter_get_val(ims_charging_cnts_h.final_ccrs));
51
+	    break;
52
+	case IMS_CHARGING_FAILED_INITIAL:
53
+	    return (counter_get_val(ims_charging_cnts_h.initial_ccrs) - counter_get_val(ims_charging_cnts_h.successful_initial_ccrs));
54
+	    break;
55
+	case IMS_CHARGING_FAILED_INTERIM:
56
+	    return (counter_get_val(ims_charging_cnts_h.interim_ccrs) - counter_get_val(ims_charging_cnts_h.successful_interim_ccrs));
57
+	    break;
58
+	case IMS_CHARGING_FAILED_FINAL:
59
+	    return (counter_get_val(ims_charging_cnts_h.final_ccrs) - counter_get_val(ims_charging_cnts_h.successful_final_ccrs));
60
+	    break;
61
+	default:
62
+	    return 0;
63
+    };
64
+    return 0;
65
+}
0 66
new file mode 100644
... ...
@@ -0,0 +1,37 @@
0
+/* 
1
+ * File:   ims_charging_stats.h
2
+ * Author: jaybeepee
3
+ *
4
+ * Created on 24 February 2015, 11:15 AM
5
+ */
6
+
7
+#ifndef IMS_CHARGING_STATS_H
8
+#define	IMS_CHARGING_STATS_H
9
+
10
+#include "../../counters.h"
11
+
12
+struct ims_charging_counters_h {
13
+    counter_handle_t billed_secs;
14
+    counter_handle_t ccr_avg_response_time;
15
+    counter_handle_t ccr_response_time;
16
+    counter_handle_t ccr_timeouts;
17
+    counter_handle_t failed_final_ccrs;
18
+    counter_handle_t failed_initial_ccrs;
19
+    counter_handle_t failed_interim_ccr;
20
+    counter_handle_t final_ccrs;
21
+    counter_handle_t initial_ccrs;
22
+    counter_handle_t interim_ccrs;
23
+    counter_handle_t killed_calls;
24
+    counter_handle_t successful_final_ccrs;
25
+    counter_handle_t successful_initial_ccrs;
26
+    counter_handle_t successful_interim_ccrs;
27
+    counter_handle_t active_ro_sessions;
28
+};
29
+
30
+int ims_charging_init_counters();
31
+void ims_charging_destroy_counters();
32
+
33
+#endif	/* IMS_CHARGING_STATS_H */
34
+
35
+
36
+
... ...
@@ -29,9 +29,9 @@
29 29
 #include "ccr.h"
30 30
 #include "config.h"
31 31
 #include "ro_session_hash.h"
32
-#include "stats.h"
33 32
 #include "ro_avp.h"
34 33
 #include "ro_db_handler.h"
34
+#include "ims_charging_stats.h"
35 35
 
36 36
 extern struct tm_binds tmb;
37 37
 extern struct cdp_binds cdpb;
... ...
@@ -40,13 +40,13 @@ extern struct dlg_binds dlgb;
40 40
 extern cdp_avp_bind_t *cdp_avp;
41 41
 extern str ro_forced_peer;
42 42
 extern int ro_db_mode;
43
+extern struct ims_charging_counters_h ims_charging_cnts_h;
43 44
 
44 45
 struct session_setup_data {
45
-	struct ro_session *ro_session;
46
-
47
-	cfg_action_t* action;
48
-	unsigned int tindex;
49
-	unsigned int tlabel;
46
+    struct ro_session *ro_session;
47
+    cfg_action_t* action;
48
+    unsigned int tindex;
49
+    unsigned int tlabel;
50 50
 };
51 51
 
52 52
 struct dlg_binds* dlgb_p;
... ...
@@ -66,17 +66,15 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
66 66
 static int get_mac_avp_value(struct sip_msg *msg, str *value);
67 67
 
68 68
 void credit_control_session_callback(int event, void* session) {
69
-	switch (event) {
70
-		case AUTH_EV_SESSION_DROP:
71
-			LM_DBG("Received notification of CC App session drop - we must free the generic data\n");
72
-			break;
73
-		default:
74
-			LM_DBG("Received unhandled event [%d] in credit control session callback from CDP\n", event);
75
-	}
69
+    switch (event) {
70
+	case AUTH_EV_SESSION_DROP:
71
+	    LM_DBG("Received notification of CC App session drop - we must free the generic data\n");
72
+	    break;
73
+	default:
74
+	    LM_DBG("Received unhandled event [%d] in credit control session callback from CDP\n", event);
75
+    }
76 76
 }
77 77
 
78
-
79
-
80 78
 /**
81 79
  * Retrieves the SIP request that generated a diameter transaction
82 80
  * @param hash - the tm hash value for this request
... ...
@@ -87,8 +85,8 @@ struct sip_msg * trans_get_request_from_current_reply() {
87 87
     struct cell *t;
88 88
     t = tmb.t_gett();
89 89
     if (!t || t == (void*) - 1) {
90
-        LM_ERR("trans_get_request_from_current_reply: Reply without transaction\n");
91
-        return 0;
90
+	LM_ERR("trans_get_request_from_current_reply: Reply without transaction\n");
91
+	return 0;
92 92
     }
93 93
     if (t) return t->uas.request;
94 94
     else return 0;
... ...
@@ -107,24 +105,24 @@ struct sip_msg * trans_get_request_from_current_reply() {
107 107
  * @returns 1 on success or 0 on failure
108 108
  */
109 109
 static inline int Ro_add_avp_list(AAA_AVP_LIST *list, char *d, int len, int avp_code,
110
-        int flags, int vendorid, int data_do, const char *func) {
110
+	int flags, int vendorid, int data_do, const char *func) {
111 111
     AAA_AVP *avp;
112 112
     if (vendorid != 0) flags |= AAA_AVP_FLAG_VENDOR_SPECIFIC;
113 113
     avp = cdpb.AAACreateAVP(avp_code, flags, vendorid, d, len, data_do);
114 114
     if (!avp) {
115
-        LM_ERR("%s: Failed creating avp\n", func);
116
-        return 0;
115
+	LM_ERR("%s: Failed creating avp\n", func);
116
+	return 0;
117 117
     }
118 118
     if (list->tail) {
119
-        avp->prev = list->tail;
120
-        avp->next = 0;
121
-        list->tail->next = avp;
122
-        list->tail = avp;
119
+	avp->prev = list->tail;
120
+	avp->next = 0;
121
+	list->tail->next = avp;
122
+	list->tail = avp;
123 123
     } else {
124
-        list->head = avp;
125
-        list->tail = avp;
126
-        avp->next = 0;
127
-        avp->prev = 0;
124
+	list->head = avp;
125
+	list->tail = avp;
126
+	avp->next = 0;
127
+	avp->prev = 0;
128 128
     }
129 129
 
130 130
     return 1;
... ...
@@ -188,7 +186,7 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used
188 188
     char x[4];
189 189
 
190 190
     //unsigned int service_id = 1000; //Removed these are now configurable config file params
191
-    
191
+
192 192
     //unsigned int rating_group = 500; //Removed these are now configurable config file params
193 193
 
194 194
     used_list.head = 0;
... ...
@@ -198,16 +196,16 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used
198 198
 
199 199
     /* if we must Used-Service-Unit */
200 200
     if (used_unit >= 0) {
201
-        set_4bytes(x, used_unit);
202
-        Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
203
-        used_group = cdpb.AAAGroupAVPS(used_list);
204
-        cdpb.AAAFreeAVPList(&used_list);
205
-        Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
201
+	set_4bytes(x, used_unit);
202
+	Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
203
+	used_group = cdpb.AAAGroupAVPS(used_list);
204
+	cdpb.AAAFreeAVPList(&used_list);
205
+	Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
206 206
     }
207 207
 
208 208
     set_4bytes(x, active_service_identifier);
209 209
     Ro_add_avp_list(&mscc_list, x, 4, AVP_Service_Identifier, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
210
-    
210
+
211 211
     set_4bytes(x, active_rating_group);
212 212
     Ro_add_avp_list(&mscc_list, x, 4, AVP_Rating_Group, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
213 213
 
... ...
@@ -220,7 +218,7 @@ inline int Ro_add_multiple_service_credit_Control_stop(AAAMessage *msg, int used
220 220
 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) {
221 221
     AAA_AVP_LIST list, used_list, mscc_list;
222 222
     str group, used_group;
223
-    
223
+
224 224
     char x[4];
225 225
 
226 226
     list.head = 0;
... ...
@@ -239,17 +237,17 @@ inline int Ro_add_multiple_service_credit_Control(AAAMessage *msg, unsigned int
239 239
 
240 240
     set_4bytes(x, active_service_identifier);
241 241
     Ro_add_avp_list(&mscc_list, x, 4, AVP_Service_Identifier, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
242
-    
242
+
243 243
     set_4bytes(x, active_rating_group);
244 244
     Ro_add_avp_list(&mscc_list, x, 4, AVP_Rating_Group, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
245 245
 
246 246
     /* if we must Used-Service-Unit */
247 247
     if (used_unit >= 0) {
248
-        set_4bytes(x, used_unit);
249
-        Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
250
-        used_group = cdpb.AAAGroupAVPS(used_list);
251
-        cdpb.AAAFreeAVPList(&used_list);
252
-        Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
248
+	set_4bytes(x, used_unit);
249
+	Ro_add_avp_list(&used_list, x, 4, AVP_CC_Time, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
250
+	used_group = cdpb.AAAGroupAVPS(used_list);
251
+	cdpb.AAAFreeAVPList(&used_list);
252
+	Ro_add_avp_list(&mscc_list, used_group.s, used_group.len, AVP_Used_Service_Unit, AAA_AVP_FLAG_MANDATORY, 0, AVP_FREE_DATA, __FUNCTION__);
253 253
     }
254 254
 
255 255
     group = cdpb.AAAGroupAVPS(mscc_list);
... ...
@@ -299,12 +297,12 @@ inline int Ro_add_vendor_specific_appid(AAAMessage *msg, unsigned int vendor_id,
299 299
     Ro_add_avp_list(&list, x, 4, AVP_Vendor_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
300 300
 
301 301
     if (auth_id) {
302
-        set_4bytes(x, auth_id);
303
-        Ro_add_avp_list(&list, x, 4, AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
302
+	set_4bytes(x, auth_id);
303
+	Ro_add_avp_list(&list, x, 4, AVP_Auth_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
304 304
     }
305 305
     if (acct_id) {
306
-        set_4bytes(x, acct_id);
307
-        Ro_add_avp_list(&list, x, 4, AVP_Acct_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
306
+	set_4bytes(x, acct_id);
307
+	Ro_add_avp_list(&list, x, 4, AVP_Acct_Application_Id, AAA_AVP_FLAG_MANDATORY, 0, AVP_DUPLICATE_DATA, __FUNCTION__);
308 308
     }
309 309
 
310 310
     group = cdpb.AAAGroupAVPS(list);
... ...
@@ -315,41 +313,41 @@ inline int Ro_add_vendor_specific_appid(AAAMessage *msg, unsigned int vendor_id,
315 315
 }
316 316
 
317 317
 int get_sip_header_info(struct sip_msg * req,
318
-        struct sip_msg * reply,
319
-        int32_t * acc_record_type,
320
-        str * sip_method,
321
-        str * event, uint32_t * expires,
322
-        str * callid, str * asserted_id_uri, str * to_uri) {
318
+	struct sip_msg * reply,
319
+	int32_t * acc_record_type,
320
+	str * sip_method,
321
+	str * event, uint32_t * expires,
322
+	str * callid, str * asserted_id_uri, str * to_uri) {
323 323
 
324 324
     sip_method->s = req->first_line.u.request.method.s;
325 325
     sip_method->len = req->first_line.u.request.method.len;
326 326
 
327 327
     if (strncmp(sip_method->s, "INVITE", 6) == 0)
328
-        *acc_record_type = AAA_ACCT_START;
328
+	*acc_record_type = AAA_ACCT_START;
329 329
     else if (strncmp(sip_method->s, "BYE", 3) == 0)
330
-        *acc_record_type = AAA_ACCT_STOP;
330
+	*acc_record_type = AAA_ACCT_STOP;
331 331
     else
332
-        *acc_record_type = AAA_ACCT_EVENT;
332
+	*acc_record_type = AAA_ACCT_EVENT;
333 333
 
334 334
     *event = cscf_get_event(req);
335 335
     *expires = cscf_get_expires_hdr(req, 0);
336 336
     *callid = cscf_get_call_id(req, NULL);
337 337
 
338 338
     if ((*asserted_id_uri = cscf_get_asserted_identity(req, 0)).len == 0) {
339
-    	LM_DBG("No P-Asserted-Identity hdr found. Using From hdr");
339
+	LM_DBG("No P-Asserted-Identity hdr found. Using From hdr");
340 340
 
341
-    	if (!cscf_get_from_uri(req, asserted_id_uri)) {
342
-    		LM_ERR("Error assigning P-Asserted-Identity using From hdr");
343
-    		goto error;
344
-    	}
341
+	if (!cscf_get_from_uri(req, asserted_id_uri)) {
342
+	    LM_ERR("Error assigning P-Asserted-Identity using From hdr");
343
+	    goto error;
344
+	}
345 345
     }
346 346
 
347
-    *to_uri	= req->first_line.u.request.uri;
347
+    *to_uri = req->first_line.u.request.uri;
348 348
 
349 349
     LM_DBG("retrieved sip info : sip_method %.*s acc_record_type %i, event %.*s expires %u "
350
-            "call_id %.*s from_uri %.*s to_uri %.*s\n",
351
-            sip_method->len, sip_method->s, *acc_record_type, event->len, event->s, *expires,
352
-            callid->len, callid->s, asserted_id_uri->len, asserted_id_uri->s, to_uri->len, to_uri->s);
350
+	    "call_id %.*s from_uri %.*s to_uri %.*s\n",
351
+	    sip_method->len, sip_method->s, *acc_record_type, event->len, event->s, *expires,
352
+	    callid->len, callid->s, asserted_id_uri->len, asserted_id_uri->s, to_uri->len, to_uri->s);
353 353
 
354 354
     return 1;
355 355
 error:
... ...
@@ -360,9 +358,9 @@ int get_ims_charging_info(struct sip_msg *req, struct sip_msg * reply, str * ici
360 360
 
361 361
     LM_DBG("get ims charging info\n");
362 362
     if (req)
363
-        cscf_get_p_charging_vector(req, icid, orig_ioi, term_ioi);
363
+	cscf_get_p_charging_vector(req, icid, orig_ioi, term_ioi);
364 364
     if (reply)
365
-        cscf_get_p_charging_vector(reply, icid, orig_ioi, term_ioi);
365
+	cscf_get_p_charging_vector(reply, icid, orig_ioi, term_ioi);
366 366
 
367 367
     return 1;
368 368
 }
... ...
@@ -370,9 +368,9 @@ int get_ims_charging_info(struct sip_msg *req, struct sip_msg * reply, str * ici
370 370
 int get_timestamps(struct sip_msg * req, struct sip_msg * reply, time_t * req_timestamp, time_t * reply_timestamp) {
371 371
 
372 372
     if (reply)
373
-        *reply_timestamp = time(NULL);
373
+	*reply_timestamp = time(NULL);
374 374
     if (req)
375
-        *req_timestamp = time(NULL);
375
+	*req_timestamp = time(NULL);
376 376
     return 1;
377 377
 }
378 378
 
... ...
@@ -381,7 +379,7 @@ int get_timestamps(struct sip_msg * req, struct sip_msg * reply, time_t * req_ti
381 381
  *
382 382
  */
383 383
 
384
-Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, AAASession ** authp, int dir, str asserted_identity, 
384
+Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, AAASession ** authp, int dir, str asserted_identity,
385 385
 	str called_asserted_identity, str subscription_id, int subscription_id_type, str* incoming_trunk_id, str *outgoing_trunk_id) {
386 386
 
387 387
     Ro_CCR_t * ro_ccr_data = 0;
... ...
@@ -401,66 +399,66 @@ Ro_CCR_t * dlg_create_ro_session(struct sip_msg * req, struct sip_msg * reply, A
401 401
     *authp = 0;
402 402
 
403 403
     if (!get_sip_header_info(req, reply, &acc_record_type, &sip_method, &event, &expires, &callid, &from_uri, &to_uri))
404
-        goto error;
404
+	goto error;
405 405
     user_name.s = subscription_id.s;
406 406
     user_name.len = subscription_id.len;
407
-	
407
+
408 408
     /*	if(!get_ims_charging_info(req, reply, &icid, &orig_ioi, &term_ioi))
409
-                    goto error;
409
+		    goto error;
410 410
      */
411 411
     LM_DBG("retrieved ims charging info icid:[%.*s] orig_ioi:[%.*s] term_ioi:[%.*s]\n",
412
-    		icid.len, icid.s, orig_ioi.len, orig_ioi.s, term_ioi.len, term_ioi.s);
412
+	    icid.len, icid.s, orig_ioi.len, orig_ioi.s, term_ioi.len, term_ioi.s);
413 413
 
414 414
     if (!get_timestamps(req, reply, &req_timestamp, &reply_timestamp))
415
-        goto error;
415
+	goto error;
416 416
 
417 417
     if (!(event_type = new_event_type(&sip_method, &event, &expires)))
418
-        goto error;
418
+	goto error;
419 419
 
420 420
     if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, &reply_timestamp, NULL)))
421
-        goto error;
421
+	goto error;
422 422
 
423
-    if (!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &asserted_identity, &called_asserted_identity, &icid, 
424
-	&orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id)))
425
-        goto error;
423
+    if (!(ims_info = new_ims_information(event_type, time_stamps, &callid, &callid, &asserted_identity, &called_asserted_identity, &icid,
424
+	    &orig_ioi, &term_ioi, dir, incoming_trunk_id, outgoing_trunk_id)))
425
+	goto error;
426 426
     event_type = 0;
427 427
     time_stamps = 0;
428 428
 
429
-    
429
+
430 430
     subscr.id.s = subscription_id.s;
431 431
     subscr.id.len = subscription_id.len;
432 432
     subscr.type = subscription_id_type;
433
-    
433
+
434 434
     ro_ccr_data = new_Ro_CCR(acc_record_type, &user_name, ims_info, &subscr);
435 435
     if (!ro_ccr_data) {
436
-        LM_ERR("dlg_create_ro_session: no memory left for generic\n");
437
-        goto out_of_memory;
436
+	LM_ERR("dlg_create_ro_session: no memory left for generic\n");
437
+	goto out_of_memory;
438 438
     }
439 439
     ims_info = 0;
440 440
 
441 441
     if (strncmp(req->first_line.u.request.method.s, "INVITE", 6) == 0) {
442
-    	//create CDP CC Accounting session
443
-    	auth = cdpb.AAACreateCCAccSession(credit_control_session_callback, 1/*is_session*/, NULL ); //must unlock session hash when done
444
-    	LM_DBG("Created Ro Session with id Session ID [%.*s]\n", auth->id.len, auth->id.s);
445
-        //save_session = auth->id;
442
+	//create CDP CC Accounting session
443
+	auth = cdpb.AAACreateCCAccSession(credit_control_session_callback, 1/*is_session*/, NULL); //must unlock session hash when done
444
+	LM_DBG("Created Ro Session with id Session ID [%.*s]\n", auth->id.len, auth->id.s);
445
+	//save_session = auth->id;
446 446
 
447 447
     }
448 448
     /*if (strncmp(req->first_line.u.request.method.s, "BYE", 3) == 0) {
449
-        auth = cdp_avp->cdp->AAAGetAuthSession(save_session);
449
+	auth = cdp_avp->cdp->AAAGetAuthSession(save_session);
450 450
     }*/
451 451
 
452 452
 
453 453
     if (!auth) {
454
-        LM_ERR("unable to create the Ro Session\n");
455
-        goto error;
454
+	LM_ERR("unable to create the Ro Session\n");
455
+	goto error;
456 456
     }
457 457
 
458 458
     *authp = auth;
459 459
     return ro_ccr_data;
460 460
 
461 461
 out_of_memory:
462
-error :
463
-    time_stamps_free(time_stamps);
462
+    error :
463
+	    time_stamps_free(time_stamps);
464 464
     event_type_free(event_type);
465 465
     ims_information_free(ims_info);
466 466
     Ro_free_CCR(ro_ccr_data);
... ...
@@ -468,18 +466,18 @@ error :
468 468
     return NULL;
469 469
 }
470 470
 
471
-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, 
471
+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,
472 472
 	str subscription_id, int subscription_id_type, str* incoming_trunk_id, str* outgoing_trunk_id) {
473 473
 
474 474
     if (msg->first_line.type == SIP_REQUEST) {
475
-        /*end of session*/
476
-        if (strncmp(msg->first_line.u.request.method.s, "INVITE", 6) == 0) {
477
-            if (!(*ro_ccr_data = dlg_create_ro_session(msg, NULL, auth, dir, asserted_identity, called_asserted_identity, subscription_id, 
475
+	/*end of session*/
476
+	if (strncmp(msg->first_line.u.request.method.s, "INVITE", 6) == 0) {
477
+	    if (!(*ro_ccr_data = dlg_create_ro_session(msg, NULL, auth, dir, asserted_identity, called_asserted_identity, subscription_id,
478 478
 		    subscription_id_type, incoming_trunk_id, outgoing_trunk_id)))
479
-                goto error;
480
-        }
479
+		goto error;
480
+	}
481 481
     } else {
482
-        goto error; //We only support Request (INVITE) messages on this interface
482
+	goto error; //We only support Request (INVITE) messages on this interface
483 483
     }
484 484
 
485 485
     return 1;
... ...
@@ -497,16 +495,16 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned
497 497
     int32_t acc_record_type;
498 498
     subscription_id_t subscr;
499 499
     time_stamps_t *time_stamps;
500
-	struct interim_ccr *i_req = shm_malloc(sizeof(struct interim_ccr));
501
-	int ret = 0;
500
+    struct interim_ccr *i_req = shm_malloc(sizeof (struct interim_ccr));
501
+    int ret = 0;
502 502
     event_type_t *event_type;
503 503
 
504
-	memset(i_req, 0, sizeof(sizeof(struct interim_ccr)));
505
-    i_req->ro_session	= ro_session;
504
+    memset(i_req, 0, sizeof (sizeof (struct interim_ccr)));
505
+    i_req->ro_session = ro_session;
506 506
 
507 507
     str sip_method = str_init("dummy");
508 508
     str sip_event = str_init("dummy");
509
-    
509
+
510 510
     str user_name = {0, 0};
511 511
 
512 512
     time_t req_timestamp;
... ...
@@ -514,45 +512,45 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned
514 514
     event_type = new_event_type(&sip_method, &sip_event, 0);
515 515
 
516 516
     LM_DBG("Sending interim CCR request for (usage:new) [%i:%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n",
517
-    						used,
518
-    						reserve,
519
-    						ro_session->asserted_identity.len, ro_session->asserted_identity.s,
520
-    						ro_session->ro_session_id.len, ro_session->ro_session_id.s,
521
-						ro_session->rating_group, ro_session->service_identifier, 
522
-						ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s,
523
-						ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s);
517
+	    used,
518
+	    reserve,
519
+	    ro_session->asserted_identity.len, ro_session->asserted_identity.s,
520
+	    ro_session->ro_session_id.len, ro_session->ro_session_id.s,
521
+	    ro_session->rating_group, ro_session->service_identifier,
522
+	    ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s,
523
+	    ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s);
524 524
 
525 525
     req_timestamp = time(0);
526 526
 
527 527
     if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, NULL, NULL)))
528
-        goto error;
528
+	goto error;
529 529
 
530
-    if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, 
530
+    if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity,
531 531
 	    &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id)))
532
-        goto error;
532
+	goto error;
533 533
 
534 534
     LM_DBG("Created IMS information\n");
535 535
 
536 536
     event_type = 0;
537 537
 
538 538
     if (ro_session->direction == RO_ORIG_DIRECTION) {
539
-        subscr.id = ro_session->asserted_identity;
540
-        
541
-	
542
-    } else if (ro_session->direction == RO_TERM_DIRECTION){
543
-        subscr.id = ro_session->called_asserted_identity;
539
+	subscr.id = ro_session->asserted_identity;
540
+
541
+
542
+    } else if (ro_session->direction == RO_TERM_DIRECTION) {
543
+	subscr.id = ro_session->called_asserted_identity;
544 544
     } else {
545
-    	LM_CRIT("don't know what to do in unknown mode - should we even get here\n");
546
-    	goto error;
545
+	LM_CRIT("don't know what to do in unknown mode - should we even get here\n");
546
+	goto error;
547 547
     }
548
-    
548
+
549 549
     //getting subscription id type
550
-    if (strncasecmp(subscr.id.s,"tel:",4)==0) {
550
+    if (strncasecmp(subscr.id.s, "tel:", 4) == 0) {
551 551
 	subscr.type = Subscription_Type_MSISDN;
552
-    }else{
552
+    } else {
553 553
 	subscr.type = Subscription_Type_IMPU; //default is END_USER_SIP_URI
554 554
     }
555
-    
555
+
556 556
     user_name.s = subscr.id.s;
557 557
     user_name.len = subscr.id.len;
558 558
 
... ...
@@ -560,53 +558,53 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned
560 560
 
561 561
     ro_ccr_data = new_Ro_CCR(acc_record_type, &user_name, ims_info, &subscr);
562 562
     if (!ro_ccr_data) {
563
-        LM_ERR("no memory left for generic\n");
564
-        goto error;
563
+	LM_ERR("no memory left for generic\n");
564
+	goto error;
565 565
     }
566 566
     ims_info = NULL;
567 567
 
568 568
     auth = cdpb.AAAGetCCAccSession(ro_session->ro_session_id);
569 569
     if (!auth) {
570
-        LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n");
571
-        /* lets try and recreate this session */
572
-        //TODO: make a CC App session auth = cdpb.AAASession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp
573
-        //BUG("Oh shit, session timed out and I don't know how to create a new one.");
570
+	LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n");
571
+	/* lets try and recreate this session */
572
+	//TODO: make a CC App session auth = cdpb.AAASession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp
573
+	//BUG("Oh shit, session timed out and I don't know how to create a new one.");
574 574
 
575
-        auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp
576
-        if (!auth)
577
-            goto error;
575
+	auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp
576
+	if (!auth)
577
+	    goto error;
578 578
     }
579 579
 
580 580
     //don't send INTERIM record if session is not in OPEN state (it could already be waiting for a previous response, etc)
581 581
     if (auth->u.cc_acc.state != ACC_CC_ST_OPEN) {
582
-	    LM_WARN("ignoring interim update on CC session not in correct state, currently in state [%d]\n", auth->u.cc_acc.state);
583
-	    goto error;
582
+	LM_WARN("ignoring interim update on CC session not in correct state, currently in state [%d]\n", auth->u.cc_acc.state);
583
+	goto error;
584 584
     }
585 585
 
586 586
     if (!(ccr = Ro_new_ccr(auth, ro_ccr_data)))
587
-        goto error;
587
+	goto error;
588 588
 
589 589
     if (!Ro_add_vendor_specific_appid(ccr, IMS_vendor_id_3GPP, IMS_Ro, 0/*acct id*/)) {
590
-        LM_ERR("Problem adding Vendor specific ID\n");
590
+	LM_ERR("Problem adding Vendor specific ID\n");
591 591
     }
592 592
     ro_session->hop_by_hop += 1;
593 593
     if (!Ro_add_cc_request(ccr, RO_CC_INTERIM, ro_session->hop_by_hop)) {
594
-        LM_ERR("Problem adding CC-Request data\n");
594
+	LM_ERR("Problem adding CC-Request data\n");
595 595
     }
596 596
     if (!Ro_add_event_timestamp(ccr, time(NULL))) {
597
-        LM_ERR("Problem adding Event-Timestamp data\n");
597
+	LM_ERR("Problem adding Event-Timestamp data\n");
598 598
     }
599 599
 
600 600
     if (!Ro_add_user_equipment_info(ccr, AVP_EPC_User_Equipment_Info_Type_MAC, ro_session->avp_value.mac)) {
601
-        LM_ERR("Problem adding User-Equipment data\n");
601
+	LM_ERR("Problem adding User-Equipment data\n");
602 602
     }
603 603
 
604 604
     if (!Ro_add_subscription_id(ccr, subscr.type, &(subscr.id))) {
605
-        LM_ERR("Problem adding Subscription ID data\n");
605
+	LM_ERR("Problem adding Subscription ID data\n");
606 606
     }
607 607
 
608 608
     if (!Ro_add_multiple_service_credit_Control(ccr, interim_request_credits/*INTERIM_CREDIT_REQ_AMOUNT*/, used, ro_session->rating_group, ro_session->service_identifier)) {
609
-        LM_ERR("Problem adding Multiple Service Credit Control data\n");
609
+	LM_ERR("Problem adding Multiple Service Credit Control data\n");
610 610
     }
611 611
 
612 612
     LM_DBG("Sending CCR Diameter message.\n");
... ...
@@ -614,32 +612,32 @@ void send_ccr_interim(struct ro_session* ro_session, unsigned int used, unsigned
614 614
     cdpb.AAASessionsUnlock(auth->hash);
615 615
 
616 616
     if (ro_forced_peer.len > 0) {
617
-    	ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_interim_ccr, (void *) i_req);
617
+	ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_interim_ccr, (void *) i_req);
618 618
     } else {
619
-    	ret = cdpb.AAASendMessage(ccr, resume_on_interim_ccr, (void *) i_req);
619
+	ret = cdpb.AAASendMessage(ccr, resume_on_interim_ccr, (void *) i_req);
620 620
     }
621 621
 
622 622
     if (ret != 1) {
623
-    	goto error;
623
+	goto error;
624 624
     }
625
-//    cdpb.AAASessionsUnlock(auth->hash);
625
+    //    cdpb.AAASessionsUnlock(auth->hash);
626 626
 
627 627
     Ro_free_CCR(ro_ccr_data);
628 628
 
629
-    update_stat(interim_ccrs, 1);
629
+    counter_inc(ims_charging_cnts_h.interim_ccrs);
630 630
     return;
631 631
 error:
632
-	LM_ERR("error trying to reserve interim credit\n");
632
+    LM_ERR("error trying to reserve interim credit\n");
633 633
 
634
-	if (ro_ccr_data)
635
-		Ro_free_CCR(ro_ccr_data);
634
+    if (ro_ccr_data)
635
+	Ro_free_CCR(ro_ccr_data);
636 636
 
637
-	if (ccr)
638
-		cdpb.AAAFreeMessage(&ccr);
637
+    if (ccr)
638
+	cdpb.AAAFreeMessage(&ccr);
639 639
 
640 640
     if (auth) {
641
-    	cdpb.AAASessionsUnlock(auth->hash);
642
-    	cdpb.AAADropCCAccSession(auth);
641
+	cdpb.AAASessionsUnlock(auth->hash);
642
+	cdpb.AAADropCCAccSession(auth);
643 643
     }
644 644
 
645 645
     shm_free(i_req);
... ...
@@ -649,76 +647,76 @@ error:
649 649
     //
650 650
     struct ro_session_entry *ro_session_entry = &(ro_session_table->entries[ro_session->h_entry]);
651 651
     ro_session_lock(ro_session_table, ro_session_entry);
652
-    unref_ro_session_unsafe(ro_session, 1, ro_session_entry);//unref from the initial timer that fired this event.
652
+    unref_ro_session_unsafe(ro_session, 1, ro_session_entry); //unref from the initial timer that fired this event.
653 653
     ro_session_unlock(ro_session_table, ro_session_entry);
654 654
 
655 655
     return;
656 656
 }
657 657
 
658 658
 static void resume_on_interim_ccr(int is_timeout, void *param, AAAMessage *cca, long elapsed_msecs) {
659
-	struct interim_ccr *i_req	= (struct interim_ccr *) param;
660
-	Ro_CCA_t * ro_cca_data = NULL;
659
+    struct interim_ccr *i_req = (struct interim_ccr *) param;
660
+    Ro_CCA_t * ro_cca_data = NULL;
661 661
 
662 662
     if (is_timeout) {
663
-        update_stat(ccr_timeouts, 1);
664
-        LM_ERR("Transaction timeout - did not get CCA\n");
665
-        goto error;
663
+	counter_inc(ims_charging_cnts_h.ccr_timeouts);
664
+	LM_ERR("Transaction timeout - did not get CCA\n");
665
+	goto error;
666 666
     }
667 667
 
668
-    update_stat(ccr_responses_time, elapsed_msecs);
668
+    counter_add(ims_charging_cnts_h.ccr_response_time, elapsed_msecs);
669 669
 
670
-	if (!i_req) {
671
-		LM_ERR("This is so wrong: ro session is NULL\n");
672
-		goto error;
673
-	}
670
+    if (!i_req) {
671
+	LM_ERR("This is so wrong: ro session is NULL\n");
672
+	goto error;
673
+    }
674 674
 
675
-	if (cca == NULL) {
676
-		LM_ERR("Error reserving credit for CCA.\n");
677
-		goto error;
678
-	}
675
+    if (cca == NULL) {
676
+	LM_ERR("Error reserving credit for CCA.\n");
677
+	goto error;
678
+    }
679 679
 
680
-	ro_cca_data = Ro_parse_CCA_avps(cca);
680
+    ro_cca_data = Ro_parse_CCA_avps(cca);
681 681
 
682
-	if (ro_cca_data == NULL) {
683
-		LM_ERR("Could not parse CCA message response.\n");
684
-		goto error;
685
-	}
682
+    if (ro_cca_data == NULL) {
683
+	LM_ERR("Could not parse CCA message response.\n");
684
+	goto error;
685
+    }
686 686
 
687
-	if (ro_cca_data->resultcode != 2001) {
688
-		LM_ERR("Got bad CCA result code [%d] - reservation failed", ro_cca_data->resultcode);
689
-		goto error;
690
-	} else {
691
-		LM_DBG("Valid CCA response with time chunk of [%i] and validity [%i].\n", ro_cca_data->mscc->granted_service_unit->cc_time, ro_cca_data->mscc->validity_time);
692
-	}
687
+    if (ro_cca_data->resultcode != 2001) {
688
+	LM_ERR("Got bad CCA result code [%d] - reservation failed", ro_cca_data->resultcode);
689
+	goto error;
690
+    } else {
691
+	LM_DBG("Valid CCA response with time chunk of [%i] and validity [%i].\n", ro_cca_data->mscc->granted_service_unit->cc_time, ro_cca_data->mscc->validity_time);
692
+    }
693 693
 
694
-	i_req->new_credit = ro_cca_data->mscc->granted_service_unit->cc_time;
695
-	i_req->credit_valid_for = ro_cca_data->mscc->validity_time;
696
-	i_req->is_final_allocation	= 0;
694
+    i_req->new_credit = ro_cca_data->mscc->granted_service_unit->cc_time;
695
+    i_req->credit_valid_for = ro_cca_data->mscc->validity_time;
696
+    i_req->is_final_allocation = 0;
697 697
 
698
-	if (ro_cca_data->mscc->final_unit_action && (ro_cca_data->mscc->final_unit_action->action == 0))
699
-		i_req->is_final_allocation = 1;
698
+    if (ro_cca_data->mscc->final_unit_action && (ro_cca_data->mscc->final_unit_action->action == 0))
699
+	i_req->is_final_allocation = 1;
700 700
 
701
-	Ro_free_CCA(ro_cca_data);
702
-	cdpb.AAAFreeMessage(&cca);
701
+    Ro_free_CCA(ro_cca_data);
702
+    cdpb.AAAFreeMessage(&cca);
703 703
 
704
-	update_stat(successful_interim_ccrs, 1);
705
-	goto success;
704
+    counter_inc(ims_charging_cnts_h.successful_interim_ccrs);
705
+    goto success;
706 706
 
707 707
 error:
708
-	if (ro_cca_data)
709
-		Ro_free_CCA(ro_cca_data);
708
+    if (ro_cca_data)
709
+	Ro_free_CCA(ro_cca_data);
710 710
 
711
-	if (!is_timeout && cca) {
712
-		cdpb.AAAFreeMessage(&cca);
713
-	}
711
+    if (!is_timeout && cca) {
712
+	cdpb.AAAFreeMessage(&cca);
713
+    }
714 714
 
715
-	if (i_req) {
716
-		i_req->credit_valid_for = 0;
717
-		i_req->new_credit = 0;
718
-	}
715
+    if (i_req) {
716
+	i_req->credit_valid_for = 0;
717
+	i_req->new_credit = 0;
718
+    }
719 719
 
720 720
 success:
721
-	resume_ro_session_ontimeout(i_req);
721
+    resume_ro_session_ontimeout(i_req);
722 722
 }
723 723
 
724 724
 void send_ccr_stop(struct ro_session *ro_session) {
... ...
@@ -731,13 +729,13 @@ void send_ccr_stop(struct ro_session *ro_session) {
731 731
     time_stamps_t *time_stamps;
732 732
     unsigned int used = 0;
733 733
     str user_name = {0, 0};
734
-    int ret  = 0;
735
-    
734
+    int ret = 0;
735
+
736 736
     if (ro_session->event_type != pending) {
737
-        used = time(0) - ro_session->last_event_timestamp;
737
+	used = time(0) - ro_session->last_event_timestamp;
738 738
     }
739 739
 
740
-    update_stat(billed_secs, used);
740
+    counter_add(ims_charging_cnts_h.billed_secs, used);
741 741
 
742 742
     event_type_t *event_type;
743 743
 
... ...
@@ -747,54 +745,54 @@ void send_ccr_stop(struct ro_session *ro_session) {
747 747
     time_t req_timestamp;
748 748
 
749 749
     event_type = new_event_type(&sip_method, &sip_event, 0);
750
-    
750
+
751 751
     LM_DBG("Sending stop CCR request for (usage) [%i] seconds for user [%.*s] using session id [%.*s] active rating group [%d] active service identifier [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n",
752
-    						used,
753
-    						ro_session->asserted_identity.len, ro_session->asserted_identity.s,
754
-    						ro_session->ro_session_id.len, ro_session->ro_session_id.s,
755
-						ro_session->rating_group, ro_session->service_identifier, 
756
-						ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s,
757
-						ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s);
752
+	    used,
753
+	    ro_session->asserted_identity.len, ro_session->asserted_identity.s,
754
+	    ro_session->ro_session_id.len, ro_session->ro_session_id.s,
755
+	    ro_session->rating_group, ro_session->service_identifier,
756
+	    ro_session->incoming_trunk_id.len, ro_session->incoming_trunk_id.s,
757
+	    ro_session->outgoing_trunk_id.len, ro_session->outgoing_trunk_id.s);
758 758
 
759 759
     req_timestamp = time(0);
760 760
 
761 761
     if (!(time_stamps = new_time_stamps(&req_timestamp, NULL, NULL, NULL)))
762
-        goto error0;
762
+	goto error0;
763
+
764
+    if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity,
765
+	    &ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id)))
766
+	goto error0;
763 767
 
764
-    if (!(ims_info = new_ims_information(event_type, time_stamps, &ro_session->callid, &ro_session->callid, &ro_session->asserted_identity, 
765
-		&ro_session->called_asserted_identity, 0, 0, 0, ro_session->direction, &ro_session->incoming_trunk_id, &ro_session->outgoing_trunk_id)))
766
-        goto error0;
767
-    
768 768
     event_type = 0;
769 769
 
770 770
     if (ro_session->direction == RO_ORIG_DIRECTION) {
771
-        subscr.id = ro_session->asserted_identity;
772
-        
773
-	
774
-    } else if (ro_session->direction == RO_TERM_DIRECTION){
775
-        subscr.id = ro_session->called_asserted_identity;
771
+	subscr.id = ro_session->asserted_identity;
772
+
773
+
774
+    } else if (ro_session->direction == RO_TERM_DIRECTION) {
775
+	subscr.id = ro_session->called_asserted_identity;
776 776
     } else {
777
-    	LM_CRIT("don't know what to do in unknown mode - should we even get here\n");
778
-    	goto error0;
777
+	LM_CRIT("don't know what to do in unknown mode - should we even get here\n");
778
+	goto error0;
779 779
     }
780
-    
780
+
781 781
     //getting subscription id type
782
-    if (strncasecmp(subscr.id.s,"tel:",4)==0) {
782
+    if (strncasecmp(subscr.id.s, "tel:", 4) == 0) {
783 783
 	subscr.type = Subscription_Type_MSISDN;
784
-    }else{
784
+    } else {
785 785
 	subscr.type = Subscription_Type_IMPU; //default is END_USER_SIP_URI
786 786
     }
787
-    
787
+
788 788
     user_name.s = subscr.id.s;
789 789
     user_name.len = subscr.id.len;
790
-    
791
-    
790
+
791
+
792 792
     acc_record_type = AAA_ACCT_STOP;
793 793
 
794 794
     ro_ccr_data = new_Ro_CCR(acc_record_type, &user_name, ims_info, &subscr);
795 795
     if (!ro_ccr_data) {
796
-        LM_ERR("send_ccr_stop: no memory left for generic\n");
797
-        goto error0;
796
+	LM_ERR("send_ccr_stop: no memory left for generic\n");
797
+	goto error0;
798 798
     }
799 799
     ims_info = 0;
800 800
 
... ...
@@ -803,63 +801,64 @@ void send_ccr_stop(struct ro_session *ro_session) {
803 803
     auth = cdpb.AAAGetCCAccSession(ro_session->ro_session_id);
804 804
 
805 805
     if (!auth) {
806
-        LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n");
807
-        /* lets try and recreate this session */
808
-        auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp
809
-        if (!auth)
810
-            goto error1;
806
+	LM_DBG("Diameter Auth Session has timed out.... creating a new one.\n");
807
+	/* lets try and recreate this session */
808
+	auth = cdpb.AAAMakeSession(ro_session->auth_appid, ro_session->auth_session_type, ro_session->ro_session_id); //TODO: would like this session to last longer (see session timeout in cdp
809
+	if (!auth)
810
+	    goto error1;
811 811
     }
812 812
 
813 813
 
814 814
     if (!(ccr = Ro_new_ccr(auth, ro_ccr_data)))
815
-        goto error1;
815
+	goto error1;
816 816
 
817 817
     LM_DBG("Created new CCR\n");
818 818
 
819 819
     if (!Ro_add_vendor_specific_appid(ccr, IMS_vendor_id_3GPP, IMS_Ro, 0)) {
820
-        LM_ERR("Problem adding Vendor specific ID\n");
820
+	LM_ERR("Problem adding Vendor specific ID\n");
821 821
     }
822
-   
822
+
823 823
     ro_session->hop_by_hop += 1;
824 824
     if (!Ro_add_cc_request(ccr, RO_CC_STOP, ro_session->hop_by_hop)) {
825
-        LM_ERR("Problem adding CC-Request data\n");
825
+	LM_ERR("Problem adding CC-Request data\n");
826 826
     }
827
-   
827
+
828 828
     if (!Ro_add_event_timestamp(ccr, time(NULL))) {
829
-        LM_ERR("Problem adding Event-Timestamp data\n");
829
+	LM_ERR("Problem adding Event-Timestamp data\n");
830 830
     }
831 831
 
832 832
     if (!Ro_add_user_equipment_info(ccr, AVP_EPC_User_Equipment_Info_Type_MAC, ro_session->avp_value.mac)) {
833
-        LM_ERR("Problem adding User-Equipment data\n");
833
+	LM_ERR("Problem adding User-Equipment data\n");
834 834
     }
835
-    
835
+
836 836
     if (!Ro_add_subscription_id(ccr, subscr.type, &subscr.id)) {
837
-        LM_ERR("Problem adding Subscription ID data\n");
837
+	LM_ERR("Problem adding Subscription ID data\n");
838 838
     }
839
-    
839
+
840 840
     if (!Ro_add_multiple_service_credit_Control_stop(ccr, used, ro_session->rating_group, ro_session->service_identifier)) {
841
-        LM_ERR("Problem adding Multiple Service Credit Control data\n");
841
+	LM_ERR("Problem adding Multiple Service Credit Control data\n");
842 842
     }
843
-    
843
+
844 844
     if (!Ro_add_termination_cause(ccr, TERM_CAUSE_LOGOUT)) {
845
-        LM_ERR("problem add Termination cause AVP to STOP record.\n");
845
+	LM_ERR("problem add Termination cause AVP to STOP record.\n");
846 846
     }
847 847
 
848 848
     cdpb.AAASessionsUnlock(auth->hash);
849 849
 
850 850
     if (ro_forced_peer.len > 0) {
851
-    	ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_termination_ccr, NULL);
851
+	ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_termination_ccr, NULL);
852 852
     } else {
853
-    	ret = cdpb.AAASendMessage(ccr, resume_on_termination_ccr, NULL);
853
+	ret = cdpb.AAASendMessage(ccr, resume_on_termination_ccr, NULL);
854 854
     }
855 855
 
856 856
     if (ret != 1) {
857
-    	goto error1;
857
+	goto error1;
858 858
     }
859 859
 
860 860
     Ro_free_CCR(ro_ccr_data);
861 861
 
862
-    update_stat(final_ccrs, 1);
862
+    counter_inc(ims_charging_cnts_h.final_ccrs);
863
+    counter_add(ims_charging_cnts_h.active_ro_sessions, -1);
863 864
     return;
864 865
 
865 866
 error1:
... ...
@@ -867,8 +866,8 @@ error1:
867 867
     Ro_free_CCR(ro_ccr_data);
868 868
 
869 869
     if (auth) {
870
-    	cdpb.AAASessionsUnlock(auth->hash);
871
-    	cdpb.AAADropCCAccSession(auth);
870
+	cdpb.AAASessionsUnlock(auth->hash);
871
+	cdpb.AAADropCCAccSession(auth);
872 872
     }
873 873
 
874 874
 error0:
... ...
@@ -880,44 +879,41 @@ static void resume_on_termination_ccr(int is_timeout, void *param, AAAMessage *c
880 880
     Ro_CCA_t *ro_cca_data = NULL;
881 881
 
882 882
     if (is_timeout) {
883
-        update_stat(ccr_timeouts, 1);
884
-        LM_ERR("Transaction timeout - did not get CCA\n");
885
-        goto error;
883
+	counter_inc(ims_charging_cnts_h.ccr_timeouts);
884
+	LM_ERR("Transaction timeout - did not get CCA\n");
885
+	goto error;
886 886
     }
887 887
 
888
-    update_stat(ccr_responses_time, elapsed_msecs);
888
+    counter_add(ims_charging_cnts_h.ccr_response_time, elapsed_msecs);
889 889
 
890 890
     if (!cca) {
891
-    	LM_ERR("Error in termination CCR.\n");
892
-        return;
891
+	LM_ERR("Error in termination CCR.\n");
892
+	return;
893 893
     }
894 894
 
895 895
     ro_cca_data = Ro_parse_CCA_avps(cca);
896 896
 
897 897
     if (ro_cca_data == NULL) {
898
-    	LM_DBG("Could not parse CCA message response.\n");
899
-    	return;
898
+	LM_DBG("Could not parse CCA message response.\n");
899
+	return;
900 900
     }
901 901
 
902 902
     if (ro_cca_data->resultcode != 2001) {
903
-    	LM_ERR("Got bad CCA result code for STOP record - [%d]\n", ro_cca_data->resultcode);
904
-        goto error;
905
-    }
906
-    else {
907
-    	LM_DBG("Valid CCA response for STOP record\n");
903
+	LM_ERR("Got bad CCA result code for STOP record - [%d]\n", ro_cca_data->resultcode);
904
+	goto error;
905
+    } else {
906
+	LM_DBG("Valid CCA response for STOP record\n");
908 907
     }
909 908
 
910
-    update_stat(successful_final_ccrs, 1);
909
+    counter_inc(ims_charging_cnts_h.successful_final_ccrs);
911 910
 
912 911
 error:
913
-	Ro_free_CCA(ro_cca_data);
914
-	if (!is_timeout && cca) {
915
-		cdpb.AAAFreeMessage(&cca);
916
-	}
912
+    Ro_free_CCA(ro_cca_data);
913
+    if (!is_timeout && cca) {
914
+	cdpb.AAAFreeMessage(&cca);
915
+    }
917 916
 }
918 917
 
919
-
920
-
921 918
 /**
922 919
  * Send a CCR to the OCS based on the SIP message (INVITE ONLY)
923 920
  * @param msg - SIP message
... ...
@@ -930,11 +926,11 @@ error:
930 930
  * @returns #CSCF_RETURN_BREAK if OK, #CSCF_RETURN_ERROR on error
931 931
  */
932 932
 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,
933
-						cfg_action_t* action, unsigned int tindex, unsigned int tlabel) {
934
-    str session_id = { 0, 0 },
935
-    called_asserted_identity = {0 , 0 },
936
-    subscription_id = {0 , 0 },
937
-    asserted_identity = {0 , 0 };
933
+	cfg_action_t* action, unsigned int tindex, unsigned int tlabel) {
934
+    str session_id = {0, 0},
935
+    called_asserted_identity = {0, 0},
936
+    subscription_id = {0, 0},
937
+    asserted_identity = {0, 0};
938 938
     int subscription_id_type = AVP_EPC_Subscription_Id_Type_End_User_SIP_URI;
939 939
     AAASession* cc_acc_session = NULL;
940 940
     Ro_CCR_t * ro_ccr_data = 0;
... ...
@@ -942,219 +938,219 @@ int Ro_Send_CCR(struct sip_msg *msg, struct dlg_cell *dlg, int dir, int reservat
942 942
     struct ro_session *new_session = 0;
943 943
     struct session_setup_data *ssd;
944 944
     int ret = 0;
945
-    struct hdr_field *h=0;
946
-    
947
-    int cc_event_number = 0;						//According to IOT tests this should start at 0
945
+    struct hdr_field *h = 0;
946
+
947
+    int cc_event_number = 0; //According to IOT tests this should start at 0
948 948
     int cc_event_type = RO_CC_START;
949 949
     int free_called_asserted_identity = 0;
950
-    
950
+
951 951
     sdp_session_cell_t* msg_sdp_session;
952 952
     sdp_stream_cell_t* msg_sdp_stream;
953
-    
953
+
954 954
     int active_service_identifier;
955 955
     int active_rating_group;
956
-    
956
+
957 957
     int sdp_stream_num = 0;
958 958
 
959 959
     LM_DBG("Sending initial CCR request for reservation_units [%d] incoming_trunk_id [%.*s] outgoing_trunk_id [%.*s]\n",
960
-						reservation_units,
961
-						incoming_trunk_id->len, incoming_trunk_id->s,
962
-						outgoing_trunk_id->len, outgoing_trunk_id->s);
963
-    
964
-    
965
-    
966
-    ssd = shm_malloc(sizeof(struct session_setup_data)); // lookup structure used to load session info from cdp callback on CCA
960
+	    reservation_units,
961
+	    incoming_trunk_id->len, incoming_trunk_id->s,
962
+	    outgoing_trunk_id->len, outgoing_trunk_id->s);
963
+
964
+
965
+
966
+    ssd = shm_malloc(sizeof (struct session_setup_data)); // lookup structure used to load session info from cdp callback on CCA
967 967
     if (!ssd) {
968
-    	LM_ERR("no more shm mem\n");
969
-    	goto error;
968
+	LM_ERR("no more shm mem\n");
969
+	goto error;
970 970
     }
971 971
 
972 972
     //getting asserted identity
973 973
     if ((asserted_identity = cscf_get_asserted_identity(msg, 0)).len == 0) {
974
-	    LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity");
975
-	    asserted_identity	= dlg->from_uri;
974
+	LM_DBG("No P-Asserted-Identity hdr found. Using From hdr for asserted_identity");
975
+	asserted_identity = dlg->from_uri;
976 976
     }
977
-    
978
-    
977
+
978
+
979 979
     //getting called asserted identity
980 980
     if ((called_asserted_identity = cscf_get_public_identity_from_called_party_id(msg, &h)).len == 0) {
981
-	    LM_DBG("No P-Called-Identity hdr found. Using request URI for called_asserted_identity");
982
-	    called_asserted_identity = cscf_get_public_identity_from_requri(msg);
983
-	    free_called_asserted_identity = 1;
981
+	LM_DBG("No P-Called-Identity hdr found. Using request URI for called_asserted_identity");
982
+	called_asserted_identity = cscf_get_public_identity_from_requri(msg);
983
+	free_called_asserted_identity = 1;
984 984
     }
985
-    
985
+
986 986
     if (dir == RO_ORIG_DIRECTION) {
987
-        subscription_id.s = asserted_identity.s;
988
-        subscription_id.len = asserted_identity.len;
989
-	
990
-    } else if (dir == RO_TERM_DIRECTION){
991
-        subscription_id.s = called_asserted_identity.s;
992
-        subscription_id.len = called_asserted_identity.len;
987
+	subscription_id.s = asserted_identity.s;
988
+	subscription_id.len = asserted_identity.len;
989
+
990
+    } else if (dir == RO_TERM_DIRECTION) {
991
+	subscription_id.s = called_asserted_identity.s;
992
+	subscription_id.len = called_asserted_identity.len;
993 993
     } else {
994
-    	LM_CRIT("don't know what to do in unknown mode - should we even get here\n");
995
-    	goto error;
994
+	LM_CRIT("don't know what to do in unknown mode - should we even get here\n");
995
+	goto error;
996 996
     }
997
-    
997
+
998 998
     //getting subscription id type
999
-    if (strncasecmp(subscription_id.s,"tel:",4)==0) {
999
+    if (strncasecmp(subscription_id.s, "tel:", 4) == 0) {
1000 1000
 	subscription_id_type = Subscription_Type_MSISDN;
1001
-    }else{
1001
+    } else {
1002 1002
 	subscription_id_type = Subscription_Type_IMPU; //default is END_USER_SIP_URI
1003 1003
     }
1004 1004
 
1005
-    str mac	= {0,0};
1005
+    str mac = {0, 0};
1006 1006
     if (get_mac_avp_value(msg, &mac) != 0)
1007
-    	LM_DBG(RO_MAC_AVP_NAME" was not set. Using default.");
1008
-    
1007
+	LM_DBG(RO_MAC_AVP_NAME" was not set. Using default.");
1008
+
1009 1009
     //by default we use voice service id and rate group
1010
-	//then we check SDP - if we find video then we use video service id and rate group
1011
-	LM_DBG("Setting default SID to %d and RG to %d for voice", 
1012
-			    voice_service_identifier, voice_rating_group);
1013
-	active_service_identifier = voice_service_identifier;
1014
-	active_rating_group = voice_rating_group;
1015
-	
1016
-	//check SDP - if there is video then set default to video, if not set it to audio
1017
-	if (parse_sdp(msg) < 0) {
1018
-	    LM_ERR("Unable to parse req SDP\n");
1019
-	    goto error;
1020
-	}
1021
-	
1022
-	msg_sdp_session = get_sdp_session(msg, 0);
1023
-	if (!msg_sdp_session ) {
1024
-            LM_ERR("Missing SDP session information from rpl\n");
1025
-        } else {
1026
-	    for (;;) {
1027
-		msg_sdp_stream = get_sdp_stream(msg, 0, sdp_stream_num);
1028
-		if (!msg_sdp_stream) {
1029
-		    //LM_ERR("Missing SDP stream information\n");
1030
-		    break;
1031
-		}
1032
-
1033
-		int intportA = atoi(msg_sdp_stream->port.s);
1034
-		if(intportA != 0 && strncasecmp(msg_sdp_stream->media.s,"video",5)==0){
1035
-		    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", 
1036
-			    video_service_identifier, video_rating_group);
1037
-		    active_service_identifier = video_service_identifier;
1038
-		    active_rating_group = video_rating_group;
1039
-		    break;
1040
-		}
1041
-
1042
-		sdp_stream_num++;
1010
+    //then we check SDP - if we find video then we use video service id and rate group
1011
+    LM_DBG("Setting default SID to %d and RG to %d for voice",
1012
+	    voice_service_identifier, voice_rating_group);
1013
+    active_service_identifier = voice_service_identifier;
1014
+    active_rating_group = voice_rating_group;
1015
+
1016
+    //check SDP - if there is video then set default to video, if not set it to audio
1017
+    if (parse_sdp(msg) < 0) {
1018
+	LM_ERR("Unable to parse req SDP\n");
1019
+	goto error;
1020
+    }
1021
+
1022
+    msg_sdp_session = get_sdp_session(msg, 0);
1023
+    if (!msg_sdp_session) {
1024
+	LM_ERR("Missing SDP session information from rpl\n");
1025
+    } else {
1026
+	for (;;) {
1027
+	    msg_sdp_stream = get_sdp_stream(msg, 0, sdp_stream_num);
1028
+	    if (!msg_sdp_stream) {
1029
+		//LM_ERR("Missing SDP stream information\n");
1030
+		break;
1043 1031
 	    }
1044
-	}
1045
-	
1046
-	free_sdp((sdp_info_t**) (void*) &msg->body);
1047 1032
 
1048
-	//create a session object without auth and diameter session id - we will add this later.
1049
-	new_session = build_new_ro_session(dir, 0, 0, &session_id, &dlg->callid,
1050
-			&asserted_identity, &called_asserted_identity, &mac, dlg->h_entry, dlg->h_id,
1051
-			reservation_units, 0, active_rating_group, active_service_identifier, incoming_trunk_id, outgoing_trunk_id);
1033
+	    int intportA = atoi(msg_sdp_stream->port.s);
1034
+	    if (intportA != 0 && strncasecmp(msg_sdp_stream->media.s, "video", 5) == 0) {
1035
+		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",
1036
+			video_service_identifier, video_rating_group);
1037
+		active_service_identifier = video_service_identifier;
1038
+		active_rating_group = video_rating_group;
1039
+		break;
1040
+	    }
1052 1041
 
1053
-	if (!new_session) {
1054
-		LM_ERR("Couldn't create new Ro Session - this is BAD!\n");
1055
-		goto error;
1042
+	    sdp_stream_num++;
1056 1043
 	}
1044
+    }
1045
+
1046
+    free_sdp((sdp_info_t**) (void*) &msg->body);
1047
+
1048
+    //create a session object without auth and diameter session id - we will add this later.
1049
+    new_session = build_new_ro_session(dir, 0, 0, &session_id, &dlg->callid,
1050
+	    &asserted_identity, &called_asserted_identity, &mac, dlg->h_entry, dlg->h_id,
1051
+	    reservation_units, 0, active_rating_group, active_service_identifier, incoming_trunk_id, outgoing_trunk_id);
1052
+
1053
+    if (!new_session) {
1054
+	LM_ERR("Couldn't create new Ro Session - this is BAD!\n");
1055
+	goto error;
1056
+    }
1057 1057
 
1058
-	ssd->action	= action;
1059
-	ssd->tindex	= tindex;
1060
-	ssd->tlabel	= tlabel;
1061
-	ssd->ro_session	= new_session;
1058
+    ssd->action = action;
1059
+    ssd->tindex = tindex;
1060
+    ssd->tlabel = tlabel;
1061
+    ssd->ro_session = new_session;
1062 1062
 
1063 1063
     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))
1064
-        goto error;
1064
+	goto error;
1065 1065
 
1066 1066
     if (!ro_ccr_data)
1067
-        goto error;
1067
+	goto error;
1068 1068
 
1069 1069
     if (!cc_acc_session)
1070
-    	goto error;	
1071
-	
1070
+	goto error;
1071
+
1072 1072
     if (!(ccr = Ro_new_ccr(cc_acc_session, ro_ccr_data)))
1073
-        goto error;
1073
+	goto error;
1074 1074
 
1075 1075
     if (!Ro_add_vendor_specific_appid(ccr, IMS_vendor_id_3GPP, IMS_Ro, 0)) {
1076
-        LM_ERR("Problem adding Vendor specific ID\n");
1077
-        goto error;
1076
+	LM_ERR("Problem adding Vendor specific ID\n");
1077
+	goto error;
1078 1078
     }
1079 1079
 
1080 1080
     if (!Ro_add_cc_request(ccr, cc_event_type, cc_event_number)) {
1081
-        LM_ERR("Problem adding CC-Request data\n");
1082
-        goto error;
1081
+	LM_ERR("Problem adding CC-Request data\n");
1082
+	goto error;
1083 1083
     }
1084 1084
 
1085 1085
     if (!Ro_add_event_timestamp(ccr, time(NULL))) {
1086
-        LM_ERR("Problem adding Event-Timestamp data\n");
1087
-        goto error;
1086
+	LM_ERR("Problem adding Event-Timestamp data\n");
1087
+	goto error;
1088 1088
     }
1089 1089
 
1090 1090
     if (!Ro_add_user_equipment_info(ccr, AVP_EPC_User_Equipment_Info_Type_MAC, mac)) {
1091
-        LM_ERR("Problem adding User-Equipment data\n");
1092
-        goto error;
1091
+	LM_ERR("Problem adding User-Equipment data\n");
1092
+	goto error;
1093 1093
     }
1094 1094
 
1095 1095
     if (!Ro_add_subscription_id(ccr, subscription_id_type, &subscription_id)) {
1096
-        LM_ERR("Problem adding Subscription ID data\n");
1097
-        goto error;
1096
+	LM_ERR("Problem adding Subscription ID data\n");
1097
+	goto error;
1098 1098
     }
1099 1099
     if (!Ro_add_multiple_service_credit_Control(ccr, reservation_units, -1, active_rating_group, active_service_identifier)) {
1100
-        LM_ERR("Problem adding Multiple Service Credit Control data\n");
1101
-        goto error;
1100
+	LM_ERR("Problem adding Multiple Service Credit Control data\n");
1101
+	goto error;
1102 1102
     }
1103
-	
1103
+
1104 1104
     /* before we send, update our session object with CC App session ID and data */
1105 1105
     new_session->auth_appid = cc_acc_session->application_id;
1106 1106
     new_session->auth_session_type = cc_acc_session->type;
1107 1107
     new_session->ro_session_id.s = (char*) shm_malloc(cc_acc_session->id.len);
1108 1108
     new_session->ro_session_id.len = cc_acc_session->id.len;
1109 1109
     memcpy(new_session->ro_session_id.s, cc_acc_session->id.s, cc_acc_session->id.len);
1110
-    
1110
+
1111 1111
     LM_DBG("new CC Ro Session ID: [%.*s]\n", cc_acc_session->id.len, cc_acc_session->id.s);
1112 1112
 
1113 1113
     LM_DBG("Sending CCR Diameter message.\n");
1114 1114
     cdpb.AAASessionsUnlock(cc_acc_session->hash);
1115 1115
 
1116 1116
     if (ro_forced_peer.len > 0) {
1117
-    	LM_DBG("Sending message with Peer\n");
1118
-    	ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_initial_ccr, (void *) ssd);
1117
+	LM_DBG("Sending message with Peer\n");
1118
+	ret = cdpb.AAASendMessageToPeer(ccr, &ro_forced_peer, resume_on_initial_ccr, (void *) ssd);
1119 1119
     } else {
1120
-    	LM_DBG("Sending message without Peer and realm is [%.*s]\n", ccr->dest_realm->data.len, ccr->dest_realm->data.s);
1121
-    	ret = cdpb.AAASendMessage(ccr, resume_on_initial_ccr, (void *) ssd);
1120
+	LM_DBG("Sending message without Peer and realm is [%.*s]\n", ccr->dest_realm->data.len, ccr->dest_realm->data.s);
1121
+	ret = cdpb.AAASendMessage(ccr, resume_on_initial_ccr, (void *) ssd);
1122 1122
     }
1123 1123
 
1124 1124
     if (ret != 1) {
1125
-    	LM_ERR("Failed to send Diameter CCR\n");
1126
-    	goto error;
1125
+	LM_ERR("Failed to send Diameter CCR\n");
1126
+	goto error;
1127 1127
     }
1128 1128
 
1129 1129
     Ro_free_CCR(ro_ccr_data);
1130 1130
 
1131 1131
     //TODO: if the following fail, we should clean up the Ro session.......
1132
-    if (dlgb.register_dlgcb(dlg, /* DLGCB_RESPONSE_FWDED */ DL