41 #define AST_AOC_ENCODED_TYPE_REQUEST (0 << 0)
42 #define AST_AOC_ENCODED_TYPE_D (1 << 0)
43 #define AST_AOC_ENCODED_TYPE_E (2 << 0)
44 #define AST_AOC_ENCODED_TYPE_S (3 << 0)
46 #define AST_AOC_ENCODED_REQUEST_S (1 << 2)
47 #define AST_AOC_ENCODED_REQUEST_D (1 << 3)
48 #define AST_AOC_ENCODED_REQUEST_E (1 << 4)
50 #define AST_AOC_ENCODED_CHARGE_NA (0 << 5)
51 #define AST_AOC_ENCODED_CHARGE_FREE (1 << 5)
52 #define AST_AOC_ENCODED_CHARGE_CURRENCY (2 << 5)
53 #define AST_AOC_ENCODED_CHARGE_UNIT (3 << 5)
55 #define AST_AOC_ENCODED_CHARGE_SUBTOTAL (1 << 7)
56 #define AST_AOC_ENCODED_CHARGE_TOTAL (0 << 7)
58 #define AST_AOC_ENCODE_VERSION 1
118 } __attribute__((packed));
124 } __attribute__((packed));
131 } __attribute__((packed));
135 } __attribute__((packed));
139 } __attribute__((packed));
143 } __attribute__((packed));
243 while (datalen >= 2) {
246 if (len > datalen -2) {
247 ast_log(
LOG_ERROR,
"AOC information element length exceeds the total message size\n");
255 memcpy(&ie, data + 2, len);
266 memcpy(&ie, data + 2, len);
275 memcpy(&ie, data + 2, len);
295 memcpy(&ie, data + 2, len);
312 datalen -= (len + 2);
393 if (datalen > ((
int)
sizeof(ied->
buf) - ied->
pos)) {
397 ied->
buf[ied->
pos++] = ie_id;
398 ied->
buf[ied->
pos++] = datalen;
400 memcpy(ied->
buf + ied->
pos, data, datalen);
491 memset(&ie, 0,
sizeof(ie));
508 memset(&ie, 0,
sizeof(ie));
525 if (!decoded || !out_size) {
539 ast_log(
LOG_WARNING,
"Failed to create ast_aoc_encoded object during decode routine. \n");
546 memcpy(encoded->
data, ied.buf, ied.pos);
547 encoded->
datalen = htons(ied.pos);
643 const char *currency_name,
646 unsigned long granularity_time,
674 const char *currency_name)
696 const char *currency_name)
789 const unsigned int amount,
847 const unsigned int amount_is_present,
848 const unsigned int amount,
849 const unsigned int type_is_present,
850 const unsigned int type)
857 if (!amount_is_present && !type_is_present) {
862 if (amount_is_present) {
869 if (type_is_present) {
997 str =
"NotAvailable";
1000 str =
"SpecialArrangement";
1003 str =
"BasicCommunication";
1006 str =
"CallAttempt";
1012 str =
"UserUserInfo";
1015 str =
"SupplementaryService";
1062 str =
"NotAvailable";
1068 str =
"FreeFromBeginning";
1080 str =
"SpecialCode";
1102 str =
"OneHundredthSecond";
1105 str =
"OneTenthSecond";
1133 str =
"NotAvailable";
1174 switch (billing_id) {
1180 return "CreditCard";
1182 return "CallForwardingUnconditional";
1184 return "CallForwardingBusy";
1186 return "CallForwardingNoReply";
1188 return "CallDeflection";
1190 return "CallTransfer";
1192 return "NotAvailable";
1196 return "NotAvailable";
1230 "Usage: 'aoc set debug on' to enable aoc debug, 'aoc set debug off' to disable debug.\n";
1266 ast_str_append(msg, 0,
"%s/%s/Length: %lu\r\n", prefix, name, time);
1285 static const char name[] =
"Amount";
1287 ast_str_append(msg, 0,
"%s/%s/Cost: %u\r\n", prefix, name, amount);
1319 const char *rate_str;
1329 for (idx = 0; idx < decoded->
aoc_s_count; ++idx) {
1330 snprintf(prefix,
sizeof(prefix),
"Rate(%d)", idx);
1341 strcat(prefix,
"/");
1342 strcat(prefix, rate_str);
1350 "StepFunction" :
"ContinuousCharging");
1361 strcat(prefix,
"/");
1362 strcat(prefix, rate_str);
1370 strcat(prefix,
"/");
1371 strcat(prefix, rate_str);
1392 const char *charge_str;
1427 for (idx = 0; idx < decoded->
unit_count; ++idx) {
1428 snprintf(prefix,
sizeof(prefix),
"%s/Item(%d)", charge_str, idx);
1446 const char *charge_str;
1455 charge_str =
"ChargingAssociation";
1459 snprintf(prefix,
sizeof(prefix),
"%s/Number", charge_str);
1495 for (idx = 0; idx < decoded->
unit_count; ++idx) {
1496 snprintf(prefix,
sizeof(prefix),
"%s/Item(%d)", charge_str, idx);
1552 if (!decoded || !msg) {
int ast_aoc_decoded2str(const struct ast_aoc_decoded *decoded, struct ast_str **msg)
Convert decoded aoc msg to string representation.
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_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.
Main Channel structure associated with a channel.
#define AST_CLI_DEFINE(fn, txt,...)
static void aoc_shutdown(void)
static void aoc_create_ie_data_charging_rate(const struct ast_aoc_s_entry *entry, struct aoc_ie_charging_rate *ie)
static void aoc_amount_str(struct ast_str **msg, const char *prefix, unsigned int amount, enum ast_aoc_currency_multiplier mult)
struct ast_module::@278 entry
#define AST_AOC_ENCODED_REQUEST_E
Asterisk main include file. File version handling, generic pbx functions.
int ast_aoc_set_termination_request(struct ast_aoc_decoded *decoded)
Mark the AST_AOC_REQUEST message as a termination request.
static int aoc_s_add_entry(struct ast_aoc_decoded *decoded, struct ast_aoc_s_entry *entry)
const ast_string_field uniqueid
String manipulation 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.
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_s_add_special_arrangement(struct ast_aoc_decoded *decoded, unsigned int code)
Add AOC-S special arrangement entry.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
#define AST_AOC_ENCODED_TYPE_E
static void aoc_e_event(const struct ast_aoc_decoded *decoded, struct ast_channel *chan, struct ast_str **msg)
#define AST_AOC_ENCODED_CHARGE_FREE
enum ast_aoc_currency_multiplier multiplier
static void aoc_request_event(const struct ast_aoc_decoded *decoded, struct ast_channel *chan, struct ast_str **msg)
static struct requests requests
static void aoc_s_event(const struct ast_aoc_decoded *decoded, struct ast_channel *owner, struct ast_str **msg)
struct ast_aoc_duration_rate duration
descriptor for a cli entry.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
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.
static void aoc_parse_ie_charging_rate(struct ast_aoc_decoded *decoded, const struct aoc_ie_charging_rate *ie)
#define AST_AOC_ENCODED_TYPE_D
#define AST_AOC_ENCODED_CHARGE_CURRENCY
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
static const char * aoc_billingid_str(enum ast_aoc_billing_id billing_id)
struct ast_aoc_charging_association_number number
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
AOC_IE
AOC Payload Information Elements.
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_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define AST_AOC_ENCODED_REQUEST_S
struct ast_str * ast_str_create(size_t init_len)
Create a malloc'ed dynamic length string.
uint8_t charging_type
Charging interval type.
static const char * aoc_type_of_totaling_str(enum ast_aoc_total_type value)
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.
static const char * aoc_charged_item_str(enum ast_aoc_s_charged_item value)
ast_aoc_currency_multiplier
Defines the currency multiplier for an aoc message.
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
static const char * aoc_volume_unit_str(enum ast_aoc_volume_unit value)
static const char * aoc_multiplier_str(enum ast_aoc_currency_multiplier mult)
enum ast_aoc_billing_id billing_id
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.
void ast_cli(int fd, const char *fmt,...)
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
#define ast_verb(level,...)
#define ast_manager_event(chan, category, event, contents,...)
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
unsigned int ast_aoc_s_get_count(struct ast_aoc_decoded *decoded)
get the number rates associated with an AOC-S message
enum ast_aoc_total_type total_type
static void aoc_display_decoded_debug(const struct ast_aoc_decoded *decoded, int decoding, struct ast_channel *chan)
static struct ast_cli_entry aoc_cli[]
static char * aoc_cli_debug_enable(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
#define AST_AOC_ENCODED_CHARGE_UNIT
Generic Advice of Charge encode and decode routines.
static const char * aoc_rate_type_str(enum ast_aoc_s_rate_type value)
struct ast_aoc_decoded * ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan)
decodes an encoded aoc payload.
struct ast_aoc_charging_association * ast_aoc_get_association_info(struct ast_aoc_decoded *decoded)
get the charging association info for AOC-E messages
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.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
struct ast_aoc_charging_association charging_association
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
int ast_register_atexit(void(*func)(void))
Register a function to be executed before Asterisk exits.
struct ast_aoc_flat_rate flat
char currency_name[AOC_CURRENCY_NAME_SIZE]
#define AST_AOC_ENCODED_CHARGE_SUBTOTAL
int ast_aoc_cli_init(void)
enable aoc cli options
unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded)
get the currency amount for AOC-D and AOC-E messages
char currency_name[AOC_CURRENCY_NAME_SIZE]
The AMI - Asterisk Manager Interface - is a TCP protocol created to manage Asterisk with third-party ...
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_test_encode_decode_match(struct ast_aoc_decoded *decoded)
test aoc encode decode routines.
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
static char aoc_debug_enabled
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
struct ast_aoc_volume_rate volume
#define AST_AOC_ENCODED_TYPE_REQUEST
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_aoc_unit_entry unit_list[32]
const ast_string_field name
unsigned int currency_amount
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
int ast_aoc_get_termination_request(struct ast_aoc_decoded *decoded)
get whether or not the AST_AOC_REQUEST message as a termination request.
#define AST_AOC_ENCODED_REQUEST_D
uint32_t granularity_time
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
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.
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
Prototypes for public functions only of internal interest,.
static const char * aoc_scale_str(enum ast_aoc_time_scale value)
char currency_name[AOC_CURRENCY_NAME_SIZE]
const char * ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded)
get the currency name for AOC-D and AOC-E messages
static void aoc_time_str(struct ast_str **msg, const char *prefix, const char *name, unsigned long time, enum ast_aoc_time_scale scale)
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
union ast_aoc_charging_association::@142 charge
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
enum ast_aoc_type msg_type
static void aoc_d_event(const struct ast_aoc_decoded *decoded, struct ast_channel *chan, struct ast_str **msg)
Standard Command Line Interface.
struct ast_aoc_charging_association ca
#define AST_AOC_ENCODE_VERSION
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
union ast_aoc_s_entry::@141 rate
Charge rate being applied.
int attribute_pure ast_false(const char *val)
Make sure something is false. Determine if a string containing a boolean value is "false"...
int ast_cli_register_multiple(struct ast_cli_entry *e, int len)
Register multiple commands.
#define AOC_CURRENCY_NAME_SIZE
ast_aoc_billing_id
Defines the billing id options for an aoc message.
#define AST_AOC_ENCODED_CHARGE_NA
struct ast_aoc_s_entry entry
#define ast_manager_event_multichan(category, event, nchans, chans, contents,...)
enum ast_aoc_request request_flag
char name[AOC_CURRENCY_NAME_SIZE]
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
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
struct ast_aoc_s_entry aoc_s_entries[10]
static void aoc_create_ie_data(struct ast_aoc_decoded *decoded, struct aoc_ie_data *ied)
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
struct ast_aoc_unit_entry * ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number)
get a specific unit entry.
static int aoc_append_ie(struct aoc_ie_data *ied, unsigned short ie_id, const void *data, unsigned short datalen)
static const char * aoc_charge_type_str(enum ast_aoc_charge_type value)
#define AST_AOC_ENCODED_TYPE_S
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
enum ast_aoc_charge_type charge_type
static int aoc_parse_ie(struct ast_aoc_decoded *decoded, unsigned char *data, unsigned int datalen)
uint16_t granularity_time_scale
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
static char prefix[MAX_PREFIX]
char currency_name[AOC_CURRENCY_NAME_SIZE]
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.