[svn-commits] dvossel: branch dvossel/generic_aoc r252970 - in /team/dvossel/generic_aoc: c...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Mar 16 17:13:06 CDT 2010
Author: dvossel
Date: Tue Mar 16 17:13:01 2010
New Revision: 252970
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=252970
Log:
sig_analog passes AOC-E and AOC-D messages to libpri
Added:
team/dvossel/generic_aoc/include/asterisk/aoc.h (with props)
team/dvossel/generic_aoc/main/aoc.c (with props)
team/dvossel/generic_aoc/tests/test_aoc.c (with props)
Modified:
team/dvossel/generic_aoc/channels/chan_sip.c
team/dvossel/generic_aoc/channels/sig_pri.c
team/dvossel/generic_aoc/main/manager.c
Modified: team/dvossel/generic_aoc/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/channels/chan_sip.c?view=diff&rev=252970&r1=252969&r2=252970
==============================================================================
--- team/dvossel/generic_aoc/channels/chan_sip.c (original)
+++ team/dvossel/generic_aoc/channels/chan_sip.c Tue Mar 16 17:13:01 2010
@@ -11853,9 +11853,9 @@
reqprep(&req, p, SIP_INFO, 0, 1);
- if (ast_aoc_get_msg_type(decoded) == AOC_D) {
+ if (ast_aoc_get_msg_type(decoded) == AST_AOC_D) {
ast_str_append(&str, 0, "type=active;");
- } else if (ast_aoc_get_msg_type(decoded) == AOC_E) {
+ } else if (ast_aoc_get_msg_type(decoded) == AST_AOC_E) {
ast_str_append(&str, 0, "type=terminated;");
} else {
/* unsupported message type */
@@ -11863,10 +11863,10 @@
}
switch (charging) {
- case AOC_CHARGE_FREE:
+ case AST_AOC_CHARGE_FREE:
ast_str_append(&str, 0, "free-of-charge;");
break;
- case AOC_CHARGE_CURRENCY:
+ case AST_AOC_CHARGE_CURRENCY:
ast_str_append(&str, 0, "charging;");
ast_str_append(&str, 0, "charging-info=currency;");
ast_str_append(&str, 0, "amount=%u;", ast_aoc_get_currency_amount(decoded));
@@ -11875,7 +11875,7 @@
ast_str_append(&str, 0, "currency=%s;", ast_aoc_get_currency_name(decoded));
}
break;
- case AOC_CHARGE_UNIT:
+ case AST_AOC_CHARGE_UNIT:
ast_str_append(&str, 0, "charging;");
ast_str_append(&str, 0, "charging-info=pulse;");
if (unit_entry) {
Modified: team/dvossel/generic_aoc/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/channels/sig_pri.c?view=diff&rev=252970&r1=252969&r2=252970
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.c (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.c Tue Mar 16 17:13:01 2010
@@ -46,6 +46,7 @@
#include "asterisk/cli.h"
#include "asterisk/transcap.h"
#include "asterisk/features.h"
+#include "asterisk/aoc.h"
#include "sig_pri.h"
#ifndef PRI_EVENT_FACILITY
@@ -2091,6 +2092,37 @@
#if defined(HAVE_PRI_AOC_EVENTS)
/*!
* \internal
+ * \brief Convert AST_AOC_MULTIPLER to PRI_AOC_MULTIPLIER.
+ * \since 1.8
+ *
+ * \return pri enum equivalent.
+ */
+static int sig_pri_aoc_multiplier_from_ast(struct ast_aoc_decoded *decoded)
+}
+ switch (ast_aoc_get_currency_multiplier(decoded)) {
+ case AST_AOC_MULT_ONETHOUSANDTH:
+ return PRI_AOC_MULTIPLIER_THOUSANDTH;
+ case AST_AOC_MULT_ONEHUNDREDTH:
+ return PRI_AOC_MULTIPLIER_HUNDREDTH;
+ case AST_AOC_MULT_ONETENTH:
+ return PRI_AOC_MULTIPLIER_TENTH;
+ case AST_AOC_MULT_ONE:
+ return PRI_AOC_MULTIPLIER_ONE;
+ case AST_AOC_MULT_TEN:
+ return PRI_AOC_MULTIPLIER_TEN;
+ case AST_AOC_MULT_HUNDRED:
+ return PRI_AOC_MULTIPLIER_HUNDRED;
+ case AST_AOC_MULT_THOUSAND:
+ return PRI_AOC_MULTIPLIER_THOUSAND;
+ default:
+ return PRI_AOC_MULTIPLIER_ONE;
+ }
+}
+#endif /* defined(HAVE_PRI_AOC_EVENTS) */
+
+#if defined(HAVE_PRI_AOC_EVENTS)
+/*!
+ * \internal
* \brief Convert PRI_AOC_TIME_SCALE to string.
* \since 1.8
*
@@ -2536,6 +2568,174 @@
ast_manager_event_multichan(EVENT_FLAG_AOC, "AOC-E", owner ? 1 : 0, chans, "%s",
ast_str_buffer(msg));
ast_free(msg);
+}
+#endif /* defined(HAVE_PRI_AOC_EVENTS) */
+
+#if defined(HAVE_PRI_AOC_EVENTS)
+/*!
+ * \internal
+ * \brief send an AOC-D message on the current call
+ *
+ * \param pvt sig_pri private channel structure.
+ * \param ast Asterisk channel
+ * \param generic decoded ast AOC message
+ *
+ * \return Nothing
+ *
+ * \note Assumes that the PRI lock is already obtained.
+ */
+static void sig_pri_aocd_from_ast(struct sig_pri_chan *pvt, struct ast_channel *ast, struct ast_aoc_decoded *decoded)
+{
+ struct pri_subcmd_aoc_d aoc_d = { 0, };
+ aoc_d.billing_accumulation = (ast_aoc_get_total_type(decoded) == AST_AOC_TOTAL) ? 1 : 0;
+
+ switch (ast_aoc_get_billing_id(decoded)) {
+ case AST_AOC_BILLING_NORMAL:
+ aoc_d.billing_id = PRI_AOC_D_BILLING_ID_NORMAL;
+ break;
+ case AST_AOC_BILLING_REVERSE_CHARGE:
+ aoc_d.billing_id = PRI_AOC_D_BILLING_ID_REVERSE;
+ break;
+ case AST_AOC_BILLING_CREDIT_CARD:
+ aoc_d.billing_id = PRI_AOC_D_BILLING_ID_CREDIT_CARD;
+ break;
+ case AST_AOC_BILLING_NA:
+ default:
+ aoc_d.billing_id = PRI_AOC_D_BILLING_ID_NOT_AVAILABLE;
+ };
+
+ switch (ast_aoc_get_charge_type(decoded)) {
+ case AST_AOC_CHARGE_FREE:
+ aoc_d.charge = PRI_AOC_DE_CHARGE_FREE;
+ break;
+ case AST_AOC_CHARGE_CURRENCY:
+ {
+ const char *currency_name = ast_aoc_get_currency_name(decoded);
+ aoc_d.charge = PRI_AOC_DE_CHARGE_CURRENCY;
+ aoc_d.recorded.money.amount.cost = ast_aoc_get_currency_amount(decoded);
+ aoc_d.recorded.money.amount.multiplier = sig_pri_aoc_multiplier_from_ast(decoded);
+ if (ast_strlen_zero(currency_name)) {
+ ast_copy_string(aoc_d.recorded.money.currency, currency_name, sizeof(aoc_d.recorded.money.currency));
+ }
+ }
+ break;
+ case AST_AOC_CHARGE_UNIT:
+ {
+ const struct ast_aoc_unit_entry *entry;
+ int i;
+ aoc_d.charge = PRI_AOC_DE_CHARGE_UNITS;
+ for (i = 0; i < ast_aoc_get_unit_count(decoded); i++) {
+ if ((entry = ast_aoc_get_unit_info(decoded, i)) && i < ARRAY_LEN(aoc_d.recorded.unit.item)) {
+ aoc_d.recorded.unit.item[i].number = entry->amount;
+ aoc_d.recorded.unit.item[i].type = entry->type;
+ aoc_d.recorded.unit.num_items++;
+ }
+ }
+ }
+ break;
+ case AST_AOC_CHARGE_NA:
+ default:
+ aoc_d.charge = PRI_AOC_DE_CHARGE_NOT_AVAILABLE;
+ };
+
+ pri_aoc_d(pvt->pri->pri, pvt->call, PVT_TO_CHANNEL(pvt), &aoc_d);
+}
+#endif /* defined(HAVE_PRI_AOC_EVENTS) */
+
+#if defined(HAVE_PRI_AOC_EVENTS)
+/*!
+ * \internal
+ * \brief send an AOC-E message on the current call
+ *
+ * \param pvt sig_pri private channel structure.
+ * \param ast Asterisk channel
+ * \param generic decoded ast AOC message
+ *
+ * \return Nothing
+ *
+ * \note Assumes that the PRI lock is already obtained.
+ */
+static void sig_pri_aoce_from_ast(struct sig_pri_chan *pvt, struct ast_channel *ast, struct ast_aoc_decoded *decoded)
+{
+ struct pri_subcmd_aoc_e aoc_e = { 0, };
+
+
+ if (ast_aoc_get_association_id(decoded)) {
+ aoc_e.associated.charge.id = ast_aoc_get_association_id(decoded);
+ aoc_e.associated.charging_type = PRI_AOC_E_CHARGING_ASSOCIATION_ID;
+ } else if (!ast_strlen_zero(ast_aoc_get_association_number(decoded))) {
+ /* TODO XXX there are more fields here that need to be filled in. Generic representation must be created first */
+ ast_copy_string(aoc_e.associated.charge.number.str, ast_aoc_get_association_number(decoded), sizeof(aoc_e.associated.charge.number.str));
+ aoc_e.associated.charging_type = PRI_AOC_E_CHARGING_ASSOCIATION_NUMBER;
+ } else {
+ aoc_e.associated.charging_type = PRI_AOC_E_CHARGING_ASSOCIATION_NOT_AVAILABLE;
+ }
+
+ switch (ast_aoc_get_billing_id(decoded)) {
+ case AST_AOC_BILLING_NORMAL:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_NORMAL;
+ break;
+ case AST_AOC_BILLING_REVERSE_CHARGE:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_REVERSE;
+ break;
+ case AST_AOC_BILLING_CREDIT_CARD:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_CREDIT_CARD;
+ break;
+ case AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_CALL_FORWARDING_UNCONDITIONAL;
+ break;
+ case AST_AOC_BILLING_CALL_FWD_BUSY:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_CALL_FORWARDING_BUSY;
+ break;
+ case AST_AOC_BILLING_CALL_FWD_NO_REPLY:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_CALL_FORWARDING_NO_REPLY;
+ break;
+ case AST_AOC_BILLING_CALL_DEFLECTION:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_CALL_DEFLECTION;
+ break;
+ case AST_AOC_BILLING_CALL_TRANSFER:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_CALL_TRANSFER;
+ break;
+ case AST_AOC_BILLING_NA:
+ default:
+ aoc_e.billing_id = PRI_AOC_E_BILLING_ID_NOT_AVAILABLE;
+ };
+
+ switch (ast_aoc_get_charge_type(decoded)) {
+ case AST_AOC_CHARGE_FREE:
+ aoc_e.charge = PRI_AOC_DE_CHARGE_FREE;
+ break;
+ case AST_AOC_CHARGE_CURRENCY:
+ {
+ const char *currency_name = ast_aoc_get_currency_name(decoded);
+ aoc_e.charge = PRI_AOC_DE_CHARGE_CURRENCY;
+ aoc_e.recorded.money.amount.cost = ast_aoc_get_currency_amount(decoded);
+ aoc_e.recorded.money.amount.multiplier = sig_pri_aoc_multiplier_from_ast(decoded);
+ if (ast_strlen_zero(currency_name)) {
+ ast_copy_string(aoc_e.recorded.money.currency, currency_name, sizeof(aoc_e.recorded.money.currency));
+ }
+ }
+ break;
+ case AST_AOC_CHARGE_UNIT:
+ {
+ const struct ast_aoc_unit_entry *entry;
+ int i;
+ aoc_e.charge = PRI_AOC_DE_CHARGE_UNITS;
+ for (i = 0; i < ast_aoc_get_unit_count(decoded); i++) {
+ if ((entry = ast_aoc_get_unit_info(decoded, i)) && i < ARRAY_LEN(aoc_e.recorded.unit.item)) {
+ aoc_e.recorded.unit.item[i].number = entry->amount;
+ aoc_e.recorded.unit.item[i].type = entry->type;
+ aoc_e.recorded.unit.num_items++;
+ }
+ }
+ }
+ break;
+ case AST_AOC_CHARGE_NA:
+ default:
+ aoc_e.charge = PRI_AOC_DE_CHARGE_NOT_AVAILABLE;
+ };
+
+ pri_aoc_e(pvt->pri->pri, pvt->call, PVT_TO_CHANNEL(pvt), &aoc_e);
}
#endif /* defined(HAVE_PRI_AOC_EVENTS) */
@@ -5350,6 +5550,30 @@
pri_rel(p->pri);
}
break;
+ case AST_CONTROL_AOC:
+ #if defined(HAVE_PRI_AOC_EVENTS)
+ {
+ struct ast_aoc_decoded *decoded = ast_aoc_decode((struct ast_aoc_encoded *) data, datalen);
+ ast_debug(1, "Received AST_CONTROL_AOC on %s\n", chan->name);
+ if (decoded && p->pri && !pri_grab(p, p->pri)) {
+ switch (ast_aoc_get_msg_type(decoded)) {
+ case AST_AOC_D:
+ sig_pri_aocd_from_ast(p, chan, decoded);
+ break;
+ case AST_AOC_E:
+ sig_pri_aoce_from_ast(p, chan, decoded);
+ break;
+ case AST_AOC_REQUEST:
+ default:
+ /* not supported for pass-through yet */
+ break;
+ };
+ pri_rel(p->pri);
+ }
+ ast_aoc_destroy_decoded(decoded);
+ }
+ #endif /* defined(HAVE_PRI_AOC_EVENTS) */
+ break;
}
return res;
Added: team/dvossel/generic_aoc/include/asterisk/aoc.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/include/asterisk/aoc.h?view=auto&rev=252970
==============================================================================
--- team/dvossel/generic_aoc/include/asterisk/aoc.h (added)
+++ team/dvossel/generic_aoc/include/asterisk/aoc.h Tue Mar 16 17:13:01 2010
@@ -1,0 +1,246 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * David Vossel <dvossel at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief Generic Advice of Charge encode and decode routines
+ *
+ * \author David Vossel <dvossel at digium.com>
+ */
+
+#ifndef _AST_AOC_H_
+#define _AST_AOC_H_
+
+/*! \brief Defines the currency multiplier for an aoc message. */
+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, /* must remain the last item in enum */
+};
+
+/*! \brief Defines the billing id options for an aoc message.
+ * \note AOC-D is limited to NORMAL, REFERSE_CHARGE, and CREDIT_CARD.
+ */
+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, /* must remain the last item in enum */
+};
+
+enum ast_aoc_type {
+ AST_AOC_REQUEST = 0,
+ /* AOC_S */ /* Reserved for AOC-S support */
+ AST_AOC_D,
+ AST_AOC_E, /* aoc-e must remain the last item in this enum */
+};
+
+enum ast_aoc_charge_type {
+ AST_AOC_CHARGE_NA = 0,
+ AST_AOC_CHARGE_FREE,
+ AST_AOC_CHARGE_CURRENCY,
+ AST_AOC_CHARGE_UNIT, /* unit must remain the last item in enum */
+};
+
+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_total_type {
+ AST_AOC_TOTAL = 0,
+ AST_AOC_SUBTOTAL = 1,
+};
+
+struct ast_aoc_unit_entry {
+ unsigned int amount;
+ unsigned int type; /* 1 - 16 by ETSI standard */
+};
+
+/*! \brief AOC Payload Header. Holds all the encoded AOC data to pass on the wire */
+struct ast_aoc_encoded;
+
+/*! \brief Decoded AOC data. This value is used to set all the values in an AOC message before encoding.*/
+struct ast_aoc_decoded;
+
+/*! \brief creates a ast_aoc_decode object of a specific message type
+ *
+ * \param message type AOC-D, AOC-E, or AOC Request
+ * \param charge type, this is ignored if message type is not
+ * AOC-D or AOC-E.
+ * \param 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.
+ *
+ * \retval heap allocated ast_aoc_decoded object ptr on success
+ * \retval NULL failure
+ */
+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);
+
+
+/*! \brief free an ast_aoc_decoded object */
+void *ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded);
+
+/*! \brief free an ast_aoc_encoded object */
+void *ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded);
+
+/*! \brief decodes an encoded aoc payload.
+ *
+ * \param ast_aoc_encoded, the encoded payload to decode.
+ * \param total size of encoded payload
+ *
+ * \retval heap allocated ast_aoc_decoded object ptr on success
+ * \retval NULL failure
+ */
+struct ast_aoc_decoded *ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size);
+
+/*! \brief encodes a decoded aoc structure so it can be passed on the wire
+ *
+ * \param ast_aoc_decoded struct to be encoded
+ * \param output parameter representing size of encoded data
+ *
+ * \retval pointer to encoded data
+ * \retval NULL failure
+ */
+struct ast_aoc_encoded *ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size);
+
+/*! \brief Sets the type of total for a AOC-D message
+ *
+ * \note If this value is not set, the default for the message is TOTAL
+ *
+ * \param total type, TOTAL or SUBTOTAL
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded, const enum ast_aoc_total_type type);
+
+/*! \brief Sets the currency values for a AOC-D or AOC-E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param currency amount REQUIRED
+ * \param currency multiplier REQUIRED, 0 or undefined value defaults to AST_AOC_MULT_ONE.
+ * \param currency name OPTIONAL
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_currency_info(struct ast_aoc_decoded *decoded,
+ const unsigned int amount,
+ const enum ast_aoc_currency_multiplier multiplier,
+ const char *name);
+
+/*! \brief Adds a unit entry into the list of units
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param number of units
+ * \param unit type
+ *
+ * \retval 0 success
+ */
+int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded,
+ const unsigned int amount,
+ const unsigned int type);
+
+/*! \brief set the billing id for a AOC-D or AST_AOC_E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param billing id
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id);
+
+/*! \brief set the charging association id for an AST_AOC_E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param charging association identifier
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id);
+
+/*! \brief set the charging accociation number for an AOC-E message
+ *
+ * \param ast_aoc_decoded struct to set values on
+ * \param charging association number
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num);
+
+/*! \brief get the message type, AOC-D, AOC-E, or AOC Request */
+enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the charging type for an AOC-D or AOC-E message */
+enum ast_aoc_charge_type ast_aoc_get_charge_type(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the types of AOC requested for when message type is AOC Request */
+enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the type of total for a AOC-D message */
+enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the currency amount for AOC-D and AOC-E messages*/
+unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the number of unit entries for AOC-D and AOC-E messages*/
+unsigned int ast_aoc_get_unit_count(struct ast_aoc_decoded *decoded);
+
+/*! \brief get a specific unit entry.
+ * \note This can be used in conjunction with ast_aoc_get_unit_count to create
+ * a unit entry iterator.
+ */
+const struct ast_aoc_unit_entry *ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number);
+
+/*! \brief get the currency multiplier for AOC-D and AOC-E messages */
+enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the currency multiplier for AOC-D and AOC-E messages in decimal format */
+const char *ast_aoc_get_currency_multiplier_decimal(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the currency name for AOC-D and AOC-E messages*/
+const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the billing id for AOC-D and AOC-E messages*/
+enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the charging association id for AOC-E messages*/
+int ast_aoc_get_association_id(struct ast_aoc_decoded *decoded);
+
+/*! \brief get the charging association number for AOC-E messages*/
+const char *ast_aoc_get_association_number(struct ast_aoc_decoded *decoded);
+
+/*! \brief test aoc encode decode routines.
+ * \note This function verifies that a decoded message matches itself after
+ * the encode decode routine.
+ */
+int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded);
+#endif
Propchange: team/dvossel/generic_aoc/include/asterisk/aoc.h
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dvossel/generic_aoc/include/asterisk/aoc.h
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/dvossel/generic_aoc/include/asterisk/aoc.h
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added: team/dvossel/generic_aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/main/aoc.c?view=auto&rev=252970
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (added)
+++ team/dvossel/generic_aoc/main/aoc.c Tue Mar 16 17:13:01 2010
@@ -1,0 +1,617 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 2010, Digium, Inc.
+ *
+ * David Vossel <dvossel at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*!
+ * \file
+ * \brief generic AOC payload generation encoding and decoding
+ *
+ * \author David Vossel <dvossel at digium.com>
+ */
+
+#include "asterisk.h"
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
+
+#include "asterisk/aoc.h"
+#include "asterisk/utils.h"
+#include "asterisk/strings.h"
+#include "asterisk/_private.h"
+
+/* Encoded Payload Flags */
+#define AST_AOC_ENCODED_TYPE_REQUEST (0 << 0)
+#define AST_AOC_ENCODED_TYPE_D (1 << 0)
+#define AST_AOC_ENCODED_TYPE_E (2 << 0)
+/* #define AOC_PAYLOAD_TYPE_S (3 << 0) This is not yet supported, but reserve this for future use */
+
+#define AST_AOC_ENCODED_REQUEST_S (1 << 2)
+#define AST_AOC_ENCODED_REQUEST_D (1 << 3)
+#define AST_AOC_ENCODED_REQUEST_E (1 << 4)
+
+#define AST_AOC_ENCODED_CHARGE_NA (0 << 5)
+#define AST_AOC_ENCODED_CHARGE_FREE (1 << 5)
+#define AST_AOC_ENCODED_CHARGE_CURRENCY (2 << 5)
+#define AST_AOC_ENCODED_CHARGE_UNIT (3 << 5)
+
+#define AST_AOC_ENCODED_CHARGE_SUBTOTAL (1 << 7)
+#define AST_AOC_ENCODED_CHARGE_TOTAL (0 << 7)
+
+#define AST_AOC_ENCODE_VERSION 1
+
+#define AOC_CURRENCY_NAME_SIZE (10 + 1)
+
+/* AOC Payload Header. Holds all the encoded AOC data to pass on the wire */
+struct ast_aoc_encoded {
+ uint8_t version;
+ uint8_t flags;
+ uint16_t datalen;
+ unsigned char data[0];
+};
+
+/* Decoded AOC data */
+struct ast_aoc_decoded {
+ enum ast_aoc_type msg_type;
+ enum ast_aoc_charge_type charge_type;
+ enum ast_aoc_request request_flag;
+ enum ast_aoc_total_type total_type;
+
+ /* currency information */
+ enum ast_aoc_currency_multiplier multiplier;
+ unsigned int currency_amount;
+ char currency_name[AOC_CURRENCY_NAME_SIZE];
+
+ /* unit information */
+ int unit_count;
+ struct ast_aoc_unit_entry unit_list[32];
+
+ /* Billing Id */
+ enum ast_aoc_billing_id billing_id;
+
+ /* Charging Association information */
+ int charging_association_id;
+ char charging_association_number[32];
+};
+
+struct aoc_pl_ie_hdr {
+ uint8_t ie_id;
+ uint8_t datalen;
+ char data[0];
+};
+
+/* AOC Payload Information Elements */
+#define AOC_IE_CURRENCY 1
+struct aoc_ie_currency {
+ uint8_t multiplier;
+ uint32_t amount;
+ char name[AOC_CURRENCY_NAME_SIZE];
+};
+
+#define AOC_IE_UNIT 2
+struct aoc_ie_unit {
+ uint32_t amount;
+ uint8_t type;
+};
+
+#define AOC_IE_BILLING 3
+struct aoc_ie_billing {
+ uint8_t id;
+};
+
+#define AOC_IE_CHARGING_ASSOCIATION 4
+struct aoc_ie_charging_association {
+ int32_t charge_id;
+ char charge_number[32];
+};
+
+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)
+{
+ struct ast_aoc_decoded *decoded = NULL;
+
+ /* verify input */
+ if (((unsigned int) charge_type > AST_AOC_CHARGE_UNIT) ||
+ ((unsigned int) msg_type > AST_AOC_E) ||
+ ((msg_type == AST_AOC_REQUEST) && !requests)) {
+
+ ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object, invalid input\n");
+ return NULL;
+ }
+
+ if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
+ ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
+ return NULL;
+ }
+
+ decoded->msg_type = msg_type;
+
+ if (msg_type == AST_AOC_REQUEST) {
+ decoded->request_flag = requests;
+ } else if ((msg_type == AST_AOC_D) || (msg_type == AST_AOC_E)) {
+ decoded->charge_type = charge_type;
+ }
+
+ return decoded;
+}
+
+void *ast_aoc_destroy_decoded(struct ast_aoc_decoded *decoded)
+{
+ ast_free(decoded);
+ return NULL;
+}
+
+void *ast_aoc_destroy_encoded(struct ast_aoc_encoded *encoded)
+{
+ ast_free(encoded);
+ return NULL;
+}
+
+static int aoc_parse_ie(struct ast_aoc_decoded *decoded, unsigned char *data, unsigned int datalen)
+{
+ int ie;
+ int len;
+
+ while (datalen >= 2) {
+ ie = data[0];
+ len = data[1];
+ if (len > datalen -2) {
+ ast_log(LOG_ERROR, "AOC information element length exceeds the total message size\n");
+ return -1;
+ }
+
+ switch(ie) {
+ case AOC_IE_CURRENCY:
+ if (len == sizeof(struct aoc_ie_currency)) {
+ struct aoc_ie_currency ie;
+ memcpy(&ie, data + 2, len);
+ decoded->currency_amount = ntohl(ie.amount);
+ decoded->multiplier = ie.multiplier; /* only one byte */
+ memcpy(decoded->currency_name, ie.name, sizeof(decoded->currency_name));
+
+ } else {
+ ast_log(LOG_WARNING, "Recieved invalid currency ie\n");
+ }
+ break;
+ case AOC_IE_UNIT:
+ if (len == sizeof(struct aoc_ie_unit)) {
+ struct aoc_ie_unit ie;
+ memcpy(&ie, data + 2, len);
+ ast_aoc_add_unit_entry(decoded, ntohl(ie.amount), ie.type);
+ } else {
+ ast_log(LOG_WARNING, "Recieved invalid unit ie\n");
+ }
+ break;
+ case AOC_IE_BILLING:
+ if (len == sizeof(struct aoc_ie_billing)) {
+ struct aoc_ie_billing ie;
+ memcpy(&ie, data + 2, len);
+ decoded->billing_id = ie.id; /* only one byte */
+ } else {
+ ast_log(LOG_WARNING, "Recieved invalid billing ie\n");
+ }
+ break;
+ case AOC_IE_CHARGING_ASSOCIATION:
+ if (len == sizeof(struct aoc_ie_charging_association)) {
+ struct aoc_ie_charging_association ie;
+ memcpy(&ie, data + 2, len);
+ decoded->charging_association_id = ntohl(ie.charge_id);
+ memcpy(decoded->charging_association_number, ie.charge_number, sizeof(decoded->charging_association_number));
+ } else {
+ ast_log(LOG_WARNING, "Recieved invalid charging association ie\n");
+ }
+ break;
+ default:
+ ast_log(LOG_WARNING, "Unknown AOC Information Element, ignoring.\n");
+ }
+
+ datalen -= (len + 2);
+ data += (len + 2);
+ }
+ return 0;
+}
+
+struct ast_aoc_decoded *ast_aoc_decode(struct ast_aoc_encoded *encoded, size_t size)
+{
+ struct ast_aoc_decoded *decoded;
+
+ /* verify our encoded payload is actually large enough to hold all the ies */
+ if ((size - (sizeof(struct ast_aoc_encoded)) != ntohs(encoded->datalen))) {
+ ast_log(LOG_WARNING, "Corrupted aoc encoded object, can not decode\n");
+ return NULL;
+ }
+
+ if (!(decoded = ast_calloc(1, sizeof(struct ast_aoc_decoded)))) {
+ ast_log(LOG_WARNING, "Failed to create ast_aoc_decoded object \n");
+ return NULL;
+ }
+
+ /* decode flags */
+ if (encoded->flags & AST_AOC_ENCODED_TYPE_E) {
+ decoded->msg_type = AST_AOC_E;
+ } else if (encoded->flags & AST_AOC_ENCODED_TYPE_D) {
+ decoded->msg_type = AST_AOC_D;
+ } else {
+ decoded->msg_type = AST_AOC_REQUEST;
+ }
+
+ if (decoded->msg_type == AST_AOC_REQUEST) {
+ if (encoded->flags & AST_AOC_ENCODED_REQUEST_S) {
+ decoded->request_flag |= AST_AOC_REQUEST_S;
+ }
+ if (encoded->flags & AST_AOC_ENCODED_REQUEST_D) {
+ decoded->request_flag |= AST_AOC_REQUEST_D;
+ }
+ if (encoded->flags & AST_AOC_ENCODED_REQUEST_E) {
+ decoded->request_flag |= AST_AOC_REQUEST_E;
+ }
+ } else {
+ if ((encoded->flags & AST_AOC_ENCODED_CHARGE_UNIT) == AST_AOC_ENCODED_CHARGE_UNIT) {
+ decoded->charge_type = AST_AOC_CHARGE_UNIT;
+ } else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_CURRENCY) == AST_AOC_ENCODED_CHARGE_CURRENCY) {
+ decoded->charge_type = AST_AOC_CHARGE_CURRENCY;
+ } else if ((encoded->flags & AST_AOC_ENCODED_CHARGE_FREE) == AST_AOC_ENCODED_CHARGE_FREE) {
+ decoded->charge_type = AST_AOC_CHARGE_FREE;
+ } else {
+ decoded->charge_type = AST_AOC_CHARGE_NA;
+ }
+
+ if (encoded->flags & AST_AOC_ENCODED_CHARGE_SUBTOTAL) {
+ decoded->total_type = AST_AOC_SUBTOTAL;
+ }
+ }
+
+ /* decode information elements */
+ aoc_parse_ie(decoded, encoded->data, ntohs(encoded->datalen));
+ return decoded;
+}
+
+struct aoc_ie_data {
+ unsigned char buf[1024];
+ int pos;
+};
+
+/*! \brief append an AOC information element
+ * \note data is expecte to already be in network byte order at this point
+ */
+static int aoc_append_ie(struct aoc_ie_data *ied, unsigned short ie_id, const void *data, unsigned short datalen)
+{
+ if (datalen > ((int)sizeof(ied->buf) - ied->pos)) {
+ ast_log(LOG_WARNING, "Failure to append AOC information element, out of space \n");
+ return -1;
+ }
+ ied->buf[ied->pos++] = ie_id;
+ ied->buf[ied->pos++] = datalen;
+ memcpy(ied->buf + ied->pos, data, datalen);
+ ied->pos += datalen;
+ return 0;
+}
+
+static void aoc_create_ie_data(struct ast_aoc_decoded *decoded, struct aoc_ie_data *ied)
+{
+
+ ied->pos = 0;
+
+ if (decoded->currency_amount) {
+ struct aoc_ie_currency ie = {
+ .amount = htonl(decoded->currency_amount),
+ .multiplier = decoded->multiplier, /* only one byte */
+ .name = { 0, },
+ };
+ if (!ast_strlen_zero(decoded->currency_name)) {
+ ast_copy_string(ie.name, decoded->currency_name, sizeof(ie.name));
+ }
+
+ aoc_append_ie(ied, AOC_IE_CURRENCY, (const void *) &ie, sizeof(ie));
+ }
+
+ if (decoded->unit_count) {
+ struct aoc_ie_unit ie = { 0 };
+ int i;
+ for (i = 0; i < decoded->unit_count; i++) {
+ ie.amount = htonl(decoded->unit_list[i].amount);
+ ie.type = decoded->unit_list[i].type; /* only one byte */
+ aoc_append_ie(ied, AOC_IE_UNIT, (const void *) &ie, sizeof(ie));
+ }
+ }
+
+ if (decoded->billing_id) {
+ struct aoc_ie_billing ie;
+ ie.id = decoded->billing_id; /* only one byte */
+ aoc_append_ie(ied, AOC_IE_BILLING, (const void *) &ie, sizeof(ie));
+ }
+
+ if (decoded->charging_association_id ||
+ !ast_strlen_zero(decoded->charging_association_number)) {
+ struct aoc_ie_charging_association ie = { 0 };
+ ie.charge_id = htonl(decoded->charging_association_id);
+ if (!ast_strlen_zero(decoded->charging_association_number)) {
+ ast_copy_string(ie.charge_number, decoded->charging_association_number, sizeof(ie.charge_number));
+ }
+ aoc_append_ie(ied, AOC_IE_CHARGING_ASSOCIATION, (const void *) &ie, sizeof(ie));
+ }
+}
+
+struct ast_aoc_encoded *ast_aoc_encode(struct ast_aoc_decoded *decoded, size_t *out_size)
+{
+ struct aoc_ie_data ied;
+ struct ast_aoc_encoded *encoded = NULL;
+ size_t size = 0;
+
+ if (!decoded || !out_size) {
+ return NULL;
+ }
+ *out_size = 0;
+
+ /* create information element buffer before allocating the payload,
+ * by doing this the exact size of the payload + the id data can be
+ * allocated all at once. */
+ aoc_create_ie_data(decoded, &ied);
+
+ size = sizeof(struct ast_aoc_encoded) + ied.pos;
+
+ if (!(encoded = ast_calloc(1, size))) {
+ ast_log(LOG_WARNING, "Failed to create ast_aoc_encoded object during decode routine. \n");
+ return NULL;
+ }
+
+ /* -- Set ie data buffer */
+ if (ied.pos) {
+ /* this is safe because encoded was allocated to fit this perfectly */
+ memcpy(encoded->data, ied.buf, ied.pos);
+ encoded->datalen = htons(ied.pos);
+ }
+
+ /* --- Set Flags --- */
+ switch (decoded->msg_type) {
+ case AST_AOC_D:
+ encoded->flags = AST_AOC_ENCODED_TYPE_D;
+ break;
+ case AST_AOC_E:
+ encoded->flags = AST_AOC_ENCODED_TYPE_E;
+ break;
+ case AST_AOC_REQUEST:
+ encoded->flags = AST_AOC_ENCODED_TYPE_REQUEST;
+ default:
+ break;
+ }
+
+ /* if it is type request, set the types requested, else set charge type */
+ if (decoded->msg_type == AST_AOC_REQUEST) {
+ if (decoded->request_flag & AST_AOC_REQUEST_S) {
+ encoded->flags |= AST_AOC_ENCODED_REQUEST_S;
+ }
+ if (decoded->request_flag & AST_AOC_REQUEST_D) {
+ encoded->flags |= AST_AOC_ENCODED_REQUEST_D;
+ }
+ if (decoded->request_flag & AST_AOC_REQUEST_E) {
+ encoded->flags |= AST_AOC_ENCODED_REQUEST_E;
+ }
+ } else {
+ switch (decoded->charge_type) {
+ case AST_AOC_CHARGE_UNIT:
+ encoded->flags |= AST_AOC_ENCODED_CHARGE_UNIT;
+ break;
+ case AST_AOC_CHARGE_CURRENCY:
+ encoded->flags |= AST_AOC_ENCODED_CHARGE_CURRENCY;
+ break;
+ case AST_AOC_CHARGE_FREE:
+ encoded->flags |= AST_AOC_ENCODED_CHARGE_FREE;
+ case AST_AOC_CHARGE_NA:
+ default:
+ encoded->flags |= AST_AOC_ENCODED_CHARGE_NA;
+ break;
+ }
+
+ if (decoded->total_type == AST_AOC_SUBTOTAL) {
+ encoded->flags |= AST_AOC_ENCODED_CHARGE_SUBTOTAL;
+ }
+ }
+
+ /* --- Set Version Number --- */
+ encoded->version = AST_AOC_ENCODE_VERSION;
+
+ /* set the output size */
+ *out_size = size;
+
+ return encoded;
+}
+
+enum ast_aoc_type ast_aoc_get_msg_type(struct ast_aoc_decoded *decoded)
+{
+ return decoded->msg_type;
+}
+
+enum ast_aoc_charge_type ast_aoc_get_charge_type(struct ast_aoc_decoded *decoded)
+{
+ return decoded->charge_type;
+}
+
+enum ast_aoc_request ast_aoc_get_request(struct ast_aoc_decoded *decoded)
+{
+ return decoded->request_flag;
+}
+
+int ast_aoc_set_total_type(struct ast_aoc_decoded *decoded,
+ const enum ast_aoc_total_type type)
+{
+ decoded->total_type = type;
+ return 0;
+}
+
+enum ast_aoc_total_type ast_aoc_get_total_type(struct ast_aoc_decoded *decoded)
+{
+ return decoded->total_type;
+}
+
+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)
+{
+
+ if (!ast_strlen_zero(name)) {
+ ast_copy_string(decoded->currency_name, name, sizeof(decoded->currency_name));
+ }
+
+ decoded->currency_amount = amount;
+
+ if (multiplier && (multiplier < AST_AOC_MULT_NUM_ENTRIES)) {
+ decoded->multiplier = multiplier;
+ } else {
+ decoded->multiplier = AST_AOC_MULT_ONE;
+ }
+
+ return 0;
+}
+
+unsigned int ast_aoc_get_currency_amount(struct ast_aoc_decoded *decoded)
+{
+ return decoded->currency_amount;
+}
+
+enum ast_aoc_currency_multiplier ast_aoc_get_currency_multiplier(struct ast_aoc_decoded *decoded)
+{
+ return decoded->multiplier;
+}
+
+const char *ast_aoc_get_currency_multiplier_decimal(struct ast_aoc_decoded *decoded)
+{
+
+ switch (decoded->multiplier) {
+ case AST_AOC_MULT_ONETHOUSANDTH:
+ return "0.001";
+ case AST_AOC_MULT_ONEHUNDREDTH:
+ return "0.01";
+ case AST_AOC_MULT_ONETENTH:
+ return "0.1";
+ case AST_AOC_MULT_ONE:
+ return "1.0";
+ case AST_AOC_MULT_TEN:
+ return "10.0";
+ case AST_AOC_MULT_HUNDRED:
+ return "100.0";
+ case AST_AOC_MULT_THOUSAND:
+ return "1000.0";
+ default:
+ return "1.0";
+ }
+}
+
+const char *ast_aoc_get_currency_name(struct ast_aoc_decoded *decoded)
+{
+ return decoded->currency_name;
+}
+
+int ast_aoc_add_unit_entry(struct ast_aoc_decoded *decoded,
+ const unsigned int amount,
+ const unsigned int type)
+{
+ if ((decoded->msg_type == AST_AOC_REQUEST) ||
+ (decoded->unit_count >= ARRAY_LEN(decoded->unit_list))) {
+ return -1;
+ }
+
+ decoded->unit_list[decoded->unit_count].amount = amount;
+ decoded->unit_list[decoded->unit_count].type = type;
+ decoded->unit_count++;
+
+ return 0;
+}
+
+const struct ast_aoc_unit_entry *ast_aoc_get_unit_info(struct ast_aoc_decoded *decoded, unsigned int entry_number)
+{
+ if (entry_number >= decoded->unit_count) {
+ return NULL;
+ }
+
+ return (const struct ast_aoc_unit_entry *) &decoded->unit_list[entry_number];
+}
+
+unsigned int ast_aoc_get_unit_count(struct ast_aoc_decoded *decoded)
+{
+ return decoded->unit_count;
+}
+
+int ast_aoc_set_billing_id(struct ast_aoc_decoded *decoded, const enum ast_aoc_billing_id id)
+{
+ if ((id >= AST_AOC_BILLING_NUM_ENTRIES) || (id < AST_AOC_BILLING_NA)) {
+ return -1;
+ }
+
+ decoded->billing_id = id;
+
+ return 0;
+}
+
+enum ast_aoc_billing_id ast_aoc_get_billing_id(struct ast_aoc_decoded *decoded)
+{
+ return decoded->billing_id;
+}
+
+int ast_aoc_set_association_id(struct ast_aoc_decoded *decoded, const int id)
+{
+ if (decoded->msg_type != AST_AOC_E) {
+ return -1;
+ }
+ decoded->charging_association_id = id;
+ return 0;
+}
+
+int ast_aoc_get_association_id(struct ast_aoc_decoded *decoded)
+{
+ return decoded->charging_association_id;
+}
+
+int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num)
+{
+ if ((decoded->msg_type != AST_AOC_E) || ast_strlen_zero(num)) {
+ return -1;
+ }
+
+ ast_copy_string(decoded->charging_association_number, num, sizeof(decoded->charging_association_number));
+
+ return 0;
+}
+
+const char *ast_aoc_get_association_number(struct ast_aoc_decoded *decoded)
+{
+ return decoded->charging_association_number;
+}
+
+int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded)
+{
+ struct ast_aoc_decoded *new = NULL;
+ struct ast_aoc_encoded *encoded = NULL;
+ size_t size;
+ int res = 0;
+
+ if (!(encoded = ast_aoc_encode(decoded, &size))) {
+ return -1;
+ }
+
+ if (!(new = ast_aoc_decode(encoded, size))) {
+ ast_free(encoded);
+ return -1;
+ }
+
+ if (memcmp(new, decoded, sizeof(struct ast_aoc_decoded))) {
+ res = -1;
+ }
+
+ ast_aoc_destroy_decoded(new);
+ ast_aoc_destroy_encoded(encoded);
+ return res;
+}
Propchange: team/dvossel/generic_aoc/main/aoc.c
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: team/dvossel/generic_aoc/main/aoc.c
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Propchange: team/dvossel/generic_aoc/main/aoc.c
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: team/dvossel/generic_aoc/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/main/manager.c?view=diff&rev=252970&r1=252969&r2=252970
==============================================================================
--- team/dvossel/generic_aoc/main/manager.c (original)
+++ team/dvossel/generic_aoc/main/manager.c Tue Mar 16 17:13:01 2010
@@ -3528,7 +3528,7 @@
enum ast_aoc_type _msgtype;
enum ast_aoc_charge_type _chargetype;
enum ast_aoc_currency_multiplier _mult = AST_AOC_MULT_ONE;
- enum ast_aoc_total_type _totaltype = AOC_TOTAL;
+ enum ast_aoc_total_type _totaltype = AST_AOC_TOTAL;
enum ast_aoc_billing_id _billingid = AST_AOC_BILLING_NA;
unsigned int _currencyamount = 0;
int _association_id = 0;
@@ -3562,22 +3562,22 @@
goto aocmessage_cleanup;
}
- _msgtype = strcasecmp(msgtype, "d") ? AOC_E : AOC_D;
+ _msgtype = strcasecmp(msgtype, "d") ? AST_AOC_E : AST_AOC_D;
if (!strcasecmp(chargetype, "NA")) {
- _chargetype = AOC_CHARGE_NA;
+ _chargetype = AST_AOC_CHARGE_NA;
} else if (!strcasecmp(chargetype, "Free")) {
- _chargetype = AOC_CHARGE_FREE;
+ _chargetype = AST_AOC_CHARGE_FREE;
} else if (!strcasecmp(chargetype, "Currency")) {
- _chargetype = AOC_CHARGE_CURRENCY;
+ _chargetype = AST_AOC_CHARGE_CURRENCY;
} else if (!strcasecmp(chargetype, "Unit")) {
- _chargetype = AOC_CHARGE_UNIT;
+ _chargetype = AST_AOC_CHARGE_UNIT;
} else {
astman_send_error(s, m, "Invalid ChargeType");
goto aocmessage_cleanup;
}
- if (_chargetype == AOC_CHARGE_CURRENCY) {
+ if (_chargetype == AST_AOC_CHARGE_CURRENCY) {
if (ast_strlen_zero(currencyamount) || (sscanf(currencyamount, "%30u", &_currencyamount) != 1)) {
astman_send_error(s, m, "Invalid CurrencyAmount, CurrencyAmount is a required when ChargeType is Currency");
@@ -3606,9 +3606,9 @@
}
}
- if (_msgtype == AOC_D) {
+ if (_msgtype == AST_AOC_D) {
if (!ast_strlen_zero(totaltype) && !strcasecmp(totaltype, "subtotal")) {
- _totaltype = AOC_SUBTOTAL;
+ _totaltype = AST_AOC_SUBTOTAL;
}
if (ast_strlen_zero(aocdbillingid)) {
@@ -3659,9 +3659,9 @@
goto aocmessage_cleanup;
}
- if (_chargetype == AOC_CHARGE_CURRENCY) {
+ if (_chargetype == AST_AOC_CHARGE_CURRENCY) {
ast_aoc_set_currency_info(decoded, _currencyamount, _mult, ast_strlen_zero(currencyname) ? NULL : currencyname);
- } else if (_chargetype == AOC_CHARGE_UNIT) {
+ } else if (_chargetype == AST_AOC_CHARGE_UNIT) {
[... 344 lines stripped ...]
More information about the svn-commits
mailing list