[asterisk-commits] dvossel: branch dvossel/generic_aoc r254157 - in /team/dvossel/generic_aoc: c...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 23 17:22:32 CDT 2010
Author: dvossel
Date: Tue Mar 23 17:22:28 2010
New Revision: 254157
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=254157
Log:
AOC CLI debug command
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/asterisk.c
team/dvossel/generic_aoc/main/manager.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=254157&r1=254156&r2=254157
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.c (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.c Tue Mar 23 17:22:28 2010
@@ -2525,7 +2525,7 @@
switch (aoc_d->billing_id) {
case PRI_AOC_D_BILLING_ID_NORMAL:
- ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NA);
+ ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NORMAL);
break;
case PRI_AOC_D_BILLING_ID_REVERSE:
ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_REVERSE_CHARGE);
@@ -2699,7 +2699,7 @@
switch (aoc_e->billing_id) {
case PRI_AOC_E_BILLING_ID_NORMAL:
- ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NA);
+ ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NORMAL);
break;
case PRI_AOC_E_BILLING_ID_REVERSE:
ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_REVERSE_CHARGE);
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=254157&r1=254156&r2=254157
==============================================================================
--- team/dvossel/generic_aoc/include/asterisk/aoc.h (original)
+++ team/dvossel/generic_aoc/include/asterisk/aoc.h Tue Mar 23 17:22:28 2010
@@ -253,4 +253,7 @@
* the encode decode routine.
*/
int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded);
+
+/*! \brief enable aoc cli options */
+int ast_aoc_cli_init(void);
#endif
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=254157&r1=254156&r2=254157
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (original)
+++ team/dvossel/generic_aoc/main/aoc.c Tue Mar 23 17:22:28 2010
@@ -30,6 +30,7 @@
#include "asterisk/utils.h"
#include "asterisk/strings.h"
#include "asterisk/_private.h"
+#include "asterisk/cli.h"
/* Encoded Payload Flags */
#define AST_AOC_ENCODED_TYPE_REQUEST (0 << 0)
@@ -52,6 +53,9 @@
#define AST_AOC_ENCODE_VERSION 1
#define AOC_CURRENCY_NAME_SIZE (10 + 1)
+
+static char aoc_debug_enabled = 0;
+static void aoc_display_decoded(const struct ast_aoc_decoded *decoded, int decoding);
/* AOC Payload Header. Holds all the encoded AOC data to pass on the wire */
struct ast_aoc_encoded {
@@ -278,6 +282,11 @@
/* decode information elements */
aoc_parse_ie(decoded, encoded->data, ntohs(encoded->datalen));
+
+ if (aoc_debug_enabled) {
+ aoc_display_decoded(decoded, 1);
+ }
+
return decoded;
}
@@ -429,6 +438,10 @@
/* set the output size */
*out_size = size;
+
+ if (aoc_debug_enabled) {
+ aoc_display_decoded(decoded, 0);
+ }
return encoded;
}
@@ -601,6 +614,165 @@
return decoded->charging_association_plan;
}
+static const char *aoc_charge_type_str(const struct ast_aoc_decoded *decoded)
+{
+ switch (decoded->charge_type) {
+ case AST_AOC_CHARGE_NA:
+ return "Charge Not Available";
+ case AST_AOC_CHARGE_FREE:
+ return "Free";
+ case AST_AOC_CHARGE_CURRENCY:
+ return "Currency";
+ case AST_AOC_CHARGE_UNIT:
+ return "Unit";
+ }
+
+ return "Unknown";
+}
+
+static const char *aoc_multiplier_str(const struct ast_aoc_decoded *decoded)
+{
+ switch (decoded->multiplier) {
+ case AST_AOC_MULT_ONETHOUSANDTH:
+ return "One Thousandth";
+ case AST_AOC_MULT_ONEHUNDREDTH:
+ return "One Hundredth";
+ case AST_AOC_MULT_ONETENTH:
+ return "One Tenth";
+ case AST_AOC_MULT_ONE:
+ return "One";
+ case AST_AOC_MULT_TEN:
+ return "Ten";
+ case AST_AOC_MULT_HUNDRED:
+ return "Hundred";
+ case AST_AOC_MULT_THOUSAND:
+ return "Thousand";
+ case AST_AOC_MULT_NUM_ENTRIES:
+ break;
+ };
+ return "Unknown";
+
+}
+
+static const char *aoc_billingid_str(const struct ast_aoc_decoded *decoded)
+{
+ switch (decoded->billing_id) {
+ case AST_AOC_BILLING_NORMAL:
+ return "Normal";
+ case AST_AOC_BILLING_REVERSE_CHARGE:
+ return "Reverse Charge";
+ case AST_AOC_BILLING_CREDIT_CARD:
+ return "Credit Card";
+ case AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL:
+ return "Call Forward Unconditional";
+ case AST_AOC_BILLING_CALL_FWD_BUSY:
+ return "Call Forward Busy";
+ case AST_AOC_BILLING_CALL_FWD_NO_REPLY:
+ return "Call Forward No Reply";
+ case AST_AOC_BILLING_CALL_DEFLECTION:
+ return "Call Deflection";
+ case AST_AOC_BILLING_CALL_TRANSFER:
+ return "Call Transfer";
+ case AST_AOC_BILLING_NA:
+ return "Not Set";
+ case AST_AOC_BILLING_NUM_ENTRIES:
+ break;
+ }
+ return "Unknown";
+}
+
+
+static const char *aoc_msg_type_str(const struct ast_aoc_decoded *decoded)
+{
+ switch (decoded->msg_type) {
+ case AST_AOC_D:
+ return "AOC-D";
+ case AST_AOC_E:
+ return "AOC-E";
+ case AST_AOC_REQUEST:
+ return "AOC-REQUEST";
+ }
+
+ return "Unknown";
+}
+static void aoc_display_decoded_aocd(const struct ast_aoc_decoded *decoded)
+{
+ ast_verb(1, "MsgType: %s\n", aoc_msg_type_str(decoded));
+ ast_verb(1, "ChargeType: %s\n", aoc_charge_type_str(decoded));
+ if (decoded->billing_id) {
+ ast_verb(1, "BillingId: %s\n", aoc_billingid_str(decoded));
+ }
+ ast_verb(1, "TotalType: %s\n", decoded->total_type ? "Total" : "Subtotal");
+ if (decoded->charge_type == AST_AOC_CHARGE_CURRENCY) {
+ ast_verb(1, "Multiplier: %s\n", aoc_multiplier_str(decoded));
+ ast_verb(1, "CurrencyAmount: %u\n", decoded->currency_amount);
+ ast_verb(1, "CurrencyName: %s\n", ast_strlen_zero(decoded->currency_name) ? "Not Available" : decoded->currency_name);
+ } else if (decoded->charge_type == AST_AOC_CHARGE_UNIT) {
+ int i;
+ ast_verb(1, "UnitCount: %u\n", decoded->unit_count);
+ for (i = 0; i < decoded->unit_count; i++) {
+ ast_verb(1, "UnitAmount(%d): %u\n", i, decoded->unit_list[i].amount);
+ ast_verb(1, "UnitType(%d): %u\n", i, decoded->unit_list[i].type);
+ }
+ }
+}
+
+static void aoc_display_decoded_aoce(const struct ast_aoc_decoded *decoded)
+{
+ ast_verb(1, "MsgType: %s\n", aoc_msg_type_str(decoded));
+ ast_verb(1, "ChargeType: %s\n", aoc_charge_type_str(decoded));
+ if (decoded->billing_id) {
+ ast_verb(1, "BillingId: %s\n", aoc_billingid_str(decoded));
+ }
+ if (decoded->charge_type == AST_AOC_CHARGE_CURRENCY) {
+ ast_verb(1, "Multiplier: %s\n", aoc_multiplier_str(decoded));
+ ast_verb(1, "CurrencyAmount: %u\n", decoded->currency_amount);
+ ast_verb(1, "CurrencyName: %s\n", ast_strlen_zero(decoded->currency_name) ? "Not Available" : decoded->currency_name);
+ } else if (decoded->charge_type == AST_AOC_CHARGE_UNIT) {
+ int i;
+ ast_verb(1, "UnitCount: %u\n", decoded->unit_count);
+ for (i = 0; i < decoded->unit_count; i++) {
+ ast_verb(1, "UnitAmount(%d): %u\n", i, decoded->unit_list[i].amount);
+ ast_verb(1, "UnitType(%d): %u\n", i, decoded->unit_list[i].type);
+ }
+ }
+}
+static void aoc_display_decoded_aoc_request(const struct ast_aoc_decoded *decoded)
+{
+ ast_verb(1, "MsgType: %s\n", aoc_msg_type_str(decoded));
+ if (decoded->request_flag & AST_AOC_REQUEST_S) {
+ ast_verb(1, "Requesting AOC-S\n");
+ }
+ if (decoded->request_flag & AST_AOC_REQUEST_D) {
+ ast_verb(1, "Requesting AOC-D\n");
+ }
+ if (decoded->request_flag & AST_AOC_REQUEST_E) {
+ ast_verb(1, "Requesting AOC-E\n");
+ }
+}
+static void aoc_display_decoded(const struct ast_aoc_decoded *decoded, int decoding)
+{
+ if (decoding) {
+ ast_verb(1, "---- DECODED AOC MSG ----\n");
+ } else {
+ ast_verb(1, "---- ENCODED AOC MSG ----\n");
+ }
+
+ switch (decoded->msg_type) {
+ case AST_AOC_D:
+ aoc_display_decoded_aocd(decoded);
+ break;
+ case AST_AOC_E:
+ aoc_display_decoded_aoce(decoded);
+ break;
+ case AST_AOC_REQUEST:
+ aoc_display_decoded_aoc_request(decoded);
+ break;
+ }
+
+ ast_verb(1, "\n");
+
+}
int ast_aoc_test_encode_decode_match(struct ast_aoc_decoded *decoded)
{
struct ast_aoc_decoded *new = NULL;
@@ -625,3 +797,39 @@
ast_aoc_destroy_encoded(encoded);
return res;
}
+
+static char *aoc_cli_debug_enable(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
+{
+ switch (cmd) {
+ case CLI_INIT:
+ e->command = "aoc set debug";
+ e->usage =
+ "Usage: 'aoc set debug on' to enable aoc debug, 'aoc set debug off' to disable debug.\n";
+ return NULL;
+ case CLI_GENERATE:
+ return NULL;
+ case CLI_HANDLER:
+ if (a->argc != 4) {
+ return CLI_SHOWUSAGE;
+ } else if(ast_true(a->argv[3])) {
+ ast_cli(a->fd, "aoc debug enabled\n");
+ aoc_debug_enabled = 1;
+ } else if (ast_false(a->argv[3])) {
+ ast_cli(a->fd, "aoc debug disabled\n");
+ aoc_debug_enabled = 0;
+ } else {
+ return CLI_SHOWUSAGE;
+ }
+ }
+
+ return CLI_SUCCESS;
+}
+
+static struct ast_cli_entry aoc_cli[] = {
+ AST_CLI_DEFINE(aoc_cli_debug_enable, "enable cli debugging of AOC messages"),
+};
+
+int ast_aoc_cli_init()
+{
+ return ast_cli_register_multiple(aoc_cli, ARRAY_LEN(aoc_cli));
+}
Modified: team/dvossel/generic_aoc/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/main/asterisk.c?view=diff&rev=254157&r1=254156&r2=254157
==============================================================================
--- team/dvossel/generic_aoc/main/asterisk.c (original)
+++ team/dvossel/generic_aoc/main/asterisk.c Tue Mar 23 17:22:28 2010
@@ -142,6 +142,7 @@
#include "asterisk/poll-compat.h"
#include "asterisk/ccss.h"
#include "asterisk/test.h"
+#include "asterisk/aoc.h"
#include "../defaults.h"
@@ -3558,6 +3559,8 @@
}
#endif
+ ast_aoc_cli_init();
+
ast_makesocket();
sigemptyset(&sigs);
sigaddset(&sigs, SIGHUP);
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=254157&r1=254156&r2=254157
==============================================================================
--- team/dvossel/generic_aoc/main/manager.c (original)
+++ team/dvossel/generic_aoc/main/manager.c Tue Mar 23 17:22:28 2010
@@ -3625,6 +3625,11 @@
astman_send_error(s, m, "Invalid AOCDBillingId");
goto aocmessage_cleanup;
}
+
+ if (ast_strlen_zero(aocdbillingid) && !ast_strlen_zero(aocebillingid)) {
+ astman_send_error(s, m, "AOC-E billingid set when message type is AOC-D");
+ goto aocmessage_cleanup;
+ }
} else {
if (ast_strlen_zero(aocebillingid)) {
/* ignore this is optional */
@@ -3646,6 +3651,11 @@
_billingid = AST_AOC_BILLING_CALL_TRANSFER;
} else {
astman_send_error(s, m, "Invalid AOCEBillingId");
+ goto aocmessage_cleanup;
+ }
+
+ if (ast_strlen_zero(aocebillingid) && !ast_strlen_zero(aocdbillingid)) {
+ astman_send_error(s, m, "AOC-D billingid set when message type is AOC-E");
goto aocmessage_cleanup;
}
More information about the asterisk-commits
mailing list