Browse code

ims_charging: bugfix for destination_host parameter, implementation was incomplete

Henning Westerholt authored on 02/07/2020 08:54:20
Showing 1 changed files
... ...
@@ -194,6 +194,9 @@ Ro_CCR_t * new_Ro_CCR(int32_t acc_record_type, str * user_name, ims_information_
194 194
     
195 195
     if (cfg.origin_realm.s && cfg.origin_realm.len >0)
196 196
         str_dup(x->origin_realm, cfg.origin_realm, pkg);
197
+
198
+    if (cfg.destination_host.s && cfg.destination_host.len > 0)
199
+        str_dup(x->destination_host, cfg.destination_host, pkg);
197 200
     
198 201
     if (cfg.destination_realm.s && cfg.destination_realm.len > 0)
199 202
         str_dup(x->destination_realm, cfg.destination_realm, pkg);
... ...
@@ -293,6 +296,7 @@ void Ro_free_CCR(Ro_CCR_t *x) {
293 296
 
294 297
     str_free(x->origin_host, pkg);
295 298
     str_free(x->origin_realm, pkg);
299
+    str_free(x->destination_host, pkg);
296 300
     str_free(x->destination_realm, pkg);
297 301
 
298 302
     str_free_ptr(x->user_name, pkg);
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
... ...
@@ -87,7 +87,8 @@ out_of_memory:
87 87
 }
88 88
 
89 89
 ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t * time_stamps, str * user_session_id, str * outgoing_session_id, str * calling_party, 
90
-	str * called_party, str * icid, str * orig_ioi, str * term_ioi, int node_role, str *incoming_trunk_id, str *outgoing_trunk_id, str* pani) {
90
+	str * called_party, str * icid, str * orig_ioi, str * term_ioi, int node_role, str *incoming_trunk_id, str *outgoing_trunk_id, str* pani,
91
+	str * app_provided_party) {
91 92
 
92 93
     str_list_slot_t *sl = 0;
93 94
     ims_information_t *x = 0;
... ...
@@ -131,6 +132,10 @@ ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t
131 132
 	str_dup_ptr(x->access_network_info, *pani, pkg);
132 133
     }
133 134
 
135
+    if (app_provided_party && app_provided_party->s && (app_provided_party->len > 0)) {
136
+	str_dup_ptr(x->app_provided_party, *app_provided_party, pkg);
137
+    }
138
+
134 139
     //WL_FREE_ALL(&(x->called_asserted_identity),str_list_t,pkg);
135 140
     //str_free_ptr(x->requested_party_address,pkg);
136 141
 
... ...
@@ -256,6 +261,7 @@ void ims_information_free(ims_information_t *x) {
256 261
     str_free_ptr(x->incoming_trunk_id, pkg);
257 262
     str_free_ptr(x->outgoing_trunk_id, pkg);
258 263
     str_free_ptr(x->access_network_info, pkg);
264
+    str_free_ptr(x->app_provided_party, pkg);
259 265
 
260 266
     time_stamps_free(x->time_stamps);
261 267
 
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
... ...
@@ -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;
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,320 @@
1
+#include "Ro_data.h"
2
+#include "config.h"
3
+
4
+
5
+#define str_dup(dst,src,mem) \
6
+do {\
7
+	if ((src).len) {\
8
+		(dst).s = mem##_malloc((src).len);\
9
+		if (!(dst).s){\
10
+			LM_ERR("Error allocating %d bytes in %s!\n",(src).len,#mem);\
11
+			(dst).len = 0;\
12
+			goto out_of_memory;\
13
+		}\
14
+		memcpy((dst).s,(src).s,(src).len);\
15
+		(dst).len = (src).len;\
16
+	}else{\
17
+		(dst).s=0;(dst).len=0;\
18
+	}\
19
+} while (0)
20
+
21
+/**
22
+ * Frees a str content.
23
+ * @param x - the str to free
24
+ * @param mem - type of memory that the content is using (shm/pkg)
25
+ */
26
+#define str_free(x,mem) \
27
+do {\
28
+	if ((x).s) mem##_free((x).s);\
29
+	(x).s=0;(x).len=0;\
30
+} while(0)
31
+
32
+extern client_ro_cfg cfg;
33
+
34
+event_type_t * new_event_type(str * sip_method, str * event, uint32_t * expires) {
35
+    event_type_t * x = 0;
36
+
37
+    mem_new(x, sizeof (event_type_t), pkg);
38
+    if (sip_method && sip_method->s)
39
+        str_dup_ptr(x->sip_method, *sip_method, pkg);
40
+    if (event && event->s)
41
+        str_dup_ptr(x->event, *event, pkg);
42
+    if (expires && *expires != 0) {
43
+        mem_new(x->expires, sizeof (uint32_t), pkg);
44
+        *(x->expires) = *expires;
45
+    }
46
+    return x;
47
+
48
+out_of_memory:
49
+    LM_ERR("out of pkg memory\n");
50
+    event_type_free(x);
51
+    return NULL;
52
+}
53
+
54
+time_stamps_t * new_time_stamps(time_t *sip_request_timestamp, uint32_t *sip_request_timestamp_fraction, time_t *sip_response_timestamp, uint32_t *sip_response_timestamp_fraction) {
55
+
56
+    time_stamps_t * x = 0;
57
+
58
+    mem_new(x, sizeof (time_stamps_t), pkg);
59
+
60
+    if (sip_request_timestamp && *sip_request_timestamp > 0) {
61
+        mem_new(x->sip_request_timestamp, sizeof (time_t), pkg);
62
+        *(x->sip_request_timestamp) = *sip_request_timestamp;
63
+    }
64
+
65
+    if (sip_request_timestamp_fraction && *sip_request_timestamp_fraction > 0) {
66
+        mem_new(x->sip_request_timestamp_fraction, sizeof (uint32_t), pkg);
67
+        *(x->sip_request_timestamp_fraction) = *sip_request_timestamp_fraction;
68
+    }
69
+
70
+    if (sip_response_timestamp && *sip_response_timestamp > 0) {
71
+        mem_new(x->sip_response_timestamp, sizeof (time_t), pkg);
72
+        *(x->sip_response_timestamp) = *sip_response_timestamp;
73
+    }
74
+
75
+    if (sip_response_timestamp_fraction && *sip_response_timestamp_fraction > 0) {
76
+        mem_new(x->sip_response_timestamp_fraction, sizeof (uint32_t), pkg);
77
+        *(x->sip_response_timestamp_fraction) = *sip_response_timestamp_fraction;
78
+    }
79
+
80
+
81
+    return x;
82
+
83
+out_of_memory:
84
+    LM_ERR("out of pkg memory\n");
85
+    time_stamps_free(x);
86
+    return 0;
87
+}
88
+
89
+ims_information_t * new_ims_information(event_type_t * event_type, time_stamps_t * time_stamps, str * user_session_id, str * outgoing_session_id, str * calling_party, 
90
+	str * called_party, str * icid, str * orig_ioi, str * term_ioi, int node_role, str *incoming_trunk_id, str *outgoing_trunk_id, str* pani) {
91
+
92
+    str_list_slot_t *sl = 0;
93
+    ims_information_t *x = 0;
94
+    ioi_list_element_t * ioi_elem = 0;
95
+
96
+    mem_new(x, sizeof (ims_information_t), pkg);
97
+
98
+    x->event_type = event_type;
99
+    x->time_stamps = time_stamps;
100
+
101
+    mem_new(x->role_of_node, sizeof (int32_t), pkg);
102
+    *(x->role_of_node) = node_role;
103
+
104
+    //x->node_functionality = cfg.node_func;
105
+
106
+    if (outgoing_session_id && outgoing_session_id->s)
107
+        str_dup_ptr(x->outgoing_session_id, *outgoing_session_id, pkg);
108
+
109
+    if (user_session_id && user_session_id->s)
110
+        str_dup_ptr(x->user_session_id, *user_session_id, pkg);
111
+
112
+    if (calling_party && calling_party->s) {
113
+        mem_new(sl, sizeof (str_list_slot_t), pkg);
114
+        str_dup(sl->data, *calling_party, pkg);
115
+        WL_APPEND(&(x->calling_party_address), sl);
116
+    }
117
+
118
+    if (called_party && called_party->s)
119
+        str_dup_ptr(x->called_party_address, *called_party, pkg);
120
+    
121
+    if (incoming_trunk_id && incoming_trunk_id->s)
122
+        str_dup_ptr(x->incoming_trunk_id, *incoming_trunk_id, pkg);
123
+    
124
+    if (outgoing_trunk_id && outgoing_trunk_id->s)
125
+        str_dup_ptr(x->outgoing_trunk_id, *outgoing_trunk_id, pkg);
126
+    
127
+    if (pani && pani->s && (pani->len > 0)) {
128
+	str_dup_ptr(x->access_network_info, *pani, pkg);
129
+    }
130
+
131
+    //WL_FREE_ALL(&(x->called_asserted_identity),str_list_t,pkg);
132
+    //str_free_ptr(x->requested_party_address,pkg);
133
+
134
+    if ((orig_ioi && orig_ioi->s) || (term_ioi && term_ioi->s)) {
135
+        mem_new(ioi_elem, sizeof (ioi_list_element_t), pkg);
136
+        if (orig_ioi)
137
+            str_dup_ptr_ptr(ioi_elem->info.originating_ioi, orig_ioi, pkg);
138
+        if (term_ioi)
139
+            str_dup_ptr_ptr(ioi_elem->info.terminating_ioi, term_ioi, pkg);
140
+    }
141
+
142
+    if (icid && icid->s)
143
+        str_dup_ptr(x->icid, *icid, pkg);
144
+
145
+    return x;
146
+
147
+out_of_memory:
148
+    LM_ERR("out of pkg memory\n");
149
+    ims_information_free(x);
150
+    return NULL;
151
+}
152
+
153
+service_information_t * new_service_information(ims_information_t * ims_info, subscription_id_t * subscription) {
154
+    service_information_t * x = 0;
155
+    subscription_id_list_element_t * sl = 0;
156
+
157
+    mem_new(x, sizeof (service_information_t), pkg);
158
+
159
+    x->ims_information = ims_info;
160
+    if (subscription) {
161
+        mem_new(sl, sizeof (subscription_id_list_element_t), pkg);
162
+        subscription_id_list_t_copy(&(sl->s), subscription, pkg);
163
+        WL_APPEND(&(x->subscription_id), sl);
164
+    }
165
+
166
+    return x;
167
+
168
+out_of_memory:
169
+    LM_ERR("new service information: out of pkg memory\n");
170
+    service_information_free(x);
171
+    return 0;
172
+}
173
+
174
+Ro_CCR_t * new_Ro_CCR(int32_t acc_record_type, str * user_name, ims_information_t * ims_info, subscription_id_t * subscription) {
175
+
176
+
177
+    Ro_CCR_t *x = 0;
178
+
179
+    service_information_t * service_info = 0;
180
+
181
+    mem_new(x, sizeof (Ro_CCR_t), pkg);
182
+
183
+    if (cfg.origin_host.s && cfg.origin_host.len > 0)
184
+        str_dup(x->origin_host, cfg.origin_host, pkg);
185
+    
186
+    if (cfg.origin_realm.s && cfg.origin_realm.len >0)
187
+        str_dup(x->origin_realm, cfg.origin_realm, pkg);
188
+    
189
+    if (cfg.destination_realm.s && cfg.destination_realm.len > 0)
190
+        str_dup(x->destination_realm, cfg.destination_realm, pkg);
191
+    
192
+    x->acct_record_type = acc_record_type;
193
+
194
+    if (user_name) {
195
+        str_dup_ptr_ptr(x->user_name, user_name, pkg);
196
+    }
197
+
198
+    if (cfg.service_context_id && cfg.service_context_id->s)
199
+        str_dup_ptr(x->service_context_id, *(cfg.service_context_id), pkg);
200
+
201
+    if (ims_info)
202
+        if (!(service_info = new_service_information(ims_info, subscription)))
203
+            goto error;
204
+
205
+    x->service_information = service_info;
206
+    service_info = 0;
207
+
208
+    return x;
209
+
210
+out_of_memory:
211
+    LM_ERR("out of pkg memory\n");
212
+error:
213
+    Ro_free_CCR(x);
214
+    service_information_free(service_info);
215
+
216
+    return 0;
217
+}
218
+
219
+void event_type_free(event_type_t *x) {
220
+    if (!x) return;
221
+    str_free_ptr(x->sip_method, pkg);
222
+    str_free_ptr(x->event, pkg);
223
+    mem_free(x->expires, pkg);
224
+    mem_free(x, pkg);
225
+}
226
+
227
+void time_stamps_free(time_stamps_t *x) {
228
+    if (!x) return;
229
+    mem_free(x->sip_request_timestamp, pkg);
230
+    mem_free(x->sip_request_timestamp_fraction, pkg);
231
+    mem_free(x->sip_response_timestamp, pkg);
232
+    mem_free(x->sip_response_timestamp_fraction, pkg);
233
+    mem_free(x, pkg);
234
+}
235
+
236
+void ims_information_free(ims_information_t *x) {
237
+    if (!x) return;
238
+
239
+    event_type_free(x->event_type);
240
+
241
+    mem_free(x->role_of_node, pkg);
242
+    str_free_ptr(x->user_session_id, pkg);
243
+    str_free_ptr(x->outgoing_session_id, pkg);
244
+
245
+    WL_FREE_ALL(&(x->calling_party_address), str_list_t, pkg);
246
+    str_free_ptr(x->called_party_address, pkg);
247
+    WL_FREE_ALL(&(x->called_asserted_identity), str_list_t, pkg);
248
+    str_free_ptr(x->requested_party_address, pkg);
249
+    
250
+    str_free_ptr(x->incoming_trunk_id, pkg);
251
+    str_free_ptr(x->outgoing_trunk_id, pkg);
252
+    str_free_ptr(x->access_network_info, pkg);
253
+
254
+    time_stamps_free(x->time_stamps);
255
+
256
+    WL_FREE_ALL(&(x->as_info), as_info_list_t, pkg);
257
+
258
+    WL_FREE_ALL(&(x->ioi), ioi_list_t, pkg);
259
+    str_free_ptr(x->icid, pkg);
260
+
261
+    str_free_ptr(x->service_id, pkg);
262
+
263
+    WL_FREE_ALL(&(x->service_specific_info), service_specific_info_list_t, pkg);
264
+
265
+    mem_free(x->cause_code, pkg);
266
+
267
+    mem_free(x, pkg);
268
+}
269
+
270
+void service_information_free(service_information_t *x) {
271
+    if (!x) return;
272
+
273
+    WL_FREE_ALL(&(x->subscription_id), subscription_id_list_t, pkg);
274
+    ims_information_free(x->ims_information);
275
+
276
+    mem_free(x, pkg);
277
+}
278
+
279
+void Ro_free_CCR(Ro_CCR_t *x) {
280
+    if (!x) return;
281
+
282
+    str_free(x->origin_host, pkg);
283
+    str_free(x->origin_realm, pkg);
284
+    str_free(x->destination_realm, pkg);
285
+
286
+    str_free_ptr(x->user_name, pkg);
287
+    mem_free(x->acct_interim_interval, pkg);
288
+    mem_free(x->origin_state_id, pkg);
289
+    mem_free(x->event_timestamp, pkg);
290
+
291
+    str_free_ptr(x->service_context_id, pkg);
292
+
293
+    service_information_free(x->service_information);
294
+
295
+    mem_free(x, pkg);
296
+}
297
+
298
+void Ro_free_CCA(Ro_CCA_t *x) {
299
+    str *p_str;
300
+	if (!x) return;
301
+
302
+    if (x->mscc->final_unit_action) {
303
+        if (x->mscc->final_unit_action->redirect_server) {
304
+			if (x->mscc->final_unit_action->redirect_server->server_address) {
305
+				p_str = x->mscc->final_unit_action->redirect_server->server_address;
306
+				if (p_str->len > 0 && p_str->s)
307
+					mem_free(p_str->s, pkg);
308
+				mem_free(p_str, pkg);
309
+			}
310
+		}
311
+		mem_free(x->mscc->final_unit_action, pkg);
312
+		
313
+    }
314
+    mem_free(x->mscc->granted_service_unit, pkg);
315
+    mem_free(x->mscc, pkg);
316
+    mem_free(x, pkg);
317
+}
318
+
319
+
320
+