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
is now available in the AVAILCAUSECODE variable. If existing dialplan logic
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
*/
.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) */
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)
} else if (!strcasecmp(data, "reversecharge")) {
ast_module_ref(ast_module_info->self);
+ dahdi_ami_channel_event(i, tmp);
if (startpbx) {
#ifdef HAVE_OPENR2
if (i->mfcr2call) {
nobch_channel = CHAN_PSEUDO - 1;
}
pvt->channel = nobch_channel;
+ pvt->span = pri->span;
chan->channel = pvt->channel;
dahdi_nobch_insert(pri, pvt);