Asterisk - The Open Source Telephony Project GIT-master-f36a736
Data Structures | Macros | Enumerations | Functions
aoc.h File Reference

Generic Advice of Charge encode and decode routines. More...

#include "asterisk/channel.h"
Include dependency graph for aoc.h:
This graph shows which files directly or indirectly include this file:

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. More...
 
enum  ast_aoc_request { AST_AOC_REQUEST_S = (1 << 0) , AST_AOC_REQUEST_D = (1 << 1) , AST_AOC_REQUEST_E = (1 << 2) }
 
enum  ast_aoc_s_charged_item {
  AST_AOC_CHARGED_ITEM_NA , AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT , AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION , AST_AOC_CHARGED_ITEM_CALL_ATTEMPT ,
  AST_AOC_CHARGED_ITEM_CALL_SETUP , AST_AOC_CHARGED_ITEM_USER_USER_INFO , AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE
}
 
enum  ast_aoc_s_rate_type {
  AST_AOC_RATE_TYPE_NA , AST_AOC_RATE_TYPE_FREE , AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING , AST_AOC_RATE_TYPE_DURATION ,
  AST_AOC_RATE_TYPE_FLAT , AST_AOC_RATE_TYPE_VOLUME , AST_AOC_RATE_TYPE_SPECIAL_CODE
}
 
enum  ast_aoc_time_scale {
  AST_AOC_TIME_SCALE_HUNDREDTH_SECOND , AST_AOC_TIME_SCALE_TENTH_SECOND , AST_AOC_TIME_SCALE_SECOND , AST_AOC_TIME_SCALE_TEN_SECOND ,
  AST_AOC_TIME_SCALE_MINUTE , AST_AOC_TIME_SCALE_HOUR , AST_AOC_TIME_SCALE_DAY
}
 
enum  ast_aoc_total_type { AST_AOC_TOTAL = 0 , AST_AOC_SUBTOTAL = 1 }
 
enum  ast_aoc_type { AST_AOC_REQUEST = 0 , AST_AOC_S , AST_AOC_D , AST_AOC_E }
 
enum  ast_aoc_volume_unit { AST_AOC_VOLUME_UNIT_OCTET , AST_AOC_VOLUME_UNIT_SEGMENT , AST_AOC_VOLUME_UNIT_MESSAGE }
 

Functions

int ast_aoc_add_unit_entry (struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type)
 Adds a unit entry into the list of units. More...
 
int ast_aoc_cli_init (void)
 enable aoc cli options More...
 
struct ast_aoc_decodedast_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_decodedast_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 More...
 
void * ast_aoc_destroy_encoded (struct ast_aoc_encoded *encoded)
 free an ast_aoc_encoded object More...
 
struct ast_aoc_encodedast_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_associationast_aoc_get_association_info (struct ast_aoc_decoded *decoded)
 get the charging association info for AOC-E messages More...
 
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 More...
 
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 More...
 
unsigned int ast_aoc_get_currency_amount (struct ast_aoc_decoded *decoded)
 get the currency amount for AOC-D and AOC-E messages More...
 
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 More...
 
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 More...
 
const char * ast_aoc_get_currency_name (struct ast_aoc_decoded *decoded)
 get the currency name for AOC-D and AOC-E messages More...
 
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 More...
 
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 More...
 
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 More...
 
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 More...
 
const struct ast_aoc_unit_entryast_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 More...
 
const struct ast_aoc_s_entryast_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...
 

Detailed Description

Generic Advice of Charge encode and decode routines.

Author
David Vossel dvoss.nosp@m.el@d.nosp@m.igium.nosp@m..com

Definition in file aoc.h.

Macro Definition Documentation

◆ AOC_CURRENCY_NAME_SIZE

#define AOC_CURRENCY_NAME_SIZE   (10 + 1)

Definition at line 31 of file aoc.h.

Enumeration Type Documentation

◆ ast_aoc_billing_id

Defines the billing id options for an aoc message.

Note
AOC-D is limited to NORMAL, REVERSE_CHARGE, and CREDIT_CARD.
Enumerator
AST_AOC_BILLING_NA 
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 

Definition at line 49 of file aoc.h.

49 {
59 AST_AOC_BILLING_NUM_ENTRIES /* must remain the last item in enum, not a valid billing id */
60};
@ AST_AOC_BILLING_NUM_ENTRIES
Definition: aoc.h:59
@ AST_AOC_BILLING_CALL_FWD_BUSY
Definition: aoc.h:55
@ AST_AOC_BILLING_CALL_FWD_NO_REPLY
Definition: aoc.h:56
@ AST_AOC_BILLING_NORMAL
Definition: aoc.h:51
@ AST_AOC_BILLING_CALL_DEFLECTION
Definition: aoc.h:57
@ AST_AOC_BILLING_CREDIT_CARD
Definition: aoc.h:53
@ AST_AOC_BILLING_CALL_TRANSFER
Definition: aoc.h:58
@ AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL
Definition: aoc.h:54
@ AST_AOC_BILLING_REVERSE_CHARGE
Definition: aoc.h:52
@ AST_AOC_BILLING_NA
Definition: aoc.h:50

◆ ast_aoc_charge_type

Enumerator
AST_AOC_CHARGE_NA 
AST_AOC_CHARGE_FREE 
AST_AOC_CHARGE_CURRENCY 
AST_AOC_CHARGE_UNIT 

Definition at line 69 of file aoc.h.

69 {
73 AST_AOC_CHARGE_UNIT, /* unit must remain the last item in enum */
74};
@ AST_AOC_CHARGE_CURRENCY
Definition: aoc.h:72
@ AST_AOC_CHARGE_FREE
Definition: aoc.h:71
@ AST_AOC_CHARGE_UNIT
Definition: aoc.h:73
@ AST_AOC_CHARGE_NA
Definition: aoc.h:70

◆ AST_AOC_CHARGING_ASSOCIATION

Enumerator
AST_AOC_CHARGING_ASSOCIATION_NA 
AST_AOC_CHARGING_ASSOCIATION_NUMBER 
AST_AOC_CHARGING_ASSOCIATION_ID 

Definition at line 185 of file aoc.h.

185 {
189};
@ AST_AOC_CHARGING_ASSOCIATION_NA
Definition: aoc.h:186
@ AST_AOC_CHARGING_ASSOCIATION_ID
Definition: aoc.h:188
@ AST_AOC_CHARGING_ASSOCIATION_NUMBER
Definition: aoc.h:187

◆ ast_aoc_currency_multiplier

Defines the currency multiplier for an aoc message.

Enumerator
AST_AOC_MULT_ONETHOUSANDTH 
AST_AOC_MULT_ONEHUNDREDTH 
AST_AOC_MULT_ONETENTH 
AST_AOC_MULT_ONE 
AST_AOC_MULT_TEN 
AST_AOC_MULT_HUNDRED 
AST_AOC_MULT_THOUSAND 
AST_AOC_MULT_NUM_ENTRIES 

Definition at line 34 of file aoc.h.

34 {
42 AST_AOC_MULT_NUM_ENTRIES, /* must remain the last item in enum, this is not a valid type */
43};
@ AST_AOC_MULT_TEN
Definition: aoc.h:39
@ AST_AOC_MULT_ONEHUNDREDTH
Definition: aoc.h:36
@ AST_AOC_MULT_HUNDRED
Definition: aoc.h:40
@ AST_AOC_MULT_NUM_ENTRIES
Definition: aoc.h:42
@ AST_AOC_MULT_ONETENTH
Definition: aoc.h:37
@ AST_AOC_MULT_ONETHOUSANDTH
Definition: aoc.h:35
@ AST_AOC_MULT_THOUSAND
Definition: aoc.h:41
@ AST_AOC_MULT_ONE
Definition: aoc.h:38

◆ ast_aoc_request

Enumerator
AST_AOC_REQUEST_S 
AST_AOC_REQUEST_D 
AST_AOC_REQUEST_E 

Definition at line 76 of file aoc.h.

76 {
77 AST_AOC_REQUEST_S = (1 << 0),
78 AST_AOC_REQUEST_D = (1 << 1),
79 AST_AOC_REQUEST_E = (1 << 2),
80};
@ AST_AOC_REQUEST_E
Definition: aoc.h:79
@ AST_AOC_REQUEST_D
Definition: aoc.h:78
@ AST_AOC_REQUEST_S
Definition: aoc.h:77

◆ ast_aoc_s_charged_item

Enumerator
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 

Definition at line 145 of file aoc.h.

145 {
153};
@ AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION
Definition: aoc.h:148
@ AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT
Definition: aoc.h:147
@ AST_AOC_CHARGED_ITEM_NA
Definition: aoc.h:146
@ AST_AOC_CHARGED_ITEM_USER_USER_INFO
Definition: aoc.h:151
@ AST_AOC_CHARGED_ITEM_CALL_SETUP
Definition: aoc.h:150
@ AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE
Definition: aoc.h:152
@ AST_AOC_CHARGED_ITEM_CALL_ATTEMPT
Definition: aoc.h:149

◆ ast_aoc_s_rate_type

Enumerator
AST_AOC_RATE_TYPE_NA 
AST_AOC_RATE_TYPE_FREE 
AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING 
AST_AOC_RATE_TYPE_DURATION 
AST_AOC_RATE_TYPE_FLAT 
AST_AOC_RATE_TYPE_VOLUME 
AST_AOC_RATE_TYPE_SPECIAL_CODE 

Definition at line 155 of file aoc.h.

155 {
163};
@ AST_AOC_RATE_TYPE_VOLUME
Definition: aoc.h:161
@ AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING
Definition: aoc.h:158
@ AST_AOC_RATE_TYPE_SPECIAL_CODE
Definition: aoc.h:162
@ AST_AOC_RATE_TYPE_NA
Definition: aoc.h:156
@ AST_AOC_RATE_TYPE_DURATION
Definition: aoc.h:159
@ AST_AOC_RATE_TYPE_FLAT
Definition: aoc.h:160
@ AST_AOC_RATE_TYPE_FREE
Definition: aoc.h:157

◆ ast_aoc_time_scale

Enumerator
AST_AOC_TIME_SCALE_HUNDREDTH_SECOND 
AST_AOC_TIME_SCALE_TENTH_SECOND 
AST_AOC_TIME_SCALE_SECOND 
AST_AOC_TIME_SCALE_TEN_SECOND 
AST_AOC_TIME_SCALE_MINUTE 
AST_AOC_TIME_SCALE_HOUR 
AST_AOC_TIME_SCALE_DAY 

Definition at line 87 of file aoc.h.

87 {
95};
@ AST_AOC_TIME_SCALE_TEN_SECOND
Definition: aoc.h:91
@ AST_AOC_TIME_SCALE_DAY
Definition: aoc.h:94
@ AST_AOC_TIME_SCALE_TENTH_SECOND
Definition: aoc.h:89
@ AST_AOC_TIME_SCALE_MINUTE
Definition: aoc.h:92
@ AST_AOC_TIME_SCALE_SECOND
Definition: aoc.h:90
@ AST_AOC_TIME_SCALE_HOUR
Definition: aoc.h:93
@ AST_AOC_TIME_SCALE_HUNDREDTH_SECOND
Definition: aoc.h:88

◆ ast_aoc_total_type

Enumerator
AST_AOC_TOTAL 
AST_AOC_SUBTOTAL 

Definition at line 82 of file aoc.h.

82 {
83 AST_AOC_TOTAL = 0,
85};
@ AST_AOC_TOTAL
Definition: aoc.h:83
@ AST_AOC_SUBTOTAL
Definition: aoc.h:84

◆ ast_aoc_type

Enumerator
AST_AOC_REQUEST 
AST_AOC_S 
AST_AOC_D 
AST_AOC_E 

Definition at line 62 of file aoc.h.

62 {
66 AST_AOC_E, /* aoc-e must remain the last item in this enum */
67};
@ AST_AOC_S
Definition: aoc.h:64
@ AST_AOC_D
Definition: aoc.h:65
@ AST_AOC_E
Definition: aoc.h:66
@ AST_AOC_REQUEST
Definition: aoc.h:63

◆ ast_aoc_volume_unit

Enumerator
AST_AOC_VOLUME_UNIT_OCTET 
AST_AOC_VOLUME_UNIT_SEGMENT 
AST_AOC_VOLUME_UNIT_MESSAGE 

Definition at line 125 of file aoc.h.

125 {
129};
@ AST_AOC_VOLUME_UNIT_OCTET
Definition: aoc.h:126
@ AST_AOC_VOLUME_UNIT_SEGMENT
Definition: aoc.h:127
@ AST_AOC_VOLUME_UNIT_MESSAGE
Definition: aoc.h:128

Function Documentation

◆ ast_aoc_add_unit_entry()

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.

Since
1.8
Parameters
decodedast_aoc_decoded struct to set values on
amount_is_presentset this if the number of units is actually present.
amountnumber of units
type_is_presentset this if the type value is present
typeunit type
Note
If neither the amount nor the type is present, the entry will not be added.
Return values
0success

Definition at line 977 of file aoc.c.

982{
983 if ((decoded->msg_type == AST_AOC_REQUEST) ||
984 (decoded->unit_count >= ARRAY_LEN(decoded->unit_list))) {
985 return -1;
986 }
987
988 if (!amount_is_present && !type_is_present) {
989 return -1;
990 }
991
992 decoded->unit_list[decoded->unit_count].valid_amount = amount_is_present;
993 if (amount_is_present) {
994 decoded->unit_list[decoded->unit_count].amount = amount;
995 } else {
996 decoded->unit_list[decoded->unit_count].amount = 0;
997 }
998
999 decoded->unit_list[decoded->unit_count].valid_type = type_is_present;
1000 if (type_is_present) {
1001 decoded->unit_list[decoded->unit_count].type = type;
1002 } else {
1003 decoded->unit_list[decoded->unit_count].type = 0;
1004 }
1005 decoded->unit_count++;
1006
1007 return 0;
1008}
static const char type[]
Definition: chan_ooh323.c:109
struct ast_aoc_unit_entry unit_list[32]
Definition: aoc.c:218
int unit_count
Definition: aoc.c:217
enum ast_aoc_type msg_type
Definition: aoc.c:206
unsigned int amount
Definition: aoc.h:180
unsigned int type
Definition: aoc.h:182
char valid_type
Definition: aoc.h:181
char valid_amount
Definition: aoc.h:179
#define ARRAY_LEN(a)
Definition: utils.h:666

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_aoc_de_message(), aoc_parse_ie(), and AST_TEST_DEFINE().

◆ ast_aoc_cli_init()

int ast_aoc_cli_init ( void  )

enable aoc cli options

Definition at line 2020 of file aoc.c.

2021{
2025
2028}
struct stasis_message_type * aoc_s_type(void)
static void aoc_shutdown(void)
Definition: aoc.c:2012
static struct ast_cli_entry aoc_cli[]
Definition: aoc.c:2008
struct stasis_message_type * aoc_d_type(void)
struct stasis_message_type * aoc_e_type(void)
int ast_register_cleanup(void(*func)(void))
Register a function to be executed before Asterisk gracefully exits.
Definition: clicompat.c:19
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define STASIS_MESSAGE_TYPE_INIT(name)
Boiler-plate messaging macro for initializing message types.
Definition: stasis.h:1493

References aoc_cli, aoc_d_type(), aoc_e_type(), aoc_s_type(), aoc_shutdown(), ARRAY_LEN, ast_cli_register_multiple, ast_register_cleanup(), and STASIS_MESSAGE_TYPE_INIT.

Referenced by asterisk_daemon().

◆ ast_aoc_create()

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

Since
1.8
Parameters
msg_typeAOC-D, AOC-E, or AOC Request
charge_typethis is ignored if message type is not AOC-D or AOC-E.
requestsflags. 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.
Return values
heapallocated ast_aoc_decoded object ptr on success
NULLfailure

Definition at line 276 of file aoc.c.

279{
280 struct ast_aoc_decoded *decoded = NULL;
281
282 /* verify input */
283 if (((unsigned int) charge_type > AST_AOC_CHARGE_UNIT) ||
284 ((unsigned int) msg_type > AST_AOC_E) ||
285 ((msg_type == AST_AOC_REQUEST) && !requests)) {
286
287 ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object, invalid input\n");
288 return NULL;
289 }
290
291 if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
292 ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
293 return NULL;
294 }
295
296 decoded->msg_type = msg_type;
297
298 if (msg_type == AST_AOC_REQUEST) {
299 decoded->request_flag = requests;
300 } else if ((msg_type == AST_AOC_D) || (msg_type == AST_AOC_E)) {
301 decoded->charge_type = charge_type;
302 }
303
304 return decoded;
305}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define ast_log
Definition: astobj2.c:42
#define LOG_WARNING
static struct requests requests
#define NULL
Definition: resample.c:96
enum ast_aoc_request request_flag
Definition: aoc.c:208
enum ast_aoc_charge_type charge_type
Definition: aoc.c:207

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, NULL, ast_aoc_decoded::request_flag, and requests.

Referenced by action_aoc_de_message(), action_aoc_s_message(), and AST_TEST_DEFINE().

◆ ast_aoc_decode()

struct ast_aoc_decoded * ast_aoc_decode ( struct ast_aoc_encoded encoded,
size_t  size,
struct ast_channel chan 
)

decodes an encoded aoc payload.

Since
1.8
Parameters
encodedthe encoded payload to decode.
sizetotal size of encoded payload
chanast channel, Optional for DEBUG output purposes
Return values
heapallocated ast_aoc_decoded object ptr on success
NULLfailure

Definition at line 449 of file aoc.c.

450{
451 struct ast_aoc_decoded *decoded;
452
453 /* verify our encoded payload is actually large enough to hold all the ies */
454 if ((size - (sizeof(struct ast_aoc_encoded)) != ntohs(encoded->datalen))) {
455 ast_log(LOG_WARNING, "Corrupted aoc encoded object, can not decode\n");
456 return NULL;
457 }
458
459 if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
460 ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
461 return NULL;
462 }
463
464 /* decode flags */
465
467 decoded->msg_type = AST_AOC_S;
468 } else if (encoded->flags & AST_AOC_ENCODED_TYPE_E) {
469 decoded->msg_type = AST_AOC_E;
470 } else if (encoded->flags & AST_AOC_ENCODED_TYPE_D) {
471 decoded->msg_type = AST_AOC_D;
472 } else {
473 decoded->msg_type = AST_AOC_REQUEST;
474 }
475
476 if (decoded->msg_type == AST_AOC_REQUEST) {
477 if (encoded->flags & AST_AOC_ENCODED_REQUEST_S) {
479 }
480 if (encoded->flags & AST_AOC_ENCODED_REQUEST_D) {
482 }
483 if (encoded->flags & AST_AOC_ENCODED_REQUEST_E) {
485 }
486 } else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) {
493 } else {
495 }
496
497 if (encoded->flags & AST_AOC_ENCODED_CHARGE_SUBTOTAL) {
498 decoded->total_type = AST_AOC_SUBTOTAL;
499 }
500 }
501
502 /* decode information elements */
503 aoc_parse_ie(decoded, encoded->data, ntohs(encoded->datalen));
504
505 if (aoc_debug_enabled) {
506 aoc_display_decoded_debug(decoded, 1, chan);
507 }
508
509 return decoded;
510}
#define AST_AOC_ENCODED_CHARGE_UNIT
Definition: aoc.c:184
static int aoc_parse_ie(struct ast_aoc_decoded *decoded, unsigned char *data, unsigned int datalen)
Definition: aoc.c:369
#define AST_AOC_ENCODED_TYPE_D
Definition: aoc.c:173
#define AST_AOC_ENCODED_CHARGE_CURRENCY
Definition: aoc.c:183
#define AST_AOC_ENCODED_REQUEST_E
Definition: aoc.c:179
#define AST_AOC_ENCODED_REQUEST_D
Definition: aoc.c:178
static char aoc_debug_enabled
Definition: aoc.c:192
static void aoc_display_decoded_debug(const struct ast_aoc_decoded *decoded, int decoding, struct ast_channel *chan)
Definition: aoc.c:1982
#define AST_AOC_ENCODED_TYPE_S
Definition: aoc.c:175
#define AST_AOC_ENCODED_CHARGE_SUBTOTAL
Definition: aoc.c:186
#define AST_AOC_ENCODED_CHARGE_FREE
Definition: aoc.c:182
#define AST_AOC_ENCODED_REQUEST_S
Definition: aoc.c:177
#define AST_AOC_ENCODED_TYPE_E
Definition: aoc.c:174
enum ast_aoc_total_type total_type
Definition: aoc.c:209
uint16_t datalen
Definition: aoc.c:200
uint8_t flags
Definition: aoc.c:199
unsigned char data[0]
Definition: aoc.c:201

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, NULL, ast_aoc_decoded::request_flag, and ast_aoc_decoded::total_type.

Referenced by aoc_framehook(), ast_aoc_test_encode_decode_match(), and wait_for_answer().

◆ ast_aoc_decoded2str()

int ast_aoc_decoded2str ( const struct ast_aoc_decoded decoded,
struct ast_str **  msg 
)

Convert decoded aoc msg to string representation.

Since
1.8
Parameters
decodedast_aoc_decoded struct to convert to string
msgdynamic heap allocated ast_str object to store string representation in
Return values
0success
-1failure

Definition at line 1954 of file aoc.c.

1955{
1956 if (!decoded || !msg) {
1957 return -1;
1958 }
1959
1960 switch (decoded->msg_type) {
1961 case AST_AOC_S:
1962 ast_str_append(msg, 0, "AOC-S\r\n");
1963 aoc_s_event(decoded, msg);
1964 break;
1965 case AST_AOC_D:
1966 ast_str_append(msg, 0, "AOC-D\r\n");
1967 aoc_d_event(decoded, msg);
1968 break;
1969 case AST_AOC_E:
1970 ast_str_append(msg, 0, "AOC-E\r\n");
1971 aoc_e_event(decoded, msg);
1972 break;
1973 case AST_AOC_REQUEST:
1974 ast_str_append(msg, 0, "AOC-Request\r\n");
1975 aoc_request_event(decoded, msg);
1976 break;
1977 }
1978
1979 return 0;
1980}
static void aoc_e_event(const struct ast_aoc_decoded *decoded, struct ast_str **msg)
Definition: aoc.c:1556
static void aoc_request_event(const struct ast_aoc_decoded *decoded, struct ast_str **msg)
Definition: aoc.c:1419
static void aoc_s_event(const struct ast_aoc_decoded *decoded, struct ast_str **msg)
Definition: aoc.c:1439
static void aoc_d_event(const struct ast_aoc_decoded *decoded, struct ast_str **msg)
Definition: aoc.c:1507
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139

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(), and AST_TEST_DEFINE().

◆ ast_aoc_destroy_decoded()

void * ast_aoc_destroy_decoded ( struct ast_aoc_decoded decoded)

free an ast_aoc_decoded object

Definition at line 307 of file aoc.c.

308{
309 ast_free(decoded);
310 return NULL;
311}
#define ast_free(a)
Definition: astmm.h:180

References ast_free, and NULL.

Referenced by action_aoc_de_message(), action_aoc_s_message(), action_aocmessage(), aoc_data_destroy(), ast_aoc_test_encode_decode_match(), AST_TEST_DEFINE(), chanlist_free(), hangupcalls(), and wait_for_answer().

◆ ast_aoc_destroy_encoded()

void * ast_aoc_destroy_encoded ( struct ast_aoc_encoded encoded)

free an ast_aoc_encoded object

Definition at line 313 of file aoc.c.

314{
315 ast_free(encoded);
316 return NULL;
317}

References ast_free, and NULL.

Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), and wait_for_answer().

◆ ast_aoc_encode()

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

Since
1.8
Parameters
decodedthe decoded struct to be encoded
out_sizeoutput parameter representing size of encoded data
chanast channel, Optional for DEBUG output purposes
Return values
pointerto encoded data
NULLfailure

Definition at line 650 of file aoc.c.

651{
652 struct aoc_ie_data ied;
653 struct ast_aoc_encoded *encoded = NULL;
654 size_t size = 0;
655
656 if (!decoded || !out_size) {
657 return NULL;
658 }
659
660 *out_size = 0;
661
662 /* create information element buffer before allocating the payload,
663 * by doing this the exact size of the payload + the id data can be
664 * allocated all at once. */
665 aoc_create_ie_data(decoded, &ied);
666
667 size = sizeof(struct ast_aoc_encoded) + ied.pos;
668
669 if (!(encoded = ast_calloc(1, size))) {
670 ast_log(LOG_WARNING, "Failed to create ast_aoc_encoded object during decode routine. \n");
671 return NULL;
672 }
673
674 /* -- Set ie data buffer */
675 if (ied.pos) {
676 /* this is safe because encoded was allocated to fit this perfectly */
677 memcpy(encoded->data, ied.buf, ied.pos);
678 encoded->datalen = htons(ied.pos);
679 }
680
681 /* --- Set Flags --- */
682 switch (decoded->msg_type) {
683 case AST_AOC_S:
684 encoded->flags = AST_AOC_ENCODED_TYPE_S;
685 break;
686 case AST_AOC_D:
687 encoded->flags = AST_AOC_ENCODED_TYPE_D;
688 break;
689 case AST_AOC_E:
690 encoded->flags = AST_AOC_ENCODED_TYPE_E;
691 break;
692 case AST_AOC_REQUEST:
694 default:
695 break;
696 }
697
698 /* if it is type request, set the types requested, else set charge type */
699 if (decoded->msg_type == AST_AOC_REQUEST) {
700 if (decoded->request_flag & AST_AOC_REQUEST_S) {
702 }
703 if (decoded->request_flag & AST_AOC_REQUEST_D) {
705 }
706 if (decoded->request_flag & AST_AOC_REQUEST_E) {
708 }
709 } else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) {
710 switch (decoded->charge_type) {
713 break;
716 break;
720 default:
722 break;
723 }
724
725 if (decoded->total_type == AST_AOC_SUBTOTAL) {
727 }
728 }
729
730 /* --- Set Version Number --- */
732
733 /* set the output size */
734 *out_size = size;
735
736 if (aoc_debug_enabled) {
737 aoc_display_decoded_debug(decoded, 0, chan);
738 }
739
740 return encoded;
741}
#define AST_AOC_ENCODED_CHARGE_NA
Definition: aoc.c:181
#define AST_AOC_ENCODE_VERSION
Definition: aoc.c:189
#define AST_AOC_ENCODED_TYPE_REQUEST
Definition: aoc.c:172
static void aoc_create_ie_data(struct ast_aoc_decoded *decoded, struct aoc_ie_data *ied)
Definition: aoc.c:583
uint8_t version
Definition: aoc.c:198

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, aoc_ie_data::buf, ast_aoc_decoded::charge_type, ast_aoc_encoded::data, ast_aoc_encoded::datalen, ast_aoc_encoded::flags, LOG_WARNING, ast_aoc_decoded::msg_type, NULL, aoc_ie_data::pos, ast_aoc_decoded::request_flag, ast_aoc_decoded::total_type, and ast_aoc_encoded::version.

Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), and wait_for_answer().

◆ ast_aoc_get_association_info()

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

Definition at line 1051 of file aoc.c.

1052{
1053 return &decoded->charging_association;
1054}
struct ast_aoc_charging_association charging_association
Definition: aoc.c:224

References ast_aoc_decoded::charging_association.

Referenced by AST_TEST_DEFINE().

◆ ast_aoc_get_billing_id()

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 1035 of file aoc.c.

1036{
1037 return decoded->billing_id;
1038}
enum ast_aoc_billing_id billing_id
Definition: aoc.c:221

References ast_aoc_decoded::billing_id.

Referenced by AST_TEST_DEFINE().

◆ ast_aoc_get_charge_type()

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 897 of file aoc.c.

898{
899 return decoded->charge_type;
900}

References ast_aoc_decoded::charge_type.

Referenced by aoc_send_as_xml(), and AST_TEST_DEFINE().

◆ ast_aoc_get_currency_amount()

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 940 of file aoc.c.

941{
942 return decoded->currency_amount;
943}
unsigned int currency_amount
Definition: aoc.c:213

References ast_aoc_decoded::currency_amount.

Referenced by aoc_send_as_xml(), and AST_TEST_DEFINE().

◆ ast_aoc_get_currency_multiplier()

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 945 of file aoc.c.

946{
947 return decoded->multiplier;
948}
enum ast_aoc_currency_multiplier multiplier
Definition: aoc.c:212

References ast_aoc_decoded::multiplier.

Referenced by aoc_send_as_xml(), and AST_TEST_DEFINE().

◆ ast_aoc_get_currency_multiplier_decimal()

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 950 of file aoc.c.

951{
952 switch (decoded->multiplier) {
954 return "0.001";
956 return "0.01";
958 return "0.1";
959 case AST_AOC_MULT_ONE:
960 return "1.0";
961 case AST_AOC_MULT_TEN:
962 return "10.0";
964 return "100.0";
966 return "1000.0";
967 default:
968 return "1.0";
969 }
970}

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.

◆ ast_aoc_get_currency_name()

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 972 of file aoc.c.

973{
974 return decoded->currency_name;
975}
char currency_name[AOC_CURRENCY_NAME_SIZE]
Definition: aoc.c:214

References ast_aoc_decoded::currency_name.

Referenced by aoc_send_as_xml(), and AST_TEST_DEFINE().

◆ ast_aoc_get_msg_type()

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 892 of file aoc.c.

893{
894 return decoded->msg_type;
895}

References ast_aoc_decoded::msg_type.

Referenced by aoc_send_as_xml(), AST_TEST_DEFINE(), and wait_for_answer().

◆ ast_aoc_get_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

Definition at line 902 of file aoc.c.

903{
904 return decoded->request_flag;
905}

References ast_aoc_decoded::request_flag.

Referenced by AST_TEST_DEFINE().

◆ ast_aoc_get_termination_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.

Since
1.8
Note
a termination request indicates that the call has terminated, but that the other side is waiting for a short period of time before hanging up so it can get the final AOC-E message.
Parameters
decodedast_aoc_decoded struct to get values on
Return values
0not a termination request
1is a termination request

Definition at line 1079 of file aoc.c.

1080{
1081 return decoded->termination_request;
1082}
char termination_request
Definition: aoc.c:231

References ast_aoc_decoded::termination_request.

Referenced by AST_TEST_DEFINE().

◆ ast_aoc_get_total_type()

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 914 of file aoc.c.

915{
916 return decoded->total_type;
917}

References ast_aoc_decoded::total_type.

Referenced by aoc_send_as_xml(), and AST_TEST_DEFINE().

◆ ast_aoc_get_unit_count()

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 1019 of file aoc.c.

1020{
1021 return decoded->unit_count;
1022}

References ast_aoc_decoded::unit_count.

Referenced by AST_TEST_DEFINE().

◆ ast_aoc_get_unit_info()

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.

Since
1.8
Note
This can be used in conjunction with ast_aoc_get_unit_count to create a unit entry iterator.

Definition at line 1010 of file aoc.c.

1011{
1012 if (entry_number >= decoded->unit_count) {
1013 return NULL;
1014 }
1015
1016 return (const struct ast_aoc_unit_entry *) &decoded->unit_list[entry_number];
1017}
Definition: aoc.h:178

References NULL, ast_aoc_decoded::unit_count, and ast_aoc_decoded::unit_list.

Referenced by aoc_send_as_xml(), and AST_TEST_DEFINE().

◆ ast_aoc_manager_event()

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

Precondition
chan is locked

Definition at line 1922 of file aoc.c.

1923{
1924 struct ast_json *blob;
1925 struct stasis_message_type *msg_type;
1926
1927 if (!decoded) {
1928 return -1;
1929 }
1930
1931 switch (decoded->msg_type) {
1932 case AST_AOC_S:
1933 blob = s_to_json(decoded);
1934 msg_type = aoc_s_type();
1935 break;
1936 case AST_AOC_D:
1937 blob = d_to_json(decoded);
1938 msg_type = aoc_d_type();
1939 break;
1940 case AST_AOC_E:
1941 blob = e_to_json(decoded);
1942 msg_type = aoc_e_type();
1943 break;
1944 default:
1945 /* events for AST_AOC_REQUEST are not generated here */
1946 return 0;
1947 }
1948
1949 aoc_publish_blob(chan, msg_type, blob);
1950 ast_json_unref(blob);
1951 return 0;
1952}
static struct ast_json * s_to_json(const struct ast_aoc_decoded *decoded)
Definition: aoc.c:1702
static struct ast_json * d_to_json(const struct ast_aoc_decoded *decoded)
Definition: aoc.c:1793
static void aoc_publish_blob(struct ast_channel *chan, struct stasis_message_type *msg_type, struct ast_json *blob)
Definition: aoc.c:1829
static struct ast_json * e_to_json(const struct ast_aoc_decoded *decoded)
Definition: aoc.c:1798
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
Abstract JSON element (object, array, string, int, ...).

References aoc_d_type(), aoc_e_type(), aoc_publish_blob(), aoc_s_type(), AST_AOC_D, AST_AOC_E, AST_AOC_S, ast_json_unref(), d_to_json(), e_to_json(), ast_aoc_decoded::msg_type, and s_to_json().

◆ ast_aoc_s_add_rate_duration()

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.

Since
1.8
Parameters
decodedaoc decoded object to add entry to
charged_itemast_aoc_s_charged_item
amountcurrency amount
multipliercurrency multiplier
currency_nametruncated after 10 characters
time
time_scalefrom 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_functionset to 1 if this is to use a step function, 0 if continuious
Return values
0success
-1failure

Definition at line 770 of file aoc.c.

780{
781
782 struct ast_aoc_s_entry entry = { 0, };
783
784 entry.charged_item = charged_item;
786 entry.rate.duration.amount = amount;
787 entry.rate.duration.multiplier = multiplier;
788 entry.rate.duration.time = time;
789 entry.rate.duration.time_scale = time_scale;
790 entry.rate.duration.granularity_time = granularity_time;
791 entry.rate.duration.granularity_time_scale = granularity_time_scale;
792 entry.rate.duration.charging_type = step_function ? 1 : 0;
793
794 if (!ast_strlen_zero(currency_name)) {
795 ast_copy_string(entry.rate.duration.currency_name, currency_name, sizeof(entry.rate.duration.currency_name));
796 }
797
798 return aoc_s_add_entry(decoded, &entry);
799}
static int aoc_s_add_entry(struct ast_aoc_decoded *decoded, struct ast_aoc_s_entry *entry)
Definition: aoc.c:743
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
Definition: aoc.h:165
uint16_t charged_item
Definition: aoc.h:166
Definition: search.h:40

References aoc_s_add_entry(), AST_AOC_RATE_TYPE_DURATION, ast_copy_string(), ast_strlen_zero(), and ast_aoc_s_entry::charged_item.

Referenced by action_aoc_s_submessage(), and AST_TEST_DEFINE().

◆ ast_aoc_s_add_rate_flat()

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.

Since
1.8
Parameters
decodedaoc decoded object to add entry to
charged_itemast_aoc_s_charged_item
amountcurrency amount
multipliercurrency multiplier
currency_nametruncated after 10 characters
Return values
0success
-1failure

Definition at line 801 of file aoc.c.

806{
807 struct ast_aoc_s_entry entry = { 0, };
808
809 entry.charged_item = charged_item;
810 entry.rate_type = AST_AOC_RATE_TYPE_FLAT;
811 entry.rate.flat.amount = amount;
812 entry.rate.flat.multiplier = multiplier;
813
814 if (!ast_strlen_zero(currency_name)) {
815 ast_copy_string(entry.rate.flat.currency_name, currency_name, sizeof(entry.rate.flat.currency_name));
816 }
817
818 return aoc_s_add_entry(decoded, &entry);
819}

References aoc_s_add_entry(), AST_AOC_RATE_TYPE_FLAT, ast_copy_string(), ast_strlen_zero(), and ast_aoc_s_entry::charged_item.

Referenced by action_aoc_s_submessage(), and AST_TEST_DEFINE().

◆ ast_aoc_s_add_rate_free()

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.

Since
1.8
Parameters
decodedaoc decoded object to add entry to
charged_itemast_aoc_s_charged_item
from_beginningTRUE if the rate is free from beginning.
Return values
0success
-1failure

Definition at line 857 of file aoc.c.

860{
861 struct ast_aoc_s_entry entry = { 0, };
862
863 entry.charged_item = charged_item;
865
866 return aoc_s_add_entry(decoded, &entry);
867}

References aoc_s_add_entry(), AST_AOC_RATE_TYPE_FREE, AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING, and ast_aoc_s_entry::charged_item.

Referenced by action_aoc_s_submessage(), and AST_TEST_DEFINE().

◆ ast_aoc_s_add_rate_na()

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.

Since
1.8
Parameters
decodedaoc decoded object to add entry to
charged_itemast_aoc_s_charged_item
Return values
0success
-1failure

Definition at line 869 of file aoc.c.

871{
872 struct ast_aoc_s_entry entry = { 0, };
873
874 entry.charged_item = charged_item;
875 entry.rate_type = AST_AOC_RATE_TYPE_NA;
876
877 return aoc_s_add_entry(decoded, &entry);
878}

References aoc_s_add_entry(), AST_AOC_RATE_TYPE_NA, and ast_aoc_s_entry::charged_item.

Referenced by action_aoc_s_submessage(), and AST_TEST_DEFINE().

◆ ast_aoc_s_add_rate_special_charge_code()

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.

Since
1.8
Parameters
decodedaoc decoded object to add entry to
charged_itemast_aoc_s_charged_item
codespecial charging code
Return values
0success
-1failure

Definition at line 844 of file aoc.c.

847{
848 struct ast_aoc_s_entry entry = { 0, };
849
850 entry.charged_item = charged_item;
852 entry.rate.special_code = code;
853
854 return aoc_s_add_entry(decoded, &entry);
855}

References aoc_s_add_entry(), AST_AOC_RATE_TYPE_SPECIAL_CODE, and ast_aoc_s_entry::charged_item.

Referenced by action_aoc_s_submessage().

◆ ast_aoc_s_add_rate_volume()

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.

Since
1.8
Parameters
decodedaoc decoded object to add entry to
charged_itemast_aoc_s_charged_item
volume_unitfrom ast_aoc_volume_unit enum
amountcurrency amount
multipliercurrency multiplier
currency_nametruncated after 10 characters
Return values
0success
-1failure

Definition at line 822 of file aoc.c.

828{
829 struct ast_aoc_s_entry entry = { 0, };
830
831 entry.charged_item = charged_item;
833 entry.rate.volume.multiplier = multiplier;
834 entry.rate.volume.amount = amount;
835 entry.rate.volume.volume_unit = volume_unit;
836
837 if (!ast_strlen_zero(currency_name)) {
838 ast_copy_string(entry.rate.volume.currency_name, currency_name, sizeof(entry.rate.volume.currency_name));
839 }
840
841 return aoc_s_add_entry(decoded, &entry);
842}

References aoc_s_add_entry(), AST_AOC_RATE_TYPE_VOLUME, ast_copy_string(), ast_strlen_zero(), and ast_aoc_s_entry::charged_item.

Referenced by action_aoc_s_submessage(), and AST_TEST_DEFINE().

◆ ast_aoc_s_add_special_arrangement()

int ast_aoc_s_add_special_arrangement ( struct ast_aoc_decoded decoded,
unsigned int  code 
)

Add AOC-S special arrangement entry.

Since
1.8
Parameters
decodedaoc decoded object to add entry to
codespecial arrangement code
Return values
0success
-1failure

Definition at line 880 of file aoc.c.

882{
883 struct ast_aoc_s_entry entry = { 0, };
884
887 entry.rate.special_code = code;
888
889 return aoc_s_add_entry(decoded, &entry);
890}

References aoc_s_add_entry(), AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, and AST_AOC_RATE_TYPE_SPECIAL_CODE.

Referenced by action_aoc_s_submessage().

◆ ast_aoc_s_get_count()

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 756 of file aoc.c.

757{
758 return decoded->aoc_s_count;
759}
int aoc_s_count
Definition: aoc.c:227

References ast_aoc_decoded::aoc_s_count.

Referenced by action_aoc_s_message(), and aoc_send_as_xml().

◆ ast_aoc_s_get_rate_info()

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.

Since
1.8
Note
This can be used in conjunction with ast_aoc_s_get_count to create a unit entry iterator.

Definition at line 761 of file aoc.c.

762{
763 if (entry_number >= decoded->aoc_s_count) {
764 return NULL;
765 }
766
767 return (const struct ast_aoc_s_entry *) &decoded->aoc_s_entries[entry_number];
768}
struct ast_aoc_s_entry aoc_s_entries[10]
Definition: aoc.c:228

References ast_aoc_decoded::aoc_s_count, ast_aoc_decoded::aoc_s_entries, and NULL.

Referenced by aoc_send_as_xml().

◆ ast_aoc_set_association_id()

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

Since
1.8
Parameters
decodedast_aoc_decoded struct to set values on
idcharging association identifier
Note
If the association number was set, this will override that value. Only the id OR the number can be set at a time, not both.
Return values
0success

Definition at line 1040 of file aoc.c.

1041{
1042 if (decoded->msg_type != AST_AOC_E) {
1043 return -1;
1044 }
1045 memset(&decoded->charging_association, 0, sizeof(decoded->charging_association));
1047 decoded->charging_association.charge.id = id;
1048 return 0;
1049}
enum queue_result id
Definition: app_queue.c:1667
union ast_aoc_charging_association::@183 charge

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, id, ast_aoc_charging_association::id, and ast_aoc_decoded::msg_type.

Referenced by action_aoc_de_message(), and AST_TEST_DEFINE().

◆ ast_aoc_set_association_number()

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

Since
1.8
Parameters
decodedast_aoc_decoded struct to set values on
numcharging association number
plancharging association number plan and type-of-number fields
Note
If the association id was set, this will override that value. Only the id OR the number can be set at a time, not both.
Return values
0success

Definition at line 1056 of file aoc.c.

1057{
1058 if ((decoded->msg_type != AST_AOC_E) || ast_strlen_zero(num)) {
1059 return -1;
1060 }
1061 memset(&decoded->charging_association, 0, sizeof(decoded->charging_association));
1063 decoded->charging_association.charge.number.plan = plan;
1065
1066 return 0;
1067}
struct ast_aoc_charging_association_number number
Definition: aoc.h:197

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_aoc_de_message(), and AST_TEST_DEFINE().

◆ ast_aoc_set_billing_id()

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

Since
1.8
Parameters
decodedast_aoc_decoded struct to set values on
idbilling id
Return values
0success

Definition at line 1024 of file aoc.c.

1025{
1026 if ((id >= AST_AOC_BILLING_NUM_ENTRIES) || (id < AST_AOC_BILLING_NA)) {
1027 return -1;
1028 }
1029
1030 decoded->billing_id = id;
1031
1032 return 0;
1033}

References AST_AOC_BILLING_NA, AST_AOC_BILLING_NUM_ENTRIES, ast_aoc_decoded::billing_id, and id.

Referenced by action_aoc_de_message(), and AST_TEST_DEFINE().

◆ ast_aoc_set_currency_info()

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.

Since
1.8
Parameters
decodedast_aoc_decoded struct to set values on
amountcurrency amount REQUIRED
multipliercurrency multiplier REQUIRED, 0 or undefined value defaults to AST_AOC_MULT_ONE.
namecurrency name OPTIONAL
Return values
0success

Definition at line 919 of file aoc.c.

923{
924
925 if (!ast_strlen_zero(name)) {
926 ast_copy_string(decoded->currency_name, name, sizeof(decoded->currency_name));
927 }
928
929 decoded->currency_amount = amount;
930
931 if (multiplier && (multiplier < AST_AOC_MULT_NUM_ENTRIES)) {
932 decoded->multiplier = multiplier;
933 } else {
934 decoded->multiplier = AST_AOC_MULT_ONE;
935 }
936
937 return 0;
938}
static const char name[]
Definition: format_mp3.c:68

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, ast_aoc_decoded::multiplier, and name.

Referenced by action_aoc_de_message(), and AST_TEST_DEFINE().

◆ ast_aoc_set_termination_request()

int ast_aoc_set_termination_request ( struct ast_aoc_decoded decoded)

Mark the AST_AOC_REQUEST message as a termination request.

Since
1.8
Parameters
decodedast_aoc_decoded struct to set values on
Note
A termination request indicates that the call has terminated, but that the other side is waiting for a short period of time before hanging up so it can get the final AOC-E message.
Return values
0success
-1failure

Definition at line 1069 of file aoc.c.

1070{
1071 if (decoded->msg_type != AST_AOC_REQUEST) {
1072 return -1;
1073 }
1074 decoded->termination_request = 1;
1075
1076 return 0;
1077}

References AST_AOC_REQUEST, ast_aoc_decoded::msg_type, and ast_aoc_decoded::termination_request.

Referenced by AST_TEST_DEFINE().

◆ ast_aoc_set_total_type()

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.

Since
1.8
Parameters
decodedast_aoc_decoded struct to set values on
typetotal type: TOTAL or SUBTOTAL
Note
If this value is not set, the default for the message is TOTAL
Return values
0success

Definition at line 907 of file aoc.c.

909{
910 decoded->total_type = type;
911 return 0;
912}

References ast_aoc_decoded::total_type, and type.

Referenced by action_aoc_de_message(), and AST_TEST_DEFINE().

◆ ast_aoc_test_encode_decode_match()

int ast_aoc_test_encode_decode_match ( struct ast_aoc_decoded decoded)

test aoc encode decode routines.

Since
1.8
Note
This function verifies that a decoded message matches itself after the encode decode routine.

Definition at line 1330 of file aoc.c.

1331{
1332 struct ast_aoc_decoded *new_decoded = NULL;
1333 struct ast_aoc_encoded *encoded = NULL;
1334 size_t size;
1335 int res = 0;
1336
1337 if (!(encoded = ast_aoc_encode(decoded, &size, NULL))) {
1338 return -1;
1339 }
1340
1341 if (!(new_decoded = ast_aoc_decode(encoded, size, NULL))) {
1342 ast_free(encoded);
1343 return -1;
1344 }
1345
1346 if (memcmp(new_decoded, decoded, sizeof(struct ast_aoc_decoded))) {
1347 res = -1;
1348 }
1349
1350 ast_aoc_destroy_decoded(new_decoded);
1351 ast_aoc_destroy_encoded(encoded);
1352 return res;
1353}
void * ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
free an ast_aoc_encoded object
Definition: aoc.c:313
struct ast_aoc_decoded * ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size, struct ast_channel *chan)
decodes an encoded aoc payload.
Definition: aoc.c:449
void * ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
free an ast_aoc_decoded object
Definition: aoc.c:307
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
Definition: aoc.c:650

References ast_aoc_decode(), ast_aoc_destroy_decoded(), ast_aoc_destroy_encoded(), ast_aoc_encode(), ast_free, and NULL.

Referenced by AST_TEST_DEFINE().