[svn-commits] dvossel: branch dvossel/generic_aoc r257647 - in /team/dvossel/generic_aoc: c...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Apr 16 15:06:37 CDT 2010


Author: dvossel
Date: Fri Apr 16 15:06:35 2010
New Revision: 257647

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=257647
Log:
fixes lots of reviewboard comments

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

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=257647&r1=257646&r2=257647
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.c (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.c Fri Apr 16 15:06:35 2010
@@ -2141,6 +2141,7 @@
  * \param owner Asterisk channel associated with the call.
  *
  * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the sig_pri private is locked
  * \note Assumes the owner channel lock is already obtained.
  *
  * \return Nothing
@@ -2230,6 +2231,7 @@
  * \param aoc_request
  *
  * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the sig_pri private is locked
  * \note Assumes the owner channel lock is already obtained.
  *
  * \return Nothing
@@ -2297,6 +2299,7 @@
  * \param owner Asterisk channel associated with the call.
  *
  * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the sig_pri private is locked
  * \note Assumes the owner channel lock is already obtained.
  *
  * \return Nothing
@@ -2345,7 +2348,7 @@
 	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:
@@ -2389,6 +2392,7 @@
  * \param owner Asterisk channel associated with the call.
  *
  * \note Assumes the pri->lock is already obtained.
+ * \note Assumes the sig_pri private is locked
  * \note Assumes the owner channel lock is already obtained.
  * \note owner channel may be NULL. In that case, generate event only
  *
@@ -2792,42 +2796,48 @@
  * \brief send an AOC-E termination request on ast_channel and set
  * hangup delay.
  *
- * \param ast Asterisk channel
+ * \param sig_pri_chan private
  * \param ms to delay hangup
  *
+ * \note assumes pvt is locked
+ *
  * \return Nothing
  */
-static void sig_pri_send_aoce_termination_request(struct ast_channel *ast, unsigned int ms)
-{
-	struct ast_aoc_decoded *decoded;
-	struct ast_aoc_encoded *encoded;
+static void sig_pri_send_aoce_termination_request(struct sig_pri_chan *pvt, unsigned int ms)
+{
+	struct ast_aoc_decoded *decoded = NULL;
+	struct ast_aoc_encoded *encoded = NULL;
 	size_t encoded_size;
 	struct timeval whentohangup = { 0, };
 
 	if (!(decoded = ast_aoc_create(AST_AOC_REQUEST, 0, AST_AOC_REQUEST_E))) {
-		ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
-		return;
+		ast_softhangup_nolock(pvt->owner, AST_SOFTHANGUP_DEV);
+		goto cleanup_termination_request;
 	}
 
 	ast_aoc_set_termination_request(decoded);
 
-	if (!(encoded = ast_aoc_encode(decoded, &encoded_size, ast))) {
-		ast_aoc_destroy_decoded(decoded);
-		ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
-		return;
+	if (!(encoded = ast_aoc_encode(decoded, &encoded_size, pvt->owner))) {
+		ast_softhangup_nolock(pvt->owner, AST_SOFTHANGUP_DEV);
+		goto cleanup_termination_request;
 	}
 
 	/* convert ms to timeval */
 	whentohangup.tv_usec = (ms % 1000) * 1000;
 	whentohangup.tv_sec = ms / 1000;
 
-	ast_queue_control_data(ast, AST_CONTROL_AOC, encoded, encoded_size);
-	ast_channel_setwhentohangup_tv(ast, whentohangup);
-
-	ast_log(LOG_DEBUG, "Delaying hangup on %s for aoc-e msg\n", ast->name);
+	if (ast_queue_control_data(pvt->owner, AST_CONTROL_AOC, encoded, encoded_size)) {
+		ast_softhangup_nolock(pvt->owner, AST_SOFTHANGUP_DEV);
+		goto cleanup_termination_request;
+	}
+
+	pvt->waiting_for_aoce = 1;
+	ast_channel_setwhentohangup_tv(pvt->owner, whentohangup);
+	ast_log(LOG_DEBUG, "Delaying hangup on %s for aoc-e msg\n", pvt->owner->name);
+
+cleanup_termination_request:
 	ast_aoc_destroy_decoded(decoded);
 	ast_aoc_destroy_encoded(encoded);
-
 }
 #endif
 
@@ -3363,13 +3373,11 @@
 #endif	/* defined(HAVE_PRI_AOC_EVENTS) */
 #if defined(HAVE_PRI_AOC_EVENTS)
 		case PRI_SUBCMD_AOC_CHARGING_REQ:
-			if (pri->aoc_passthrough_flag) {
-				sig_pri_lock_owner(pri, chanpos);
-				owner = pri->pvts[chanpos]->owner;
-				if (owner) {
-					sig_pri_aoc_request_from_pri(&subcmd->u.aoc_request, pri->pvts[chanpos], call_rsp);
-					ast_channel_unlock(owner);
-				}
+			sig_pri_lock_owner(pri, chanpos);
+			owner = pri->pvts[chanpos]->owner;
+			if (owner) {
+				sig_pri_aoc_request_from_pri(&subcmd->u.aoc_request, pri->pvts[chanpos], call_rsp);
+				ast_channel_unlock(owner);
 			}
 			break;
 #endif	/* defined(HAVE_PRI_AOC_EVENTS) */
@@ -4674,8 +4682,7 @@
 								if (do_hangup) {
 #if defined(HAVE_PRI_AOC_EVENTS)
 									if (!pri->pvts[chanpos]->holding_aoce && pri->aoce_delayhangup && ast_bridged_channel(pri->pvts[chanpos]->owner)) {
-										sig_pri_send_aoce_termination_request(pri->pvts[chanpos]->owner, pri_get_timer(pri->pri, PRI_TIMER_T305) / 2);
-										pri->pvts[chanpos]->waiting_for_aoce = 1;
+										sig_pri_send_aoce_termination_request(pri->pvts[chanpos], pri_get_timer(pri->pri, PRI_TIMER_T305) / 2);
 									} else if (detect_aoc_e_subcmd(e->hangup.subcmds)) {
 										/* If a AOC-E msg was sent during the Disconnect, we must use a
 										 * AST_CONTROL_HANGUP frame to guarantee that frame gets read before hangup */
@@ -4795,8 +4802,7 @@
 							if (do_hangup) {
 #if defined(HAVE_PRI_AOC_EVENTS)
 								if (!pri->pvts[chanpos]->holding_aoce && pri->aoce_delayhangup && ast_bridged_channel(pri->pvts[chanpos]->owner)) {
-									sig_pri_send_aoce_termination_request(pri->pvts[chanpos]->owner, pri_get_timer(pri->pri, PRI_TIMER_T305) / 2);
-									pri->pvts[chanpos]->waiting_for_aoce = 1;
+									sig_pri_send_aoce_termination_request(pri->pvts[chanpos], pri_get_timer(pri->pri, PRI_TIMER_T305) / 2);
 								} else if (detect_aoc_e_subcmd(e->hangup.subcmds)) {
 									/* If a AOC-E msg was sent during the Disconnect, we must use a AST_CONTROL_HANGUP frame
 									 * to guarantee that frame gets read before hangup */
@@ -5783,7 +5789,7 @@
 		}
 		break;
 	case AST_CONTROL_AOC:
-		#if defined(HAVE_PRI_AOC_EVENTS)
+#if defined(HAVE_PRI_AOC_EVENTS)
 		{
 			struct ast_aoc_decoded *decoded = ast_aoc_decode((struct ast_aoc_encoded *) data, datalen, chan);
 			ast_debug(1, "Received AST_CONTROL_AOC on %s\n", chan->name);
@@ -5808,8 +5814,8 @@
 					 * this delay.  Instead of waiting for that timeout to occur, go ahead
 					 * and initiate the softhangup since the delay is no longer necessary */
 					if (p->waiting_for_aoce) {
+						p->waiting_for_aoce = 0;
 						ast_log(LOG_DEBUG, "Received final AOC-E msg, continue with hangup on %s\n", chan->name);
-						p->waiting_for_aoce = 0;
 						ast_softhangup_nolock(chan, AST_SOFTHANGUP_DEV);
 					}
 					break;
@@ -5826,7 +5832,7 @@
 			}
 			ast_aoc_destroy_decoded(decoded);
 		}
-		#endif	/* defined(HAVE_PRI_AOC_EVENTS) */
+#endif	/* defined(HAVE_PRI_AOC_EVENTS) */
 		break;
 	}
 

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=257647&r1=257646&r2=257647
==============================================================================
--- team/dvossel/generic_aoc/include/asterisk/aoc.h (original)
+++ team/dvossel/generic_aoc/include/asterisk/aoc.h Fri Apr 16 15:06:35 2010
@@ -100,15 +100,17 @@
 };
 
 struct ast_aoc_duration_rate {
-	uint16_t multiplier;
 	uint32_t amount;
-
 	uint32_t time;
-	uint16_t time_scale;
-
 	/*! Not present if the granularity time is zero. */
 	uint32_t granularity_time;
+
+	uint16_t multiplier;
+	uint16_t time_scale;
 	uint16_t granularity_time_scale;
+
+	/*! Name of currency involved.  Null terminated. */
+	char currency_name[AOC_CURRENCY_NAME_SIZE];
 
 	/*!
 	 * \brief Charging interval type
@@ -117,8 +119,6 @@
 	 * stepFunction(1)
 	 */
 	uint8_t charging_type;
-	/*! Name of currency involved.  Null terminated. */
-	char currency_name[AOC_CURRENCY_NAME_SIZE];
 };
 
 enum ast_aoc_volume_unit {
@@ -128,16 +128,15 @@
 };
 
 struct ast_aoc_volume_rate {
+	uint32_t amount;
 	uint16_t multiplier;
-	uint32_t amount;
 	uint16_t volume_unit;
 	char currency_name[AOC_CURRENCY_NAME_SIZE];
 };
 
 struct ast_aoc_flat_rate {
+	uint32_t amount;
 	uint16_t multiplier;
-	uint32_t amount;
-
 	/*! Name of currency involved.  Null terminated. */
 	char currency_name[AOC_CURRENCY_NAME_SIZE];
 };
@@ -163,7 +162,6 @@
 };
 struct ast_aoc_s_entry {
 	uint16_t charged_item;
-
 	uint16_t rate_type;
 
 	/*! \brief Charge rate being applied. */
@@ -173,7 +171,7 @@
 		struct ast_aoc_volume_rate volume;
 		uint16_t special_code; /* 1...10 */
 	} rate;
-};
+}__attribute__ ((packed));
 
 struct ast_aoc_unit_entry {
 	char valid_amount;

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=257647&r1=257646&r2=257647
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (original)
+++ team/dvossel/generic_aoc/main/aoc.c Fri Apr 16 15:06:35 2010
@@ -98,48 +98,49 @@
 	char termination_request;
 };
 
+/*! \brief AOC Payload Information Elements */
+enum AOC_IE {
+	AOC_IE_CURRENCY = 1,
+	AOC_IE_UNIT = 2,
+	AOC_IE_BILLING = 3,
+	AOC_IE_CHARGING_ASSOCIATION = 4,
+	AOC_IE_RATE = 5,
+	AOC_IE_TERMINATION_REQUEST = 6,
+};
+
+/*! \brief AOC IE payload header */
 struct aoc_pl_ie_hdr {
 	uint8_t ie_id;
 	uint8_t datalen;
 	char data[0];
-};
-
-/* AOC Payload Information Elements */
-#define AOC_IE_CURRENCY 1
+}__attribute__ ((packed));
+
 struct aoc_ie_currency {
+	uint32_t amount;
 	uint8_t  multiplier;
-	uint32_t amount;
 	char name[AOC_CURRENCY_NAME_SIZE];
-};
-
-#define AOC_IE_UNIT 2
+}__attribute__ ((packed));
+
 struct aoc_ie_unit {
-	uint8_t valid_amount;
 	uint32_t amount;
 	uint8_t valid_type;
-	uint8_t  type;
-};
-
-#define AOC_IE_BILLING 3
+	uint8_t valid_amount;
+	uint8_t type;
+}__attribute__ ((packed));
+
 struct aoc_ie_billing {
 	uint8_t id;
-};
-
-#define AOC_IE_CHARGING_ASSOCIATION 4
+}__attribute__ ((packed));
+
 struct aoc_ie_charging_association {
 	int32_t charge_id;
+	char charge_number[32];
 	uint8_t charge_plan;
-	char charge_number[32];
-};
-
-#define AOC_IE_RATE 5
+}__attribute__ ((packed));
+
 struct aoc_ie_charging_rate {
 	struct ast_aoc_s_entry entry;
-};
-
-#define AOC_IE_TERMINATION_REQUEST 6
-/* termination request has no data associated with it.
- * the ie is either present or it is not */
+}__attribute__ ((packed));
 
 struct ast_aoc_decoded *ast_aoc_create(const enum ast_aoc_type msg_type,
 		const enum ast_aoc_charge_type charge_type,
@@ -236,18 +237,18 @@
 
 static int aoc_parse_ie(struct ast_aoc_decoded *decoded, unsigned char *data, unsigned int datalen)
 {
-	int ie;
-	int len;
+	enum AOC_IE ie_id;
+	unsigned int len;
 
 	while (datalen >= 2) {
-		ie = data[0];
+		ie_id = 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) {
+		switch(ie_id) {
 		case AOC_IE_CURRENCY:
 			if (len == sizeof(struct aoc_ie_currency)) {
 				struct aoc_ie_currency ie;
@@ -1567,7 +1568,7 @@
 	AST_CLI_DEFINE(aoc_cli_debug_enable, "enable cli debugging of AOC messages"),
 };
 
-int ast_aoc_cli_init()
+int ast_aoc_cli_init(void)
 {
 	return ast_cli_register_multiple(aoc_cli, ARRAY_LEN(aoc_cli));
 }

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=257647&r1=257646&r2=257647
==============================================================================
--- team/dvossel/generic_aoc/main/manager.c (original)
+++ team/dvossel/generic_aoc/main/manager.c Fri Apr 16 15:06:35 2010
@@ -712,7 +712,7 @@
 				the first matched channel has the message sent on it. </para>
 			</parameter>
 			<parameter name="MsgType" required="true">
-				<para>Defines what time of AOC message to create, ACO-D or AOC-E</para>
+				<para>Defines what type of AOC message to create, ACO-D or AOC-E</para>
 				<enumlist>
 					<enum name="D" />
 					<enum name="E" />
@@ -799,7 +799,9 @@
 				for AOC-E.</para>
 			</parameter>
 			<parameter name="ChargingAssociationPlan">
-				<para>Integer representing the charging plan associated with the ChargingAssociationNumber.</para>
+				<para>Integer representing the charging plan associated with the ChargingAssociationNumber.
+				The value is bits 7 through 1 of the Q.931 octet containing the type-of-number and
+				numbering-plan-identification fields.</para>
 			</parameter>
 		</syntax>
 		<description>




More information about the svn-commits mailing list