Asterisk - The Open Source Telephony Project GIT-master-f36a736
test_aoc.c
Go to the documentation of this file.
1/*
2 * Asterisk -- An open source telephony toolkit.
3 *
4 * Copyright (C) 2010, Digium, Inc.
5 *
6 * David Vossel <dvossel@digium.com>
7 *
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
13 *
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
17 */
18
19/*!
20 * \file
21 * \brief Generic AOC encode decode tests
22 *
23 * \author David Vossel <dvossel@digium.com>
24 *
25 * \ingroup tests
26 */
27
28/*** MODULEINFO
29 <depend>TEST_FRAMEWORK</depend>
30 <support_level>core</support_level>
31 ***/
32
33#include "asterisk.h"
34
35#include "asterisk/utils.h"
36#include "asterisk/module.h"
37#include "asterisk/test.h"
38#include "asterisk/aoc.h"
39
40
41AST_TEST_DEFINE(aoc_event_generation_test)
42{
43 int res = AST_TEST_PASS;
44 struct ast_aoc_decoded *decoded = NULL;
45 struct ast_str *msg = NULL;
46
47 switch (cmd) {
48 case TEST_INIT:
49 info->name = "aoc_event_test";
50 info->category = "/main/aoc/";
51 info->summary = "Advice of Charge event generation test";
52 info->description =
53 "Creates AOC messages, verify event string matches expected results";
54 return AST_TEST_NOT_RUN;
55 case TEST_EXECUTE:
56 break;
57 }
58
59 if (!(msg = ast_str_create(1024))) {
60 goto cleanup_aoc_event_test;
61 }
62
63 /* ---- TEST 1, AOC-D event generation */
64 if (!(decoded = ast_aoc_create(AST_AOC_D, AST_AOC_CHARGE_CURRENCY, 0))) {
65
66 ast_test_status_update(test, "failed to create AOC-D message for event generation.\n");
67 res = AST_TEST_FAIL;
68 goto cleanup_aoc_event_test;
69 }
70 /* Add billing id information */
72
73 /* Set currency information, verify results */
74 if ((ast_aoc_set_currency_info(decoded, 100, AST_AOC_MULT_ONE, "usd")) ||
76
77 ast_test_status_update(test, "failed to set currency info in AOC-D msg\n");
78 res = AST_TEST_FAIL;
79 goto cleanup_aoc_event_test;
80 }
81 if (ast_aoc_decoded2str(decoded, &msg)) {
82
83 ast_test_status_update(test, "failed to generate AOC-D msg string.\n");
84 res = AST_TEST_FAIL;
85 goto cleanup_aoc_event_test;
86 }
87 if (strncmp(ast_str_buffer(msg),
88 "AOC-D\r\n"
89 "Type: Currency\r\n"
90 "BillingID: CreditCard\r\n"
91 "TypeOfCharging: SubTotal\r\n"
92 "Currency: usd\r\n"
93 "Currency/Amount/Cost: 100\r\n"
94 "Currency/Amount/Multiplier: 1\r\n",
95 strlen(ast_str_buffer(msg)))) {
96
97 ast_test_status_update(test, "AOC-D msg event did not match expected results\n");
98 res = AST_TEST_FAIL;
99 goto cleanup_aoc_event_test;
100 }
101 decoded = ast_aoc_destroy_decoded(decoded);
102 ast_str_reset(msg);
103
104
105 /* ---- TEST 2, AOC-S event generation */
106 if (!(decoded = ast_aoc_create(AST_AOC_S, 0, 0))) {
107 ast_test_status_update(test, "failed to create AOC-S message for event generation.\n");
108
109 res = AST_TEST_FAIL;
110 goto cleanup_aoc_event_test;
111 }
112
115 123,
117 "pineapple");
118
122 937,
124 "oranges");
125
128 937,
130 "bananas",
131 848,
133 949,
135 1);
136
139 937,
141 "bananas",
142 1111,
144 2222,
146 0);
147
148 if (ast_aoc_decoded2str(decoded, &msg)) {
149
150 ast_test_status_update(test, "failed to generate AOC-D msg string.\n");
151 res = AST_TEST_FAIL;
152 goto cleanup_aoc_event_test;
153 }
154
155
156 if (strncmp(ast_str_buffer(msg),
157 "AOC-S\r\n"
158 "NumberRates: 4\r\n"
159 "Rate(0)/Chargeable: BasicCommunication\r\n"
160 "Rate(0)/Type: Flat\r\n"
161 "Rate(0)/Flat/Currency: pineapple\r\n"
162 "Rate(0)/Flat/Amount/Cost: 123\r\n"
163 "Rate(0)/Flat/Amount/Multiplier: 10\r\n"
164 "Rate(1)/Chargeable: CallAttempt\r\n"
165 "Rate(1)/Type: Volume\r\n"
166 "Rate(1)/Volume/Currency: oranges\r\n"
167 "Rate(1)/Volume/Amount/Cost: 937\r\n"
168 "Rate(1)/Volume/Amount/Multiplier: 1/100\r\n"
169 "Rate(1)/Volume/Unit: Segment\r\n"
170 "Rate(2)/Chargeable: CallAttempt\r\n"
171 "Rate(2)/Type: Duration\r\n"
172 "Rate(2)/Duration/Currency: bananas\r\n"
173 "Rate(2)/Duration/Amount/Cost: 937\r\n"
174 "Rate(2)/Duration/Amount/Multiplier: 1/1000\r\n"
175 "Rate(2)/Duration/ChargingType: StepFunction\r\n"
176 "Rate(2)/Duration/Time/Length: 848\r\n"
177 "Rate(2)/Duration/Time/Scale: OneTenthSecond\r\n"
178 "Rate(2)/Duration/Granularity/Length: 949\r\n"
179 "Rate(2)/Duration/Granularity/Scale: Hour\r\n"
180 "Rate(3)/Chargeable: UserUserInfo\r\n"
181 "Rate(3)/Type: Duration\r\n"
182 "Rate(3)/Duration/Currency: bananas\r\n"
183 "Rate(3)/Duration/Amount/Cost: 937\r\n"
184 "Rate(3)/Duration/Amount/Multiplier: 1000\r\n"
185 "Rate(3)/Duration/ChargingType: ContinuousCharging\r\n"
186 "Rate(3)/Duration/Time/Length: 1111\r\n"
187 "Rate(3)/Duration/Time/Scale: Second\r\n"
188 "Rate(3)/Duration/Granularity/Length: 2222\r\n"
189 "Rate(3)/Duration/Granularity/Scale: Day\r\n",
190 strlen(ast_str_buffer(msg)))) {
191
192 ast_test_status_update(test, "AOC-S msg event did not match expected results\n");
193 res = AST_TEST_FAIL;
194 goto cleanup_aoc_event_test;
195 }
196 decoded = ast_aoc_destroy_decoded(decoded);
197 ast_str_reset(msg);
198
199 /* ---- TEST 3, AOC-E event generation with various charging association information*/
200 if (!(decoded = ast_aoc_create(AST_AOC_E, AST_AOC_CHARGE_UNIT, 0))) {
201 ast_test_status_update(test, "failed to create AOC-E message for event generation.\n");
202
203 res = AST_TEST_FAIL;
204 goto cleanup_aoc_event_test;
205 }
206 if ((ast_aoc_add_unit_entry(decoded, 1, 111, 1, 1)) ||
207 (!ast_aoc_add_unit_entry(decoded, 0, 2222, 0, 2)) || /* we expect this to fail, and it should not be added to entry list */
208 (ast_aoc_add_unit_entry(decoded, 1, 3333, 0, 3)) ||
209 (ast_aoc_add_unit_entry(decoded, 0, 44444, 1, 4))) {
210
211 ast_test_status_update(test, "failed to set unit info for AOC-E message\n");
212 res = AST_TEST_FAIL;
213 goto cleanup_aoc_event_test;
214 }
215
216 if (ast_aoc_decoded2str(decoded, &msg)) {
217 ast_test_status_update(test, "failed to generate AOC-E msg string.\n");
218 res = AST_TEST_FAIL;
219 goto cleanup_aoc_event_test;
220 }
221
222 if (strncmp(ast_str_buffer(msg),
223 "AOC-E\r\n"
224 "Type: Units\r\n"
225 "BillingID: NotAvailable\r\n"
226 "Units/NumberItems: 3\r\n"
227 "Units/Item(0)/NumberOf: 111\r\n"
228 "Units/Item(0)/TypeOf: 1\r\n"
229 "Units/Item(1)/NumberOf: 3333\r\n"
230 "Units/Item(2)/TypeOf: 4\r\n",
231 strlen(ast_str_buffer(msg)))) {
232
233 ast_test_status_update(test, "AOC-E msg event did not match expected results, with no charging association info\n");
234 res = AST_TEST_FAIL;
235 goto cleanup_aoc_event_test;
236 }
237
238 /* add AOC-E charging association number info */
239 if (ast_aoc_set_association_number(decoded, "555-555-5555", 16)) {
240 ast_test_status_update(test, "failed to set the charging association number info correctly, 3\n");
241 res = AST_TEST_FAIL;
242 goto cleanup_aoc_event_test;
243 }
244
245 ast_str_reset(msg);
246 if (ast_aoc_decoded2str(decoded, &msg)) {
247 ast_test_status_update(test, "failed to generate AOC-E msg string.\n");
248 res = AST_TEST_FAIL;
249 goto cleanup_aoc_event_test;
250 }
251
252 if (strncmp(ast_str_buffer(msg),
253 "AOC-E\r\n"
254 "ChargingAssociation/Number: 555-555-5555\r\n"
255 "ChargingAssociation/Number/Plan: 16\r\n"
256 "Type: Units\r\n"
257 "BillingID: NotAvailable\r\n"
258 "Units/NumberItems: 3\r\n"
259 "Units/Item(0)/NumberOf: 111\r\n"
260 "Units/Item(0)/TypeOf: 1\r\n"
261 "Units/Item(1)/NumberOf: 3333\r\n"
262 "Units/Item(2)/TypeOf: 4\r\n",
263 strlen(ast_str_buffer(msg)))) {
264
265 ast_test_status_update(test, "AOC-E msg event did not match expected results, with charging association number\n");
266 res = AST_TEST_FAIL;
267 goto cleanup_aoc_event_test;
268 }
269
270 /* add AOC-E charging association id info */
271 if (ast_aoc_set_association_id(decoded, 2222)) {
272 ast_test_status_update(test, "failed to set the charging association number info correctly, 3\n");
273 res = AST_TEST_FAIL;
274 goto cleanup_aoc_event_test;
275 }
276
277 ast_str_reset(msg);
278 if (ast_aoc_decoded2str(decoded, &msg)) {
279 ast_test_status_update(test, "failed to generate AOC-E msg string.\n");
280 res = AST_TEST_FAIL;
281 goto cleanup_aoc_event_test;
282 }
283
284 if (strncmp(ast_str_buffer(msg),
285 "AOC-E\r\n"
286 "ChargingAssociation/ID: 2222\r\n"
287 "Type: Units\r\n"
288 "BillingID: NotAvailable\r\n"
289 "Units/NumberItems: 3\r\n"
290 "Units/Item(0)/NumberOf: 111\r\n"
291 "Units/Item(0)/TypeOf: 1\r\n"
292 "Units/Item(1)/NumberOf: 3333\r\n"
293 "Units/Item(2)/TypeOf: 4\r\n",
294 strlen(ast_str_buffer(msg)))) {
295
296 ast_test_status_update(test, "AOC-E msg event did not match expected results with charging association id.\n");
297 res = AST_TEST_FAIL;
298 goto cleanup_aoc_event_test;
299 }
300
301
302cleanup_aoc_event_test:
303
304 decoded = ast_aoc_destroy_decoded(decoded);
305 ast_free(msg);
306 return res;
307}
308
309AST_TEST_DEFINE(aoc_encode_decode_test)
310{
311 int res = AST_TEST_PASS;
312 struct ast_aoc_decoded *decoded;
313
314 switch (cmd) {
315 case TEST_INIT:
316 info->name = "aoc_encode_decode_test";
317 info->category = "/main/aoc/";
318 info->summary = "Advice of Charge encode and decode test";
319 info->description =
320 "This tests the Advice of Charge encode and decode routines.";
321 return AST_TEST_NOT_RUN;
322 case TEST_EXECUTE:
323 break;
324 }
325
326 /* ---- Test 1 ---- create AOC-D message, encode message, and decode message once again. */
327 /* create AOC-D message */
328 if (!(decoded = ast_aoc_create(AST_AOC_D, AST_AOC_CHARGE_CURRENCY, 0)) ||
329 (ast_aoc_get_msg_type(decoded) != AST_AOC_D) ||
331
332 ast_test_status_update(test, "Test 1: failed to create AOC-D message\n");
333 res = AST_TEST_FAIL;
334 goto cleanup_aoc_test;
335 }
336
337 /* Add billing id information */
340
341 ast_test_status_update(test, "TEST 1, could not set billing id correctly\n");
342 res = AST_TEST_FAIL;
343 goto cleanup_aoc_test;
344
345 }
346
347 /* Set currency information, verify results*/
348 if ((ast_aoc_set_currency_info(decoded, 100, AST_AOC_MULT_ONE, "usd")) ||
351 (ast_aoc_get_currency_amount(decoded) != 100) ||
353 (strcmp(ast_aoc_get_currency_name(decoded), "usd"))) {
354
355 ast_test_status_update(test, "Test 1: failed to set currency info\n");
356 res = AST_TEST_FAIL;
357 goto cleanup_aoc_test;
358 }
359
360 /* Set a currency name larger than 10 characters which is the maximum
361 * length allowed by the ETSI aoc standard. The name is expected to truncate
362 * to 10 characters. */
363 if ((ast_aoc_set_currency_info(decoded, 100, AST_AOC_MULT_ONE, "12345678901234567890")) ||
364 (ast_aoc_get_currency_amount(decoded) != 100) ||
366 (strcmp(ast_aoc_get_currency_name(decoded), "1234567890"))) {
367
368 ast_test_status_update(test, "Test 1: failed to set currency info currency name exceeding limit\n");
369 res = AST_TEST_FAIL;
370 goto cleanup_aoc_test;
371 }
372
373 /* Encode the message */
375 ast_test_status_update(test, "Test1: encode decode routine did not match expected results \n");
376 res = AST_TEST_FAIL;
377 goto cleanup_aoc_test;
378 }
379 /* cleanup decoded msg */
380 decoded = ast_aoc_destroy_decoded(decoded);
381
382 /* ---- Test 2 ---- create AOC-E message with charge type == unit */
383 /* create AOC-E message */
384 if (!(decoded = ast_aoc_create(AST_AOC_E, AST_AOC_CHARGE_UNIT, 0)) ||
385 (ast_aoc_get_msg_type(decoded) != AST_AOC_E) ||
387
388 ast_test_status_update(test, "Test 2: failed to create AOC-E message\n");
389 res = AST_TEST_FAIL;
390 goto cleanup_aoc_test;
391 }
392
393 /* Set unit information, verify results*/
394 if ((ast_aoc_add_unit_entry(decoded, 1, 1, 1, 2)) ||
395 (!ast_aoc_add_unit_entry(decoded, 0, 123, 0, 123)) || /* this entry should fail since either number nor type are present */
396 (ast_aoc_add_unit_entry(decoded, 0, 2, 1, 3)) ||
397 (ast_aoc_add_unit_entry(decoded, 1, 3, 0, 4))) {
398
399 ast_test_status_update(test, "Test 2: failed to set unit info\n");
400 res = AST_TEST_FAIL;
401 goto cleanup_aoc_test;
402 }
403
404 /* verify unit list is correct */
405 if (ast_aoc_get_unit_count(decoded) == 3) {
406 int i;
407 const struct ast_aoc_unit_entry *unit;
408 for (i = 0; i < 3; i++) {
409 if (!(unit = ast_aoc_get_unit_info(decoded, i)) ||
410 ((unit->valid_amount) && (unit->amount != (i+1))) ||
411 ((unit->valid_type) && (unit->type != (i+2)))) {
412 ast_test_status_update(test, "TEST 2, invalid unit entry result, got %u,%u, expected %d,%d\n",
413 unit->amount,
414 unit->type,
415 i+1,
416 i+2);
417 res = AST_TEST_FAIL;
418 goto cleanup_aoc_test;
419 }
420 }
421 } else {
422 ast_test_status_update(test, "TEST 2, invalid unit list entry count \n");
423 res = AST_TEST_FAIL;
424 goto cleanup_aoc_test;
425 }
426
427
428 /* Test charging association information */
429 {
430 const struct ast_aoc_charging_association *ca;
431 if ((ast_aoc_set_association_id(decoded, 1234)) ||
432 (!(ca = ast_aoc_get_association_info(decoded)))) {
433 ast_test_status_update(test, "TEST 2, could not set charging association id info correctly\n");
434 res = AST_TEST_FAIL;
435 goto cleanup_aoc_test;
436 }
437
438 if ((ca->charging_type != AST_AOC_CHARGING_ASSOCIATION_ID) || (ca->charge.id != 1234)) {
439 ast_test_status_update(test, "TEST 2, could not get charging association id info correctly, 2\n");
440 }
441
442 if ((ast_aoc_set_association_number(decoded, "1234", 16)) ||
443 (!(ca = ast_aoc_get_association_info(decoded)))) {
444 ast_test_status_update(test, "TEST 2, could not set charging association number info correctly, 3\n");
445 res = AST_TEST_FAIL;
446 goto cleanup_aoc_test;
447 }
448
450 (ca->charge.number.plan != 16) ||
451 (strcmp(ca->charge.number.number, "1234"))) {
452 ast_test_status_update(test, "TEST 2, could not get charging association number info correctly\n");
453 }
454 }
455
456 /* Test every billing id possibility */
457 {
458 int billid[9] = {
468 };
469 int i;
470
471 /* these should fail */
472 if (!(ast_aoc_set_billing_id(decoded, (AST_AOC_BILLING_NA - 1))) ||
474
475 ast_test_status_update(test, "TEST 2, setting invalid billing id should fail\n");
476 res = AST_TEST_FAIL;
477 goto cleanup_aoc_test;
478 }
479
480 for (i = 0; i < ARRAY_LEN(billid); i++) {
481 if ((ast_aoc_set_billing_id(decoded, billid[i]) ||
482 (ast_aoc_get_billing_id(decoded) != billid[i]))) {
483
484 ast_test_status_update(test, "TEST 2, could not set billing id correctly, iteration #%d\n", i);
485 res = AST_TEST_FAIL;
486 goto cleanup_aoc_test;
487 }
488 }
489 }
490 /* Encode the message */
492 ast_test_status_update(test, "Test2: encode decode routine did not match expected results \n");
493 res = AST_TEST_FAIL;
494 goto cleanup_aoc_test;
495 }
496 /* cleanup decoded msg */
497 decoded = ast_aoc_destroy_decoded(decoded);
498
499 /* ---- Test 3 ---- create AOC-Request. test all possible combinations */
500 {
501 int request[7] = { /* all possible request combinations */
509 };
510 int i;
511
512 for (i = 0; i < ARRAY_LEN(request); i++) {
513 if (!(decoded = ast_aoc_create(AST_AOC_REQUEST, 0, request[i])) ||
516 (ast_aoc_get_request(decoded) != request[i])) {
517
518 ast_test_status_update(test, "Test 3: failed to create AOC-Request message, iteration #%d\n", i);
519 res = AST_TEST_FAIL;
520 goto cleanup_aoc_test;
521 }
522
523 /* Encode the message */
525 ast_test_status_update(test, "Test3: encode decode routine did not match expected results, iteration #%d\n", i);
526 res = AST_TEST_FAIL;
527 goto cleanup_aoc_test;
528 }
529 /* cleanup decoded msg */
530 decoded = ast_aoc_destroy_decoded(decoded);
531 }
532
533
534 /* Test termination Request Type */
535 if (!(decoded = ast_aoc_create(AST_AOC_REQUEST, 0, AST_AOC_REQUEST_E)) ||
540
541 ast_test_status_update(test, "Test 3: failed to create AOC-Request message with Termination Request set\n");
542 res = AST_TEST_FAIL;
543 goto cleanup_aoc_test;
544 }
545
546 /* Encode the message */
548 ast_test_status_update(test, "Test3: encode decode routine did not match expected results with termination request set\n");
549 res = AST_TEST_FAIL;
550 goto cleanup_aoc_test;
551 }
552 /* cleanup decoded msg */
553 decoded = ast_aoc_destroy_decoded(decoded);
554 }
555
556 /* ---- Test 4 ---- Make stuff blow up */
557 if ((decoded = ast_aoc_create(AST_AOC_D, 1234567, 0))) {
558
559 ast_test_status_update(test, "Test 4: aoc-d creation with no valid charge type should fail\n");
560 res = AST_TEST_FAIL;
561 goto cleanup_aoc_test;
562 }
563 if ((decoded = ast_aoc_create(AST_AOC_REQUEST, 0, 0))) {
564
565 ast_test_status_update(test, "Test 4: aoc request creation with no data should have failed\n");
566 res = AST_TEST_FAIL;
567 goto cleanup_aoc_test;
568 }
569 if ((decoded = ast_aoc_create(AST_AOC_REQUEST, -12345678, -23456789))) {
570
571 ast_test_status_update(test, "Test 4: aoc request creation with random data should have failed\n");
572 res = AST_TEST_FAIL;
573 goto cleanup_aoc_test;
574 }
575
576 /* ---- Test 5 ---- create AOC-E message with charge type == FREE and charge type == NA */
577 /* create AOC-E message */
578 if (!(decoded = ast_aoc_create(AST_AOC_E, AST_AOC_CHARGE_FREE, 0)) ||
579 (ast_aoc_get_msg_type(decoded) != AST_AOC_E) ||
581
582 ast_test_status_update(test, "Test 5: failed to create AOC-E message, charge type Free\n");
583 res = AST_TEST_FAIL;
584 goto cleanup_aoc_test;
585 }
587 ast_test_status_update(test, "Test5: encode decode routine did not match expected results, charge type Free\n");
588 res = AST_TEST_FAIL;
589 goto cleanup_aoc_test;
590 }
591 /* cleanup decoded msg */
592 decoded = ast_aoc_destroy_decoded(decoded);
593
594 /* create AOC-E message */
595 if (!(decoded = ast_aoc_create(AST_AOC_E, AST_AOC_CHARGE_NA, 0)) ||
596 (ast_aoc_get_msg_type(decoded) != AST_AOC_E) ||
598
599 ast_test_status_update(test, "Test 5: failed to create AOC-E message, charge type NA\n");
600 res = AST_TEST_FAIL;
601 goto cleanup_aoc_test;
602 }
604 ast_test_status_update(test, "Test5: encode decode routine did not match expected results, charge type NA.\n");
605 res = AST_TEST_FAIL;
606 goto cleanup_aoc_test;
607 }
608 /* cleanup decoded msg */
609 decoded = ast_aoc_destroy_decoded(decoded);
610
611
612/* ---- TEST 6, AOC-S encode decode */
613 if (!(decoded = ast_aoc_create(AST_AOC_S, 0, 0))) {
614 ast_test_status_update(test, "failed to create AOC-S message for encode decode testing.\n");
615
616 res = AST_TEST_FAIL;
617 goto cleanup_aoc_test;
618 }
619
622 937,
624 "jkasdf",
625 235328,
627 905423,
629 1);
630
633 1337,
635 "MONEYS");
636
640 5555,
642 "pounds");
643
646 78923,
648 "SNAP",
649 9354,
651 234933,
653 0);
654
658
660 ast_test_status_update(test, "Test6: encode decode routine for AOC-S did not match expected results\n");
661 res = AST_TEST_FAIL;
662 goto cleanup_aoc_test;
663 }
664 /* cleanup decoded msg */
665 decoded = ast_aoc_destroy_decoded(decoded);
666
667
668
669cleanup_aoc_test:
670
671 decoded = ast_aoc_destroy_decoded(decoded);
672 return res;
673}
674
675static int unload_module(void)
676{
677 AST_TEST_UNREGISTER(aoc_encode_decode_test);
678 AST_TEST_UNREGISTER(aoc_event_generation_test);
679 return 0;
680}
681
682static int load_module(void)
683{
684 AST_TEST_REGISTER(aoc_encode_decode_test);
685 AST_TEST_REGISTER(aoc_event_generation_test);
687}
688
Generic Advice of Charge encode and decode routines.
int ast_aoc_decoded2str(const struct ast_aoc_decoded *decoded, struct ast_str **msg)
Convert decoded aoc msg to string representation.
Definition: aoc.c:1954
unsigned int ast_aoc_get_unit_count(struct ast_aoc_decoded *decoded)
get the number of unit entries for AOC-D and AOC-E messages
Definition: aoc.c:1019
int ast_aoc_s_add_rate_duration(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name, unsigned long time, enum ast_aoc_time_scale time_scale, unsigned long granularity_time, enum ast_aoc_time_scale granularity_time_scale, int step_function)
Add AOC-S duration rate entry.
Definition: aoc.c:770
enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decoded)
get the type of total for a AOC-D message
Definition: aoc.c:914
const char * ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded)
get the currency name for AOC-D and AOC-E messages
Definition: aoc.c:972
@ AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION
Definition: aoc.h:148
@ AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT
Definition: aoc.h:147
@ AST_AOC_CHARGED_ITEM_USER_USER_INFO
Definition: aoc.h:151
@ AST_AOC_CHARGED_ITEM_CALL_SETUP
Definition: aoc.h:150
@ AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE
Definition: aoc.h:152
@ AST_AOC_CHARGED_ITEM_CALL_ATTEMPT
Definition: aoc.h:149
@ AST_AOC_CHARGE_CURRENCY
Definition: aoc.h:72
@ AST_AOC_CHARGE_FREE
Definition: aoc.h:71
@ AST_AOC_CHARGE_UNIT
Definition: aoc.h:73
@ AST_AOC_CHARGE_NA
Definition: aoc.h:70
@ AST_AOC_TIME_SCALE_DAY
Definition: aoc.h:94
@ AST_AOC_TIME_SCALE_TENTH_SECOND
Definition: aoc.h:89
@ AST_AOC_TIME_SCALE_SECOND
Definition: aoc.h:90
@ AST_AOC_TIME_SCALE_HOUR
Definition: aoc.h:93
@ AST_AOC_TIME_SCALE_HUNDREDTH_SECOND
Definition: aoc.h:88
enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded)
get the message type, AOC-D, AOC-E, or AOC Request
Definition: aoc.c:892
@ AST_AOC_VOLUME_UNIT_SEGMENT
Definition: aoc.h:127
int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded)
test aoc encode decode routines.
Definition: aoc.c:1330
int ast_aoc_get_termination_request(struct ast_aoc_decoded *decoded)
get whether or not the AST_AOC_REQUEST message as a termination request.
Definition: aoc.c:1079
@ AST_AOC_MULT_TEN
Definition: aoc.h:39
@ AST_AOC_MULT_ONEHUNDREDTH
Definition: aoc.h:36
@ AST_AOC_MULT_ONETHOUSANDTH
Definition: aoc.h:35
@ AST_AOC_MULT_THOUSAND
Definition: aoc.h:41
@ AST_AOC_MULT_ONE
Definition: aoc.h:38
struct ast_aoc_decoded * ast_aoc_create(const enum ast_aoc_type msg_type, const enum ast_aoc_charge_type charge_type, const enum ast_aoc_request requests)
creates a ast_aoc_decode object of a specific message type
Definition: aoc.c:276
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
Definition: aoc.c:307
@ AST_AOC_CHARGING_ASSOCIATION_ID
Definition: aoc.h:188
@ AST_AOC_CHARGING_ASSOCIATION_NUMBER
Definition: aoc.h:187
int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan)
set the charging association number for an AOC-E message
Definition: aoc.c:1056
int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type)
Adds a unit entry into the list of units.
Definition: aoc.c:977
@ AST_AOC_BILLING_CALL_FWD_BUSY
Definition: aoc.h:55
@ AST_AOC_BILLING_CALL_FWD_NO_REPLY
Definition: aoc.h:56
@ AST_AOC_BILLING_NORMAL
Definition: aoc.h:51
@ AST_AOC_BILLING_CALL_DEFLECTION
Definition: aoc.h:57
@ AST_AOC_BILLING_CREDIT_CARD
Definition: aoc.h:53
@ AST_AOC_BILLING_CALL_TRANSFER
Definition: aoc.h:58
@ AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL
Definition: aoc.h:54
@ AST_AOC_BILLING_REVERSE_CHARGE
Definition: aoc.h:52
@ AST_AOC_BILLING_NA
Definition: aoc.h:50
int ast_aoc_s_add_rate_free(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, int from_beginning)
Add AOC-S indicating charge item is free.
Definition: aoc.c:857
const struct ast_aoc_unit_entry * ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number)
get a specific unit entry.
Definition: aoc.c:1010
enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decoded)
get the types of AOC requested for when message type is AOC Request
Definition: aoc.c:902
int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id)
set the billing id for a AOC-D or AST_AOC_E message
Definition: aoc.c:1024
int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded, const unsigned int amount, const enum ast_aoc_currency_multiplier multiplier, const char *name)
Sets the currency values for a AOC-D or AOC-E message.
Definition: aoc.c:919
int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id)
set the charging association id for an AST_AOC_E message
Definition: aoc.c:1040
int ast_aoc_s_add_rate_flat(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S flat rate entry.
Definition: aoc.c:801
int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type)
Sets the type of total for a AOC-D message.
Definition: aoc.c:907
int ast_aoc_s_add_rate_volume(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item, enum ast_aoc_volume_unit volume_unit, unsigned int amount, enum ast_aoc_currency_multiplier multiplier, const char *currency_name)
Add AOC-S volume rate entry.
Definition: aoc.c:822
@ AST_AOC_S
Definition: aoc.h:64
@ AST_AOC_D
Definition: aoc.h:65
@ AST_AOC_E
Definition: aoc.h:66
@ AST_AOC_REQUEST
Definition: aoc.h:63
enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decoded)
get the billing id for AOC-D and AOC-E messages
Definition: aoc.c:1035
const struct ast_aoc_charging_association * ast_aoc_get_association_info(struct ast_aoc_decoded *decoded)
get the charging association info for AOC-E messages
Definition: aoc.c:1051
enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded)
get the currency multiplier for AOC-D and AOC-E messages
Definition: aoc.c:945
@ AST_AOC_REQUEST_E
Definition: aoc.h:79
@ AST_AOC_REQUEST_D
Definition: aoc.h:78
@ AST_AOC_REQUEST_S
Definition: aoc.h:77
int ast_aoc_set_termination_request(struct ast_aoc_decoded *decoded)
Mark the AST_AOC_REQUEST message as a termination request.
Definition: aoc.c:1069
enum ast_aoc_charge_type ast_aoc_get_charge_type(struct ast_aoc_decoded *decoded)
get the charging type for an AOC-D or AOC-E message
Definition: aoc.c:897
int ast_aoc_s_add_rate_na(struct ast_aoc_decoded *decoded, enum ast_aoc_s_charged_item charged_item)
Add AOC-S entry indicating charge item is not available.
Definition: aoc.c:869
unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded)
get the currency amount for AOC-D and AOC-E messages
Definition: aoc.c:940
@ AST_AOC_SUBTOTAL
Definition: aoc.h:84
Asterisk main include file. File version handling, generic pbx functions.
#define ast_free(a)
Definition: astmm.h:180
static int request(void *obj)
Definition: chan_pjsip.c:2604
Asterisk module definitions.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Definition: module.h:581
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
@ AST_MODULE_LOAD_SUCCESS
Definition: module.h:70
def info(msg)
#define NULL
Definition: resample.c:96
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
void ast_str_reset(struct ast_str *buf)
Reset the content of a dynamic string. Useful before a series of ast_str_append.
Definition: strings.h:693
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
union ast_aoc_charging_association::@183 charge
struct ast_aoc_charging_association_number number
Definition: aoc.h:197
Definition: aoc.h:178
unsigned int amount
Definition: aoc.h:180
unsigned int type
Definition: aoc.h:182
char valid_type
Definition: aoc.h:181
char valid_amount
Definition: aoc.h:179
Support for dynamic strings.
Definition: strings.h:623
Test Framework API.
@ TEST_INIT
Definition: test.h:200
@ TEST_EXECUTE
Definition: test.h:201
#define AST_TEST_REGISTER(cb)
Definition: test.h:127
#define ast_test_status_update(a, b, c...)
Definition: test.h:129
#define AST_TEST_UNREGISTER(cb)
Definition: test.h:128
@ AST_TEST_PASS
Definition: test.h:195
@ AST_TEST_FAIL
Definition: test.h:196
@ AST_TEST_NOT_RUN
Definition: test.h:194
AST_TEST_DEFINE(aoc_event_generation_test)
Definition: test_aoc.c:41
static int load_module(void)
Definition: test_aoc.c:682
static int unload_module(void)
Definition: test_aoc.c:675
Utility functions.
#define ARRAY_LEN(a)
Definition: utils.h:666