--- chan_dahdi.c.orig 2009-01-28 10:29:26.000000000 -0700 +++ chan_dahdi.c 2009-02-18 15:37:12.000000000 -0700 @@ -2678,6 +2678,7 @@ ldp_strip = 0; prilocaldialplan = p->pri->localdialplan - 1; + if ((l != NULL) && (prilocaldialplan == -2 || prilocaldialplan == -3)) { /* compute dynamically */ if (strncmp(l, p->pri->internationalprefix, strlen(p->pri->internationalprefix)) == 0) { if (prilocaldialplan == -2) { @@ -2890,6 +2891,76 @@ } #ifdef HAVE_PRI +static char *dahdi_send_mwi_act_facility_app = "DAHDISendMWIActFacility"; + +static char *dahdi_send_mwi_act_facility_synopsis = "Send MWI activate via CISC"; + +static char *dahdi_send_mwi_act_facility_descrip = +" DAHDISendMWIActFacility(): This application will send an MWI Facility message over the ISDN D-channel.\n"; + +static int dahdi_send_mwi_act_facility_exec(struct ast_channel *chan, void *data) +{ + /* Data will be the extension number */ + struct dahdi_pvt *p; + char *digits = (char *) data; + + if (ast_strlen_zero(digits)) { + ast_log(LOG_WARNING, "No digit string sent to application!\n"); + return -1; + } + + p = (struct dahdi_pvt *)chan->tech_pvt; + + ast_mutex_lock(&p->lock); + + if ((p->call = pri_new_call(p->pri->pri))) { + pri_mwi_activate(p->pri->pri, p->call, "274", PRI_UNKNOWN, "Asterisk MWI", PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, digits, PRI_UNKNOWN); + pri_rel(p->pri); + } else { + ast_debug(1, "Unable to setup new call via pri_new_call.\n"); + return -1; + } + + ast_mutex_unlock(&p->lock); + + return 0; +} + +static char *dahdi_send_mwi_deact_facility_app = "DAHDISendMWIDeactFacility"; + +static char *dahdi_send_mwi_deact_facility_synopsis = "Send MWI deactivate via CISC"; + +static char *dahdi_send_mwi_deact_facility_descrip = +" DAHDISendMWIDeactFacility(): This application will send an MWI Facility message over the ISDN D-channel.\n"; + +static int dahdi_send_mwi_deact_facility_exec(struct ast_channel *chan, void *data) +{ + /* Data will be the extension number */ + struct dahdi_pvt *p; + char *digits = (char *) data; + + if (ast_strlen_zero(digits)) { + ast_log(LOG_WARNING, "No digit string sent to application!\n"); + return -1; + } + + p = (struct dahdi_pvt *)chan->tech_pvt; + + ast_mutex_lock(&p->lock); + + if ((p->call = pri_new_call(p->pri->pri))) { + pri_mwi_deactivate(p->pri->pri, p->call, "274", PRI_UNKNOWN, "Asterisk MWI", PRES_ALLOWED_USER_NUMBER_PASSED_SCREEN, digits, PRI_UNKNOWN); + pri_rel(p->pri); + } else { + ast_debug(1, "Unable to setup new call via pri_new_call.\n"); + return -1; + } + + ast_mutex_unlock(&p->lock); + + return 0; +} + static char *dahdi_send_keypad_facility_app = "DAHDISendKeypadFacility"; static char *dahdi_send_keypad_facility_synopsis = "Send digits out of band over a PRI"; @@ -13550,6 +13621,8 @@ } ast_cli_unregister_multiple(dahdi_pri_cli, ARRAY_LEN(dahdi_pri_cli)); ast_unregister_application(dahdi_send_keypad_facility_app); + ast_unregister_application(dahdi_send_mwi_act_facility_app); + ast_unregister_application(dahdi_send_mwi_deact_facility_app); #endif #if defined(HAVE_SS7) for (i = 0; i < NUM_SPANS; i++) { @@ -14832,6 +14905,10 @@ pri_set_message(dahdi_pri_message); ast_register_application(dahdi_send_keypad_facility_app, dahdi_send_keypad_facility_exec, dahdi_send_keypad_facility_synopsis, dahdi_send_keypad_facility_descrip); + ast_register_application(dahdi_send_mwi_act_facility_app, dahdi_send_mwi_act_facility_exec, + dahdi_send_mwi_act_facility_synopsis, dahdi_send_mwi_act_facility_descrip); + ast_register_application(dahdi_send_mwi_deact_facility_app, dahdi_send_mwi_deact_facility_exec, + dahdi_send_mwi_deact_facility_synopsis, dahdi_send_mwi_deact_facility_descrip); #endif #ifdef HAVE_SS7 memset(linksets, 0, sizeof(linksets));