Sat Mar 10 01:54:30 2012

Asterisk developer's documentation


aoc.h File Reference

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

#include "asterisk/channel.h"

Go to the source code of this file.

Data Structures

struct  ast_aoc_charging_association
struct  ast_aoc_charging_association_number
struct  ast_aoc_duration_rate
struct  ast_aoc_flat_rate
struct  ast_aoc_s_entry
struct  ast_aoc_time
struct  ast_aoc_unit_entry
struct  ast_aoc_volume_rate

Defines

#define AOC_CURRENCY_NAME_SIZE   (10 + 1)

Enumerations

enum  ast_aoc_billing_id {
  AST_AOC_BILLING_NA = 0, AST_AOC_BILLING_NORMAL, AST_AOC_BILLING_REVERSE_CHARGE, AST_AOC_BILLING_CREDIT_CARD,
  AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL, AST_AOC_BILLING_CALL_FWD_BUSY, AST_AOC_BILLING_CALL_FWD_NO_REPLY, AST_AOC_BILLING_CALL_DEFLECTION,
  AST_AOC_BILLING_CALL_TRANSFER, AST_AOC_BILLING_NUM_ENTRIES
}
 Defines the billing id options for an aoc message. More...
enum  ast_aoc_charge_type { AST_AOC_CHARGE_NA = 0, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_UNIT }
enum  AST_AOC_CHARGING_ASSOCIATION { AST_AOC_CHARGING_ASSOCIATION_NA, AST_AOC_CHARGING_ASSOCIATION_NUMBER, AST_AOC_CHARGING_ASSOCIATION_ID }
enum  ast_aoc_currency_multiplier {
  AST_AOC_MULT_ONETHOUSANDTH = 1, AST_AOC_MULT_ONEHUNDREDTH, AST_AOC_MULT_ONETENTH, AST_AOC_MULT_ONE,
  AST_AOC_MULT_TEN, AST_AOC_MULT_HUNDRED, AST_AOC_MULT_THOUSAND, AST_AOC_MULT_NUM_ENTRIES
}
 Defines the currency multiplier for an aoc message. More...
enum  ast_aoc_request { AST_AOC_REQUEST_S = (1 << 0), AST_AOC_REQUEST_D = (1 << 1), AST_AOC_REQUEST_E = (1 << 2) }
enum  ast_aoc_s_charged_item {
  AST_AOC_CHARGED_ITEM_NA, AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, AST_AOC_CHARGED_ITEM_BASIC_COMMUNICATION, AST_AOC_CHARGED_ITEM_CALL_ATTEMPT,
  AST_AOC_CHARGED_ITEM_CALL_SETUP, AST_AOC_CHARGED_ITEM_USER_USER_INFO, AST_AOC_CHARGED_ITEM_SUPPLEMENTARY_SERVICE
}
enum  ast_aoc_s_rate_type {
  AST_AOC_RATE_TYPE_NA, AST_AOC_RATE_TYPE_FREE, AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING, AST_AOC_RATE_TYPE_DURATION,
  AST_AOC_RATE_TYPE_FLAT, AST_AOC_RATE_TYPE_VOLUME, AST_AOC_RATE_TYPE_SPECIAL_CODE
}
enum  ast_aoc_time_scale {
  AST_AOC_TIME_SCALE_HUNDREDTH_SECOND, AST_AOC_TIME_SCALE_TENTH_SECOND, AST_AOC_TIME_SCALE_SECOND, AST_AOC_TIME_SCALE_TEN_SECOND,
  AST_AOC_TIME_SCALE_MINUTE, AST_AOC_TIME_SCALE_HOUR, AST_AOC_TIME_SCALE_DAY
}
enum  ast_aoc_total_type { AST_AOC_TOTAL = 0, AST_AOC_SUBTOTAL = 1 }
enum  ast_aoc_type { AST_AOC_REQUEST = 0, AST_AOC_S, AST_AOC_D, AST_AOC_E }
enum  ast_aoc_volume_unit { AST_AOC_VOLUME_UNIT_OCTET, AST_AOC_VOLUME_UNIT_SEGMENT, AST_AOC_VOLUME_UNIT_MESSAGE }

Functions

int ast_aoc_add_unit_entry (struct ast_aoc_decoded *decoded, const unsigned int amount_is_present, const unsigned int amount, const unsigned int type_is_present, const unsigned int type)
 Adds a unit entry into the list of units.
int ast_aoc_cli_init (void)
 enable aoc cli options
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
ast_aoc_decodedast_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
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
ast_aoc_charging_associationast_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
ast_aoc_unit_entryast_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
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.
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.


Detailed Description

Generic Advice of Charge encode and decode routines.

Author:
David Vossel <dvossel@digium.com>

Definition in file aoc.h.


Define Documentation

#define AOC_CURRENCY_NAME_SIZE   (10 + 1)

Definition at line 31 of file aoc.h.


Enumeration Type Documentation

enum 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.

enum 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.

00069                          {
00070    AST_AOC_CHARGE_NA = 0,
00071    AST_AOC_CHARGE_FREE,
00072    AST_AOC_CHARGE_CURRENCY,
00073    AST_AOC_CHARGE_UNIT, /* unit must remain the last item in enum */
00074 };

enum 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.

enum 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.

00034                                  {
00035    AST_AOC_MULT_ONETHOUSANDTH = 1,
00036    AST_AOC_MULT_ONEHUNDREDTH,
00037    AST_AOC_MULT_ONETENTH,
00038    AST_AOC_MULT_ONE,
00039    AST_AOC_MULT_TEN,
00040    AST_AOC_MULT_HUNDRED,
00041    AST_AOC_MULT_THOUSAND,
00042    AST_AOC_MULT_NUM_ENTRIES, /* must remain the last item in enum, this is not a valid type */
00043 };

enum ast_aoc_request

Enumerator:
AST_AOC_REQUEST_S 
AST_AOC_REQUEST_D 
AST_AOC_REQUEST_E 

Definition at line 76 of file aoc.h.

00076                      {
00077    AST_AOC_REQUEST_S = (1 << 0),
00078    AST_AOC_REQUEST_D = (1 << 1),
00079    AST_AOC_REQUEST_E = (1 << 2),
00080 };

enum 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.

enum 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.

enum 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.

enum ast_aoc_total_type

Enumerator:
AST_AOC_TOTAL 
AST_AOC_SUBTOTAL 

Definition at line 82 of file aoc.h.

00082                         {
00083    AST_AOC_TOTAL = 0,
00084    AST_AOC_SUBTOTAL = 1,
00085 };

enum ast_aoc_type

Enumerator:
AST_AOC_REQUEST 
AST_AOC_S 
AST_AOC_D 
AST_AOC_E 

Definition at line 62 of file aoc.h.

00062                   {
00063    AST_AOC_REQUEST = 0,
00064    AST_AOC_S,
00065    AST_AOC_D,
00066    AST_AOC_E, /* aoc-e must remain the last item in this enum */
00067 };

enum 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.


Function Documentation

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:
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
Note:
If neither the amount nor the type is present, the entry will not be added.
Return values:
0 success

Definition at line 842 of file aoc.c.

References ast_aoc_unit_entry::amount, ARRAY_LEN, AST_AOC_REQUEST, ast_aoc_decoded::msg_type, 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().

00847 {
00848    if ((decoded->msg_type == AST_AOC_REQUEST) ||
00849       (decoded->unit_count >= ARRAY_LEN(decoded->unit_list))) {
00850       return -1;
00851    }
00852 
00853    if (!amount_is_present && !type_is_present) {
00854       return -1;
00855    }
00856 
00857    decoded->unit_list[decoded->unit_count].valid_amount = amount_is_present;
00858    if (amount_is_present) {
00859       decoded->unit_list[decoded->unit_count].amount = amount;
00860    } else {
00861       decoded->unit_list[decoded->unit_count].amount = 0;
00862    }
00863 
00864    decoded->unit_list[decoded->unit_count].valid_type = type_is_present;
00865    if (type_is_present) {
00866       decoded->unit_list[decoded->unit_count].type = type;
00867    } else {
00868       decoded->unit_list[decoded->unit_count].type = 0;
00869    }
00870    decoded->unit_count++;
00871 
00872    return 0;
00873 }

int ast_aoc_cli_init ( void   ) 

enable aoc cli options

Definition at line 1604 of file aoc.c.

References aoc_cli, ARRAY_LEN, and ast_cli_register_multiple().

Referenced by main().

01605 {
01606    return ast_cli_register_multiple(aoc_cli, ARRAY_LEN(aoc_cli));
01607 }

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_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.
Return values:
heap allocated ast_aoc_decoded object ptr on success
NULL failure

Definition at line 141 of file aoc.c.

References AST_AOC_CHARGE_UNIT, AST_AOC_D, AST_AOC_E, AST_AOC_REQUEST, ast_calloc, ast_log(), ast_aoc_decoded::charge_type, LOG_WARNING, ast_aoc_decoded::msg_type, and ast_aoc_decoded::request_flag.

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().

00144 {
00145    struct ast_aoc_decoded *decoded = NULL;
00146 
00147    /* verify input */
00148    if (((unsigned int) charge_type > AST_AOC_CHARGE_UNIT) ||
00149       ((unsigned int) msg_type > AST_AOC_E) ||
00150       ((msg_type == AST_AOC_REQUEST) && !requests)) {
00151 
00152       ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object, invalid input\n");
00153       return NULL;
00154    }
00155 
00156    if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
00157       ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
00158       return NULL;
00159    }
00160 
00161    decoded->msg_type = msg_type;
00162 
00163    if (msg_type == AST_AOC_REQUEST) {
00164       decoded->request_flag = requests;
00165    } else if ((msg_type == AST_AOC_D) || (msg_type == AST_AOC_E)) {
00166       decoded->charge_type = charge_type;
00167    }
00168 
00169    return decoded;
00170 }

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:
encoded the encoded payload to decode.
size total size of encoded payload
chan ast channel, Optional for DEBUG output purposes
Return values:
heap allocated ast_aoc_decoded object ptr on success
NULL failure

Definition at line 314 of file aoc.c.

References aoc_debug_enabled, aoc_display_decoded_debug(), aoc_parse_ie(), AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_NA, AST_AOC_CHARGE_UNIT, AST_AOC_D, AST_AOC_E, AST_AOC_ENCODED_CHARGE_CURRENCY, AST_AOC_ENCODED_CHARGE_FREE, AST_AOC_ENCODED_CHARGE_SUBTOTAL, AST_AOC_ENCODED_CHARGE_UNIT, AST_AOC_ENCODED_REQUEST_D, AST_AOC_ENCODED_REQUEST_E, AST_AOC_ENCODED_REQUEST_S, AST_AOC_ENCODED_TYPE_D, AST_AOC_ENCODED_TYPE_E, AST_AOC_ENCODED_TYPE_S, AST_AOC_REQUEST, AST_AOC_REQUEST_D, AST_AOC_REQUEST_E, AST_AOC_REQUEST_S, AST_AOC_S, AST_AOC_SUBTOTAL, ast_calloc, ast_log(), ast_aoc_decoded::charge_type, ast_aoc_encoded::data, ast_aoc_encoded::datalen, ast_aoc_encoded::flags, LOG_WARNING, ast_aoc_decoded::msg_type, ast_aoc_decoded::request_flag, and ast_aoc_decoded::total_type.

Referenced by ast_aoc_test_encode_decode_match(), sig_pri_indicate(), and sip_indicate().

00315 {
00316    struct ast_aoc_decoded *decoded;
00317 
00318    /* verify our encoded payload is actually large enough to hold all the ies */
00319    if ((size - (sizeof(struct ast_aoc_encoded)) != ntohs(encoded->datalen))) {
00320       ast_log(LOG_WARNING, "Corrupted aoc encoded object, can not decode\n");
00321       return NULL;
00322    }
00323 
00324    if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
00325       ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
00326       return NULL;
00327    }
00328 
00329    /* decode flags */
00330 
00331    if ((encoded->flags & AST_AOC_ENCODED_TYPE_S) == AST_AOC_ENCODED_TYPE_S) {
00332       decoded->msg_type = AST_AOC_S;
00333    } else if (encoded->flags & AST_AOC_ENCODED_TYPE_E) {
00334       decoded->msg_type = AST_AOC_E;
00335    } else if (encoded->flags & AST_AOC_ENCODED_TYPE_D) {
00336       decoded->msg_type = AST_AOC_D;
00337    } else {
00338       decoded->msg_type = AST_AOC_REQUEST;
00339    }
00340 
00341    if (decoded->msg_type == AST_AOC_REQUEST) {
00342       if (encoded->flags & AST_AOC_ENCODED_REQUEST_S) {
00343          decoded->request_flag |= AST_AOC_REQUEST_S;
00344       }
00345       if (encoded->flags & AST_AOC_ENCODED_REQUEST_D) {
00346          decoded->request_flag |= AST_AOC_REQUEST_D;
00347       }
00348       if (encoded->flags & AST_AOC_ENCODED_REQUEST_E) {
00349          decoded->request_flag |= AST_AOC_REQUEST_E;
00350       }
00351    } else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) {
00352       if ((encoded->flags & AST_AOC_ENCODED_CHARGE_UNIT) == AST_AOC_ENCODED_CHARGE_UNIT) {
00353          decoded->charge_type = AST_AOC_CHARGE_UNIT;
00354       } else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_CURRENCY) == AST_AOC_ENCODED_CHARGE_CURRENCY) {
00355          decoded->charge_type = AST_AOC_CHARGE_CURRENCY;
00356       } else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_FREE) == AST_AOC_ENCODED_CHARGE_FREE) {
00357          decoded->charge_type = AST_AOC_CHARGE_FREE;
00358       } else {
00359          decoded->charge_type = AST_AOC_CHARGE_NA;
00360       }
00361 
00362       if (encoded->flags & AST_AOC_ENCODED_CHARGE_SUBTOTAL) {
00363          decoded->total_type = AST_AOC_SUBTOTAL;
00364       }
00365    }
00366 
00367    /* decode information elements */
00368    aoc_parse_ie(decoded, encoded->data, ntohs(encoded->datalen));
00369 
00370    if (aoc_debug_enabled) {
00371       aoc_display_decoded_debug(decoded, 1, chan);
00372    }
00373 
00374    return decoded;
00375 }

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:
decoded ast_aoc_decoded struct to convert to string
msg dynamic heap allocated ast_str object to store string representation in
Return values:
0 success
-1 failure

Definition at line 1546 of file aoc.c.

References aoc_d_event(), aoc_e_event(), aoc_request_event(), aoc_s_event(), AST_AOC_D, AST_AOC_E, AST_AOC_REQUEST, AST_AOC_S, ast_str_append(), and ast_aoc_decoded::msg_type.

Referenced by aoc_display_decoded_debug().

01547 {
01548    if (!decoded || !msg) {
01549       return -1;
01550    }
01551 
01552    switch (decoded->msg_type) {
01553    case AST_AOC_S:
01554       ast_str_append(msg, 0, "AOC-S\r\n");
01555       aoc_s_event(decoded, NULL, msg);
01556       break;
01557    case AST_AOC_D:
01558       ast_str_append(msg, 0, "AOC-D\r\n");
01559       aoc_d_event(decoded, NULL, msg);
01560       break;
01561    case AST_AOC_E:
01562       ast_str_append(msg, 0, "AOC-E\r\n");
01563       aoc_e_event(decoded, NULL, msg);
01564       break;
01565    case AST_AOC_REQUEST:
01566       ast_str_append(msg, 0, "AOC-Request\r\n");
01567       aoc_request_event(decoded, NULL, msg);
01568       break;
01569    }
01570 
01571    return 0;
01572 }

void* ast_aoc_destroy_decoded ( struct ast_aoc_decoded decoded  ) 

free an ast_aoc_decoded object

Definition at line 172 of file aoc.c.

References ast_free.

Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), chanlist_free(), hangupcalls(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_indicate(), sig_pri_send_aoce_termination_request(), and sip_indicate().

00173 {
00174    ast_free(decoded);
00175    return NULL;
00176 }

void* ast_aoc_destroy_encoded ( struct ast_aoc_encoded encoded  ) 

free an ast_aoc_encoded object

Definition at line 178 of file aoc.c.

References ast_free.

Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_send_aoce_termination_request(), and wait_for_answer().

00179 {
00180    ast_free(encoded);
00181    return NULL;
00182 }

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:
decoded the decoded struct to be encoded
out_size output parameter representing size of encoded data
chan ast channel, Optional for DEBUG output purposes
Return values:
pointer to encoded data
NULL failure

Definition at line 515 of file aoc.c.

References aoc_create_ie_data(), aoc_debug_enabled, aoc_display_decoded_debug(), AST_AOC_CHARGE_CURRENCY, AST_AOC_CHARGE_FREE, AST_AOC_CHARGE_NA, AST_AOC_CHARGE_UNIT, AST_AOC_D, AST_AOC_E, AST_AOC_ENCODE_VERSION, AST_AOC_ENCODED_CHARGE_CURRENCY, AST_AOC_ENCODED_CHARGE_FREE, AST_AOC_ENCODED_CHARGE_NA, AST_AOC_ENCODED_CHARGE_SUBTOTAL, AST_AOC_ENCODED_CHARGE_UNIT, AST_AOC_ENCODED_REQUEST_D, AST_AOC_ENCODED_REQUEST_E, AST_AOC_ENCODED_REQUEST_S, AST_AOC_ENCODED_TYPE_D, AST_AOC_ENCODED_TYPE_E, AST_AOC_ENCODED_TYPE_REQUEST, AST_AOC_ENCODED_TYPE_S, AST_AOC_REQUEST, AST_AOC_REQUEST_D, AST_AOC_REQUEST_E, AST_AOC_REQUEST_S, AST_AOC_S, AST_AOC_SUBTOTAL, ast_calloc, ast_log(), ast_aoc_decoded::charge_type, ast_aoc_encoded::data, ast_aoc_encoded::datalen, ast_aoc_encoded::flags, LOG_WARNING, ast_aoc_decoded::msg_type, ast_aoc_decoded::request_flag, ast_aoc_decoded::total_type, and ast_aoc_encoded::version.

Referenced by action_aocmessage(), ast_aoc_test_encode_decode_match(), sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), sig_pri_aoc_s_from_pri(), sig_pri_send_aoce_termination_request(), and wait_for_answer().

00516 {
00517    struct aoc_ie_data ied;
00518    struct ast_aoc_encoded *encoded = NULL;
00519    size_t size = 0;
00520 
00521    if (!decoded || !out_size) {
00522       return NULL;
00523    }
00524 
00525    *out_size = 0;
00526 
00527    /* create information element buffer before allocating the payload,
00528     * by doing this the exact size of the payload + the id data can be
00529     * allocated all at once. */
00530    aoc_create_ie_data(decoded, &ied);
00531 
00532    size = sizeof(struct ast_aoc_encoded) + ied.pos;
00533 
00534    if (!(encoded = ast_calloc(1, size))) {
00535       ast_log(LOG_WARNING, "Failed to create ast_aoc_encoded object during decode routine. \n");
00536       return NULL;
00537    }
00538 
00539    /* -- Set ie data buffer */
00540    if (ied.pos) {
00541       /* this is safe because encoded was allocated to fit this perfectly */
00542       memcpy(encoded->data, ied.buf, ied.pos);
00543       encoded->datalen = htons(ied.pos);
00544    }
00545 
00546    /* --- Set Flags --- */
00547    switch (decoded->msg_type) {
00548    case AST_AOC_S:
00549       encoded->flags = AST_AOC_ENCODED_TYPE_S;
00550       break;
00551    case AST_AOC_D:
00552       encoded->flags = AST_AOC_ENCODED_TYPE_D;
00553       break;
00554    case AST_AOC_E:
00555       encoded->flags = AST_AOC_ENCODED_TYPE_E;
00556       break;
00557    case AST_AOC_REQUEST:
00558       encoded->flags = AST_AOC_ENCODED_TYPE_REQUEST;
00559    default:
00560       break;
00561    }
00562 
00563    /* if it is type request, set the types requested, else set charge type */
00564    if (decoded->msg_type == AST_AOC_REQUEST) {
00565       if (decoded->request_flag & AST_AOC_REQUEST_S) {
00566          encoded->flags |= AST_AOC_ENCODED_REQUEST_S;
00567       }
00568       if (decoded->request_flag & AST_AOC_REQUEST_D) {
00569          encoded->flags |= AST_AOC_ENCODED_REQUEST_D;
00570       }
00571       if (decoded->request_flag & AST_AOC_REQUEST_E) {
00572          encoded->flags |= AST_AOC_ENCODED_REQUEST_E;
00573       }
00574    } else if ((decoded->msg_type == AST_AOC_D) || (decoded->msg_type == AST_AOC_E)) {
00575       switch (decoded->charge_type) {
00576       case AST_AOC_CHARGE_UNIT:
00577          encoded->flags |= AST_AOC_ENCODED_CHARGE_UNIT;
00578          break;
00579       case AST_AOC_CHARGE_CURRENCY:
00580          encoded->flags |= AST_AOC_ENCODED_CHARGE_CURRENCY;
00581          break;
00582       case AST_AOC_CHARGE_FREE:
00583          encoded->flags |= AST_AOC_ENCODED_CHARGE_FREE;
00584       case AST_AOC_CHARGE_NA:
00585       default:
00586          encoded->flags |= AST_AOC_ENCODED_CHARGE_NA;
00587          break;
00588       }
00589 
00590       if (decoded->total_type == AST_AOC_SUBTOTAL) {
00591          encoded->flags |= AST_AOC_ENCODED_CHARGE_SUBTOTAL;
00592       }
00593    }
00594 
00595    /* --- Set Version Number --- */
00596    encoded->version = AST_AOC_ENCODE_VERSION;
00597 
00598    /* set the output size  */
00599    *out_size = size;
00600 
00601    if (aoc_debug_enabled) {
00602       aoc_display_decoded_debug(decoded, 0, chan);
00603    }
00604 
00605    return encoded;
00606 }

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

References ast_aoc_decoded::charging_association.

Referenced by sig_pri_aoc_e_from_ast().

00917 {
00918    return &decoded->charging_association;
00919 }

enum ast_aoc_billing_id ast_aoc_get_billing_id ( struct ast_aoc_decoded decoded  ) 

get the billing id for AOC-D and AOC-E messages

Definition at line 900 of file aoc.c.

References ast_aoc_decoded::billing_id.

Referenced by sig_pri_aoc_d_from_ast(), and sig_pri_aoc_e_from_ast().

00901 {
00902    return decoded->billing_id;
00903 }

enum ast_aoc_charge_type ast_aoc_get_charge_type ( struct ast_aoc_decoded decoded  ) 

get the charging type for an AOC-D or AOC-E message

Definition at line 762 of file aoc.c.

References ast_aoc_decoded::charge_type.

Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().

00763 {
00764    return decoded->charge_type;
00765 }

unsigned int ast_aoc_get_currency_amount ( struct ast_aoc_decoded decoded  ) 

get the currency amount for AOC-D and AOC-E messages

Definition at line 805 of file aoc.c.

References ast_aoc_decoded::currency_amount.

Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().

00806 {
00807    return decoded->currency_amount;
00808 }

enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier ( struct ast_aoc_decoded decoded  ) 

get the currency multiplier for AOC-D and AOC-E messages

Definition at line 810 of file aoc.c.

References ast_aoc_decoded::multiplier.

Referenced by sig_pri_aoc_d_from_ast(), and sig_pri_aoc_e_from_ast().

00811 {
00812    return decoded->multiplier;
00813 }

const char* ast_aoc_get_currency_multiplier_decimal ( struct ast_aoc_decoded decoded  ) 

get the currency multiplier for AOC-D and AOC-E messages in decimal format

Definition at line 815 of file aoc.c.

References AST_AOC_MULT_HUNDRED, AST_AOC_MULT_ONE, AST_AOC_MULT_ONEHUNDREDTH, AST_AOC_MULT_ONETENTH, AST_AOC_MULT_ONETHOUSANDTH, AST_AOC_MULT_TEN, AST_AOC_MULT_THOUSAND, and ast_aoc_decoded::multiplier.

Referenced by transmit_info_with_aoc().

00816 {
00817    switch (decoded->multiplier) {
00818    case AST_AOC_MULT_ONETHOUSANDTH:
00819       return "0.001";
00820    case AST_AOC_MULT_ONEHUNDREDTH:
00821       return "0.01";
00822    case AST_AOC_MULT_ONETENTH:
00823       return "0.1";
00824    case AST_AOC_MULT_ONE:
00825       return "1.0";
00826    case AST_AOC_MULT_TEN:
00827       return "10.0";
00828    case AST_AOC_MULT_HUNDRED:
00829       return "100.0";
00830    case AST_AOC_MULT_THOUSAND:
00831       return "1000.0";
00832    default:
00833       return "1.0";
00834    }
00835 }

const char* ast_aoc_get_currency_name ( struct ast_aoc_decoded decoded  ) 

get the currency name for AOC-D and AOC-E messages

Definition at line 837 of file aoc.c.

References ast_aoc_decoded::currency_name.

Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().

00838 {
00839    return decoded->currency_name;
00840 }

enum ast_aoc_type ast_aoc_get_msg_type ( struct ast_aoc_decoded decoded  ) 

get the message type, AOC-D, AOC-E, or AOC Request

Definition at line 757 of file aoc.c.

References ast_aoc_decoded::msg_type.

Referenced by sig_pri_indicate(), sip_indicate(), and transmit_info_with_aoc().

00758 {
00759    return decoded->msg_type;
00760 }

enum ast_aoc_request ast_aoc_get_request ( struct ast_aoc_decoded decoded  ) 

get the types of AOC requested for when message type is AOC Request

Definition at line 767 of file aoc.c.

References ast_aoc_decoded::request_flag.

00768 {
00769    return decoded->request_flag;
00770 }

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:
decoded ast_aoc_decoded struct to get values on
Return values:
0 not a termination request
1 is a termination request

Definition at line 944 of file aoc.c.

References ast_aoc_decoded::termination_request.

Referenced by sig_pri_indicate(), and sip_indicate().

00945 {
00946    return decoded->termination_request;
00947 }

enum ast_aoc_total_type ast_aoc_get_total_type ( struct ast_aoc_decoded decoded  ) 

get the type of total for a AOC-D message

Definition at line 779 of file aoc.c.

References ast_aoc_decoded::total_type.

Referenced by sig_pri_aoc_d_from_ast().

00780 {
00781    return decoded->total_type;
00782 }

unsigned int ast_aoc_get_unit_count ( struct ast_aoc_decoded decoded  ) 

get the number of unit entries for AOC-D and AOC-E messages

Definition at line 884 of file aoc.c.

References ast_aoc_decoded::unit_count.

Referenced by sig_pri_aoc_d_from_ast(), and sig_pri_aoc_e_from_ast().

00885 {
00886    return decoded->unit_count;
00887 }

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

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

Referenced by sig_pri_aoc_d_from_ast(), sig_pri_aoc_e_from_ast(), and transmit_info_with_aoc().

00876 {
00877    if (entry_number >= decoded->unit_count) {
00878       return NULL;
00879    }
00880 
00881    return (const struct ast_aoc_unit_entry *) &decoded->unit_list[entry_number];
00882 }

int ast_aoc_manager_event ( const struct ast_aoc_decoded decoded,
struct ast_channel chan 
)

generate AOC manager event for an AOC-S, AOC-D, or AOC-E msg

Definition at line 1508 of file aoc.c.

References aoc_d_event(), aoc_e_event(), aoc_s_event(), AST_AOC_D, AST_AOC_E, AST_AOC_S, ast_free, ast_manager_event, ast_manager_event_multichan, ast_str_buffer(), ast_str_create(), EVENT_FLAG_AOC, and ast_aoc_decoded::msg_type.

Referenced by sig_pri_aoc_d_from_pri(), sig_pri_aoc_e_from_pri(), and sig_pri_aoc_s_from_pri().

01509 {
01510    struct ast_str *msg;
01511 
01512    if (!decoded || !(msg = ast_str_create(1024))) {
01513       return -1;
01514    }
01515 
01516    switch (decoded->msg_type) {
01517    case AST_AOC_S:
01518       if (chan) {
01519          aoc_s_event(decoded, chan, &msg);
01520          ast_manager_event(chan, EVENT_FLAG_AOC, "AOC-S", "%s", ast_str_buffer(msg));
01521       }
01522       break;
01523    case AST_AOC_D:
01524       if (chan) {
01525          aoc_d_event(decoded, chan, &msg);
01526          ast_manager_event(chan, EVENT_FLAG_AOC, "AOC-D", "%s", ast_str_buffer(msg));
01527       }
01528       break;
01529    case AST_AOC_E:
01530       {
01531          struct ast_channel *chans[1];
01532          aoc_e_event(decoded, chan, &msg);
01533          chans[0] = chan;
01534          ast_manager_event_multichan(EVENT_FLAG_AOC, "AOC-E", chan ? 1 : 0, chans, "%s", ast_str_buffer(msg));
01535       }
01536       break;
01537    default:
01538       /* events for AST_AOC_REQUEST are not generated here */
01539       break;
01540    }
01541 
01542    ast_free(msg);
01543    return 0;
01544 }

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:
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
Return values:
0 success
-1 failure

Definition at line 635 of file aoc.c.

References ast_aoc_duration_rate::amount, aoc_s_add_entry(), AST_AOC_RATE_TYPE_DURATION, ast_copy_string(), ast_strlen_zero(), ast_aoc_s_entry::charged_item, ast_aoc_duration_rate::charging_type, ast_aoc_duration_rate::currency_name, ast_aoc_s_entry::duration, ast_aoc_duration_rate::granularity_time, ast_aoc_duration_rate::granularity_time_scale, ast_aoc_duration_rate::multiplier, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, ast_aoc_duration_rate::time, and ast_aoc_duration_rate::time_scale.

Referenced by sig_pri_aoc_s_from_pri().

00645 {
00646 
00647    struct ast_aoc_s_entry entry = { 0, };
00648 
00649    entry.charged_item = charged_item;
00650    entry.rate_type = AST_AOC_RATE_TYPE_DURATION;
00651    entry.rate.duration.amount = amount;
00652    entry.rate.duration.multiplier = multiplier;
00653    entry.rate.duration.time = time;
00654    entry.rate.duration.time_scale = time_scale;
00655    entry.rate.duration.granularity_time = granularity_time;
00656    entry.rate.duration.granularity_time_scale = granularity_time_scale;
00657    entry.rate.duration.charging_type = step_function ? 1 : 0;
00658 
00659    if (!ast_strlen_zero(currency_name)) {
00660       ast_copy_string(entry.rate.duration.currency_name, currency_name, sizeof(entry.rate.duration.currency_name));
00661    }
00662 
00663    return aoc_s_add_entry(decoded, &entry);
00664 }

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:
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
Return values:
0 success
-1 failure

Definition at line 666 of file aoc.c.

References ast_aoc_flat_rate::amount, aoc_s_add_entry(), AST_AOC_RATE_TYPE_FLAT, ast_copy_string(), ast_strlen_zero(), ast_aoc_s_entry::charged_item, ast_aoc_flat_rate::currency_name, ast_aoc_s_entry::flat, ast_aoc_flat_rate::multiplier, ast_aoc_s_entry::rate, and ast_aoc_s_entry::rate_type.

Referenced by sig_pri_aoc_s_from_pri().

00671 {
00672    struct ast_aoc_s_entry entry = { 0, };
00673 
00674    entry.charged_item = charged_item;
00675    entry.rate_type = AST_AOC_RATE_TYPE_FLAT;
00676    entry.rate.flat.amount = amount;
00677    entry.rate.flat.multiplier = multiplier;
00678 
00679    if (!ast_strlen_zero(currency_name)) {
00680       ast_copy_string(entry.rate.flat.currency_name, currency_name, sizeof(entry.rate.flat.currency_name));
00681    }
00682 
00683    return aoc_s_add_entry(decoded, &entry);
00684 }

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:
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.
Return values:
0 success
-1 failure

Definition at line 722 of file aoc.c.

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

Referenced by sig_pri_aoc_s_from_pri().

00725 {
00726    struct ast_aoc_s_entry entry = { 0, };
00727 
00728    entry.charged_item = charged_item;
00729    entry.rate_type = from_beginning ? AST_AOC_RATE_TYPE_FREE_FROM_BEGINNING : AST_AOC_RATE_TYPE_FREE;
00730 
00731    return aoc_s_add_entry(decoded, &entry);
00732 }

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:
decoded aoc decoded object to add entry to
charged_item ast_aoc_s_charged_item
Return values:
0 success
-1 failure

Definition at line 734 of file aoc.c.

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

Referenced by sig_pri_aoc_s_from_pri().

00736 {
00737    struct ast_aoc_s_entry entry = { 0, };
00738 
00739    entry.charged_item = charged_item;
00740    entry.rate_type = AST_AOC_RATE_TYPE_NA;
00741 
00742    return aoc_s_add_entry(decoded, &entry);
00743 }

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:
decoded aoc decoded object to add entry to
charged_item ast_aoc_s_charged_item
code special charging code
Return values:
0 success
-1 failure

Definition at line 709 of file aoc.c.

References aoc_s_add_entry(), AST_AOC_RATE_TYPE_SPECIAL_CODE, ast_aoc_s_entry::charged_item, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, and ast_aoc_s_entry::special_code.

Referenced by sig_pri_aoc_s_from_pri().

00712 {
00713    struct ast_aoc_s_entry entry = { 0, };
00714 
00715    entry.charged_item = charged_item;
00716    entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE;
00717    entry.rate.special_code = code;
00718 
00719    return aoc_s_add_entry(decoded, &entry);
00720 }

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:
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
Return values:
0 success
-1 failure

Definition at line 687 of file aoc.c.

References ast_aoc_volume_rate::amount, aoc_s_add_entry(), AST_AOC_RATE_TYPE_VOLUME, ast_copy_string(), ast_strlen_zero(), ast_aoc_s_entry::charged_item, ast_aoc_volume_rate::currency_name, ast_aoc_volume_rate::multiplier, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, ast_aoc_s_entry::volume, and ast_aoc_volume_rate::volume_unit.

Referenced by sig_pri_aoc_s_from_pri().

00693 {
00694    struct ast_aoc_s_entry entry = { 0, };
00695 
00696    entry.charged_item = charged_item;
00697    entry.rate_type = AST_AOC_RATE_TYPE_VOLUME;
00698    entry.rate.volume.multiplier = multiplier;
00699    entry.rate.volume.amount = amount;
00700    entry.rate.volume.volume_unit = volume_unit;
00701 
00702    if (!ast_strlen_zero(currency_name)) {
00703       ast_copy_string(entry.rate.volume.currency_name, currency_name, sizeof(entry.rate.volume.currency_name));
00704    }
00705 
00706    return aoc_s_add_entry(decoded, &entry);
00707 }

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:
decoded aoc decoded object to add entry to
code special arrangement code
Return values:
0 success
-1 failure

Definition at line 745 of file aoc.c.

References aoc_s_add_entry(), AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT, AST_AOC_RATE_TYPE_SPECIAL_CODE, ast_aoc_s_entry::charged_item, ast_aoc_s_entry::rate, ast_aoc_s_entry::rate_type, and ast_aoc_s_entry::special_code.

00747 {
00748    struct ast_aoc_s_entry entry = { 0, };
00749 
00750    entry.charged_item = AST_AOC_CHARGED_ITEM_SPECIAL_ARRANGEMENT;
00751    entry.rate_type = AST_AOC_RATE_TYPE_SPECIAL_CODE;
00752    entry.rate.special_code = code;
00753 
00754    return aoc_s_add_entry(decoded, &entry);
00755 }

unsigned int ast_aoc_s_get_count ( struct ast_aoc_decoded decoded  ) 

get the number rates associated with an AOC-S message

Definition at line 621 of file aoc.c.

References ast_aoc_decoded::aoc_s_count.

Referenced by sig_pri_aoc_s_from_ast().

00622 {
00623    return decoded->aoc_s_count;
00624 }

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

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

Referenced by sig_pri_aoc_s_from_ast().

00627 {
00628    if (entry_number >= decoded->aoc_s_count) {
00629       return NULL;
00630    }
00631 
00632    return (const struct ast_aoc_s_entry *) &decoded->aoc_s_entries[entry_number];
00633 }

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:
decoded ast_aoc_decoded struct to set values on
id charging 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:
0 success

Definition at line 905 of file aoc.c.

References AST_AOC_CHARGING_ASSOCIATION_ID, AST_AOC_E, ast_aoc_charging_association::charge, ast_aoc_decoded::charging_association, ast_aoc_charging_association::charging_type, ast_aoc_charging_association::id, and ast_aoc_decoded::msg_type.

Referenced by action_aocmessage(), and sig_pri_aoc_e_from_pri().

00906 {
00907    if (decoded->msg_type != AST_AOC_E) {
00908       return -1;
00909    }
00910    memset(&decoded->charging_association, 0, sizeof(decoded->charging_association));
00911    decoded->charging_association.charging_type = AST_AOC_CHARGING_ASSOCIATION_ID;
00912    decoded->charging_association.charge.id = id;
00913    return 0;
00914 }

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

Since:
1.8
Parameters:
decoded ast_aoc_decoded struct to set values on
num charging association number
plan charging 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:
0 success

Definition at line 921 of file aoc.c.

References AST_AOC_CHARGING_ASSOCIATION_NUMBER, AST_AOC_E, ast_copy_string(), ast_strlen_zero(), ast_aoc_charging_association::charge, ast_aoc_decoded::charging_association, ast_aoc_charging_association::charging_type, ast_aoc_decoded::msg_type, ast_aoc_charging_association::number, ast_aoc_charging_association_number::number, and ast_aoc_charging_association_number::plan.

Referenced by action_aocmessage(), and sig_pri_aoc_e_from_pri().

00922 {
00923    if ((decoded->msg_type != AST_AOC_E) || ast_strlen_zero(num)) {
00924       return -1;
00925    }
00926    memset(&decoded->charging_association, 0, sizeof(decoded->charging_association));
00927    decoded->charging_association.charging_type = AST_AOC_CHARGING_ASSOCIATION_NUMBER;
00928    decoded->charging_association.charge.number.plan = plan;
00929    ast_copy_string(decoded->charging_association.charge.number.number, num, sizeof(decoded->charging_association.charge.number.number));
00930 
00931    return 0;
00932 }

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:
decoded ast_aoc_decoded struct to set values on
id billing id
Return values:
0 success

Definition at line 889 of file aoc.c.

References AST_AOC_BILLING_NA, AST_AOC_BILLING_NUM_ENTRIES, and ast_aoc_decoded::billing_id.

Referenced by action_aocmessage(), sig_pri_aoc_d_from_pri(), and sig_pri_aoc_e_from_pri().

00890 {
00891    if ((id >= AST_AOC_BILLING_NUM_ENTRIES) || (id < AST_AOC_BILLING_NA)) {
00892       return -1;
00893    }
00894 
00895    decoded->billing_id = id;
00896 
00897    return 0;
00898 }

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:
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
Return values:
0 success

Definition at line 784 of file aoc.c.

References AST_AOC_MULT_NUM_ENTRIES, AST_AOC_MULT_ONE, ast_copy_string(), ast_strlen_zero(), ast_aoc_decoded::currency_amount, ast_aoc_decoded::currency_name, and ast_aoc_decoded::multiplier.

Referenced by action_aocmessage(), sig_pri_aoc_d_from_pri(), and sig_pri_aoc_e_from_pri().

00788 {
00789 
00790    if (!ast_strlen_zero(name)) {
00791       ast_copy_string(decoded->currency_name, name, sizeof(decoded->currency_name));
00792    }
00793 
00794    decoded->currency_amount = amount;
00795 
00796    if (multiplier && (multiplier < AST_AOC_MULT_NUM_ENTRIES)) {
00797       decoded->multiplier = multiplier;
00798    } else {
00799       decoded->multiplier = AST_AOC_MULT_ONE;
00800    }
00801 
00802    return 0;
00803 }

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:
decoded ast_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:
0 success
-1 failure

Definition at line 934 of file aoc.c.

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

Referenced by sig_pri_send_aoce_termination_request().

00935 {
00936    if (decoded->msg_type != AST_AOC_REQUEST) {
00937       return -1;
00938    }
00939    decoded->termination_request = 1;
00940 
00941    return 0;
00942 }

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:
decoded ast_aoc_decoded struct to set values on
type total type: TOTAL or SUBTOTAL
Note:
If this value is not set, the default for the message is TOTAL
Return values:
0 success

Definition at line 772 of file aoc.c.

References ast_aoc_decoded::total_type.

Referenced by action_aocmessage(), and sig_pri_aoc_d_from_pri().

00774 {
00775    decoded->total_type = type;
00776    return 0;
00777 }

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

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

01196 {
01197    struct ast_aoc_decoded *new_decoded = NULL;
01198    struct ast_aoc_encoded *encoded = NULL;
01199    size_t size;
01200    int res = 0;
01201 
01202    if (!(encoded = ast_aoc_encode(decoded, &size, NULL))) {
01203       return -1;
01204    }
01205 
01206    if (!(new_decoded = ast_aoc_decode(encoded, size, NULL))) {
01207       ast_free(encoded);
01208       return -1;
01209    }
01210 
01211    if (memcmp(new_decoded, decoded, sizeof(struct ast_aoc_decoded))) {
01212       res = -1;
01213    }
01214 
01215    ast_aoc_destroy_decoded(new_decoded);
01216    ast_aoc_destroy_encoded(encoded);
01217    return res;
01218 }


Generated on Sat Mar 10 01:54:30 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7