generic AOC payload generation encoding and decoding More...
#include "asterisk.h"#include "asterisk/aoc.h"#include "asterisk/utils.h"#include "asterisk/strings.h"#include "asterisk/_private.h"#include "asterisk/cli.h"#include "asterisk/manager.h"
Go to the source code of this file.
Data Structures | |
| struct | aoc_ie_billing |
| struct | aoc_ie_charging_association |
| struct | aoc_ie_charging_rate |
| struct | aoc_ie_currency |
| struct | aoc_ie_data |
| struct | aoc_ie_unit |
| struct | aoc_pl_ie_hdr |
| AOC IE payload header. More... | |
| struct | ast_aoc_decoded |
| struct | ast_aoc_encoded |
Defines | |
| #define | AST_AOC_ENCODE_VERSION 1 |
| #define | AST_AOC_ENCODED_CHARGE_CURRENCY (2 << 5) |
| #define | AST_AOC_ENCODED_CHARGE_FREE (1 << 5) |
| #define | AST_AOC_ENCODED_CHARGE_NA (0 << 5) |
| #define | AST_AOC_ENCODED_CHARGE_SUBTOTAL (1 << 7) |
| #define | AST_AOC_ENCODED_CHARGE_TOTAL (0 << 7) |
| #define | AST_AOC_ENCODED_CHARGE_UNIT (3 << 5) |
| #define | AST_AOC_ENCODED_REQUEST_D (1 << 3) |
| #define | AST_AOC_ENCODED_REQUEST_E (1 << 4) |
| #define | AST_AOC_ENCODED_REQUEST_S (1 << 2) |
| #define | AST_AOC_ENCODED_TYPE_D (1 << 0) |
| #define | AST_AOC_ENCODED_TYPE_E (2 << 0) |
| #define | AST_AOC_ENCODED_TYPE_REQUEST (0 << 0) |
| #define | AST_AOC_ENCODED_TYPE_S (3 << 0) |
Enumerations | |
| enum | AOC_IE { AOC_IE_CURRENCY = 1, AOC_IE_UNIT = 2, AOC_IE_BILLING = 3, AOC_IE_CHARGING_ASSOCIATION = 4, AOC_IE_RATE = 5, AOC_IE_TERMINATION_REQUEST = 6 } |
| AOC Payload Information Elements. More... | |
Functions | |
| static void | aoc_amount_str (struct ast_str **msg, const char *prefix, unsigned int amount, enum ast_aoc_currency_multiplier mult) |
| static int | aoc_append_ie (struct aoc_ie_data *ied, unsigned short ie_id, const void *data, unsigned short datalen) |
| static const char * | aoc_billingid_str (enum ast_aoc_billing_id billing_id) |
| static const char * | aoc_charge_type_str (enum ast_aoc_charge_type value) |
| static const char * | aoc_charged_item_str (enum ast_aoc_s_charged_item value) |
| static char * | aoc_cli_debug_enable (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static void | aoc_create_ie_data (struct ast_aoc_decoded *decoded, struct aoc_ie_data *ied) |
| static void | aoc_create_ie_data_charging_rate (const struct ast_aoc_s_entry *entry, struct aoc_ie_charging_rate *ie) |
| static void | aoc_d_event (const struct ast_aoc_decoded *decoded, struct ast_channel *chan, struct ast_str **msg) |
| static void | aoc_display_decoded_debug (const struct ast_aoc_decoded *decoded, int decoding, struct ast_channel *chan) |
| static void | aoc_e_event (const struct ast_aoc_decoded *decoded, struct ast_channel *chan, struct ast_str **msg) |
| static const char * | aoc_multiplier_str (enum ast_aoc_currency_multiplier mult) |
| static int | aoc_parse_ie (struct ast_aoc_decoded *decoded, unsigned char *data, unsigned int datalen) |
| static void | aoc_parse_ie_charging_rate (struct ast_aoc_decoded *decoded, const struct aoc_ie_charging_rate *ie) |
| static const char * | aoc_rate_type_str (enum ast_aoc_s_rate_type value) |
| static void | aoc_request_event (const struct ast_aoc_decoded *decoded, struct ast_channel *chan, struct ast_str **msg) |
| static int | aoc_s_add_entry (struct ast_aoc_decoded *decoded, struct ast_aoc_s_entry *entry) |
| static void | aoc_s_event (const struct ast_aoc_decoded *decoded, struct ast_channel *owner, struct ast_str **msg) |
| static const char * | aoc_scale_str (enum ast_aoc_time_scale value) |
| static void | aoc_shutdown (void) |
| static void | aoc_time_str (struct ast_str **msg, const char *prefix, const char *name, unsigned long time, enum ast_aoc_time_scale scale) |
| static const char * | aoc_type_of_totaling_str (enum ast_aoc_total_type value) |
| static const char * | aoc_volume_unit_str (enum ast_aoc_volume_unit value) |
| 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. | |
| ASTERISK_FILE_VERSION (__FILE__,"$Revision: 377883 $") | |
Variables | |
| static struct ast_cli_entry | aoc_cli [] |
| static char | aoc_debug_enabled = 0 |
generic AOC payload generation encoding and decoding
Definition in file aoc.c.
| #define AST_AOC_ENCODE_VERSION 1 |
Definition at line 58 of file aoc.c.
Referenced by ast_aoc_encode().
| #define AST_AOC_ENCODED_CHARGE_CURRENCY (2 << 5) |
Definition at line 52 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_CHARGE_FREE (1 << 5) |
Definition at line 51 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_CHARGE_NA (0 << 5) |
Definition at line 50 of file aoc.c.
Referenced by ast_aoc_encode().
| #define AST_AOC_ENCODED_CHARGE_SUBTOTAL (1 << 7) |
Definition at line 55 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_CHARGE_TOTAL (0 << 7) |
| #define AST_AOC_ENCODED_CHARGE_UNIT (3 << 5) |
Definition at line 53 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_REQUEST_D (1 << 3) |
Definition at line 47 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_REQUEST_E (1 << 4) |
Definition at line 48 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_REQUEST_S (1 << 2) |
Definition at line 46 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_TYPE_D (1 << 0) |
Definition at line 42 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_TYPE_E (2 << 0) |
Definition at line 43 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| #define AST_AOC_ENCODED_TYPE_REQUEST (0 << 0) |
Definition at line 41 of file aoc.c.
Referenced by ast_aoc_encode().
| #define AST_AOC_ENCODED_TYPE_S (3 << 0) |
Definition at line 44 of file aoc.c.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
| enum AOC_IE |
AOC Payload Information Elements.
| AOC_IE_CURRENCY | |
| AOC_IE_UNIT | |
| AOC_IE_BILLING | |
| AOC_IE_CHARGING_ASSOCIATION | |
| AOC_IE_RATE | |
| AOC_IE_TERMINATION_REQUEST |
Definition at line 104 of file aoc.c.
{
AOC_IE_CURRENCY = 1,
AOC_IE_UNIT = 2,
AOC_IE_BILLING = 3,
AOC_IE_CHARGING_ASSOCIATION = 4,
AOC_IE_RATE = 5,
AOC_IE_TERMINATION_REQUEST = 6,
};
| static void aoc_amount_str | ( | struct ast_str ** | msg, |
| const char * | prefix, | ||
| unsigned int | amount, | ||
| enum ast_aoc_currency_multiplier | mult | ||
| ) | [static] |
Definition at line 1283 of file aoc.c.
References aoc_multiplier_str(), ast_str_append(), and name.
Referenced by aoc_d_event(), aoc_e_event(), and aoc_s_event().
{
static const char name[] = "Amount";
ast_str_append(msg, 0, "%s/%s/Cost: %u\r\n", prefix, name, amount);
ast_str_append(msg, 0, "%s/%s/Multiplier: %s\r\n", prefix, name,
aoc_multiplier_str(mult));
}
| static int aoc_append_ie | ( | struct aoc_ie_data * | ied, |
| unsigned short | ie_id, | ||
| const void * | data, | ||
| unsigned short | datalen | ||
| ) | [static] |
Definition at line 391 of file aoc.c.
References ast_log(), aoc_ie_data::buf, LOG_WARNING, and aoc_ie_data::pos.
Referenced by aoc_create_ie_data().
{
if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
ast_log(LOG_WARNING, "Failure to append AOC information element, out of space \n");
return -1;
}
ied->buf[ied->pos++] = ie_id;
ied->buf[ied->pos++] = datalen;
if (datalen) {
memcpy(ied->buf + ied->pos, data, datalen);
ied->pos += datalen;
}
return 0;
}
| static const char* aoc_billingid_str | ( | enum ast_aoc_billing_id | billing_id | ) | [static] |
Definition at line 1172 of file aoc.c.
References AST_AOC_BILLING_CALL_DEFLECTION, AST_AOC_BILLING_CALL_FWD_BUSY, AST_AOC_BILLING_CALL_FWD_NO_REPLY, AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL, AST_AOC_BILLING_CALL_TRANSFER, AST_AOC_BILLING_CREDIT_CARD, AST_AOC_BILLING_NA, AST_AOC_BILLING_NORMAL, AST_AOC_BILLING_NUM_ENTRIES, and AST_AOC_BILLING_REVERSE_CHARGE.
Referenced by aoc_d_event(), and aoc_e_event().
{
switch (billing_id) {
case AST_AOC_BILLING_NORMAL:
return "Normal";
case AST_AOC_BILLING_REVERSE_CHARGE:
return "Reverse";
case AST_AOC_BILLING_CREDIT_CARD:
return "CreditCard";
case AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL:
return "CallForwardingUnconditional";
case AST_AOC_BILLING_CALL_FWD_BUSY:
return "CallForwardingBusy";
case AST_AOC_BILLING_CALL_FWD_NO_REPLY:
return "CallForwardingNoReply";
case AST_AOC_BILLING_CALL_DEFLECTION:
return "CallDeflection";
case AST_AOC_BILLING_CALL_TRANSFER:
return "CallTransfer";
case AST_AOC_BILLING_NA:
return "NotAvailable";
case AST_AOC_BILLING_NUM_ENTRIES:
break;
}
return "NotAvailable";
}
| static const char* aoc_charge_type_str | ( | enum ast_aoc_charge_type | value | ) | [static] |
Definition at line 1126 of file aoc.c.
References AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_NA, AST_AOC_CHARGE_UNIT, and str.
Referenced by aoc_d_event(), and aoc_e_event().
{
const char *str;
switch (value) {
default:
case AST_AOC_CHARGE_NA:
str = "NotAvailable";
break;
case AST_AOC_CHARGE_FREE:
str = "Free";
break;
case AST_AOC_CHARGE_CURRENCY:
str = "Currency";
break;
case AST_AOC_CHARGE_UNIT:
str = "Units";
break;
}
return str;
}
| static const char* aoc_charged_item_str | ( | enum ast_aoc_s_charged_item | value | ) | [static] |
Definition at line 990 of file aoc.c.
References AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION, AST_AOC_CHARGED_ITEM_CALL_ATTEMPT, AST_AOC_CHARGED_ITEM_CALL_SETUP, AST_AOC_CHARGED_ITEM_NA, AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE, AST_AOC_CHARGED_ITEM_USER_USER_INFO, and str.
Referenced by aoc_s_event().
{
const char *str;
switch (value) {
default:
case AST_AOC_CHARGED_ITEM_NA:
str = "NotAvailable";
break;
case AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT:
str = "SpecialArrangement";
break;
case AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION:
str = "BasicCommunication";
break;
case AST_AOC_CHARGED_ITEM_CALL_ATTEMPT:
str = "CallAttempt";
break;
case AST_AOC_CHARGED_ITEM_CALL_SETUP:
str = "CallSetup";
break;
case AST_AOC_CHARGED_ITEM_USER_USER_INFO:
str = "UserUserInfo";
break;
case AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE:
str = "SupplementaryService";
break;
}
return str;
}
| static char* aoc_cli_debug_enable | ( | struct ast_cli_entry * | e, |
| int | cmd, | ||
| struct ast_cli_args * | a | ||
| ) | [static] |
Definition at line 1224 of file aoc.c.
References aoc_debug_enabled, ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_false(), ast_true(), CLI_GENERATE, CLI_HANDLER, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ast_cli_args::fd, and ast_cli_entry::usage.
{
switch (cmd) {
case CLI_INIT:
e->command = "aoc set debug";
e->usage =
"Usage: 'aoc set debug on' to enable aoc debug, 'aoc set debug off' to disable debug.\n";
return NULL;
case CLI_GENERATE:
return NULL;
case CLI_HANDLER:
if (a->argc != 4) {
return CLI_SHOWUSAGE;
} else if(ast_true(a->argv[3])) {
ast_cli(a->fd, "aoc debug enabled\n");
aoc_debug_enabled = 1;
} else if (ast_false(a->argv[3])) {
ast_cli(a->fd, "aoc debug disabled\n");
aoc_debug_enabled = 0;
} else {
return CLI_SHOWUSAGE;
}
}
return CLI_SUCCESS;
}
| static void aoc_create_ie_data | ( | struct ast_aoc_decoded * | decoded, |
| struct aoc_ie_data * | ied | ||
| ) | [static] |
Definition at line 452 of file aoc.c.
References aoc_ie_currency::amount, aoc_ie_unit::amount, ast_aoc_unit_entry::amount, aoc_append_ie(), aoc_create_ie_data_charging_rate(), AOC_IE_BILLING, AOC_IE_CHARGING_ASSOCIATION, AOC_IE_CURRENCY, AOC_IE_RATE, AOC_IE_TERMINATION_REQUEST, AOC_IE_UNIT, ast_aoc_decoded::aoc_s_count, ast_aoc_decoded::aoc_s_entries, AST_AOC_CHARGING_ASSOCIATION_ID, AST_AOC_CHARGING_ASSOCIATION_NA, AST_AOC_CHARGING_ASSOCIATION_NUMBER, ast_copy_string(), ast_strlen_zero(), ast_aoc_decoded::billing_id, aoc_ie_charging_association::ca, ast_aoc_charging_association::charge, ast_aoc_decoded::charging_association, ast_aoc_charging_association::charging_type, ast_aoc_decoded::currency_amount, ast_aoc_decoded::currency_name, aoc_ie_billing::id, ast_aoc_charging_association::id, ast_aoc_decoded::multiplier, aoc_ie_currency::name, ast_aoc_charging_association_number::number, ast_aoc_charging_association::number, ast_aoc_charging_association_number::plan, aoc_ie_data::pos, ast_aoc_decoded::termination_request, aoc_ie_unit::type, ast_aoc_unit_entry::type, ast_aoc_decoded::unit_count, ast_aoc_decoded::unit_list, aoc_ie_unit::valid_amount, ast_aoc_unit_entry::valid_amount, aoc_ie_unit::valid_type, and ast_aoc_unit_entry::valid_type.
Referenced by ast_aoc_encode().
{
ied->pos = 0;
if (decoded->currency_amount) {
struct aoc_ie_currency ie = {
.amount = htonl(decoded->currency_amount),
.multiplier = decoded->multiplier, /* only one byte */
.name = { 0, },
};
if (!ast_strlen_zero(decoded->currency_name)) {
ast_copy_string(ie.name, decoded->currency_name, sizeof(ie.name));
}
aoc_append_ie(ied, AOC_IE_CURRENCY, (const void *) &ie, sizeof(ie));
}
if (decoded->unit_count) {
struct aoc_ie_unit ie = { 0 };
int i;
for (i = 0; i < decoded->unit_count; i++) {
ie.valid_amount = decoded->unit_list[i].valid_amount; /* only one byte */
ie.amount = htonl(decoded->unit_list[i].amount);
ie.valid_type = decoded->unit_list[i].valid_type; /* only one byte */
ie.type = decoded->unit_list[i].type; /* only one byte */
aoc_append_ie(ied, AOC_IE_UNIT, (const void *) &ie, sizeof(ie));
}
}
if (decoded->billing_id) {
struct aoc_ie_billing ie;
ie.id = decoded->billing_id; /* only one byte */
aoc_append_ie(ied, AOC_IE_BILLING, (const void *) &ie, sizeof(ie));
}
if (decoded->charging_association.charging_type != AST_AOC_CHARGING_ASSOCIATION_NA) {
struct aoc_ie_charging_association ie;
memset(&ie, 0, sizeof(ie));
ie.ca.charging_type = decoded->charging_association.charging_type; /* only one byte */
if (decoded->charging_association.charging_type == AST_AOC_CHARGING_ASSOCIATION_NUMBER) {
ie.ca.charge.number.plan = decoded->charging_association.charge.number.plan; /* only one byte */
ast_copy_string(ie.ca.charge.number.number,
decoded->charging_association.charge.number.number,
sizeof(ie.ca.charge.number.number));
} else if (decoded->charging_association.charging_type == AST_AOC_CHARGING_ASSOCIATION_ID) {
ie.ca.charge.id = htonl(decoded->charging_association.charge.id);
}
aoc_append_ie(ied, AOC_IE_CHARGING_ASSOCIATION, (const void *) &ie, sizeof(ie));
}
if (decoded->aoc_s_count) {
struct aoc_ie_charging_rate ie;
int i;
for (i = 0; i < decoded->aoc_s_count; i++) {
memset(&ie, 0, sizeof(ie));
aoc_create_ie_data_charging_rate(&decoded->aoc_s_entries[i], &ie);
aoc_append_ie(ied, AOC_IE_RATE, (const void *) &ie, sizeof(ie));
}
}
if (decoded->termination_request) {
aoc_append_ie(ied, AOC_IE_TERMINATION_REQUEST, NULL, 0);
}
}
| static void aoc_create_ie_data_charging_rate | ( | const struct ast_aoc_s_entry * | entry, |
| struct aoc_ie_charging_rate * | ie | ||
| ) | [static] |
Definition at line 406 of file aoc.c.
References ast_aoc_duration_rate::amount, ast_aoc_volume_rate::amount, ast_aoc_flat_rate::amount, AST_AOC_RATE_TYPE_DURATION, AST_AOC_RATE_TYPE_FLAT, AST_AOC_RATE_TYPE_SPECIAL_CODE, AST_AOC_RATE_TYPE_VOLUME, 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_volume_rate::currency_name, ast_aoc_flat_rate::currency_name, ast_aoc_s_entry::duration, aoc_ie_charging_rate::entry, ast_aoc_s_entry::flat, ast_aoc_duration_rate::granularity_time, ast_aoc_duration_rate::granularity_time_scale, ast_aoc_duration_rate::multiplier, ast_aoc_volume_rate::multiplier, ast_aoc_flat_rate::multiplier, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, ast_aoc_s_entry::special_code, ast_aoc_duration_rate::time, ast_aoc_duration_rate::time_scale, ast_aoc_s_entry::volume, and ast_aoc_volume_rate::volume_unit.
Referenced by aoc_create_ie_data().
{
ie->entry.charged_item = htons(entry->charged_item);
ie->entry.rate_type = htons(entry->rate_type);
switch (entry->rate_type) {
case AST_AOC_RATE_TYPE_DURATION:
ie->entry.rate.duration.multiplier = htons(entry->rate.duration.multiplier);
ie->entry.rate.duration.amount = htonl(entry->rate.duration.amount);
ie->entry.rate.duration.time = htonl(entry->rate.duration.time);
ie->entry.rate.duration.time_scale = htons(entry->rate.duration.time_scale);
ie->entry.rate.duration.granularity_time = htonl(entry->rate.duration.granularity_time);
ie->entry.rate.duration.granularity_time_scale = htons(entry->rate.duration.granularity_time_scale);
ie->entry.rate.duration.charging_type = entry->rate.duration.charging_type; /* only one byte */
if (!ast_strlen_zero(entry->rate.duration.currency_name)) {
ast_copy_string(ie->entry.rate.duration.currency_name,
entry->rate.duration.currency_name,
sizeof(ie->entry.rate.duration.currency_name));
}
break;
case AST_AOC_RATE_TYPE_FLAT:
ie->entry.rate.flat.multiplier = htons(entry->rate.flat.multiplier);
ie->entry.rate.flat.amount = htonl(entry->rate.flat.amount);
if (!ast_strlen_zero(entry->rate.flat.currency_name)) {
ast_copy_string(ie->entry.rate.flat.currency_name,
entry->rate.flat.currency_name,
sizeof(ie->entry.rate.flat.currency_name));
}
break;
case AST_AOC_RATE_TYPE_VOLUME:
ie->entry.rate.volume.multiplier = htons(entry->rate.volume.multiplier);
ie->entry.rate.volume.amount = htonl(entry->rate.volume.amount);
ie->entry.rate.volume.volume_unit = htons(entry->rate.volume.volume_unit);
if (!ast_strlen_zero(entry->rate.volume.currency_name)) {
ast_copy_string(ie->entry.rate.volume.currency_name,
entry->rate.volume.currency_name,
sizeof(ie->entry.rate.volume.currency_name));
}
break;
case AST_AOC_RATE_TYPE_SPECIAL_CODE:
ie->entry.rate.special_code = htons(entry->rate.special_code);
break;
}
}
| static void aoc_d_event | ( | const struct ast_aoc_decoded * | decoded, |
| struct ast_channel * | chan, | ||
| struct ast_str ** | msg | ||
| ) | [static] |
Definition at line 1390 of file aoc.c.
References ast_aoc_unit_entry::amount, aoc_amount_str(), aoc_billingid_str(), aoc_charge_type_str(), aoc_type_of_totaling_str(), AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_UNIT, ast_channel_name(), ast_channel_uniqueid(), ast_str_append(), ast_aoc_decoded::billing_id, ast_aoc_decoded::charge_type, ast_aoc_decoded::currency_amount, ast_aoc_decoded::currency_name, ast_aoc_decoded::multiplier, prefix, ast_aoc_decoded::total_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 ast_aoc_decoded2str(), and ast_aoc_manager_event().
{
const char *charge_str;
int idx;
char prefix[32];
if (chan) {
ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(chan));
ast_str_append(msg, 0, "UniqueID: %s\r\n", ast_channel_uniqueid(chan));
}
charge_str = aoc_charge_type_str(decoded->charge_type);
ast_str_append(msg, 0, "Type: %s\r\n", charge_str);
switch (decoded->charge_type) {
case AST_AOC_CHARGE_CURRENCY:
case AST_AOC_CHARGE_UNIT:
ast_str_append(msg, 0, "BillingID: %s\r\n",
aoc_billingid_str(decoded->billing_id));
ast_str_append(msg, 0, "TypeOfCharging: %s\r\n",
aoc_type_of_totaling_str(decoded->total_type));
break;
default:
break;
}
switch (decoded->charge_type) {
case AST_AOC_CHARGE_CURRENCY:
ast_str_append(msg, 0, "%s: %s\r\n", charge_str,
decoded->currency_name);
aoc_amount_str(msg, charge_str,
decoded->currency_amount,
decoded->multiplier);
break;
case AST_AOC_CHARGE_UNIT:
ast_str_append(msg, 0, "%s/NumberItems: %d\r\n", charge_str,
decoded->unit_count);
for (idx = 0; idx < decoded->unit_count; ++idx) {
snprintf(prefix, sizeof(prefix), "%s/Item(%d)", charge_str, idx);
if (decoded->unit_list[idx].valid_amount) {
ast_str_append(msg, 0, "%s/NumberOf: %u\r\n", prefix,
decoded->unit_list[idx].amount);
}
if (decoded->unit_list[idx].valid_type) {
ast_str_append(msg, 0, "%s/TypeOf: %d\r\n", prefix,
decoded->unit_list[idx].type);
}
}
break;
default:
break;
}
}
| static void aoc_display_decoded_debug | ( | const struct ast_aoc_decoded * | decoded, |
| int | decoding, | ||
| struct ast_channel * | chan | ||
| ) | [static] |
Definition at line 1578 of file aoc.c.
References ast_aoc_decoded2str(), ast_channel_name(), ast_free, ast_str_append(), ast_str_buffer(), ast_str_create(), and ast_verb.
Referenced by ast_aoc_decode(), and ast_aoc_encode().
{
struct ast_str *msg;
if (!decoded || !(msg = ast_str_create(1024))) {
return;
}
if (decoding) {
ast_str_append(&msg, 0, "---- DECODED AOC MSG ----\r\n");
} else {
ast_str_append(&msg, 0, "---- ENCODED AOC MSG ----\r\n");
}
if (chan) {
ast_str_append(&msg, 0, "CHANNEL: %s\r\n", ast_channel_name(chan));
}
if (ast_aoc_decoded2str(decoded, &msg)) {
ast_free(msg);
return;
}
ast_verb(1, "%s\r\n", ast_str_buffer(msg));
ast_free(msg);
}
| static void aoc_e_event | ( | const struct ast_aoc_decoded * | decoded, |
| struct ast_channel * | chan, | ||
| struct ast_str ** | msg | ||
| ) | [static] |
Definition at line 1444 of file aoc.c.
References ast_aoc_unit_entry::amount, aoc_amount_str(), aoc_billingid_str(), aoc_charge_type_str(), AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_UNIT, AST_AOC_CHARGING_ASSOCIATION_ID, AST_AOC_CHARGING_ASSOCIATION_NA, AST_AOC_CHARGING_ASSOCIATION_NUMBER, ast_channel_name(), ast_channel_uniqueid(), ast_str_append(), ast_aoc_decoded::billing_id, ast_aoc_charging_association::charge, ast_aoc_decoded::charge_type, ast_aoc_decoded::charging_association, ast_aoc_charging_association::charging_type, ast_aoc_decoded::currency_amount, ast_aoc_decoded::currency_name, ast_aoc_charging_association::id, ast_aoc_decoded::multiplier, ast_aoc_charging_association_number::number, ast_aoc_charging_association::number, ast_aoc_charging_association_number::plan, prefix, 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 ast_aoc_decoded2str(), and ast_aoc_manager_event().
{
const char *charge_str;
int idx;
char prefix[32];
if (chan) {
ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(chan));
ast_str_append(msg, 0, "UniqueID: %s\r\n", ast_channel_uniqueid(chan));
}
charge_str = "ChargingAssociation";
switch (decoded->charging_association.charging_type) {
case AST_AOC_CHARGING_ASSOCIATION_NUMBER:
snprintf(prefix, sizeof(prefix), "%s/Number", charge_str);
ast_str_append(msg, 0, "%s: %s\r\n", prefix,
decoded->charging_association.charge.number.number);
ast_str_append(msg, 0, "%s/Plan: %d\r\n", prefix,
decoded->charging_association.charge.number.plan);
break;
case AST_AOC_CHARGING_ASSOCIATION_ID:
ast_str_append(msg, 0, "%s/ID: %d\r\n", charge_str, decoded->charging_association.charge.id);
break;
case AST_AOC_CHARGING_ASSOCIATION_NA:
default:
break;
}
charge_str = aoc_charge_type_str(decoded->charge_type);
ast_str_append(msg, 0, "Type: %s\r\n", charge_str);
switch (decoded->charge_type) {
case AST_AOC_CHARGE_CURRENCY:
case AST_AOC_CHARGE_UNIT:
ast_str_append(msg, 0, "BillingID: %s\r\n",
aoc_billingid_str(decoded->billing_id));
break;
default:
break;
}
switch (decoded->charge_type) {
case AST_AOC_CHARGE_CURRENCY:
ast_str_append(msg, 0, "%s: %s\r\n", charge_str,
decoded->currency_name);
aoc_amount_str(msg, charge_str,
decoded->currency_amount,
decoded->multiplier);
break;
case AST_AOC_CHARGE_UNIT:
ast_str_append(msg, 0, "%s/NumberItems: %d\r\n", charge_str,
decoded->unit_count);
for (idx = 0; idx < decoded->unit_count; ++idx) {
snprintf(prefix, sizeof(prefix), "%s/Item(%d)", charge_str, idx);
if (decoded->unit_list[idx].valid_amount) {
ast_str_append(msg, 0, "%s/NumberOf: %u\r\n", prefix,
decoded->unit_list[idx].amount);
}
if (decoded->unit_list[idx].valid_type) {
ast_str_append(msg, 0, "%s/TypeOf: %d\r\n", prefix,
decoded->unit_list[idx].type);
}
}
break;
default:
break;
}
}
| static const char* aoc_multiplier_str | ( | enum ast_aoc_currency_multiplier | mult | ) | [static] |
Definition at line 1149 of file aoc.c.
References AST_AOC_MULT_HUNDRED, AST_AOC_MULT_NUM_ENTRIES, AST_AOC_MULT_ONE, AST_AOC_MULT_ONEHUNDREDTH, AST_AOC_MULT_ONETENTH, AST_AOC_MULT_ONETHOUSANDTH, AST_AOC_MULT_TEN, and AST_AOC_MULT_THOUSAND.
Referenced by aoc_amount_str().
{
switch (mult) {
case AST_AOC_MULT_ONETHOUSANDTH:
return "1/1000";
case AST_AOC_MULT_ONEHUNDREDTH:
return "1/100";
case AST_AOC_MULT_ONETENTH:
return "1/10";
case AST_AOC_MULT_ONE:
return "1";
case AST_AOC_MULT_TEN:
return "10";
case AST_AOC_MULT_HUNDRED:
return "100";
case AST_AOC_MULT_THOUSAND:
return "1000";
case AST_AOC_MULT_NUM_ENTRIES:
break;
}
return "1";
}
| static int aoc_parse_ie | ( | struct ast_aoc_decoded * | decoded, |
| unsigned char * | data, | ||
| unsigned int | datalen | ||
| ) | [static] |
Definition at line 238 of file aoc.c.
References aoc_ie_currency::amount, aoc_ie_unit::amount, AOC_IE_BILLING, AOC_IE_CHARGING_ASSOCIATION, AOC_IE_CURRENCY, AOC_IE_RATE, AOC_IE_TERMINATION_REQUEST, AOC_IE_UNIT, aoc_parse_ie_charging_rate(), ast_aoc_add_unit_entry(), AST_AOC_CHARGING_ASSOCIATION_ID, ast_log(), ast_aoc_decoded::billing_id, ast_aoc_charging_association::charge, ast_aoc_decoded::charging_association, ast_aoc_charging_association::charging_type, ast_aoc_decoded::currency_amount, ast_aoc_decoded::currency_name, aoc_ie_billing::id, ast_aoc_charging_association::id, len(), LOG_ERROR, LOG_WARNING, ast_aoc_decoded::multiplier, aoc_ie_currency::multiplier, aoc_ie_currency::name, ast_aoc_decoded::termination_request, aoc_ie_unit::type, aoc_ie_unit::valid_amount, and aoc_ie_unit::valid_type.
Referenced by ast_aoc_decode().
{
enum AOC_IE ie_id;
unsigned int len;
while (datalen >= 2) {
ie_id = data[0];
len = data[1];
if (len > datalen -2) {
ast_log(LOG_ERROR, "AOC information element length exceeds the total message size\n");
return -1;
}
switch(ie_id) {
case AOC_IE_CURRENCY:
if (len == sizeof(struct aoc_ie_currency)) {
struct aoc_ie_currency ie;
memcpy(&ie, data + 2, len);
decoded->currency_amount = ntohl(ie.amount);
decoded->multiplier = ie.multiplier; /* only one byte */
memcpy(decoded->currency_name, ie.name, sizeof(decoded->currency_name));
} else {
ast_log(LOG_WARNING, "Received invalid currency ie\n");
}
break;
case AOC_IE_UNIT:
if (len == sizeof(struct aoc_ie_unit)) {
struct aoc_ie_unit ie;
memcpy(&ie, data + 2, len);
ast_aoc_add_unit_entry(decoded, ie.valid_amount, ntohl(ie.amount), ie.valid_type, ie.type);
} else {
ast_log(LOG_WARNING, "Received invalid unit ie\n");
}
break;
case AOC_IE_BILLING:
if (len == sizeof(struct aoc_ie_billing)) {
struct aoc_ie_billing ie;
memcpy(&ie, data + 2, len);
decoded->billing_id = ie.id; /* only one byte */
} else {
ast_log(LOG_WARNING, "Received invalid billing ie\n");
}
break;
case AOC_IE_CHARGING_ASSOCIATION:
if (len == sizeof(struct aoc_ie_charging_association)) {
memcpy(&decoded->charging_association, data + 2, sizeof(decoded->charging_association));
/* everything in the charging_association struct is a single byte except for the id */
if (decoded->charging_association.charging_type == AST_AOC_CHARGING_ASSOCIATION_ID) {
decoded->charging_association.charge.id = ntohl(decoded->charging_association.charge.id);
}
} else {
ast_log(LOG_WARNING, "Received invalid charging association ie\n");
}
break;
case AOC_IE_RATE:
if (len == sizeof(struct aoc_ie_charging_rate)) {
struct aoc_ie_charging_rate ie;
memcpy(&ie, data + 2, len);
aoc_parse_ie_charging_rate(decoded, &ie);
} else {
ast_log(LOG_WARNING, "Received invalid charging rate ie\n");
}
break;
case AOC_IE_TERMINATION_REQUEST:
if (len == 0) {
decoded->termination_request = 1;
} else {
ast_log(LOG_WARNING, "Received invalid termination request ie\n");
}
break;
default:
ast_log(LOG_WARNING, "Unknown AOC Information Element, ignoring.\n");
}
datalen -= (len + 2);
data += (len + 2);
}
return 0;
}
| static void aoc_parse_ie_charging_rate | ( | struct ast_aoc_decoded * | decoded, |
| const struct aoc_ie_charging_rate * | ie | ||
| ) | [static] |
Definition at line 188 of file aoc.c.
References ast_aoc_duration_rate::amount, ast_aoc_volume_rate::amount, ast_aoc_flat_rate::amount, aoc_s_add_entry(), AST_AOC_RATE_TYPE_DURATION, AST_AOC_RATE_TYPE_FLAT, AST_AOC_RATE_TYPE_SPECIAL_CODE, AST_AOC_RATE_TYPE_VOLUME, 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_volume_rate::currency_name, ast_aoc_flat_rate::currency_name, ast_aoc_s_entry::duration, aoc_ie_charging_rate::entry, ast_aoc_s_entry::flat, ast_aoc_duration_rate::granularity_time, ast_aoc_duration_rate::granularity_time_scale, ast_aoc_duration_rate::multiplier, ast_aoc_volume_rate::multiplier, ast_aoc_flat_rate::multiplier, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, ast_aoc_s_entry::special_code, ast_aoc_duration_rate::time, ast_aoc_duration_rate::time_scale, ast_aoc_s_entry::volume, and ast_aoc_volume_rate::volume_unit.
Referenced by aoc_parse_ie().
{
struct ast_aoc_s_entry entry = { 0, };
entry.charged_item = ntohs(ie->entry.charged_item);
entry.rate_type = ntohs(ie->entry.rate_type);
switch (entry.rate_type) {
case AST_AOC_RATE_TYPE_DURATION:
entry.rate.duration.multiplier = ntohs(ie->entry.rate.duration.multiplier);
entry.rate.duration.amount = ntohl(ie->entry.rate.duration.amount);
entry.rate.duration.time = ntohl(ie->entry.rate.duration.time);
entry.rate.duration.time_scale = ntohs(ie->entry.rate.duration.time_scale);
entry.rate.duration.granularity_time = ntohl(ie->entry.rate.duration.granularity_time);
entry.rate.duration.granularity_time_scale = ntohs(ie->entry.rate.duration.granularity_time_scale);
entry.rate.duration.charging_type = ie->entry.rate.duration.charging_type; /* only one byte */
if (!ast_strlen_zero(ie->entry.rate.duration.currency_name)) {
ast_copy_string(entry.rate.duration.currency_name,
ie->entry.rate.duration.currency_name,
sizeof(entry.rate.duration.currency_name));
}
break;
case AST_AOC_RATE_TYPE_FLAT:
entry.rate.flat.multiplier = ntohs(ie->entry.rate.flat.multiplier);
entry.rate.flat.amount = ntohl(ie->entry.rate.flat.amount);
if (!ast_strlen_zero(ie->entry.rate.flat.currency_name)) {
ast_copy_string(entry.rate.flat.currency_name,
ie->entry.rate.flat.currency_name,
sizeof(entry.rate.flat.currency_name));
}
break;
case AST_AOC_RATE_TYPE_VOLUME:
entry.rate.volume.multiplier = ntohs(ie->entry.rate.volume.multiplier);
entry.rate.volume.amount = ntohl(ie->entry.rate.volume.amount);
entry.rate.volume.volume_unit = ntohs(ie->entry.rate.volume.volume_unit);
if (!ast_strlen_zero(ie->entry.rate.volume.currency_name)) {
ast_copy_string(entry.rate.volume.currency_name,
ie->entry.rate.volume.currency_name,
sizeof(entry.rate.volume.currency_name));
}
break;
case AST_AOC_RATE_TYPE_SPECIAL_CODE:
entry.rate.special_code = ntohs(ie->entry.rate.special_code);
break;
}
aoc_s_add_entry(decoded, &entry);
}
| static const char* aoc_rate_type_str | ( | enum ast_aoc_s_rate_type | value | ) | [static] |
Definition at line 1055 of file aoc.c.
References AST_AOC_RATE_TYPE_DURATION, AST_AOC_RATE_TYPE_FLAT, AST_AOC_RATE_TYPE_FREE, AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING, AST_AOC_RATE_TYPE_NA, AST_AOC_RATE_TYPE_SPECIAL_CODE, AST_AOC_RATE_TYPE_VOLUME, and str.
Referenced by aoc_s_event().
{
const char *str;
switch (value) {
default:
case AST_AOC_RATE_TYPE_NA:
str = "NotAvailable";
break;
case AST_AOC_RATE_TYPE_FREE:
str = "Free";
break;
case AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING:
str = "FreeFromBeginning";
break;
case AST_AOC_RATE_TYPE_DURATION:
str = "Duration";
break;
case AST_AOC_RATE_TYPE_FLAT:
str = "Flat";
break;
case AST_AOC_RATE_TYPE_VOLUME:
str = "Volume";
break;
case AST_AOC_RATE_TYPE_SPECIAL_CODE:
str = "SpecialCode";
break;
}
return str;
}
| static void aoc_request_event | ( | const struct ast_aoc_decoded * | decoded, |
| struct ast_channel * | chan, | ||
| struct ast_str ** | msg | ||
| ) | [static] |
Definition at line 1292 of file aoc.c.
References AST_AOC_REQUEST_D, AST_AOC_REQUEST_E, AST_AOC_REQUEST_S, ast_channel_name(), ast_channel_uniqueid(), ast_str_append(), and ast_aoc_decoded::request_flag.
Referenced by ast_aoc_decoded2str().
{
if (chan) {
ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(chan));
ast_str_append(msg, 0, "UniqueID: %s\r\n", ast_channel_uniqueid(chan));
}
if (decoded->request_flag) {
ast_str_append(msg, 0, "AOCRequest:");
if (decoded->request_flag & AST_AOC_REQUEST_S) {
ast_str_append(msg, 0, "S");
}
if (decoded->request_flag & AST_AOC_REQUEST_D) {
ast_str_append(msg, 0, "D");
}
if (decoded->request_flag & AST_AOC_REQUEST_E) {
ast_str_append(msg, 0, "E");
}
ast_str_append(msg, 0, "\r\n");
} else {
ast_str_append(msg, 0, "AOCRequest: NONE\r\n");
}
}
| static int aoc_s_add_entry | ( | struct ast_aoc_decoded * | decoded, |
| struct ast_aoc_s_entry * | entry | ||
| ) | [static] |
Definition at line 612 of file aoc.c.
References ast_aoc_decoded::aoc_s_count, ast_aoc_decoded::aoc_s_entries, and ARRAY_LEN.
Referenced by aoc_parse_ie_charging_rate(), ast_aoc_s_add_rate_duration(), ast_aoc_s_add_rate_flat(), ast_aoc_s_add_rate_free(), ast_aoc_s_add_rate_na(), ast_aoc_s_add_rate_special_charge_code(), ast_aoc_s_add_rate_volume(), and ast_aoc_s_add_special_arrangement().
{
if (decoded->aoc_s_count >= ARRAY_LEN(decoded->aoc_s_entries)) {
return -1;
}
decoded->aoc_s_entries[decoded->aoc_s_count] = *entry;
decoded->aoc_s_count++;
return 0;
}
| static void aoc_s_event | ( | const struct ast_aoc_decoded * | decoded, |
| struct ast_channel * | owner, | ||
| struct ast_str ** | msg | ||
| ) | [static] |
Definition at line 1317 of file aoc.c.
References ast_aoc_duration_rate::amount, ast_aoc_volume_rate::amount, ast_aoc_flat_rate::amount, aoc_amount_str(), aoc_charged_item_str(), aoc_rate_type_str(), ast_aoc_decoded::aoc_s_count, ast_aoc_decoded::aoc_s_entries, aoc_time_str(), aoc_volume_unit_str(), AST_AOC_CHARGED_ITEM_NA, AST_AOC_RATE_TYPE_DURATION, AST_AOC_RATE_TYPE_FLAT, AST_AOC_RATE_TYPE_SPECIAL_CODE, AST_AOC_RATE_TYPE_VOLUME, ast_channel_name(), ast_channel_uniqueid(), ast_str_append(), ast_aoc_s_entry::charged_item, ast_aoc_duration_rate::charging_type, ast_aoc_duration_rate::currency_name, ast_aoc_volume_rate::currency_name, ast_aoc_flat_rate::currency_name, ast_aoc_s_entry::duration, ast_aoc_s_entry::flat, ast_aoc_duration_rate::granularity_time, ast_aoc_duration_rate::granularity_time_scale, ast_aoc_duration_rate::multiplier, ast_aoc_volume_rate::multiplier, ast_aoc_flat_rate::multiplier, prefix, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, ast_aoc_s_entry::special_code, ast_aoc_duration_rate::time, ast_aoc_duration_rate::time_scale, ast_aoc_s_entry::volume, and ast_aoc_volume_rate::volume_unit.
Referenced by ast_aoc_decoded2str(), and ast_aoc_manager_event().
{
const char *rate_str;
char prefix[32];
int idx;
if (owner) {
ast_str_append(msg, 0, "Channel: %s\r\n", ast_channel_name(owner));
ast_str_append(msg, 0, "UniqueID: %s\r\n", ast_channel_uniqueid(owner));
}
ast_str_append(msg, 0, "NumberRates: %d\r\n", decoded->aoc_s_count);
for (idx = 0; idx < decoded->aoc_s_count; ++idx) {
snprintf(prefix, sizeof(prefix), "Rate(%d)", idx);
ast_str_append(msg, 0, "%s/Chargeable: %s\r\n", prefix,
aoc_charged_item_str(decoded->aoc_s_entries[idx].charged_item));
if (decoded->aoc_s_entries[idx].charged_item == AST_AOC_CHARGED_ITEM_NA) {
continue;
}
rate_str = aoc_rate_type_str(decoded->aoc_s_entries[idx].rate_type);
ast_str_append(msg, 0, "%s/Type: %s\r\n", prefix, rate_str);
switch (decoded->aoc_s_entries[idx].rate_type) {
case AST_AOC_RATE_TYPE_DURATION:
strcat(prefix, "/");
strcat(prefix, rate_str);
ast_str_append(msg, 0, "%s/Currency: %s\r\n", prefix,
decoded->aoc_s_entries[idx].rate.duration.currency_name);
aoc_amount_str(msg, prefix,
decoded->aoc_s_entries[idx].rate.duration.amount,
decoded->aoc_s_entries[idx].rate.duration.multiplier);
ast_str_append(msg, 0, "%s/ChargingType: %s\r\n", prefix,
decoded->aoc_s_entries[idx].rate.duration.charging_type ?
"StepFunction" : "ContinuousCharging");
aoc_time_str(msg, prefix, "Time",
decoded->aoc_s_entries[idx].rate.duration.time,
decoded->aoc_s_entries[idx].rate.duration.time_scale);
if (decoded->aoc_s_entries[idx].rate.duration.granularity_time) {
aoc_time_str(msg, prefix, "Granularity",
decoded->aoc_s_entries[idx].rate.duration.granularity_time,
decoded->aoc_s_entries[idx].rate.duration.granularity_time_scale);
}
break;
case AST_AOC_RATE_TYPE_FLAT:
strcat(prefix, "/");
strcat(prefix, rate_str);
ast_str_append(msg, 0, "%s/Currency: %s\r\n", prefix,
decoded->aoc_s_entries[idx].rate.flat.currency_name);
aoc_amount_str(msg, prefix,
decoded->aoc_s_entries[idx].rate.flat.amount,
decoded->aoc_s_entries[idx].rate.flat.multiplier);
break;
case AST_AOC_RATE_TYPE_VOLUME:
strcat(prefix, "/");
strcat(prefix, rate_str);
ast_str_append(msg, 0, "%s/Currency: %s\r\n", prefix,
decoded->aoc_s_entries[idx].rate.volume.currency_name);
aoc_amount_str(msg, prefix,
decoded->aoc_s_entries[idx].rate.volume.amount,
decoded->aoc_s_entries[idx].rate.volume.multiplier);
ast_str_append(msg, 0, "%s/Unit: %s\r\n", prefix,
aoc_volume_unit_str(decoded->aoc_s_entries[idx].rate.volume.volume_unit));
break;
case AST_AOC_RATE_TYPE_SPECIAL_CODE:
ast_str_append(msg, 0, "%s/%s: %d\r\n", prefix, rate_str,
decoded->aoc_s_entries[idx].rate.special_code);
break;
default:
break;
}
}
}
| static const char* aoc_scale_str | ( | enum ast_aoc_time_scale | value | ) | [static] |
Definition at line 1095 of file aoc.c.
References AST_AOC_TIME_SCALE_DAY, AST_AOC_TIME_SCALE_HOUR, AST_AOC_TIME_SCALE_HUNDREDTH_SECOND, AST_AOC_TIME_SCALE_MINUTE, AST_AOC_TIME_SCALE_SECOND, AST_AOC_TIME_SCALE_TEN_SECOND, AST_AOC_TIME_SCALE_TENTH_SECOND, and str.
Referenced by aoc_time_str().
{
const char *str;
switch (value) {
default:
case AST_AOC_TIME_SCALE_HUNDREDTH_SECOND:
str = "OneHundredthSecond";
break;
case AST_AOC_TIME_SCALE_TENTH_SECOND:
str = "OneTenthSecond";
break;
case AST_AOC_TIME_SCALE_SECOND:
str = "Second";
break;
case AST_AOC_TIME_SCALE_TEN_SECOND:
str = "TenSeconds";
break;
case AST_AOC_TIME_SCALE_MINUTE:
str = "Minute";
break;
case AST_AOC_TIME_SCALE_HOUR:
str = "Hour";
break;
case AST_AOC_TIME_SCALE_DAY:
str = "Day";
break;
}
return str;
}
| static void aoc_shutdown | ( | void | ) | [static] |
Definition at line 1608 of file aoc.c.
References ARRAY_LEN, and ast_cli_unregister_multiple().
Referenced by ast_aoc_cli_init().
| static void aoc_time_str | ( | struct ast_str ** | msg, |
| const char * | prefix, | ||
| const char * | name, | ||
| unsigned long | time, | ||
| enum ast_aoc_time_scale | scale | ||
| ) | [static] |
Definition at line 1264 of file aoc.c.
References aoc_scale_str(), and ast_str_append().
Referenced by aoc_s_event().
{
ast_str_append(msg, 0, "%s/%s/Length: %lu\r\n", prefix, name, time);
ast_str_append(msg, 0, "%s/%s/Scale: %s\r\n", prefix, name,
aoc_scale_str(scale));
}
| static const char* aoc_type_of_totaling_str | ( | enum ast_aoc_total_type | value | ) | [static] |
Definition at line 1030 of file aoc.c.
References AST_AOC_SUBTOTAL, AST_AOC_TOTAL, and str.
Referenced by aoc_d_event().
{
const char *str;
switch (value) {
default:
case AST_AOC_SUBTOTAL:
str = "SubTotal";
break;
case AST_AOC_TOTAL:
str = "Total";
break;
}
return str;
}
| static const char* aoc_volume_unit_str | ( | enum ast_aoc_volume_unit | value | ) | [static] |
Definition at line 962 of file aoc.c.
References AST_AOC_VOLUME_UNIT_MESSAGE, AST_AOC_VOLUME_UNIT_OCTET, AST_AOC_VOLUME_UNIT_SEGMENT, and str.
Referenced by aoc_s_event().
{
const char *str;
switch (value) {
default:
case AST_AOC_VOLUME_UNIT_OCTET:
str = "Octet";
break;
case AST_AOC_VOLUME_UNIT_SEGMENT:
str = "Segment";
break;
case AST_AOC_VOLUME_UNIT_MESSAGE:
str = "Message";
break;
}
return str;
}
| 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, 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 1612 of file aoc.c.
References aoc_shutdown(), ARRAY_LEN, ast_cli_register_multiple(), and ast_register_atexit().
Referenced by main().
{
ast_register_atexit(aoc_shutdown);
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 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, 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 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(), 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 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().
{
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 176 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 182 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 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(), 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 920 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 904 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 766 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 809 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 814 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 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().
{
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 841 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 761 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 771 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 948 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 783 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 888 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 879 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 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.
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 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.
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 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.
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 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.
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 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.
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 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.
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 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.
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 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.
{
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 625 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 630 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 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, 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 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(), 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 893 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 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(), 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 938 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 776 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 1199 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;
}
| ASTERISK_FILE_VERSION | ( | __FILE__ | , |
| "$Revision: 377883 $" | |||
| ) |
struct ast_cli_entry aoc_cli[] [static] |
{
AST_CLI_DEFINE(aoc_cli_debug_enable, "enable cli debugging of AOC messages"),
}
char aoc_debug_enabled = 0 [static] |
Definition at line 61 of file aoc.c.
Referenced by aoc_cli_debug_enable(), ast_aoc_decode(), and ast_aoc_encode().