Index: channels/chan_dahdi.c =================================================================== --- channels/chan_dahdi.c (revision 274530) +++ channels/chan_dahdi.c (working copy) @@ -46,6 +46,12 @@ openr2 ***/ + +/* Define to have variables set in a PRI base channel */ +/* holding the span and the channel numbers. */ + +/* #define PRI_VARS 1 */ + #include "asterisk.h" ASTERISK_FILE_VERSION(__FILE__, "$Revision$") @@ -6564,6 +6570,14 @@ break; } ast_mutex_unlock(&p->lock); + } else if (!strcasecmp(data, "pri_span")) { + ast_mutex_lock(&p->lock); + snprintf(buf, len, "%d", p->span); + ast_mutex_unlock(&p->lock); + } else if (!strcasecmp(data, "pri_channel")) { + ast_mutex_lock(&p->lock); + snprintf(buf, len, "%d", p->channel); + ast_mutex_unlock(&p->lock); #endif /* defined(HAVE_PRI) */ } else { *buf = '\0'; @@ -9129,6 +9143,16 @@ for (v = i->vars ; v ; v = v->next) pbx_builtin_setvar_helper(tmp, v->name, v->value); +#if defined(PRI_VARS) +#if defined(HAVE_PRI) + char tmpvalue[256]; + snprintf(tmpvalue, sizeof(tmpvalue), "%d", i->channel); + pbx_builtin_setvar_helper(tmp, "PRI_CHANNEL", tmpvalue); + snprintf(tmpvalue, sizeof(tmpvalue), "%d", i->span); + pbx_builtin_setvar_helper(tmp, "PRI_SPAN", tmpvalue); +#endif +#endif + ast_module_ref(ast_module_info->self); if (startpbx) { @@ -9137,6 +9161,8 @@ pbx_builtin_setvar_helper(tmp, "MFCR2_CATEGORY", openr2_proto_get_category_string(i->mfcr2_recvd_category)); } #endif + + if (ast_pbx_start(tmp)) { ast_log(LOG_WARNING, "Unable to start PBX on %s\n", tmp->name); ast_hangup(tmp); Index: funcs/func_channel.c =================================================================== --- funcs/func_channel.c (revision 274530) +++ funcs/func_channel.c (working copy) @@ -228,6 +228,12 @@ + + R/O Get the span related to this DAHDI channel. + + + R/O Get the PRI channel related to this DAHDI channel. +