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

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Apr 9 11:34:45 CDT 2010


Author: dvossel
Date: Fri Apr  9 11:34:42 2010
New Revision: 256568

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=256568
Log:
Addition of aoce_delayhangup option to delay hangup in attempt to receive final AOC-E msg

Modified:
    team/dvossel/generic_aoc/channels/chan_dahdi.c
    team/dvossel/generic_aoc/channels/chan_sip.c
    team/dvossel/generic_aoc/channels/sig_pri.c
    team/dvossel/generic_aoc/channels/sig_pri.h
    team/dvossel/generic_aoc/configs/chan_dahdi.conf.sample
    team/dvossel/generic_aoc/main/aoc.c

Modified: team/dvossel/generic_aoc/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/channels/chan_dahdi.c?view=diff&rev=256568&r1=256567&r2=256568
==============================================================================
--- team/dvossel/generic_aoc/channels/chan_dahdi.c (original)
+++ team/dvossel/generic_aoc/channels/chan_dahdi.c Fri Apr  9 11:34:42 2010
@@ -11696,6 +11696,7 @@
 						pris[span].pri.facilityenable = conf->pri.pri.facilityenable;
 #if defined(HAVE_PRI_AOC_EVENTS)
 						pris[span].pri.aoc_grant_flag = conf->pri.pri.aoc_grant_flag;
+						pris[span].pri.aoce_delayhangup = conf->pri.pri.aoce_delayhangup;
 #endif
 						ast_copy_string(pris[span].pri.msn_list, conf->pri.pri.msn_list, sizeof(pris[span].pri.msn_list));
 						ast_copy_string(pris[span].pri.idledial, conf->pri.pri.idledial, sizeof(pris[span].pri.idledial));
@@ -17100,6 +17101,8 @@
 				if (strchr(v->value, 'e')) {
 					confp->pri.pri.aoc_grant_flag |= PRI_AOC_GRANT_E;
 				}
+			} else if (!strcasecmp(v->name, "aoce_delayhangup")) {
+				confp->pri.pri.aoce_delayhangup = ast_true(v->value);
 #endif	/* defined(HAVE_PRI_AOC_EVENTS) */
 #if defined(HAVE_PRI_CALL_HOLD)
 			} else if (!strcasecmp(v->name, "hold_disconnect_transfer")) {

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=256568&r1=256567&r2=256568
==============================================================================
--- team/dvossel/generic_aoc/channels/chan_sip.c (original)
+++ team/dvossel/generic_aoc/channels/chan_sip.c Fri Apr  9 11:34:42 2010
@@ -6241,15 +6241,36 @@
 		update_redirecting(p, data, datalen);
 		break;
 	case AST_CONTROL_AOC:
-		if (ast_test_flag(&p->flags[2], SIP_PAGE3_SNOM_AOC)) {
+		{
 			struct ast_aoc_decoded *decoded = ast_aoc_decode((struct ast_aoc_encoded *) data, datalen);
-			if (decoded) {
-				transmit_info_with_aoc(p, decoded);
-				ast_aoc_destroy_decoded(decoded);
-			} else {
+			if (!decoded) {
 				ast_log(LOG_ERROR, "Error decoding indicated AOC data\n");
 				res = -1;
+				break;
 			}
+			switch (ast_aoc_get_msg_type(decoded)) {
+			case AST_AOC_REQUEST:
+				if (ast_aoc_get_termination_request(decoded)) {
+					/* TODO, once there is a way to get AOC-E on hangup, attempt that here
+					 * before hanging up the channel.*/
+
+					/* The other side has already initiated the hangup. This frame
+					 * just says they are waiting to get AOC-E before completely tearing
+					 * the call down.  Since SIP does not support this at the moment go
+					 * ahead and terminate the call here to avoid an unnecessary timeout. */
+					 ast_log(LOG_DEBUG, "AOC-E termination request received on %s. This is not yet supported on sip. Continue with hangup \n", p->owner->name);
+					ast_softhangup_nolock(p->owner, AST_SOFTHANGUP_DEV);
+				}
+			case AST_AOC_D:
+			case AST_AOC_E:
+				if (ast_test_flag(&p->flags[2], SIP_PAGE3_SNOM_AOC)) {
+					transmit_info_with_aoc(p, decoded);
+				}
+			case AST_AOC_S: /* S not supported yet */
+			default:
+				break;
+			}
+			ast_aoc_destroy_decoded(decoded);
 		}
 		break;
 	case -1:

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=256568&r1=256567&r2=256568
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.c (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.c Fri Apr  9 11:34:42 2010
@@ -2727,6 +2727,52 @@
 	};
 }
 #endif	/* defined(HAVE_PRI_AOC_EVENTS) */
+
+
+#if defined(HAVE_PRI_AOC_EVENTS)
+/*!
+ * \internal
+ * \brief send an AOC-E termination request on ast_channel and set
+ * hangup delay.
+ *
+ * \param ast Asterisk channel
+ *
+ * \return Nothing
+ */
+static void sig_pri_send_aoce_termination_request(struct ast_channel *ast)
+{
+	struct ast_aoc_decoded *decoded;
+	struct ast_aoc_encoded *encoded;
+	size_t encoded_size;
+	struct timeval whentohangup = {
+		.tv_sec = 10,
+		.tv_usec = 0,
+	};
+
+	if (!(decoded = ast_aoc_create(AST_AOC_REQUEST, 0, AST_AOC_REQUEST_E))) {
+		ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
+		return;
+	}
+
+	ast_aoc_set_termination_request(decoded);
+
+	if (!(encoded = ast_aoc_encode(decoded, &encoded_size))) {
+		ast_aoc_destroy_decoded(decoded);
+		ast_softhangup_nolock(ast, AST_SOFTHANGUP_DEV);
+		return;
+	}
+
+	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);
+	ast_aoc_destroy_decoded(decoded);
+	ast_aoc_destroy_encoded(encoded);
+
+}
+#endif
+
 
 /*!
  * \internal
@@ -4560,7 +4606,10 @@
 
 								if (do_hangup) {
 #if defined(HAVE_PRI_AOC_EVENTS)
-									if (detect_aoc_e_subcmd(e->hangup.subcmds)) {
+									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->pvts[chanpos]->waiting_for_aoce = 1;
+									} 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 */
 										ast_queue_control(pri->pvts[chanpos]->owner, AST_CONTROL_HANGUP);
@@ -4678,7 +4727,10 @@
 
 							if (do_hangup) {
 #if defined(HAVE_PRI_AOC_EVENTS)
-								if (detect_aoc_e_subcmd(e->hangup.subcmds)) {
+								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->pvts[chanpos]->waiting_for_aoce = 1;
+								} 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 */
 									ast_queue_control(pri->pvts[chanpos]->owner, AST_CONTROL_HANGUP);
@@ -5676,9 +5728,24 @@
 					break;
 				case AST_AOC_E:
 					sig_pri_aoc_e_from_ast(p, chan, decoded);
+					/* if hangup was delayed for this AOC-E msg, waiting_for_aoc
+					 * will be set.  A hangup is already occuring via a timeout during
+					 * 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) {
+						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;
 				case AST_AOC_REQUEST:
-					/* TODO XXX do we pass through requests? */
+					/* We do not pass through requests except on call setup.
+					 * So unless this is a AOC termination request it will be
+					 * ignored */
+					if (ast_aoc_get_termination_request(decoded)) {
+						pri_hangup(p->pri->pri, p->call, -1);
+					}
+
 				default:
 					/* not supported for pass-through yet */
 					break;

Modified: team/dvossel/generic_aoc/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/channels/sig_pri.h?view=diff&rev=256568&r1=256567&r2=256568
==============================================================================
--- team/dvossel/generic_aoc/channels/sig_pri.h (original)
+++ team/dvossel/generic_aoc/channels/sig_pri.h Fri Apr  9 11:34:42 2010
@@ -245,7 +245,8 @@
 
 #if defined(HAVE_PRI_AOC_EVENTS)
 	struct pri_subcmd_aoc_e aoc_e;
-	unsigned int holding_aoce:1; /*!< received AOC-E msg from asterisk. holding for disconnect/release */
+	unsigned int waiting_for_aoce:1; /*!< Delaying hangup for AOC-E msg. If this is set and AOC-E is recieved, continue with hangup before timeout period. */
+	unsigned int holding_aoce:1;     /*!< received AOC-E msg from asterisk. holding for disconnect/release */
 #endif
 };
 
@@ -354,6 +355,7 @@
 
 #if defined(HAVE_PRI_AOC_EVENTS)
 	int aoc_grant_flag;
+	int aoce_delayhangup;
 #endif
 };
 

Modified: team/dvossel/generic_aoc/configs/chan_dahdi.conf.sample
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/generic_aoc/configs/chan_dahdi.conf.sample?view=diff&rev=256568&r1=256567&r2=256568
==============================================================================
--- team/dvossel/generic_aoc/configs/chan_dahdi.conf.sample (original)
+++ team/dvossel/generic_aoc/configs/chan_dahdi.conf.sample Fri Apr  9 11:34:42 2010
@@ -295,6 +295,11 @@
 ; both 'd,e'. Without setting this option AOC requests will be responded to
 ; as service not available.
 ;aoc_grant_request=d,e
+
+; When this option is enabled, a hangup initiated by the technology (or pri) side of the channel
+; will result in the ast channel delaying it's hangup in an attempt to recieve the final
+; AOC-E message from its bridge.  If the ast channel is not bridged the hangup will occur immediatly.
+;aoce_delayhangup=yes
 ;
 ; pritimer cannot be changed on a reload.
 ;

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=256568&r1=256567&r2=256568
==============================================================================
--- team/dvossel/generic_aoc/main/aoc.c (original)
+++ team/dvossel/generic_aoc/main/aoc.c Fri Apr  9 11:34:42 2010
@@ -299,6 +299,7 @@
 			} else {
 				ast_log(LOG_WARNING, "Recieved invalid termination request ie\n");
 			}
+			break;
 		default:
 			ast_log(LOG_WARNING, "Unknown AOC Information Element, ignoring.\n");
 		}




More information about the svn-commits mailing list