Generic Advice of Charge encode and decode routines. More...
#include "asterisk/channel.h"

Go to the source code of this file.
Data Structures | |
| struct | ast_aoc_charging_association |
| struct | ast_aoc_charging_association_number |
| struct | ast_aoc_duration_rate |
| struct | ast_aoc_flat_rate |
| struct | ast_aoc_s_entry |
| struct | ast_aoc_time |
| struct | ast_aoc_unit_entry |
| struct | ast_aoc_volume_rate |
Defines | |
| #define | AOC_CURRENCY_NAME_SIZE (10 + 1) |
Enumerations | |
| enum | ast_aoc_billing_id { AST_AOC_BILLING_NA = 0, AST_AOC_BILLING_NORMAL, AST_AOC_BILLING_REVERSE_CHARGE, AST_AOC_BILLING_CREDIT_CARD, AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL, AST_AOC_BILLING_CALL_FWD_BUSY, AST_AOC_BILLING_CALL_FWD_NO_REPLY, AST_AOC_BILLING_CALL_DEFLECTION, AST_AOC_BILLING_CALL_TRANSFER, AST_AOC_BILLING_NUM_ENTRIES } |
| Defines the billing id options for an aoc message. More... | |
| enum | ast_aoc_charge_type { AST_AOC_CHARGE_NA = 0, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_UNIT } |
| enum | AST_AOC_CHARGING_ASSOCIATION { AST_AOC_CHARGING_ASSOCIATION_NA, AST_AOC_CHARGING_ASSOCIATION_NUMBER, AST_AOC_CHARGING_ASSOCIATION_ID } |
| enum | ast_aoc_currency_multiplier { AST_AOC_MULT_ONETHOUSANDTH = 1, 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 } |
| Defines the currency multiplier for an aoc message. More... | |
| enum | ast_aoc_request { AST_AOC_REQUEST_S = (1 << 0), AST_AOC_REQUEST_D = (1 << 1), AST_AOC_REQUEST_E = (1 << 2) } |
| enum | ast_aoc_s_charged_item { AST_AOC_CHARGED_ITEM_NA, AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION, AST_AOC_CHARGED_ITEM_CALL_ATTEMPT, AST_AOC_CHARGED_ITEM_CALL_SETUP, AST_AOC_CHARGED_ITEM_USER_USER_INFO, AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE } |
| 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 } |
| 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 } |
| enum | ast_aoc_total_type { AST_AOC_TOTAL = 0, AST_AOC_SUBTOTAL = 1 } |
| enum | ast_aoc_type { AST_AOC_REQUEST = 0, AST_AOC_S, AST_AOC_D, AST_AOC_E } |
| enum | ast_aoc_volume_unit { AST_AOC_VOLUME_UNIT_OCTET, AST_AOC_VOLUME_UNIT_SEGMENT, AST_AOC_VOLUME_UNIT_MESSAGE } |
Functions | |
| 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. | |
| int | ast_aoc_cli_init (void) |
| enable aoc cli options | |
| 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 | |
| struct ast_aoc_decoded * | ast_aoc_decode (struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan) |
| decodes an encoded aoc payload. | |
| int | ast_aoc_decoded2str (const struct ast_aoc_decoded *decoded, struct ast_str **msg) |
| Convert decoded aoc msg to string representation. | |
| void * | ast_aoc_destroy_decoded (struct ast_aoc_decoded *decoded) |
| free an ast_aoc_decoded object | |
| void * | ast_aoc_destroy_encoded (struct ast_aoc_encoded *encoded) |
| free an ast_aoc_encoded object | |
| struct ast_aoc_encoded * | ast_aoc_encode (struct ast_aoc_decoded *decoded, size_t *out_size, struct ast_channel *chan) |
| encodes a decoded aoc structure so it can be passed on the wire | |
| struct ast_aoc_charging_association * | ast_aoc_get_association_info (struct ast_aoc_decoded *decoded) |
| get the charging association info for AOC-E messages | |
| 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 | |
| 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 | |
| unsigned int | ast_aoc_get_currency_amount (struct ast_aoc_decoded *decoded) |
| get the currency amount for AOC-D and AOC-E messages | |
| 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 | |
| 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 | |
| const char * | ast_aoc_get_currency_name (struct ast_aoc_decoded *decoded) |
| get the currency name for AOC-D and AOC-E messages | |
| 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 | |
| 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 | |
| int | ast_aoc_get_termination_request (struct ast_aoc_decoded *decoded) |
| get whether or not the AST_AOC_REQUEST message as a termination request. | |
| 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 | |
| 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 | |
| struct ast_aoc_unit_entry * | ast_aoc_get_unit_info (struct ast_aoc_decoded *decoded, unsigned int entry_number) |
| get a specific unit entry. | |
| 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 | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| int | ast_aoc_s_add_special_arrangement (struct ast_aoc_decoded *decoded, unsigned int code) |
| Add AOC-S special arrangement entry. | |
| unsigned int | ast_aoc_s_get_count (struct ast_aoc_decoded *decoded) |
| get the number rates associated with an AOC-S message | |
| struct ast_aoc_s_entry * | ast_aoc_s_get_rate_info (struct ast_aoc_decoded *decoded, unsigned int entry_number) |
| get a specific AOC-S rate entry. | |
| 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 | |
| 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 | |
| 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 | |
| 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. | |
| int | ast_aoc_set_termination_request (struct ast_aoc_decoded *decoded) |
| Mark the AST_AOC_REQUEST message as a termination request. | |
| 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. | |
| int | ast_aoc_test_encode_decode_match (struct ast_aoc_decoded *decoded) |
| test aoc encode decode routines. | |
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.
{
AST_AOC_BILLING_NA = 0,
AST_AOC_BILLING_NORMAL,
AST_AOC_BILLING_REVERSE_CHARGE,
AST_AOC_BILLING_CREDIT_CARD,
AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL,
AST_AOC_BILLING_CALL_FWD_BUSY,
AST_AOC_BILLING_CALL_FWD_NO_REPLY,
AST_AOC_BILLING_CALL_DEFLECTION,
AST_AOC_BILLING_CALL_TRANSFER,
AST_AOC_BILLING_NUM_ENTRIES /* must remain the last item in enum, not a valid billing id */
};
| enum ast_aoc_charge_type |
Definition at line 69 of file aoc.h.
{
AST_AOC_CHARGE_NA = 0,
AST_AOC_CHARGE_FREE,
AST_AOC_CHARGE_CURRENCY,
AST_AOC_CHARGE_UNIT, /* unit must remain the last item in enum */
};
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.
{
AST_AOC_MULT_ONETHOUSANDTH = 1,
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, /* must remain the last item in enum, this is not a valid type */
};
| enum ast_aoc_request |
Definition at line 76 of file aoc.h.
{
AST_AOC_REQUEST_S = (1 << 0),
AST_AOC_REQUEST_D = (1 << 1),
AST_AOC_REQUEST_E = (1 << 2),
};
| enum ast_aoc_s_rate_type |
| enum ast_aoc_time_scale |
| enum ast_aoc_total_type |
Definition at line 82 of file aoc.h.
{
AST_AOC_TOTAL = 0,
AST_AOC_SUBTOTAL = 1,
};
| enum ast_aoc_type |
| enum ast_aoc_volume_unit |
| 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 842 of file aoc.c.
References ast_aoc_unit_entry::amount, ARRAY_LEN, AST_AOC_REQUEST, ast_aoc_decoded::msg_type, 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(), aoc_parse_ie(), sig_pri_aoc_d_from_pri(), and sig_pri_aoc_e_from_pri().
{
if ((decoded->msg_type == AST_AOC_REQUEST) ||
(decoded->unit_count >= ARRAY_LEN(decoded->unit_list))) {
return -1;
}
if (!amount_is_present && !type_is_present) {
return -1;
}
decoded->unit_list[decoded->unit_count].valid_amount = amount_is_present;
if (amount_is_present) {
decoded->unit_list[decoded->unit_count].amount = amount;
} else {
decoded->unit_list[decoded->unit_count].amount = 0;
}
decoded->unit_list[decoded->unit_count].valid_type = type_is_present;
if (type_is_present) {
decoded->unit_list[decoded->unit_count].type = type;
} else {
decoded->unit_list[decoded->unit_count].type = 0;
}
decoded->unit_count++;
return 0;
}
| int ast_aoc_cli_init | ( | void | ) |
enable aoc cli options
Definition at line 1604 of file aoc.c.
References ARRAY_LEN, and ast_cli_register_multiple().
Referenced by main().
{
return ast_cli_register_multiple(aoc_cli, ARRAY_LEN(aoc_cli));
}
| 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 141 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, ast_aoc_decoded::request_flag, and requests.
Referenced by action_aocmessage(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), and sig_pri_send_aoce_termination_request().
{
struct ast_aoc_decoded *decoded = NULL;
/* verify input */
if (((unsigned int) charge_type > AST_AOC_CHARGE_UNIT) ||
((unsigned int) msg_type > AST_AOC_E) ||
((msg_type == AST_AOC_REQUEST) && !requests)) {
ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object, invalid input\n");
return NULL;
}
if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
return NULL;
}
decoded->msg_type = msg_type;
if (msg_type == AST_AOC_REQUEST) {
decoded->request_flag = requests;
} else if ((msg_type == AST_AOC_D) || (msg_type == AST_AOC_E)) {
decoded->charge_type = charge_type;
}
return decoded;
}
| 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 314 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(), sig_pri_indicate(), sip_indicate(), and wait_for_answer().
{
struct ast_aoc_decoded *decoded;
/* verify our encoded payload is actually large enough to hold all the ies */
if ((size - (sizeof(struct ast_aoc_encoded)) != ntohs(encoded->datalen))) {
ast_log(LOG_WARNING, "Corrupted aoc encoded object, can not decode\n");
return NULL;
}
if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
return NULL;
}
/* decode flags */
if ((encoded->flags & AST_AOC_ENCODED_TYPE_S) == AST_AOC_ENCODED_TYPE_S) {
decoded->msg_type = AST_AOC_S;
} else if (encoded->flags & AST_AOC_ENCODED_TYPE_E) {
decoded->msg_type = AST_AOC_E;
} else if (encoded->flags & AST_AOC_ENCODED_TYPE_D) {
decoded->msg_type = AST_AOC_D;
} else {
decoded->msg_type = AST_AOC_REQUEST;
}
if (decoded->msg_type == AST_AOC_REQUEST) {
if (encoded->flags & AST_AOC_ENCODED_REQUEST_S) {
decoded->request_flag |= AST_AOC_REQUEST_S;
}
if (encoded->flags & AST_AOC_ENCODED_REQUEST_D) {
decoded->request_flag |= AST_AOC_REQUEST_D;
}
if (encoded->flags & AST_AOC_ENCODED_REQUEST_E) {
decoded->request_flag |= AST_AOC_REQUEST_E;
}
} else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) {
if ((encoded->flags & AST_AOC_ENCODED_CHARGE_UNIT) == AST_AOC_ENCODED_CHARGE_UNIT) {
decoded->charge_type = AST_AOC_CHARGE_UNIT;
} else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_CURRENCY) == AST_AOC_ENCODED_CHARGE_CURRENCY) {
decoded->charge_type = AST_AOC_CHARGE_CURRENCY;
} else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_FREE) == AST_AOC_ENCODED_CHARGE_FREE) {
decoded->charge_type = AST_AOC_CHARGE_FREE;
} else {
decoded->charge_type = AST_AOC_CHARGE_NA;
}
if (encoded->flags & AST_AOC_ENCODED_CHARGE_SUBTOTAL) {
decoded->total_type = AST_AOC_SUBTOTAL;
}
}
/* decode information elements */
aoc_parse_ie(decoded, encoded->data, ntohs(encoded->datalen));
if (aoc_debug_enabled) {
aoc_display_decoded_debug(decoded, 1, chan);
}
return decoded;
}
| 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 1546 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().
{
if (!decoded || !msg) {
return -1;
}
switch (decoded->msg_type) {
case AST_AOC_S:
ast_str_append(msg, 0, "AOC-S\r\n");
aoc_s_event(decoded, NULL, msg);
break;
case AST_AOC_D:
ast_str_append(msg, 0, "AOC-D\r\n");
aoc_d_event(decoded, NULL, msg);
break;
case AST_AOC_E:
ast_str_append(msg, 0, "AOC-E\r\n");
aoc_e_event(decoded, NULL, msg);
break;
case AST_AOC_REQUEST:
ast_str_append(msg, 0, "AOC-Request\r\n");
aoc_request_event(decoded, NULL, msg);
break;
}
return 0;
}
| void* ast_aoc_destroy_decoded | ( | struct ast_aoc_decoded * | decoded | ) |
free an ast_aoc_decoded object
Definition at line 172 of file aoc.c.
References ast_free.
Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), chanlist_free(), hangupcalls(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_indicate(), sig_pri_send_aoce_termination_request(), sip_indicate(), and wait_for_answer().
{
ast_free(decoded);
return NULL;
}
| void* ast_aoc_destroy_encoded | ( | struct ast_aoc_encoded * | encoded | ) |
free an ast_aoc_encoded object
Definition at line 178 of file aoc.c.
References ast_free.
Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_send_aoce_termination_request(), and wait_for_answer().
{
ast_free(encoded);
return NULL;
}
| 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 515 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(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_send_aoce_termination_request(), and wait_for_answer().
{
struct aoc_ie_data ied;
struct ast_aoc_encoded *encoded = NULL;
size_t size = 0;
if (!decoded || !out_size) {
return NULL;
}
*out_size = 0;
/* create information element buffer before allocating the payload,
* by doing this the exact size of the payload + the id data can be
* allocated all at once. */
aoc_create_ie_data(decoded, &ied);
size = sizeof(struct ast_aoc_encoded) + ied.pos;
if (!(encoded = ast_calloc(1, size))) {
ast_log(LOG_WARNING, "Failed to create ast_aoc_encoded object during decode routine. \n");
return NULL;
}
/* -- Set ie data buffer */
if (ied.pos) {
/* this is safe because encoded was allocated to fit this perfectly */
memcpy(encoded->data, ied.buf, ied.pos);
encoded->datalen = htons(ied.pos);
}
/* --- Set Flags --- */
switch (decoded->msg_type) {
case AST_AOC_S:
encoded->flags = AST_AOC_ENCODED_TYPE_S;
break;
case AST_AOC_D:
encoded->flags = AST_AOC_ENCODED_TYPE_D;
break;
case AST_AOC_E:
encoded->flags = AST_AOC_ENCODED_TYPE_E;
break;
case AST_AOC_REQUEST:
encoded->flags = AST_AOC_ENCODED_TYPE_REQUEST;
default:
break;
}
/* if it is type request, set the types requested, else set charge type */
if (decoded->msg_type == AST_AOC_REQUEST) {
if (decoded->request_flag & AST_AOC_REQUEST_S) {
encoded->flags |= AST_AOC_ENCODED_REQUEST_S;
}
if (decoded->request_flag & AST_AOC_REQUEST_D) {
encoded->flags |= AST_AOC_ENCODED_REQUEST_D;
}
if (decoded->request_flag & AST_AOC_REQUEST_E) {
encoded->flags |= AST_AOC_ENCODED_REQUEST_E;
}
} else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) {
switch (decoded->charge_type) {
case AST_AOC_CHARGE_UNIT:
encoded->flags |= AST_AOC_ENCODED_CHARGE_UNIT;
break;
case AST_AOC_CHARGE_CURRENCY:
encoded->flags |= AST_AOC_ENCODED_CHARGE_CURRENCY;
break;
case AST_AOC_CHARGE_FREE:
encoded->flags |= AST_AOC_ENCODED_CHARGE_FREE;
case AST_AOC_CHARGE_NA:
default:
encoded->flags |= AST_AOC_ENCODED_CHARGE_NA;
break;
}
if (decoded->total_type == AST_AOC_SUBTOTAL) {
encoded->flags |= AST_AOC_ENCODED_CHARGE_SUBTOTAL;
}
}
/* --- Set Version Number --- */
encoded->version = AST_AOC_ENCODE_VERSION;
/* set the output size */
*out_size = size;
if (aoc_debug_enabled) {
aoc_display_decoded_debug(decoded, 0, chan);
}
return encoded;
}
| 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 916 of file aoc.c.
References ast_aoc_decoded::charging_association.
Referenced by sig_pri_aoc_e_from_ast().
{
return &decoded->charging_association;
}
| 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 900 of file aoc.c.
References ast_aoc_decoded::billing_id.
Referenced by sig_pri_aoc_d_from_ast(), and sig_pri_aoc_e_from_ast().
{
return decoded->billing_id;
}
| 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 762 of file aoc.c.
References ast_aoc_decoded::charge_type.
Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().
{
return decoded->charge_type;
}
| 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 805 of file aoc.c.
References ast_aoc_decoded::currency_amount.
Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().
{
return decoded->currency_amount;
}
| 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 810 of file aoc.c.
References ast_aoc_decoded::multiplier.
Referenced by sig_pri_aoc_d_from_ast(), and sig_pri_aoc_e_from_ast().
{
return decoded->multiplier;
}
| 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 815 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().
{
switch (decoded->multiplier) {
case AST_AOC_MULT_ONETHOUSANDTH:
return "0.001";
case AST_AOC_MULT_ONEHUNDREDTH:
return "0.01";
case AST_AOC_MULT_ONETENTH:
return "0.1";
case AST_AOC_MULT_ONE:
return "1.0";
case AST_AOC_MULT_TEN:
return "10.0";
case AST_AOC_MULT_HUNDRED:
return "100.0";
case AST_AOC_MULT_THOUSAND:
return "1000.0";
default:
return "1.0";
}
}
| 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 837 of file aoc.c.
References ast_aoc_decoded::currency_name.
Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().
{
return decoded->currency_name;
}
| 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 757 of file aoc.c.
References ast_aoc_decoded::msg_type.
Referenced by sig_pri_indicate(), sip_indicate(), transmit_info_with_aoc(), and wait_for_answer().
{
return decoded->msg_type;
}
| 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 767 of file aoc.c.
References ast_aoc_decoded::request_flag.
{
return decoded->request_flag;
}
| 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 944 of file aoc.c.
References ast_aoc_decoded::termination_request.
Referenced by sig_pri_indicate(), and sip_indicate().
{
return decoded->termination_request;
}
| 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 779 of file aoc.c.
References ast_aoc_decoded::total_type.
Referenced by sig_pri_aoc_d_from_ast().
{
return decoded->total_type;
}
| 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 884 of file aoc.c.
References ast_aoc_decoded::unit_count.
Referenced by sig_pri_aoc_d_from_ast(), and sig_pri_aoc_e_from_ast().
{
return decoded->unit_count;
}
| 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 875 of file aoc.c.
References ast_aoc_decoded::unit_count, and ast_aoc_decoded::unit_list.
Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().
{
if (entry_number >= decoded->unit_count) {
return NULL;
}
return (const struct ast_aoc_unit_entry *) &decoded->unit_list[entry_number];
}
| 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 1508 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.
Referenced by sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), and sig_pri_aoc_s_from_pri().
{
struct ast_str *msg;
if (!decoded || !(msg = ast_str_create(1024))) {
return -1;
}
switch (decoded->msg_type) {
case AST_AOC_S:
if (chan) {
aoc_s_event(decoded, chan, &msg);
ast_manager_event(chan, EVENT_FLAG_AOC, "AOC-S", "%s", ast_str_buffer(msg));
}
break;
case AST_AOC_D:
if (chan) {
aoc_d_event(decoded, chan, &msg);
ast_manager_event(chan, EVENT_FLAG_AOC, "AOC-D", "%s", ast_str_buffer(msg));
}
break;
case AST_AOC_E:
{
struct ast_channel *chans[1];
aoc_e_event(decoded, chan, &msg);
chans[0] = chan;
ast_manager_event_multichan(EVENT_FLAG_AOC, "AOC-E", chan ? 1 : 0, chans, "%s", ast_str_buffer(msg));
}
break;
default:
/* events for AST_AOC_REQUEST are not generated here */
break;
}
ast_free(msg);
return 0;
}
| 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 635 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.
Referenced by sig_pri_aoc_s_from_pri().
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = charged_item;
entry.rate_type = AST_AOC_RATE_TYPE_DURATION;
entry.rate.duration.amount = amount;
entry.rate.duration.multiplier = multiplier;
entry.rate.duration.time = time;
entry.rate.duration.time_scale = time_scale;
entry.rate.duration.granularity_time = granularity_time;
entry.rate.duration.granularity_time_scale = granularity_time_scale;
entry.rate.duration.charging_type = step_function ? 1 : 0;
if (!ast_strlen_zero(currency_name)) {
ast_copy_string(entry.rate.duration.currency_name, currency_name, sizeof(entry.rate.duration.currency_name));
}
return aoc_s_add_entry(decoded, &entry);
}
| 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 666 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.
Referenced by sig_pri_aoc_s_from_pri().
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = charged_item;
entry.rate_type = AST_AOC_RATE_TYPE_FLAT;
entry.rate.flat.amount = amount;
entry.rate.flat.multiplier = multiplier;
if (!ast_strlen_zero(currency_name)) {
ast_copy_string(entry.rate.flat.currency_name, currency_name, sizeof(entry.rate.flat.currency_name));
}
return aoc_s_add_entry(decoded, &entry);
}
| 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 722 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.
Referenced by sig_pri_aoc_s_from_pri().
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = charged_item;
entry.rate_type = from_beginning ? AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING : AST_AOC_RATE_TYPE_FREE;
return aoc_s_add_entry(decoded, &entry);
}
| 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 734 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.
Referenced by sig_pri_aoc_s_from_pri().
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = charged_item;
entry.rate_type = AST_AOC_RATE_TYPE_NA;
return aoc_s_add_entry(decoded, &entry);
}
| 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 709 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.
Referenced by sig_pri_aoc_s_from_pri().
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = charged_item;
entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE;
entry.rate.special_code = code;
return aoc_s_add_entry(decoded, &entry);
}
| 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 687 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.
Referenced by sig_pri_aoc_s_from_pri().
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = charged_item;
entry.rate_type = AST_AOC_RATE_TYPE_VOLUME;
entry.rate.volume.multiplier = multiplier;
entry.rate.volume.amount = amount;
entry.rate.volume.volume_unit = volume_unit;
if (!ast_strlen_zero(currency_name)) {
ast_copy_string(entry.rate.volume.currency_name, currency_name, sizeof(entry.rate.volume.currency_name));
}
return aoc_s_add_entry(decoded, &entry);
}
| 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 745 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.
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT;
entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE;
entry.rate.special_code = code;
return aoc_s_add_entry(decoded, &entry);
}
| 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 621 of file aoc.c.
References ast_aoc_decoded::aoc_s_count.
Referenced by sig_pri_aoc_s_from_ast().
{
return decoded->aoc_s_count;
}
| 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 626 of file aoc.c.
References ast_aoc_decoded::aoc_s_count, and ast_aoc_decoded::aoc_s_entries.
Referenced by sig_pri_aoc_s_from_ast().
{
if (entry_number >= decoded->aoc_s_count) {
return NULL;
}
return (const struct ast_aoc_s_entry *) &decoded->aoc_s_entries[entry_number];
}
| 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 905 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, id, and ast_aoc_decoded::msg_type.
Referenced by action_aocmessage(), and sig_pri_aoc_e_from_pri().
{
if (decoded->msg_type != AST_AOC_E) {
return -1;
}
memset(&decoded->charging_association, 0, sizeof(decoded->charging_association));
decoded->charging_association.charging_type = AST_AOC_CHARGING_ASSOCIATION_ID;
decoded->charging_association.charge.id = id;
return 0;
}
| 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 921 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(), and sig_pri_aoc_e_from_pri().
{
if ((decoded->msg_type != AST_AOC_E) || ast_strlen_zero(num)) {
return -1;
}
memset(&decoded->charging_association, 0, sizeof(decoded->charging_association));
decoded->charging_association.charging_type = AST_AOC_CHARGING_ASSOCIATION_NUMBER;
decoded->charging_association.charge.number.plan = plan;
ast_copy_string(decoded->charging_association.charge.number.number, num, sizeof(decoded->charging_association.charge.number.number));
return 0;
}
| 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 889 of file aoc.c.
References AST_AOC_BILLING_NA, AST_AOC_BILLING_NUM_ENTRIES, ast_aoc_decoded::billing_id, and id.
Referenced by action_aocmessage(), sig_pri_aoc_d_from_pri(), and sig_pri_aoc_e_from_pri().
{
if ((id >= AST_AOC_BILLING_NUM_ENTRIES) || (id < AST_AOC_BILLING_NA)) {
return -1;
}
decoded->billing_id = id;
return 0;
}
| 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 784 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(), sig_pri_aoc_d_from_pri(), and sig_pri_aoc_e_from_pri().
{
if (!ast_strlen_zero(name)) {
ast_copy_string(decoded->currency_name, name, sizeof(decoded->currency_name));
}
decoded->currency_amount = amount;
if (multiplier && (multiplier < AST_AOC_MULT_NUM_ENTRIES)) {
decoded->multiplier = multiplier;
} else {
decoded->multiplier = AST_AOC_MULT_ONE;
}
return 0;
}
| 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 934 of file aoc.c.
References AST_AOC_REQUEST, ast_aoc_decoded::msg_type, and ast_aoc_decoded::termination_request.
Referenced by sig_pri_send_aoce_termination_request().
{
if (decoded->msg_type != AST_AOC_REQUEST) {
return -1;
}
decoded->termination_request = 1;
return 0;
}
| 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 772 of file aoc.c.
References ast_aoc_decoded::total_type, and type.
Referenced by action_aocmessage(), and sig_pri_aoc_d_from_pri().
{
decoded->total_type = type;
return 0;
}
| int ast_aoc_test_encode_decode_match | ( | struct ast_aoc_decoded * | decoded | ) |
test aoc encode decode routines.
Definition at line 1195 of file aoc.c.
References ast_aoc_decode(), ast_aoc_destroy_decoded(), ast_aoc_destroy_encoded(), ast_aoc_encode(), and ast_free.
{
struct ast_aoc_decoded *new_decoded = NULL;
struct ast_aoc_encoded *encoded = NULL;
size_t size;
int res = 0;
if (!(encoded = ast_aoc_encode(decoded, &size, NULL))) {
return -1;
}
if (!(new_decoded = ast_aoc_decode(encoded, size, NULL))) {
ast_free(encoded);
return -1;
}
if (memcmp(new_decoded, decoded, sizeof(struct ast_aoc_decoded))) {
res = -1;
}
ast_aoc_destroy_decoded(new_decoded);
ast_aoc_destroy_encoded(encoded);
return res;
}