Generic Advice of Charge encode and decode routines. More...
#include "asterisk/channel.h"
Go to the source code of this file.
Generic Advice of Charge encode and decode routines.
Definition in file aoc.h.
enum ast_aoc_billing_id |
Defines the billing id options for an aoc message.
Definition at line 49 of file aoc.h.
00049 { 00050 AST_AOC_BILLING_NA = 0, 00051 AST_AOC_BILLING_NORMAL, 00052 AST_AOC_BILLING_REVERSE_CHARGE, 00053 AST_AOC_BILLING_CREDIT_CARD, 00054 AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL, 00055 AST_AOC_BILLING_CALL_FWD_BUSY, 00056 AST_AOC_BILLING_CALL_FWD_NO_REPLY, 00057 AST_AOC_BILLING_CALL_DEFLECTION, 00058 AST_AOC_BILLING_CALL_TRANSFER, 00059 AST_AOC_BILLING_NUM_ENTRIES /* must remain the last item in enum, not a valid billing id */ 00060 };
enum ast_aoc_charge_type |
Definition at line 69 of file aoc.h.
00069 { 00070 AST_AOC_CHARGE_NA = 0, 00071 AST_AOC_CHARGE_FREE, 00072 AST_AOC_CHARGE_CURRENCY, 00073 AST_AOC_CHARGE_UNIT, /* unit must remain the last item in enum */ 00074 };
AST_AOC_CHARGING_ASSOCIATION_NA | |
AST_AOC_CHARGING_ASSOCIATION_NUMBER | |
AST_AOC_CHARGING_ASSOCIATION_ID |
Definition at line 185 of file aoc.h.
00185 { 00186 AST_AOC_CHARGING_ASSOCIATION_NA, 00187 AST_AOC_CHARGING_ASSOCIATION_NUMBER, 00188 AST_AOC_CHARGING_ASSOCIATION_ID, 00189 };
Defines the currency multiplier for an aoc message.
AST_AOC_MULT_ONETHOUSANDTH | |
AST_AOC_MULT_ONEHUNDREDTH | |
AST_AOC_MULT_ONETENTH | |
AST_AOC_MULT_ONE | |
AST_AOC_MULT_TEN | |
AST_AOC_MULT_HUNDRED | |
AST_AOC_MULT_THOUSAND | |
AST_AOC_MULT_NUM_ENTRIES |
Definition at line 34 of file aoc.h.
00034 { 00035 AST_AOC_MULT_ONETHOUSANDTH = 1, 00036 AST_AOC_MULT_ONEHUNDREDTH, 00037 AST_AOC_MULT_ONETENTH, 00038 AST_AOC_MULT_ONE, 00039 AST_AOC_MULT_TEN, 00040 AST_AOC_MULT_HUNDRED, 00041 AST_AOC_MULT_THOUSAND, 00042 AST_AOC_MULT_NUM_ENTRIES, /* must remain the last item in enum, this is not a valid type */ 00043 };
enum ast_aoc_request |
Definition at line 76 of file aoc.h.
00076 { 00077 AST_AOC_REQUEST_S = (1 << 0), 00078 AST_AOC_REQUEST_D = (1 << 1), 00079 AST_AOC_REQUEST_E = (1 << 2), 00080 };
Definition at line 145 of file aoc.h.
00145 { 00146 AST_AOC_CHARGED_ITEM_NA, 00147 AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, 00148 AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION, 00149 AST_AOC_CHARGED_ITEM_CALL_ATTEMPT, 00150 AST_AOC_CHARGED_ITEM_CALL_SETUP, 00151 AST_AOC_CHARGED_ITEM_USER_USER_INFO, 00152 AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE, 00153 };
enum ast_aoc_s_rate_type |
AST_AOC_RATE_TYPE_NA | |
AST_AOC_RATE_TYPE_FREE | |
AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING | |
AST_AOC_RATE_TYPE_DURATION | |
AST_AOC_RATE_TYPE_FLAT | |
AST_AOC_RATE_TYPE_VOLUME | |
AST_AOC_RATE_TYPE_SPECIAL_CODE |
Definition at line 155 of file aoc.h.
00155 { 00156 AST_AOC_RATE_TYPE_NA, 00157 AST_AOC_RATE_TYPE_FREE, 00158 AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING, 00159 AST_AOC_RATE_TYPE_DURATION, 00160 AST_AOC_RATE_TYPE_FLAT, 00161 AST_AOC_RATE_TYPE_VOLUME, 00162 AST_AOC_RATE_TYPE_SPECIAL_CODE, 00163 };
enum ast_aoc_time_scale |
AST_AOC_TIME_SCALE_HUNDREDTH_SECOND | |
AST_AOC_TIME_SCALE_TENTH_SECOND | |
AST_AOC_TIME_SCALE_SECOND | |
AST_AOC_TIME_SCALE_TEN_SECOND | |
AST_AOC_TIME_SCALE_MINUTE | |
AST_AOC_TIME_SCALE_HOUR | |
AST_AOC_TIME_SCALE_DAY |
Definition at line 87 of file aoc.h.
00087 { 00088 AST_AOC_TIME_SCALE_HUNDREDTH_SECOND, 00089 AST_AOC_TIME_SCALE_TENTH_SECOND, 00090 AST_AOC_TIME_SCALE_SECOND, 00091 AST_AOC_TIME_SCALE_TEN_SECOND, 00092 AST_AOC_TIME_SCALE_MINUTE, 00093 AST_AOC_TIME_SCALE_HOUR, 00094 AST_AOC_TIME_SCALE_DAY, 00095 };
enum ast_aoc_total_type |
Definition at line 82 of file aoc.h.
00082 { 00083 AST_AOC_TOTAL = 0, 00084 AST_AOC_SUBTOTAL = 1, 00085 };
enum ast_aoc_type |
enum ast_aoc_volume_unit |
Definition at line 125 of file aoc.h.
00125 { 00126 AST_AOC_VOLUME_UNIT_OCTET, 00127 AST_AOC_VOLUME_UNIT_SEGMENT, 00128 AST_AOC_VOLUME_UNIT_MESSAGE, 00129 };
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.
decoded | ast_aoc_decoded struct to set values on | |
amount_is_present | set this if the number of units is actually present. | |
amount | number of units | |
type_is_present | set this if the type value is present | |
type | unit type |
0 | success |
Definition at line 846 of file aoc.c.
References ast_aoc_unit_entry::amount, ARRAY_LEN, AST_AOC_REQUEST, ast_aoc_decoded::msg_type, ast_aoc_unit_entry::type, ast_aoc_decoded::unit_count, ast_aoc_decoded::unit_list, ast_aoc_unit_entry::valid_amount, and ast_aoc_unit_entry::valid_type.
Referenced by action_aocmessage(), and aoc_parse_ie().
00851 { 00852 if ((decoded->msg_type == AST_AOC_REQUEST) || 00853 (decoded->unit_count >= ARRAY_LEN(decoded->unit_list))) { 00854 return -1; 00855 } 00856 00857 if (!amount_is_present && !type_is_present) { 00858 return -1; 00859 } 00860 00861 decoded->unit_list[decoded->unit_count].valid_amount = amount_is_present; 00862 if (amount_is_present) { 00863 decoded->unit_list[decoded->unit_count].amount = amount; 00864 } else { 00865 decoded->unit_list[decoded->unit_count].amount = 0; 00866 } 00867 00868 decoded->unit_list[decoded->unit_count].valid_type = type_is_present; 00869 if (type_is_present) { 00870 decoded->unit_list[decoded->unit_count].type = type; 00871 } else { 00872 decoded->unit_list[decoded->unit_count].type = 0; 00873 } 00874 decoded->unit_count++; 00875 00876 return 0; 00877 }
int ast_aoc_cli_init | ( | void | ) |
enable aoc cli options
Definition at line 1612 of file aoc.c.
References aoc_shutdown(), ARRAY_LEN, ast_cli_register_multiple(), and ast_register_atexit().
Referenced by main().
01613 { 01614 ast_register_atexit(aoc_shutdown); 01615 return ast_cli_register_multiple(aoc_cli, ARRAY_LEN(aoc_cli)); 01616 }
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 | |||
) | [read] |
creates a ast_aoc_decode object of a specific message type
msg_type | AOC-D, AOC-E, or AOC Request | |
charge_type | this is ignored if message type is not AOC-D or AOC-E. | |
requests | flags. This defines the types of AOC requested. This field should only be set when the message type is AOC Request, the value is ignored otherwise. |
heap | allocated ast_aoc_decoded object ptr on success | |
NULL | failure |
Definition at line 145 of file aoc.c.
References AST_AOC_CHARGE_UNIT, AST_AOC_D, AST_AOC_E, AST_AOC_REQUEST, ast_calloc, ast_log(), ast_aoc_decoded::charge_type, LOG_WARNING, ast_aoc_decoded::msg_type, and ast_aoc_decoded::request_flag.
Referenced by action_aocmessage().
00148 { 00149 struct ast_aoc_decoded *decoded = NULL; 00150 00151 /* verify input */ 00152 if (((unsigned int) charge_type > AST_AOC_CHARGE_UNIT) || 00153 ((unsigned int) msg_type > AST_AOC_E) || 00154 ((msg_type == AST_AOC_REQUEST) && !requests)) { 00155 00156 ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object, invalid input\n"); 00157 return NULL; 00158 } 00159 00160 if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) { 00161 ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n"); 00162 return NULL; 00163 } 00164 00165 decoded->msg_type = msg_type; 00166 00167 if (msg_type == AST_AOC_REQUEST) { 00168 decoded->request_flag = requests; 00169 } else if ((msg_type == AST_AOC_D) || (msg_type == AST_AOC_E)) { 00170 decoded->charge_type = charge_type; 00171 } 00172 00173 return decoded; 00174 }
struct ast_aoc_decoded* ast_aoc_decode | ( | struct ast_aoc_encoded * | encoded, | |
size_t | size, | |||
struct ast_channel * | chan | |||
) | [read] |
decodes an encoded aoc payload.
encoded | the encoded payload to decode. | |
size | total size of encoded payload | |
chan | ast channel, Optional for DEBUG output purposes |
heap | allocated ast_aoc_decoded object ptr on success | |
NULL | failure |
Definition at line 318 of file aoc.c.
References aoc_debug_enabled, aoc_display_decoded_debug(), aoc_parse_ie(), AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_NA, AST_AOC_CHARGE_UNIT, AST_AOC_D, AST_AOC_E, AST_AOC_ENCODED_CHARGE_CURRENCY, AST_AOC_ENCODED_CHARGE_FREE, AST_AOC_ENCODED_CHARGE_SUBTOTAL, AST_AOC_ENCODED_CHARGE_UNIT, AST_AOC_ENCODED_REQUEST_D, AST_AOC_ENCODED_REQUEST_E, AST_AOC_ENCODED_REQUEST_S, AST_AOC_ENCODED_TYPE_D, AST_AOC_ENCODED_TYPE_E, AST_AOC_ENCODED_TYPE_S, AST_AOC_REQUEST, AST_AOC_REQUEST_D, AST_AOC_REQUEST_E, AST_AOC_REQUEST_S, AST_AOC_S, AST_AOC_SUBTOTAL, ast_calloc, ast_log(), ast_aoc_decoded::charge_type, ast_aoc_encoded::data, ast_aoc_encoded::datalen, ast_aoc_encoded::flags, LOG_WARNING, ast_aoc_decoded::msg_type, ast_aoc_decoded::request_flag, and ast_aoc_decoded::total_type.
Referenced by ast_aoc_test_encode_decode_match(), sip_indicate(), and wait_for_answer().
00319 { 00320 struct ast_aoc_decoded *decoded; 00321 00322 /* verify our encoded payload is actually large enough to hold all the ies */ 00323 if ((size - (sizeof(struct ast_aoc_encoded)) != ntohs(encoded->datalen))) { 00324 ast_log(LOG_WARNING, "Corrupted aoc encoded object, can not decode\n"); 00325 return NULL; 00326 } 00327 00328 if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) { 00329 ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n"); 00330 return NULL; 00331 } 00332 00333 /* decode flags */ 00334 00335 if ((encoded->flags & AST_AOC_ENCODED_TYPE_S) == AST_AOC_ENCODED_TYPE_S) { 00336 decoded->msg_type = AST_AOC_S; 00337 } else if (encoded->flags & AST_AOC_ENCODED_TYPE_E) { 00338 decoded->msg_type = AST_AOC_E; 00339 } else if (encoded->flags & AST_AOC_ENCODED_TYPE_D) { 00340 decoded->msg_type = AST_AOC_D; 00341 } else { 00342 decoded->msg_type = AST_AOC_REQUEST; 00343 } 00344 00345 if (decoded->msg_type == AST_AOC_REQUEST) { 00346 if (encoded->flags & AST_AOC_ENCODED_REQUEST_S) { 00347 decoded->request_flag |= AST_AOC_REQUEST_S; 00348 } 00349 if (encoded->flags & AST_AOC_ENCODED_REQUEST_D) { 00350 decoded->request_flag |= AST_AOC_REQUEST_D; 00351 } 00352 if (encoded->flags & AST_AOC_ENCODED_REQUEST_E) { 00353 decoded->request_flag |= AST_AOC_REQUEST_E; 00354 } 00355 } else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) { 00356 if ((encoded->flags & AST_AOC_ENCODED_CHARGE_UNIT) == AST_AOC_ENCODED_CHARGE_UNIT) { 00357 decoded->charge_type = AST_AOC_CHARGE_UNIT; 00358 } else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_CURRENCY) == AST_AOC_ENCODED_CHARGE_CURRENCY) { 00359 decoded->charge_type = AST_AOC_CHARGE_CURRENCY; 00360 } else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_FREE) == AST_AOC_ENCODED_CHARGE_FREE) { 00361 decoded->charge_type = AST_AOC_CHARGE_FREE; 00362 } else { 00363 decoded->charge_type = AST_AOC_CHARGE_NA; 00364 } 00365 00366 if (encoded->flags & AST_AOC_ENCODED_CHARGE_SUBTOTAL) { 00367 decoded->total_type = AST_AOC_SUBTOTAL; 00368 } 00369 } 00370 00371 /* decode information elements */ 00372 aoc_parse_ie(decoded, encoded->data, ntohs(encoded->datalen)); 00373 00374 if (aoc_debug_enabled) { 00375 aoc_display_decoded_debug(decoded, 1, chan); 00376 } 00377 00378 return decoded; 00379 }
int ast_aoc_decoded2str | ( | const struct ast_aoc_decoded * | decoded, | |
struct ast_str ** | msg | |||
) |
Convert decoded aoc msg to string representation.
decoded | ast_aoc_decoded struct to convert to string | |
msg | dynamic heap allocated ast_str object to store string representation in |
0 | success | |
-1 | failure |
Definition at line 1550 of file aoc.c.
References aoc_d_event(), aoc_e_event(), aoc_request_event(), aoc_s_event(), AST_AOC_D, AST_AOC_E, AST_AOC_REQUEST, AST_AOC_S, ast_str_append(), and ast_aoc_decoded::msg_type.
Referenced by aoc_display_decoded_debug().
01551 { 01552 if (!decoded || !msg) { 01553 return -1; 01554 } 01555 01556 switch (decoded->msg_type) { 01557 case AST_AOC_S: 01558 ast_str_append(msg, 0, "AOC-S\r\n"); 01559 aoc_s_event(decoded, NULL, msg); 01560 break; 01561 case AST_AOC_D: 01562 ast_str_append(msg, 0, "AOC-D\r\n"); 01563 aoc_d_event(decoded, NULL, msg); 01564 break; 01565 case AST_AOC_E: 01566 ast_str_append(msg, 0, "AOC-E\r\n"); 01567 aoc_e_event(decoded, NULL, msg); 01568 break; 01569 case AST_AOC_REQUEST: 01570 ast_str_append(msg, 0, "AOC-Request\r\n"); 01571 aoc_request_event(decoded, NULL, msg); 01572 break; 01573 } 01574 01575 return 0; 01576 }
void* ast_aoc_destroy_decoded | ( | struct ast_aoc_decoded * | decoded | ) |
free an ast_aoc_decoded object
Definition at line 176 of file aoc.c.
References ast_free.
Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), chanlist_free(), hangupcalls(), sip_indicate(), and wait_for_answer().
00177 { 00178 ast_free(decoded); 00179 return NULL; 00180 }
void* ast_aoc_destroy_encoded | ( | struct ast_aoc_encoded * | encoded | ) |
free an ast_aoc_encoded object
Definition at line 182 of file aoc.c.
References ast_free.
Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), and wait_for_answer().
00183 { 00184 ast_free(encoded); 00185 return NULL; 00186 }
struct ast_aoc_encoded* ast_aoc_encode | ( | struct ast_aoc_decoded * | decoded, | |
size_t * | out_size, | |||
struct ast_channel * | chan | |||
) | [read] |
encodes a decoded aoc structure so it can be passed on the wire
decoded | the decoded struct to be encoded | |
out_size | output parameter representing size of encoded data | |
chan | ast channel, Optional for DEBUG output purposes |
pointer | to encoded data | |
NULL | failure |
Definition at line 519 of file aoc.c.
References aoc_create_ie_data(), aoc_debug_enabled, aoc_display_decoded_debug(), AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_NA, AST_AOC_CHARGE_UNIT, AST_AOC_D, AST_AOC_E, AST_AOC_ENCODE_VERSION, AST_AOC_ENCODED_CHARGE_CURRENCY, AST_AOC_ENCODED_CHARGE_FREE, AST_AOC_ENCODED_CHARGE_NA, AST_AOC_ENCODED_CHARGE_SUBTOTAL, AST_AOC_ENCODED_CHARGE_UNIT, AST_AOC_ENCODED_REQUEST_D, AST_AOC_ENCODED_REQUEST_E, AST_AOC_ENCODED_REQUEST_S, AST_AOC_ENCODED_TYPE_D, AST_AOC_ENCODED_TYPE_E, AST_AOC_ENCODED_TYPE_REQUEST, AST_AOC_ENCODED_TYPE_S, AST_AOC_REQUEST, AST_AOC_REQUEST_D, AST_AOC_REQUEST_E, AST_AOC_REQUEST_S, AST_AOC_S, AST_AOC_SUBTOTAL, ast_calloc, ast_log(), ast_aoc_decoded::charge_type, ast_aoc_encoded::data, ast_aoc_encoded::datalen, ast_aoc_encoded::flags, LOG_WARNING, ast_aoc_decoded::msg_type, ast_aoc_decoded::request_flag, ast_aoc_decoded::total_type, and ast_aoc_encoded::version.
Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), and wait_for_answer().
00520 { 00521 struct aoc_ie_data ied; 00522 struct ast_aoc_encoded *encoded = NULL; 00523 size_t size = 0; 00524 00525 if (!decoded || !out_size) { 00526 return NULL; 00527 } 00528 00529 *out_size = 0; 00530 00531 /* create information element buffer before allocating the payload, 00532 * by doing this the exact size of the payload + the id data can be 00533 * allocated all at once. */ 00534 aoc_create_ie_data(decoded, &ied); 00535 00536 size = sizeof(struct ast_aoc_encoded) + ied.pos; 00537 00538 if (!(encoded = ast_calloc(1, size))) { 00539 ast_log(LOG_WARNING, "Failed to create ast_aoc_encoded object during decode routine. \n"); 00540 return NULL; 00541 } 00542 00543 /* -- Set ie data buffer */ 00544 if (ied.pos) { 00545 /* this is safe because encoded was allocated to fit this perfectly */ 00546 memcpy(encoded->data, ied.buf, ied.pos); 00547 encoded->datalen = htons(ied.pos); 00548 } 00549 00550 /* --- Set Flags --- */ 00551 switch (decoded->msg_type) { 00552 case AST_AOC_S: 00553 encoded->flags = AST_AOC_ENCODED_TYPE_S; 00554 break; 00555 case AST_AOC_D: 00556 encoded->flags = AST_AOC_ENCODED_TYPE_D; 00557 break; 00558 case AST_AOC_E: 00559 encoded->flags = AST_AOC_ENCODED_TYPE_E; 00560 break; 00561 case AST_AOC_REQUEST: 00562 encoded->flags = AST_AOC_ENCODED_TYPE_REQUEST; 00563 default: 00564 break; 00565 } 00566 00567 /* if it is type request, set the types requested, else set charge type */ 00568 if (decoded->msg_type == AST_AOC_REQUEST) { 00569 if (decoded->request_flag & AST_AOC_REQUEST_S) { 00570 encoded->flags |= AST_AOC_ENCODED_REQUEST_S; 00571 } 00572 if (decoded->request_flag & AST_AOC_REQUEST_D) { 00573 encoded->flags |= AST_AOC_ENCODED_REQUEST_D; 00574 } 00575 if (decoded->request_flag & AST_AOC_REQUEST_E) { 00576 encoded->flags |= AST_AOC_ENCODED_REQUEST_E; 00577 } 00578 } else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) { 00579 switch (decoded->charge_type) { 00580 case AST_AOC_CHARGE_UNIT: 00581 encoded->flags |= AST_AOC_ENCODED_CHARGE_UNIT; 00582 break; 00583 case AST_AOC_CHARGE_CURRENCY: 00584 encoded->flags |= AST_AOC_ENCODED_CHARGE_CURRENCY; 00585 break; 00586 case AST_AOC_CHARGE_FREE: 00587 encoded->flags |= AST_AOC_ENCODED_CHARGE_FREE; 00588 case AST_AOC_CHARGE_NA: 00589 default: 00590 encoded->flags |= AST_AOC_ENCODED_CHARGE_NA; 00591 break; 00592 } 00593 00594 if (decoded->total_type == AST_AOC_SUBTOTAL) { 00595 encoded->flags |= AST_AOC_ENCODED_CHARGE_SUBTOTAL; 00596 } 00597 } 00598 00599 /* --- Set Version Number --- */ 00600 encoded->version = AST_AOC_ENCODE_VERSION; 00601 00602 /* set the output size */ 00603 *out_size = size; 00604 00605 if (aoc_debug_enabled) { 00606 aoc_display_decoded_debug(decoded, 0, chan); 00607 } 00608 00609 return encoded; 00610 }
struct ast_aoc_charging_association* ast_aoc_get_association_info | ( | struct ast_aoc_decoded * | decoded | ) | [read] |
get the charging association info for AOC-E messages
Definition at line 920 of file aoc.c.
References ast_aoc_decoded::charging_association.
00921 { 00922 return &decoded->charging_association; 00923 }
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 at line 904 of file aoc.c.
References ast_aoc_decoded::billing_id.
00905 { 00906 return decoded->billing_id; 00907 }
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 at line 766 of file aoc.c.
References ast_aoc_decoded::charge_type.
Referenced by transmit_info_with_aoc().
00767 { 00768 return decoded->charge_type; 00769 }
unsigned int ast_aoc_get_currency_amount | ( | struct ast_aoc_decoded * | decoded | ) |
get the currency amount for AOC-D and AOC-E messages
Definition at line 809 of file aoc.c.
References ast_aoc_decoded::currency_amount.
Referenced by transmit_info_with_aoc().
00810 { 00811 return decoded->currency_amount; 00812 }
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 at line 814 of file aoc.c.
References ast_aoc_decoded::multiplier.
00815 { 00816 return decoded->multiplier; 00817 }
const char* ast_aoc_get_currency_multiplier_decimal | ( | struct ast_aoc_decoded * | decoded | ) |
get the currency multiplier for AOC-D and AOC-E messages in decimal format
Definition at line 819 of file aoc.c.
References AST_AOC_MULT_HUNDRED, AST_AOC_MULT_ONE, AST_AOC_MULT_ONEHUNDREDTH, AST_AOC_MULT_ONETENTH, AST_AOC_MULT_ONETHOUSANDTH, AST_AOC_MULT_TEN, AST_AOC_MULT_THOUSAND, and ast_aoc_decoded::multiplier.
Referenced by transmit_info_with_aoc().
00820 { 00821 switch (decoded->multiplier) { 00822 case AST_AOC_MULT_ONETHOUSANDTH: 00823 return "0.001"; 00824 case AST_AOC_MULT_ONEHUNDREDTH: 00825 return "0.01"; 00826 case AST_AOC_MULT_ONETENTH: 00827 return "0.1"; 00828 case AST_AOC_MULT_ONE: 00829 return "1.0"; 00830 case AST_AOC_MULT_TEN: 00831 return "10.0"; 00832 case AST_AOC_MULT_HUNDRED: 00833 return "100.0"; 00834 case AST_AOC_MULT_THOUSAND: 00835 return "1000.0"; 00836 default: 00837 return "1.0"; 00838 } 00839 }
const char* ast_aoc_get_currency_name | ( | struct ast_aoc_decoded * | decoded | ) |
get the currency name for AOC-D and AOC-E messages
Definition at line 841 of file aoc.c.
References ast_aoc_decoded::currency_name.
Referenced by transmit_info_with_aoc().
00842 { 00843 return decoded->currency_name; 00844 }
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 at line 761 of file aoc.c.
References ast_aoc_decoded::msg_type.
Referenced by sip_indicate(), transmit_info_with_aoc(), and wait_for_answer().
00762 { 00763 return decoded->msg_type; 00764 }
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 at line 771 of file aoc.c.
References ast_aoc_decoded::request_flag.
00772 { 00773 return decoded->request_flag; 00774 }
int ast_aoc_get_termination_request | ( | struct ast_aoc_decoded * | decoded | ) |
get whether or not the AST_AOC_REQUEST message as a termination request.
decoded | ast_aoc_decoded struct to get values on |
0 | not a termination request | |
1 | is a termination request |
Definition at line 948 of file aoc.c.
References ast_aoc_decoded::termination_request.
Referenced by sip_indicate().
00949 { 00950 return decoded->termination_request; 00951 }
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 at line 783 of file aoc.c.
References ast_aoc_decoded::total_type.
00784 { 00785 return decoded->total_type; 00786 }
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 at line 888 of file aoc.c.
References ast_aoc_decoded::unit_count.
00889 { 00890 return decoded->unit_count; 00891 }
struct ast_aoc_unit_entry* ast_aoc_get_unit_info | ( | struct ast_aoc_decoded * | decoded, | |
unsigned int | entry_number | |||
) | [read] |
get a specific unit entry.
Definition at line 879 of file aoc.c.
References ast_aoc_decoded::unit_count, and ast_aoc_decoded::unit_list.
Referenced by transmit_info_with_aoc().
00880 { 00881 if (entry_number >= decoded->unit_count) { 00882 return NULL; 00883 } 00884 00885 return (const struct ast_aoc_unit_entry *) &decoded->unit_list[entry_number]; 00886 }
int ast_aoc_manager_event | ( | const struct ast_aoc_decoded * | decoded, | |
struct ast_channel * | chan | |||
) |
generate AOC manager event for an AOC-S, AOC-D, or AOC-E msg
Definition at line 1512 of file aoc.c.
References aoc_d_event(), aoc_e_event(), aoc_s_event(), AST_AOC_D, AST_AOC_E, AST_AOC_S, ast_free, ast_manager_event, ast_manager_event_multichan, ast_str_buffer(), ast_str_create(), EVENT_FLAG_AOC, and ast_aoc_decoded::msg_type.
01513 { 01514 struct ast_str *msg; 01515 01516 if (!decoded || !(msg = ast_str_create(1024))) { 01517 return -1; 01518 } 01519 01520 switch (decoded->msg_type) { 01521 case AST_AOC_S: 01522 if (chan) { 01523 aoc_s_event(decoded, chan, &msg); 01524 ast_manager_event(chan, EVENT_FLAG_AOC, "AOC-S", "%s", ast_str_buffer(msg)); 01525 } 01526 break; 01527 case AST_AOC_D: 01528 if (chan) { 01529 aoc_d_event(decoded, chan, &msg); 01530 ast_manager_event(chan, EVENT_FLAG_AOC, "AOC-D", "%s", ast_str_buffer(msg)); 01531 } 01532 break; 01533 case AST_AOC_E: 01534 { 01535 struct ast_channel *chans[1]; 01536 aoc_e_event(decoded, chan, &msg); 01537 chans[0] = chan; 01538 ast_manager_event_multichan(EVENT_FLAG_AOC, "AOC-E", chan ? 1 : 0, chans, "%s", ast_str_buffer(msg)); 01539 } 01540 break; 01541 default: 01542 /* events for AST_AOC_REQUEST are not generated here */ 01543 break; 01544 } 01545 01546 ast_free(msg); 01547 return 0; 01548 }
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.
decoded | aoc decoded object to add entry to | |
charged_item | ast_aoc_s_charged_item | |
amount | currency amount | |
multiplier | currency multiplier | |
currency_name | truncated after 10 characters | |
time | ||
time_scale | from ast_aoc_time_scale enum | |
granularity_time | (optional, set to 0 if not present); | |
granularity_time_scale | (optional, set to 0 if not present); | |
step_function | set to 1 if this is to use a step function, 0 if continuious |
0 | success | |
-1 | failure |
Definition at line 639 of file aoc.c.
References ast_aoc_duration_rate::amount, aoc_s_add_entry(), AST_AOC_RATE_TYPE_DURATION, ast_copy_string(), ast_strlen_zero(), ast_aoc_s_entry::charged_item, ast_aoc_duration_rate::charging_type, ast_aoc_duration_rate::currency_name, ast_aoc_s_entry::duration, ast_aoc_duration_rate::granularity_time, ast_aoc_duration_rate::granularity_time_scale, ast_aoc_duration_rate::multiplier, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, ast_aoc_duration_rate::time, and ast_aoc_duration_rate::time_scale.
00649 { 00650 00651 struct ast_aoc_s_entry entry = { 0, }; 00652 00653 entry.charged_item = charged_item; 00654 entry.rate_type = AST_AOC_RATE_TYPE_DURATION; 00655 entry.rate.duration.amount = amount; 00656 entry.rate.duration.multiplier = multiplier; 00657 entry.rate.duration.time = time; 00658 entry.rate.duration.time_scale = time_scale; 00659 entry.rate.duration.granularity_time = granularity_time; 00660 entry.rate.duration.granularity_time_scale = granularity_time_scale; 00661 entry.rate.duration.charging_type = step_function ? 1 : 0; 00662 00663 if (!ast_strlen_zero(currency_name)) { 00664 ast_copy_string(entry.rate.duration.currency_name, currency_name, sizeof(entry.rate.duration.currency_name)); 00665 } 00666 00667 return aoc_s_add_entry(decoded, &entry); 00668 }
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.
decoded | aoc decoded object to add entry to | |
charged_item | ast_aoc_s_charged_item | |
amount | currency amount | |
multiplier | currency multiplier | |
currency_name | truncated after 10 characters |
0 | success | |
-1 | failure |
Definition at line 670 of file aoc.c.
References ast_aoc_flat_rate::amount, aoc_s_add_entry(), AST_AOC_RATE_TYPE_FLAT, ast_copy_string(), ast_strlen_zero(), ast_aoc_s_entry::charged_item, ast_aoc_flat_rate::currency_name, ast_aoc_s_entry::flat, ast_aoc_flat_rate::multiplier, ast_aoc_s_entry::rate, and ast_aoc_s_entry::rate_type.
00675 { 00676 struct ast_aoc_s_entry entry = { 0, }; 00677 00678 entry.charged_item = charged_item; 00679 entry.rate_type = AST_AOC_RATE_TYPE_FLAT; 00680 entry.rate.flat.amount = amount; 00681 entry.rate.flat.multiplier = multiplier; 00682 00683 if (!ast_strlen_zero(currency_name)) { 00684 ast_copy_string(entry.rate.flat.currency_name, currency_name, sizeof(entry.rate.flat.currency_name)); 00685 } 00686 00687 return aoc_s_add_entry(decoded, &entry); 00688 }
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.
decoded | aoc decoded object to add entry to | |
charged_item | ast_aoc_s_charged_item | |
from_beginning | TRUE if the rate is free from beginning. |
0 | success | |
-1 | failure |
Definition at line 726 of file aoc.c.
References aoc_s_add_entry(), AST_AOC_RATE_TYPE_FREE, AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING, ast_aoc_s_entry::charged_item, and ast_aoc_s_entry::rate_type.
00729 { 00730 struct ast_aoc_s_entry entry = { 0, }; 00731 00732 entry.charged_item = charged_item; 00733 entry.rate_type = from_beginning ? AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING : AST_AOC_RATE_TYPE_FREE; 00734 00735 return aoc_s_add_entry(decoded, &entry); 00736 }
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.
decoded | aoc decoded object to add entry to | |
charged_item | ast_aoc_s_charged_item |
0 | success | |
-1 | failure |
Definition at line 738 of file aoc.c.
References aoc_s_add_entry(), AST_AOC_RATE_TYPE_NA, ast_aoc_s_entry::charged_item, and ast_aoc_s_entry::rate_type.
00740 { 00741 struct ast_aoc_s_entry entry = { 0, }; 00742 00743 entry.charged_item = charged_item; 00744 entry.rate_type = AST_AOC_RATE_TYPE_NA; 00745 00746 return aoc_s_add_entry(decoded, &entry); 00747 }
int ast_aoc_s_add_rate_special_charge_code | ( | struct ast_aoc_decoded * | decoded, | |
enum ast_aoc_s_charged_item | charged_item, | |||
unsigned int | code | |||
) |
Add AOC-S special rate entry.
decoded | aoc decoded object to add entry to | |
charged_item | ast_aoc_s_charged_item | |
code | special charging code |
0 | success | |
-1 | failure |
Definition at line 713 of file aoc.c.
References aoc_s_add_entry(), AST_AOC_RATE_TYPE_SPECIAL_CODE, ast_aoc_s_entry::charged_item, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, and ast_aoc_s_entry::special_code.
00716 { 00717 struct ast_aoc_s_entry entry = { 0, }; 00718 00719 entry.charged_item = charged_item; 00720 entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE; 00721 entry.rate.special_code = code; 00722 00723 return aoc_s_add_entry(decoded, &entry); 00724 }
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.
decoded | aoc decoded object to add entry to | |
charged_item | ast_aoc_s_charged_item | |
volume_unit | from ast_aoc_volume_unit enum | |
amount | currency amount | |
multiplier | currency multiplier | |
currency_name | truncated after 10 characters |
0 | success | |
-1 | failure |
Definition at line 691 of file aoc.c.
References ast_aoc_volume_rate::amount, aoc_s_add_entry(), AST_AOC_RATE_TYPE_VOLUME, ast_copy_string(), ast_strlen_zero(), ast_aoc_s_entry::charged_item, ast_aoc_volume_rate::currency_name, ast_aoc_volume_rate::multiplier, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, ast_aoc_s_entry::volume, and ast_aoc_volume_rate::volume_unit.
00697 { 00698 struct ast_aoc_s_entry entry = { 0, }; 00699 00700 entry.charged_item = charged_item; 00701 entry.rate_type = AST_AOC_RATE_TYPE_VOLUME; 00702 entry.rate.volume.multiplier = multiplier; 00703 entry.rate.volume.amount = amount; 00704 entry.rate.volume.volume_unit = volume_unit; 00705 00706 if (!ast_strlen_zero(currency_name)) { 00707 ast_copy_string(entry.rate.volume.currency_name, currency_name, sizeof(entry.rate.volume.currency_name)); 00708 } 00709 00710 return aoc_s_add_entry(decoded, &entry); 00711 }
int ast_aoc_s_add_special_arrangement | ( | struct ast_aoc_decoded * | decoded, | |
unsigned int | code | |||
) |
Add AOC-S special arrangement entry.
decoded | aoc decoded object to add entry to | |
code | special arrangement code |
0 | success | |
-1 | failure |
Definition at line 749 of file aoc.c.
References aoc_s_add_entry(), AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, AST_AOC_RATE_TYPE_SPECIAL_CODE, ast_aoc_s_entry::charged_item, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, and ast_aoc_s_entry::special_code.
00751 { 00752 struct ast_aoc_s_entry entry = { 0, }; 00753 00754 entry.charged_item = AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT; 00755 entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE; 00756 entry.rate.special_code = code; 00757 00758 return aoc_s_add_entry(decoded, &entry); 00759 }
unsigned int ast_aoc_s_get_count | ( | struct ast_aoc_decoded * | decoded | ) |
get the number rates associated with an AOC-S message
Definition at line 625 of file aoc.c.
References ast_aoc_decoded::aoc_s_count.
00626 { 00627 return decoded->aoc_s_count; 00628 }
struct ast_aoc_s_entry* ast_aoc_s_get_rate_info | ( | struct ast_aoc_decoded * | decoded, | |
unsigned int | entry_number | |||
) | [read] |
get a specific AOC-S rate entry.
Definition at line 630 of file aoc.c.
References ast_aoc_decoded::aoc_s_count, and ast_aoc_decoded::aoc_s_entries.
00631 { 00632 if (entry_number >= decoded->aoc_s_count) { 00633 return NULL; 00634 } 00635 00636 return (const struct ast_aoc_s_entry *) &decoded->aoc_s_entries[entry_number]; 00637 }
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
decoded | ast_aoc_decoded struct to set values on | |
id | charging association identifier |
0 | success |
Definition at line 909 of file aoc.c.
References AST_AOC_CHARGING_ASSOCIATION_ID, AST_AOC_E, ast_aoc_charging_association::charge, ast_aoc_decoded::charging_association, ast_aoc_charging_association::charging_type, ast_aoc_charging_association::id, and ast_aoc_decoded::msg_type.
Referenced by action_aocmessage().
00910 { 00911 if (decoded->msg_type != AST_AOC_E) { 00912 return -1; 00913 } 00914 memset(&decoded->charging_association, 0, sizeof(decoded->charging_association)); 00915 decoded->charging_association.charging_type = AST_AOC_CHARGING_ASSOCIATION_ID; 00916 decoded->charging_association.charge.id = id; 00917 return 0; 00918 }
int ast_aoc_set_association_number | ( | struct ast_aoc_decoded * | decoded, | |
const char * | num, | |||
uint8_t | plan | |||
) |
set the charging accociation number for an AOC-E message
decoded | ast_aoc_decoded struct to set values on | |
num | charging association number | |
plan | charging association number plan and type-of-number fields |
0 | success |
Definition at line 925 of file aoc.c.
References AST_AOC_CHARGING_ASSOCIATION_NUMBER, AST_AOC_E, ast_copy_string(), ast_strlen_zero(), ast_aoc_charging_association::charge, ast_aoc_decoded::charging_association, ast_aoc_charging_association::charging_type, ast_aoc_decoded::msg_type, ast_aoc_charging_association_number::number, ast_aoc_charging_association::number, and ast_aoc_charging_association_number::plan.
Referenced by action_aocmessage().
00926 { 00927 if ((decoded->msg_type != AST_AOC_E) || ast_strlen_zero(num)) { 00928 return -1; 00929 } 00930 memset(&decoded->charging_association, 0, sizeof(decoded->charging_association)); 00931 decoded->charging_association.charging_type = AST_AOC_CHARGING_ASSOCIATION_NUMBER; 00932 decoded->charging_association.charge.number.plan = plan; 00933 ast_copy_string(decoded->charging_association.charge.number.number, num, sizeof(decoded->charging_association.charge.number.number)); 00934 00935 return 0; 00936 }
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
decoded | ast_aoc_decoded struct to set values on | |
id | billing id |
0 | success |
Definition at line 893 of file aoc.c.
References AST_AOC_BILLING_NA, AST_AOC_BILLING_NUM_ENTRIES, and ast_aoc_decoded::billing_id.
Referenced by action_aocmessage().
00894 { 00895 if ((id >= AST_AOC_BILLING_NUM_ENTRIES) || (id < AST_AOC_BILLING_NA)) { 00896 return -1; 00897 } 00898 00899 decoded->billing_id = id; 00900 00901 return 0; 00902 }
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.
decoded | ast_aoc_decoded struct to set values on | |
amount | currency amount REQUIRED | |
multiplier | currency multiplier REQUIRED, 0 or undefined value defaults to AST_AOC_MULT_ONE. | |
name | currency name OPTIONAL |
0 | success |
Definition at line 788 of file aoc.c.
References AST_AOC_MULT_NUM_ENTRIES, AST_AOC_MULT_ONE, ast_copy_string(), ast_strlen_zero(), ast_aoc_decoded::currency_amount, ast_aoc_decoded::currency_name, and ast_aoc_decoded::multiplier.
Referenced by action_aocmessage().
00792 { 00793 00794 if (!ast_strlen_zero(name)) { 00795 ast_copy_string(decoded->currency_name, name, sizeof(decoded->currency_name)); 00796 } 00797 00798 decoded->currency_amount = amount; 00799 00800 if (multiplier && (multiplier < AST_AOC_MULT_NUM_ENTRIES)) { 00801 decoded->multiplier = multiplier; 00802 } else { 00803 decoded->multiplier = AST_AOC_MULT_ONE; 00804 } 00805 00806 return 0; 00807 }
int ast_aoc_set_termination_request | ( | struct ast_aoc_decoded * | decoded | ) |
Mark the AST_AOC_REQUEST message as a termination request.
decoded | ast_aoc_decoded struct to set values on |
0 | success | |
-1 | failure |
Definition at line 938 of file aoc.c.
References AST_AOC_REQUEST, ast_aoc_decoded::msg_type, and ast_aoc_decoded::termination_request.
00939 { 00940 if (decoded->msg_type != AST_AOC_REQUEST) { 00941 return -1; 00942 } 00943 decoded->termination_request = 1; 00944 00945 return 0; 00946 }
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.
decoded | ast_aoc_decoded struct to set values on | |
type | total type: TOTAL or SUBTOTAL |
0 | success |
Definition at line 776 of file aoc.c.
References ast_aoc_decoded::total_type.
Referenced by action_aocmessage().
00778 { 00779 decoded->total_type = type; 00780 return 0; 00781 }
int ast_aoc_test_encode_decode_match | ( | struct ast_aoc_decoded * | decoded | ) |
test aoc encode decode routines.
Definition at line 1199 of file aoc.c.
References ast_aoc_decode(), ast_aoc_destroy_decoded(), ast_aoc_destroy_encoded(), ast_aoc_encode(), and ast_free.
01200 { 01201 struct ast_aoc_decoded *new_decoded = NULL; 01202 struct ast_aoc_encoded *encoded = NULL; 01203 size_t size; 01204 int res = 0; 01205 01206 if (!(encoded = ast_aoc_encode(decoded, &size, NULL))) { 01207 return -1; 01208 } 01209 01210 if (!(new_decoded = ast_aoc_decode(encoded, size, NULL))) { 01211 ast_free(encoded); 01212 return -1; 01213 } 01214 01215 if (memcmp(new_decoded, decoded, sizeof(struct ast_aoc_decoded))) { 01216 res = -1; 01217 } 01218 01219 ast_aoc_destroy_decoded(new_decoded); 01220 ast_aoc_destroy_encoded(encoded); 01221 return res; 01222 }