Asterisk - The Open Source Telephony Project
21.4.1
|
Generic Advice of Charge encode and decode routines. More...
#include "asterisk/channel.h"
Go to the source code of this file.
Data Structures | |
struct | ast_aoc_charging_association |
struct | ast_aoc_charging_association_number |
struct | ast_aoc_duration_rate |
struct | ast_aoc_flat_rate |
struct | ast_aoc_s_entry |
struct | ast_aoc_time |
struct | ast_aoc_unit_entry |
struct | ast_aoc_volume_rate |
Macros | |
#define | AOC_CURRENCY_NAME_SIZE (10 + 1) |
Enumerations | |
enum | ast_aoc_billing_id { AST_AOC_BILLING_NA = 0, AST_AOC_BILLING_NORMAL, AST_AOC_BILLING_REVERSE_CHARGE, AST_AOC_BILLING_CREDIT_CARD, AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL, AST_AOC_BILLING_CALL_FWD_BUSY, AST_AOC_BILLING_CALL_FWD_NO_REPLY, AST_AOC_BILLING_CALL_DEFLECTION, AST_AOC_BILLING_CALL_TRANSFER, AST_AOC_BILLING_NUM_ENTRIES } |
Defines the billing id options for an aoc message. More... | |
enum | ast_aoc_charge_type { AST_AOC_CHARGE_NA = 0, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_UNIT } |
enum | AST_AOC_CHARGING_ASSOCIATION { AST_AOC_CHARGING_ASSOCIATION_NA, AST_AOC_CHARGING_ASSOCIATION_NUMBER, AST_AOC_CHARGING_ASSOCIATION_ID } |
enum | ast_aoc_currency_multiplier { AST_AOC_MULT_ONETHOUSANDTH = 1, AST_AOC_MULT_ONEHUNDREDTH, AST_AOC_MULT_ONETENTH, AST_AOC_MULT_ONE, AST_AOC_MULT_TEN, AST_AOC_MULT_HUNDRED, AST_AOC_MULT_THOUSAND, AST_AOC_MULT_NUM_ENTRIES } |
Defines the currency multiplier for an aoc message. | |
enum | ast_aoc_request { AST_AOC_REQUEST_S = (1 << 0), AST_AOC_REQUEST_D = (1 << 1), AST_AOC_REQUEST_E = (1 << 2) } |
enum | ast_aoc_s_charged_item { AST_AOC_CHARGED_ITEM_NA, AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION, AST_AOC_CHARGED_ITEM_CALL_ATTEMPT, AST_AOC_CHARGED_ITEM_CALL_SETUP, AST_AOC_CHARGED_ITEM_USER_USER_INFO, AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE } |
enum | ast_aoc_s_rate_type { AST_AOC_RATE_TYPE_NA, AST_AOC_RATE_TYPE_FREE, AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING, AST_AOC_RATE_TYPE_DURATION, AST_AOC_RATE_TYPE_FLAT, AST_AOC_RATE_TYPE_VOLUME, AST_AOC_RATE_TYPE_SPECIAL_CODE } |
enum | ast_aoc_time_scale { AST_AOC_TIME_SCALE_HUNDREDTH_SECOND, AST_AOC_TIME_SCALE_TENTH_SECOND, AST_AOC_TIME_SCALE_SECOND, AST_AOC_TIME_SCALE_TEN_SECOND, AST_AOC_TIME_SCALE_MINUTE, AST_AOC_TIME_SCALE_HOUR, AST_AOC_TIME_SCALE_DAY } |
enum | ast_aoc_total_type { AST_AOC_TOTAL = 0, AST_AOC_SUBTOTAL = 1 } |
enum | ast_aoc_type { AST_AOC_REQUEST = 0, AST_AOC_S, AST_AOC_D, AST_AOC_E } |
enum | ast_aoc_volume_unit { AST_AOC_VOLUME_UNIT_OCTET, AST_AOC_VOLUME_UNIT_SEGMENT, AST_AOC_VOLUME_UNIT_MESSAGE } |
Functions | |
int | ast_aoc_add_unit_entry (struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type) |
Adds a unit entry into the list of units. More... | |
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 More... | |
struct ast_aoc_decoded * | ast_aoc_decode (struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan) |
decodes an encoded aoc payload. More... | |
int | ast_aoc_decoded2str (const struct ast_aoc_decoded *decoded, struct ast_str **msg) |
Convert decoded aoc msg to string representation. More... | |
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 More... | |
const struct ast_aoc_charging_association * | ast_aoc_get_association_info (struct ast_aoc_decoded *decoded) |
get the charging association info for AOC-E messages | |
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. More... | |
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 | |
const struct ast_aoc_unit_entry * | ast_aoc_get_unit_info (struct ast_aoc_decoded *decoded, unsigned int entry_number) |
get a specific unit entry. More... | |
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 More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
int | ast_aoc_s_add_special_arrangement (struct ast_aoc_decoded *decoded, unsigned int code) |
Add AOC-S special arrangement entry. More... | |
unsigned int | ast_aoc_s_get_count (struct ast_aoc_decoded *decoded) |
get the number rates associated with an AOC-S message | |
const 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. More... | |
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 More... | |
int | ast_aoc_set_association_number (struct ast_aoc_decoded *decoded, const char *num, uint8_t plan) |
set the charging association number for an AOC-E message More... | |
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 More... | |
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. More... | |
int | ast_aoc_set_termination_request (struct ast_aoc_decoded *decoded) |
Mark the AST_AOC_REQUEST message as a termination request. More... | |
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. More... | |
int | ast_aoc_test_encode_decode_match (struct ast_aoc_decoded *decoded) |
test aoc encode decode routines. More... | |
Generic Advice of Charge encode and decode routines.
Definition in file aoc.h.
enum ast_aoc_billing_id |
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 977 of file aoc.c.
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
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 276 of file aoc.c.
References ast_calloc.
struct ast_aoc_decoded* ast_aoc_decode | ( | struct ast_aoc_encoded * | encoded, |
size_t | size, | ||
struct ast_channel * | chan | ||
) |
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 449 of file aoc.c.
References ast_calloc.
Referenced by ast_aoc_test_encode_decode_match(), and wait_for_answer().
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 1954 of file aoc.c.
References ast_str_append().
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
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 650 of file aoc.c.
References ast_calloc.
Referenced by ast_aoc_test_encode_decode_match(), and wait_for_answer().
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 |
const struct ast_aoc_unit_entry* ast_aoc_get_unit_info | ( | struct ast_aoc_decoded * | decoded, |
unsigned int | 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 1922 of file aoc.c.
References ast_json_unref().
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 770 of file aoc.c.
References ast_copy_string(), ast_aoc_duration_rate::charging_type, ast_aoc_duration_rate::currency_name, ast_aoc_duration_rate::granularity_time, and ast_aoc_s_entry::rate.
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 801 of file aoc.c.
References ast_copy_string(), ast_aoc_flat_rate::currency_name, and ast_aoc_s_entry::rate.
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 857 of file aoc.c.
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 869 of file aoc.c.
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 844 of file aoc.c.
References ast_aoc_s_entry::rate.
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 822 of file aoc.c.
References ast_copy_string(), and ast_aoc_s_entry::rate.
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 880 of file aoc.c.
References ast_aoc_s_entry::rate.
const struct ast_aoc_s_entry* ast_aoc_s_get_rate_info | ( | struct ast_aoc_decoded * | decoded, |
unsigned int | 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 1040 of file aoc.c.
References ast_aoc_charging_association::charging_type.
int ast_aoc_set_association_number | ( | struct ast_aoc_decoded * | decoded, |
const char * | num, | ||
uint8_t | plan | ||
) |
set the charging association number for an AOC-E message
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 1056 of file aoc.c.
References ast_copy_string(), and ast_aoc_charging_association::charging_type.
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 |
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 919 of file aoc.c.
References ast_copy_string().
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 |
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 |
int ast_aoc_test_encode_decode_match | ( | struct ast_aoc_decoded * | decoded | ) |
test aoc encode decode routines.
Definition at line 1330 of file aoc.c.
References ast_aoc_decode(), ast_aoc_destroy_decoded(), ast_aoc_destroy_encoded(), and ast_aoc_encode().