[svn-commits] dvossel: branch dvossel/generic_aoc r253467 - /team/dvossel/generic_aoc/chann...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Mar 18 15:29:46 CDT 2010


Author: dvossel
Date: Thu Mar 18 15:29:42 2010
New Revision: 253467

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=253467
Log:
create generic AOC representation of aoc pri msg, queue on channel

Modified:
    team/dvossel/generic_aoc/channels/sig_pri.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=253467&r1=253466&r2=253467
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.c (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.c Thu Mar 18 15:29:42 2010
@@ -2123,6 +2123,38 @@
 #if defined(HAVE_PRI_AOC_EVENTS)
 /*!
  * \internal
+ * \brief Convert PRI_AOC_MULTIPLIER to AST_AOC_MULTIPLIER
+ * \since 1.8
+ *
+ * \return ast enum equivalent.
+ */
+static int sig_pri_aoc_multiplier_from_pri(const int mult)
+{
+	switch (mult) {
+	case PRI_AOC_MULTIPLIER_THOUSANDTH:
+		return AST_AOC_MULT_ONETHOUSANDTH;
+	case PRI_AOC_MULTIPLIER_HUNDREDTH:
+		return AST_AOC_MULT_ONEHUNDREDTH;
+	case PRI_AOC_MULTIPLIER_TENTH:
+		return AST_AOC_MULT_ONETENTH;
+	case PRI_AOC_MULTIPLIER_ONE:
+		return AST_AOC_MULT_ONE;
+	case PRI_AOC_MULTIPLIER_TEN:
+		return AST_AOC_MULT_TEN;
+	case PRI_AOC_MULTIPLIER_HUNDRED:
+		return AST_AOC_MULT_HUNDRED;
+	case PRI_AOC_MULTIPLIER_THOUSAND:
+		return AST_AOC_MULT_THOUSAND;
+	default:
+		return AST_AOC_MULT_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
  *
@@ -2408,6 +2440,93 @@
 #if defined(HAVE_PRI_AOC_EVENTS)
 /*!
  * \internal
+ * \brief Generate AOC-D AST_CONTROL_AOC frame
+ * \since 1.8
+ *
+ * \param aoc_e AOC-D event parameters.
+ * \param owner Asterisk channel associated with the call.
+ *
+ * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the owner channel lock is already obtained.
+ *
+ * \return Nothing
+ */
+static void sig_pri_aoc_d_from_pri(const struct pri_subcmd_aoc_d *aoc_d, struct ast_channel *owner)
+{
+
+	struct ast_aoc_decoded *decoded = NULL;
+	struct ast_aoc_encoded *encoded = NULL;
+	size_t encoded_size = 0;
+	enum ast_aoc_charge_type type;
+	if (!owner || !aoc_d) {
+		return;
+	}
+
+	switch (aoc_d->charge) {
+	case PRI_AOC_DE_CHARGE_CURRENCY:
+		type = AST_AOC_CHARGE_CURRENCY;
+		break;
+	case PRI_AOC_DE_CHARGE_UNITS:
+		type = AST_AOC_CHARGE_UNIT;
+		break;
+	case PRI_AOC_DE_CHARGE_FREE:
+		type = AST_AOC_CHARGE_FREE;
+		break;
+	default:
+		type = AST_AOC_CHARGE_NA;
+		break;
+	}
+
+	if (!(decoded = ast_aoc_create(AST_AOC_D, type, 0))) {
+		return;
+	}
+
+	switch (aoc_d->billing_id) {
+	case PRI_AOC_D_BILLING_ID_NORMAL:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NA);
+		break;
+	case PRI_AOC_D_BILLING_ID_REVERSE:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_REVERSE_CHARGE);
+		break;
+	case PRI_AOC_D_BILLING_ID_CREDIT_CARD:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_CREDIT_CARD);
+		break;
+	case PRI_AOC_D_BILLING_ID_NOT_AVAILABLE:
+	default:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NA);
+	};
+
+	switch (aoc_d->charge) {
+	case PRI_AOC_DE_CHARGE_CURRENCY:
+		ast_aoc_set_currency_info(decoded,
+			aoc_d->recorded.money.amount.cost,
+			sig_pri_aoc_multiplier_from_pri(aoc_d->recorded.money.amount.multiplier),
+			aoc_d->recorded.money.currency);
+		break;
+	case PRI_AOC_DE_CHARGE_UNITS:
+		{
+			int i;
+			for (i = 0; i < aoc_d->recorded.unit.num_items; ++i) {
+				if (aoc_d->recorded.unit.item[i].number >= 0) {
+					ast_aoc_add_unit_entry(decoded, aoc_d->recorded.unit.item[i].number,
+						(aoc_d->recorded.unit.item[i].type < 0) ? 0 : aoc_d->recorded.unit.item[i].type);
+				}
+			}
+		}
+	}
+
+	if ((encoded = ast_aoc_encode(decoded, &encoded_size))) {
+		ast_queue_control_data(owner, AST_CONTROL_AOC, encoded, encoded_size);
+	}
+
+	ast_aoc_destroy_decoded(decoded);
+	ast_aoc_destroy_encoded(encoded);
+}
+#endif	/* defined(HAVE_PRI_AOC_EVENTS) */
+
+#if defined(HAVE_PRI_AOC_EVENTS)
+/*!
+ * \internal
  * \brief Handle the AOC-D event.
  * \since 1.8
  *
@@ -2433,6 +2552,8 @@
 
 	ast_str_append(&msg, 0, "Channel: %s\r\n", owner->name);
 	ast_str_append(&msg, 0, "UniqueID: %s\r\n", owner->uniqueid);
+	/* Queue AST_CONTROL_AOC frame on channel */
+	sig_pri_aoc_d_from_pri(aoc_d, owner);
 
 	charge_str = sig_pri_aoc_de_charge_str(aoc_d->charge);
 	ast_str_append(&msg, 0, "Type: %s\r\n", charge_str);
@@ -2479,6 +2600,122 @@
 #if defined(HAVE_PRI_AOC_EVENTS)
 /*!
  * \internal
+ * \brief Generate AOC-E AST_CONTROL_AOC frame
+ * \since 1.8
+ *
+ * \param aoc_e AOC-E event parameters.
+ * \param owner Asterisk channel associated with the call.
+ *
+ * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the owner channel lock is already obtained.
+ *
+ * \return Nothing
+ */
+static void sig_pri_aoc_e_from_pri(const struct pri_subcmd_aoc_e *aoc_e, struct ast_channel *owner)
+{
+
+	struct ast_aoc_decoded *decoded = NULL;
+	struct ast_aoc_encoded *encoded = NULL;
+	size_t encoded_size = 0;
+	enum ast_aoc_charge_type type;
+	if (!owner || !aoc_e) {
+		return;
+	}
+
+	switch (aoc_e->charge) {
+	case PRI_AOC_DE_CHARGE_CURRENCY:
+		type = AST_AOC_CHARGE_CURRENCY;
+		break;
+	case PRI_AOC_DE_CHARGE_UNITS:
+		type = AST_AOC_CHARGE_UNIT;
+		break;
+	case PRI_AOC_DE_CHARGE_FREE:
+		type = AST_AOC_CHARGE_FREE;
+		break;
+	default:
+		type = AST_AOC_CHARGE_NA;
+		break;
+	}
+
+	if (!(decoded = ast_aoc_create(AST_AOC_E, type, 0))) {
+		return;
+	}
+
+	switch (aoc_e->associated.charging_type) {
+	case PRI_AOC_E_CHARGING_ASSOCIATION_NUMBER:
+		if (!aoc_e->associated.charge.number.valid) {
+			break;
+		}
+		/*TODO do charging association number correctly */
+		break;
+	case PRI_AOC_E_CHARGING_ASSOCIATION_ID:
+		ast_aoc_set_association_id(decoded, aoc_e->associated.charge.id);
+		break;
+	default:
+		break;
+	}
+
+	switch (aoc_e->billing_id) {
+	case PRI_AOC_E_BILLING_ID_NORMAL:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NA);
+		break;
+	case PRI_AOC_E_BILLING_ID_REVERSE:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_REVERSE_CHARGE);
+		break;
+	case PRI_AOC_E_BILLING_ID_CREDIT_CARD:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_CREDIT_CARD);
+		break;
+	case PRI_AOC_E_BILLING_ID_CALL_FORWARDING_UNCONDITIONAL:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_CALL_FWD_UNCONDITIONAL);
+		break;
+	case PRI_AOC_E_BILLING_ID_CALL_FORWARDING_BUSY:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_CALL_FWD_BUSY);
+		break;
+	case PRI_AOC_E_BILLING_ID_CALL_FORWARDING_NO_REPLY:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_CALL_FWD_NO_REPLY);
+		break;
+	case PRI_AOC_E_BILLING_ID_CALL_DEFLECTION:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_CALL_DEFLECTION);
+		break;
+	case PRI_AOC_E_BILLING_ID_CALL_TRANSFER:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_CALL_TRANSFER);
+		break;
+	case PRI_AOC_E_BILLING_ID_NOT_AVAILABLE:
+	default:
+		ast_aoc_set_billing_id(decoded, AST_AOC_BILLING_NA);
+	};
+
+	switch (aoc_e->charge) {
+	case PRI_AOC_DE_CHARGE_CURRENCY:
+		ast_aoc_set_currency_info(decoded,
+			aoc_e->recorded.money.amount.cost,
+			sig_pri_aoc_multiplier_from_pri(aoc_e->recorded.money.amount.multiplier),
+			aoc_e->recorded.money.currency);
+		break;
+	case PRI_AOC_DE_CHARGE_UNITS:
+		{
+			int i;
+			for (i = 0; i < aoc_e->recorded.unit.num_items; ++i) {
+				if (aoc_e->recorded.unit.item[i].number >= 0) {
+					ast_aoc_add_unit_entry(decoded, aoc_e->recorded.unit.item[i].number,
+						(aoc_e->recorded.unit.item[i].type < 0) ? 0 : aoc_e->recorded.unit.item[i].type);
+				}
+			}
+		}
+	}
+
+	if ((encoded = ast_aoc_encode(decoded, &encoded_size))) {
+		ast_queue_control_data(owner, AST_CONTROL_AOC, encoded, encoded_size);
+	}
+
+	ast_aoc_destroy_decoded(decoded);
+	ast_aoc_destroy_encoded(encoded);
+}
+#endif	/* defined(HAVE_PRI_AOC_EVENTS) */
+
+#if defined(HAVE_PRI_AOC_EVENTS)
+/*!
+ * \internal
  * \brief Handle the AOC-E event.
  * \since 1.8
  *
@@ -2507,6 +2744,8 @@
 	if (owner) {
 		ast_str_append(&msg, 0, "Channel: %s\r\n", owner->name);
 		ast_str_append(&msg, 0, "UniqueID: %s\r\n", owner->uniqueid);
+		/* Queue AST_CONTROL_AOC frame */
+		sig_pri_aoc_e_from_pri(aoc_e, owner);
 	}
 
 	/* If there is no owner then there should be a charging association. */




More information about the svn-commits mailing list