[asterisk-commits] dvossel: branch dvossel/generic_aoc r253711 - in /team/dvossel/generic_aoc: c...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Mar 22 09:20:39 CDT 2010
Author: dvossel
Date: Mon Mar 22 09:20:34 2010
New Revision: 253711
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=253711
Log:
addition of charging association plan representation in generic aoc
Modified:
team/dvossel/generic_aoc/channels/sig_pri.c
team/dvossel/generic_aoc/include/asterisk/aoc.h
team/dvossel/generic_aoc/main/aoc.c
team/dvossel/generic_aoc/main/manager.c
team/dvossel/generic_aoc/tests/test_aoc.c
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=253711&r1=253710&r2=253711
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.c (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.c Mon Mar 22 09:20:34 2010
@@ -2646,7 +2646,7 @@
if (!aoc_e->associated.charge.number.valid) {
break;
}
- /*TODO do charging association number correctly */
+ ast_aoc_set_association_number(decoded, aoc_e->associated.charge.number.str, aoc_e->associated.charge.number.plan);
break;
case PRI_AOC_E_CHARGING_ASSOCIATION_ID:
ast_aoc_set_association_id(decoded, aoc_e->associated.charge.id);
@@ -2905,8 +2905,8 @@
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.charge.number.plan = ast_aoc_get_association_plan(decoded);
aoc_e.associated.charging_type = PRI_AOC_E_CHARGING_ASSOCIATION_NUMBER;
} else {
aoc_e.associated.charging_type = PRI_AOC_E_CHARGING_ASSOCIATION_NOT_AVAILABLE;
Modified: team/dvossel/generic_aoc/include/asterisk/aoc.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/include/asterisk/aoc.h?view=diff&rev=253711&r1=253710&r2=253711
==============================================================================
--- team/dvossel/generic_aoc/include/asterisk/aoc.h (original)
+++ team/dvossel/generic_aoc/include/asterisk/aoc.h Mon Mar 22 09:20:34 2010
@@ -191,10 +191,18 @@
*
* \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);
+ * \param charging association plan
+ * unknown(0),
+ * public(1) - The numbering plan is according to ITU-T E.164,
+ * nsapEncoded(2),
+ * data(3) - Reserved,
+ * telex(4) - Reserved,
+ * private(5),
+ * nationalStandard(8) - Reserved
+ *
+ * \retval 0 success
+ */
+int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan);
/*! \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);
@@ -235,6 +243,8 @@
/*! \brief get the charging association id for AOC-E messages*/
int ast_aoc_get_association_id(struct ast_aoc_decoded *decoded);
+unsigned short ast_aoc_get_association_plan(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);
Modified: team/dvossel/generic_aoc/main/aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/main/aoc.c?view=diff&rev=253711&r1=253710&r2=253711
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (original)
+++ team/dvossel/generic_aoc/main/aoc.c Mon Mar 22 09:20:34 2010
@@ -82,6 +82,7 @@
/* Charging Association information */
int charging_association_id;
+ uint8_t charging_association_plan;
char charging_association_number[32];
};
@@ -113,6 +114,7 @@
#define AOC_IE_CHARGING_ASSOCIATION 4
struct aoc_ie_charging_association {
int32_t charge_id;
+ uint8_t charge_plan;
char charge_number[32];
};
@@ -208,6 +210,7 @@
struct aoc_ie_charging_association ie;
memcpy(&ie, data + 2, len);
decoded->charging_association_id = ntohl(ie.charge_id);
+ decoded->charging_association_plan = ie.charge_plan;
memcpy(decoded->charging_association_number, ie.charge_number, sizeof(decoded->charging_association_number));
} else {
ast_log(LOG_WARNING, "Recieved invalid charging association ie\n");
@@ -337,6 +340,7 @@
!ast_strlen_zero(decoded->charging_association_number)) {
struct aoc_ie_charging_association ie = { 0 };
ie.charge_id = htonl(decoded->charging_association_id);
+ ie.charge_plan = decoded->charging_association_plan; /* only one byte */
if (!ast_strlen_zero(decoded->charging_association_number)) {
ast_copy_string(ie.charge_number, decoded->charging_association_number, sizeof(ie.charge_number));
}
@@ -575,12 +579,13 @@
return decoded->charging_association_id;
}
-int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num)
+int ast_aoc_set_association_number(struct ast_aoc_decoded *decoded, const char *num, uint8_t plan)
{
if ((decoded->msg_type != AST_AOC_E) || ast_strlen_zero(num)) {
return -1;
}
+ decoded->charging_association_plan = plan;
ast_copy_string(decoded->charging_association_number, num, sizeof(decoded->charging_association_number));
return 0;
@@ -589,6 +594,11 @@
const char *ast_aoc_get_association_number(struct ast_aoc_decoded *decoded)
{
return decoded->charging_association_number;
+}
+
+unsigned short ast_aoc_get_association_plan(struct ast_aoc_decoded *decoded)
+{
+ return decoded->charging_association_plan;
}
int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded)
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=253711&r1=253710&r2=253711
==============================================================================
--- team/dvossel/generic_aoc/main/manager.c (original)
+++ team/dvossel/generic_aoc/main/manager.c Mon Mar 22 09:20:34 2010
@@ -3524,6 +3524,7 @@
const char *aocdbillingid = astman_get_header(m, "AOCDBillingId");
const char *association_id= astman_get_header(m, "ChargingAssociationId");
const char *association_num = astman_get_header(m, "ChargingAssociationNumber");
+ const char *association_plan = astman_get_header(m, "ChargingAssociationPlan");
enum ast_aoc_type _msgtype;
enum ast_aoc_charge_type _chargetype;
@@ -3532,6 +3533,7 @@
enum ast_aoc_billing_id _billingid = AST_AOC_BILLING_NA;
unsigned int _currencyamount = 0;
int _association_id = 0;
+ unsigned int _association_plan = 0;
struct ast_channel *chan = NULL;
struct ast_aoc_decoded *decoded = NULL;
@@ -3650,7 +3652,15 @@
if (!ast_strlen_zero(association_id) && (sscanf(association_id, "%30d", &_association_id) != 1)) {
astman_send_error(s, m, "Invalid ChargingAssociationId");
}
-
+ if (!ast_strlen_zero(association_plan) && (sscanf(association_plan, "%30u", &_association_plan) != 1)) {
+ astman_send_error(s, m, "Invalid ChargingAssociationId");
+ }
+
+ if (_association_id) {
+ ast_aoc_set_association_id(decoded, _association_id);
+ } else if (!ast_strlen_zero(association_num)) {
+ ast_aoc_set_association_number(decoded, association_num, _association_plan);
+ }
}
/* create decoded object and start setting values */
@@ -3682,8 +3692,6 @@
}
- ast_aoc_set_association_number(decoded, association_num);
- ast_aoc_set_association_id(decoded, _association_id);
ast_aoc_set_billing_id(decoded, _billingid);
ast_aoc_set_total_type(decoded, _totaltype);
Modified: team/dvossel/generic_aoc/tests/test_aoc.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/tests/test_aoc.c?view=diff&rev=253711&r1=253710&r2=253711
==============================================================================
--- team/dvossel/generic_aoc/tests/test_aoc.c (original)
+++ team/dvossel/generic_aoc/tests/test_aoc.c Mon Mar 22 09:20:34 2010
@@ -157,9 +157,10 @@
}
/* Add charging association information */
- if ((ast_aoc_set_association_id(decoded, 1234) ||
- (ast_aoc_get_association_id(decoded) != 1234)) ||
- (ast_aoc_set_association_number(decoded, "5-555-555-555-555-5555")) ||
+ if ((ast_aoc_set_association_id(decoded, 1234)) ||
+ (ast_aoc_get_association_id(decoded) != 1234) ||
+ (ast_aoc_set_association_number(decoded, "5-555-555-555-555-5555", 2)) ||
+ (ast_aoc_get_association_plan(decoded) != 2) ||
(strcmp(ast_aoc_get_association_number(decoded), "5-555-555-555-555-5555"))) {
ast_test_status_update(test, "TEST 2, could not set charging association info correctly\n");
More information about the asterisk-commits
mailing list