Browse code

ims_charging: add structured debug logging for key functions

Henning Westerholt authored on 10/06/2020 19:25:20
Showing 3 changed files
... ...
@@ -93,6 +93,8 @@ ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t
93 93
     ims_information_t *x = 0;
94 94
     ioi_list_element_t * ioi_elem = 0;
95 95
 
96
+    LM_DBG("create new IMS information\n");
97
+
96 98
     mem_new(x, sizeof (ims_information_t), pkg);
97 99
 
98 100
     x->event_type = event_type;
... ...
@@ -115,8 +117,9 @@ ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t
115 117
         WL_APPEND(&(x->calling_party_address), sl);
116 118
     }
117 119
 
118
-    if (called_party && called_party->s)
120
+    if (called_party && called_party->s) {
119 121
         str_dup_ptr(x->called_party_address, *called_party, pkg);
122
+    }
120 123
     
121 124
     if (incoming_trunk_id && incoming_trunk_id->s)
122 125
         str_dup_ptr(x->incoming_trunk_id, *incoming_trunk_id, pkg);
... ...
@@ -154,6 +157,7 @@ service_information_t * new_service_information(ims_information_t * ims_info, su
154 157
     service_information_t * x = 0;
155 158
     subscription_id_list_element_t * sl = 0;
156 159
 
160
+    LM_DBG("create new service information\n");
157 161
     mem_new(x, sizeof (service_information_t), pkg);
158 162
 
159 163
     x->ims_information = ims_info;
... ...
@@ -177,7 +181,7 @@ Ro_CCR_t * new_Ro_CCR(int32_t acc_record_type, str * user_name, ims_information_
177 181
     Ro_CCR_t *x = 0;
178 182
 
179 183
     service_information_t * service_info = 0;
180
-
184
+    LM_DBG("create new Ro CCR\n");
181 185
     mem_new(x, sizeof (Ro_CCR_t), pkg);
182 186
 
183 187
     if (cfg.origin_host.s && cfg.origin_host.len > 0)
... ...
@@ -198,9 +202,11 @@ Ro_CCR_t * new_Ro_CCR(int32_t acc_record_type, str * user_name, ims_information_
198 202
     if (cfg.service_context_id && cfg.service_context_id->s)
199 203
         str_dup_ptr(x->service_context_id, *(cfg.service_context_id), pkg);
200 204
 
201
-    if (ims_info)
205
+    if (ims_info) {
202 206
         if (!(service_info = new_service_information(ims_info, subscription)))
203 207
             goto error;
208
+        LM_DBG("Created service information\n");
209
+    }
204 210
 
205 211
     x->service_information = service_info;
206 212
     service_info = 0;
... ...
@@ -11,6 +11,7 @@ extern struct cdp_binds cdpb;
11 11
 int Ro_write_event_type_avps(AAA_AVP_LIST * avp_list, event_type_t * x) {
12 12
     AAA_AVP_LIST aList = {0, 0};
13 13
 
14
+    LM_DBG("write event type AVPs\n");
14 15
     if (x->sip_method) {
15 16
         if (!cdp_avp->epcapp.add_SIP_Method(&aList, *(x->sip_method), AVP_DUPLICATE_DATA))
16 17
             goto error;
... ...
@@ -37,6 +38,7 @@ error:
37 38
 int Ro_write_time_stamps_avps(AAA_AVP_LIST * avp_list, time_stamps_t* x) {
38 39
     AAA_AVP_LIST aList = {0, 0};
39 40
 
41
+    LM_DBG("write timestamp AVPs\n");
40 42
     if (x->sip_request_timestamp)
41 43
         if (!cdp_avp->epcapp.add_SIP_Request_Timestamp(&aList, *(x->sip_request_timestamp)))
42 44
             goto error;
... ...
@@ -74,6 +76,8 @@ int Ro_write_ims_information_avps(AAA_AVP_LIST * avp_list, ims_information_t* x)
74 76
     service_specific_info_list_element_t * info = 0;
75 77
     ioi_list_element_t * ioi_elem = 0;
76 78
 
79
+    LM_DBG("write IMS information AVPs\n");
80
+
77 81
     if (x->event_type)
78 82
         if (!Ro_write_event_type_avps(&aList2, x->event_type))
79 83
             goto error;
... ...
@@ -90,11 +94,15 @@ int Ro_write_ims_information_avps(AAA_AVP_LIST * avp_list, ims_information_t* x)
90 94
     for (sl = x->calling_party_address.head; sl; sl = sl->next) {
91 95
         if (!cdp_avp->epcapp.add_Calling_Party_Address(&aList2, sl->data, 0))
92 96
             goto error;
97
+        LM_DBG("added calling party address %.*s\n", sl->data.len, sl->data.s);
93 98
     }
94 99
 
95
-    if (x->called_party_address)
100
+    if (x->called_party_address) {
96 101
         if (!cdp_avp->epcapp.add_Called_Party_Address(&aList2, *(x->called_party_address), 0))
97 102
             goto error;
103
+        LM_DBG("added called party address %.*s\n",
104
+                x->called_party_address->len, x->called_party_address->s);
105
+    }
98 106
     
99 107
     if (x->incoming_trunk_id && (x->incoming_trunk_id->len > 0) && x->outgoing_trunk_id && (x->outgoing_trunk_id->len > 0)) {
100 108
 	if (!cdp_avp->epcapp.add_Outgoing_Trunk_Group_Id(&aList, *(x->outgoing_trunk_id), 0))
... ...
@@ -176,7 +184,7 @@ error:
176 184
     /*free aList*/
177 185
     cdp_avp->cdp->AAAFreeAVPList(&aList);
178 186
     cdp_avp->cdp->AAAFreeAVPList(&aList2);
179
-    LM_ERR("could not add ims information avps\n");
187
+    LM_ERR("could not add ims information AVPs\n");
180 188
     return 0;
181 189
 }
182 190
 
... ...
@@ -184,6 +192,7 @@ int Ro_write_service_information_avps(AAA_AVP_LIST * avp_list, service_informati
184 192
     subscription_id_list_element_t * elem = 0;
185 193
     AAA_AVP_LIST aList = {0, 0};
186 194
 
195
+    LM_DBG("write service information\n");
187 196
     for (elem = x->subscription_id.head; elem; elem = elem->next) {
188 197
 
189 198
         if (!cdp_avp->ccapp.add_Subscription_Id_Group(&aList, elem->s.type, elem->s.id, 0))
... ...
@@ -207,6 +216,7 @@ error:
207 216
 AAAMessage * Ro_write_CCR_avps(AAAMessage * ccr, Ro_CCR_t* x) {
208 217
 
209 218
     if (!ccr) return 0;
219
+    LM_DBG("write all CCR AVPs\n");
210 220
 
211 221
     if (x->origin_host.s && x->origin_host.len > 0) {
212 222
         if (!cdp_avp->base.add_Origin_Host(&(ccr->avpList), x->origin_host, 0)) goto error;
... ...
@@ -250,6 +260,7 @@ error:
250 260
 AAAMessage *Ro_new_ccr(AAASession * session, Ro_CCR_t * ro_ccr_data) {
251 261
 
252 262
     AAAMessage * ccr = 0;
263
+    LM_DBG("create a new CCR\n");
253 264
     ccr = cdp_avp->cdp->AAACreateRequest(IMS_Ro, Diameter_CCR, Flag_Proxyable, session);
254 265
     if (!ccr) {
255 266
         LM_ERR("could not create CCR\n");
... ...
@@ -265,6 +276,7 @@ Ro_CCA_t *Ro_parse_CCA_avps(AAAMessage *cca) {
265 276
     if (!cca)
266 277
         return 0;
267 278
 
279
+    LM_DBG("parse CCA AVPs\n");
268 280
     Ro_CCA_t *ro_cca_data = 0;
269 281
     mem_new(ro_cca_data, sizeof (Ro_CCR_t), pkg);
270 282
     multiple_services_credit_control_t *mscc = 0;
... ...
@@ -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;