Index: chan_dahdi.c =================================================================== --- chan_dahdi.c (revision 274530) +++ chan_dahdi.c (working copy) @@ -46,6 +46,11 @@ 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$") @@ -9129,6 +9134,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 +9152,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);