[svn-commits] rmudgett: trunk r309446 - in /trunk: ./ channels/ funcs/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Mar 4 09:28:26 CST 2011


Author: rmudgett
Date: Fri Mar  4 09:28:20 2011
New Revision: 309446

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=309446
Log:
Merged revisions 309445 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.8

........
  r309445 | rmudgett | 2011-03-04 09:22:04 -0600 (Fri, 04 Mar 2011) | 46 lines
  
  Get real channel of a DAHDI call.
  
  Starting with Asterisk v1.8, the DAHDI channel name format was changed for
  ISDN calls to: DAHDI/i<span>/<number>[:<subaddress>]-<sequence-number>
  
  There were several reasons that the channel name had to change.
  
  1) Call completion requires a device state for ISDN phones.  The generic
  device state uses the channel name.
  
  2) Calls do not necessarily have B channels.  Calls placed on hold by an
  ISDN phone do not have B channels.
  
  3) The B channel a call initially requests may not be the B channel the
  call ultimately uses.  Changes to the internal implementation of the
  Asterisk master channel list caused deadlock problems for chan_dahdi if it
  needed to change the channel name.  Chan_dahdi no longer changes the
  channel name.
  
  4) DTMF attended transfers now work with ISDN phones because the channel
  name is "dialable" like the chan_sip channel names.
  
  For various reasons, some people need to know which B channel a DAHDI call
  is using.
  
  * Added CHANNEL(dahdi_span), CHANNEL(dahdi_channel), and
  CHANNEL(dahdi_type) so the dialplan can determine the B channel currently
  in use by the channel.  Use CHANNEL(no_media_path) to determine if the
  channel even has a B channel.
  
  * Added AMI event DAHDIChannel to associate a DAHDI channel with an
  Asterisk channel so AMI applications can passively determine the B channel
  currently in use.  Calls with "no-media" as the DAHDIChannel do not have
  an associated B channel.  No-media calls are either on hold or
  call-waiting.
  
  (closes issue #17683)
  Reported by: mrwho
  Tested by: rmudgett
  
  (closes issue #18603)
  Reported by: arjankroon
  Patches:
        issue17683_18603_v1.8_v2.patch uploaded by rmudgett (license 664)
  Tested by: stever28, rmudgett
........

Modified:
    trunk/   (props changed)
    trunk/UPGRADE-1.8.txt
    trunk/channels/chan_dahdi.c
    trunk/channels/sig_pri.c
    trunk/channels/sig_pri.h
    trunk/funcs/func_channel.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: trunk/UPGRADE-1.8.txt
URL: http://svnview.digium.com/svn/asterisk/trunk/UPGRADE-1.8.txt?view=diff&rev=309446&r1=309445&r2=309446
==============================================================================
--- trunk/UPGRADE-1.8.txt (original)
+++ trunk/UPGRADE-1.8.txt Fri Mar  4 09:28:20 2011
@@ -71,6 +71,15 @@
   collisions, the channel name format is changed.
   The new channel naming for PRI channels is:
   DAHDI/i<span>/<number>[:<subaddress>]-<sequence-number>
+
+* Added CHANNEL(dahdi_span), CHANNEL(dahdi_channel), and CHANNEL(dahdi_type)
+  so the dialplan can determine the B channel currently in use by the channel.
+  Use CHANNEL(no_media_path) to determine if the channel even has a B channel.
+
+* Added AMI event DAHDIChannel to associate a DAHDI channel with an Asterisk
+  channel so AMI applications can passively determine the B channel currently
+  in use.  Calls with "no-media" as the DAHDIChannel do not have an associated
+  B channel.  No-media calls are either on hold or call-waiting.
 
 * The ChanIsAvail application has been changed so the AVAILSTATUS variable
   no longer contains both the device state and cause code. The cause code

Modified: trunk/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_dahdi.c?view=diff&rev=309446&r1=309445&r2=309446
==============================================================================
--- trunk/channels/chan_dahdi.c (original)
+++ trunk/channels/chan_dahdi.c Fri Mar  4 09:28:20 2011
@@ -2109,6 +2109,58 @@
 	DEADLOCK_AVOIDANCE(&p->lock);
 }
 
+/*!
+ * \internal
+ * \brief Post an AMI DAHDI channel association event.
+ * \since 1.8
+ *
+ * \param p DAHDI private pointer
+ * \param chan Channel associated with the private pointer
+ *
+ * \return Nothing
+ */
+static void dahdi_ami_channel_event(struct dahdi_pvt *p, struct ast_channel *chan)
+{
+	char ch_name[20];
+
+	if (p->channel < CHAN_PSEUDO) {
+		/* No B channel */
+		snprintf(ch_name, sizeof(ch_name), "no-media (%d)", p->channel);
+	} else if (p->channel == CHAN_PSEUDO) {
+		/* Pseudo channel */
+		strcpy(ch_name, "pseudo");
+	} else {
+		/* Real channel */
+		snprintf(ch_name, sizeof(ch_name), "%d", p->channel);
+	}
+	ast_manager_event(chan, EVENT_FLAG_CALL, "DAHDIChannel",
+		"Channel: %s\r\n"
+		"Uniqueid: %s\r\n"
+		"DAHDISpan: %d\r\n"
+		"DAHDIChannel: %s\r\n",
+		chan->name,
+		chan->uniqueid,
+		p->span,
+		ch_name);
+}
+
+/*!
+ * \internal
+ * \brief Post an AMI DAHDI channel association event.
+ * \since 1.8
+ *
+ * \param pvt DAHDI private pointer
+ * \param chan Channel associated with the private pointer
+ *
+ * \return Nothing
+ */
+static void my_ami_channel_event(void *pvt, struct ast_channel *chan)
+{
+	struct dahdi_pvt *p = pvt;
+
+	dahdi_ami_channel_event(p, chan);
+}
+
 /* linear_mode = 0 - turn linear mode off, >0 - turn linear mode on
 * 	returns the last value of the linear setting 
 */ 
@@ -3294,6 +3346,7 @@
 	.module_ref = my_module_ref,
 	.module_unref = my_module_unref,
 	.open_media = my_pri_open_media,
+	.ami_channel_event = my_ami_channel_event,
 };
 #endif	/* defined(HAVE_PRI) */
 
@@ -6791,6 +6844,41 @@
 	} else if (!strcasecmp(data, "txgain")) {
 		ast_mutex_lock(&p->lock);
 		snprintf(buf, len, "%f", p->txgain);
+		ast_mutex_unlock(&p->lock);
+	} else if (!strcasecmp(data, "dahdi_channel")) {
+		ast_mutex_lock(&p->lock);
+		snprintf(buf, len, "%d", p->channel);
+		ast_mutex_unlock(&p->lock);
+	} else if (!strcasecmp(data, "dahdi_span")) {
+		ast_mutex_lock(&p->lock);
+		snprintf(buf, len, "%d", p->span);
+		ast_mutex_unlock(&p->lock);
+	} else if (!strcasecmp(data, "dahdi_type")) {
+		ast_mutex_lock(&p->lock);
+		switch (p->sig) {
+#if defined(HAVE_OPENR2)
+		case SIG_MFCR2:
+			ast_copy_string(buf, "mfc/r2", len);
+			break;
+#endif	/* defined(HAVE_OPENR2) */
+#if defined(HAVE_PRI)
+		case SIG_PRI_LIB_HANDLE_CASES:
+			ast_copy_string(buf, "pri", len);
+			break;
+#endif	/* defined(HAVE_PRI) */
+		case 0:
+			ast_copy_string(buf, "pseudo", len);
+			break;
+#if defined(HAVE_SS7)
+		case SIG_SS7:
+			ast_copy_string(buf, "ss7", len);
+			break;
+#endif	/* defined(HAVE_SS7) */
+		default:
+			/* The only thing left is analog ports. */
+			ast_copy_string(buf, "analog", len);
+			break;
+		}
 		ast_mutex_unlock(&p->lock);
 #if defined(HAVE_PRI)
 #if defined(HAVE_PRI_REVERSE_CHARGE)
@@ -9530,6 +9618,7 @@
 
 	ast_module_ref(ast_module_info->self);
 
+	dahdi_ami_channel_event(i, tmp);
 	if (startpbx) {
 #ifdef HAVE_OPENR2
 		if (i->mfcr2call) {
@@ -13089,6 +13178,7 @@
 		nobch_channel = CHAN_PSEUDO - 1;
 	}
 	pvt->channel = nobch_channel;
+	pvt->span = pri->span;
 	chan->channel = pvt->channel;
 
 	dahdi_nobch_insert(pri, pvt);

Modified: trunk/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.c?view=diff&rev=309446&r1=309445&r2=309446
==============================================================================
--- trunk/channels/sig_pri.c (original)
+++ trunk/channels/sig_pri.c Fri Mar  4 09:28:20 2011
@@ -932,6 +932,24 @@
 	}
 }
 
+/*!
+ * \internal
+ * \brief Post an AMI B channel association event.
+ * \since 1.8
+ *
+ * \param p Channel private control structure.
+ *
+ * \note Assumes the private and owner are locked.
+ *
+ * \return Nothing
+ */
+static void sig_pri_ami_channel_event(struct sig_pri_chan *p)
+{
+	if (p->calls->ami_channel_event) {
+		p->calls->ami_channel_event(p->chan_pvt, p->owner);
+	}
+}
+
 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor, int transfercapability)
 {
 	struct ast_channel *ast;
@@ -1331,6 +1349,10 @@
 			 * bridged.)
 			 */
 			sig_pri_open_media(new_chan);
+		}
+
+		if (new_chan->owner) {
+			sig_pri_ami_channel_event(new_chan);
 		}
 
 		sig_pri_unlock_private(old_chan);

Modified: trunk/channels/sig_pri.h
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/sig_pri.h?view=diff&rev=309446&r1=309445&r2=309446
==============================================================================
--- trunk/channels/sig_pri.h (original)
+++ trunk/channels/sig_pri.h Fri Mar  4 09:28:20 2011
@@ -199,6 +199,16 @@
 	void (* const update_span_devstate)(struct sig_pri_span *pri);
 
 	void (* const open_media)(void *pvt);
+
+	/*!
+	 * \brief Post an AMI B channel association event.
+	 *
+	 * \param pvt Private structure of the user of this module.
+	 * \param chan Channel associated with the private pointer
+	 *
+	 * \return Nothing
+	 */
+	void (* const ami_channel_event)(void *pvt, struct ast_channel *chan);
 
 	/*! Reference the parent module. */
 	void (*module_ref)(void);

Modified: trunk/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/trunk/funcs/func_channel.c?view=diff&rev=309446&r1=309445&r2=309446
==============================================================================
--- trunk/funcs/func_channel.c (original)
+++ trunk/funcs/func_channel.c Fri Mar  4 09:28:20 2011
@@ -224,6 +224,22 @@
 				</enumlist>
 				<para><emphasis>chan_dahdi</emphasis> provides the following additional options:</para>
 				<enumlist>
+					<enum name="dahdi_channel">
+						<para>R/O DAHDI channel related to this channel.</para>
+					</enum>
+					<enum name="dahdi_span">
+						<para>R/O DAHDI span related to this channel.</para>
+					</enum>
+					<enum name="dahdi_type">
+						<para>R/O DAHDI channel type, one of:</para>
+						<enumlist>
+							<enum name="analog" />
+							<enum name="mfc/r2" />
+							<enum name="pri" />
+							<enum name="pseudo" />
+							<enum name="ss7" />
+						</enumlist>
+					</enum>
 					<enum name="keypad_digits">
 						<para>R/O PRI Keypad digits that came in with the SETUP message.</para>
 					</enum>




More information about the svn-commits mailing list