diff options
author | mattf <mattf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-12-01 18:52:24 +0000 |
---|---|---|
committer | mattf <mattf@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-12-01 18:52:24 +0000 |
commit | ceafc46bc4d40b54b801e98e561c71cd4e587281 (patch) | |
tree | 2b58fb1fe93ad150a68fe1bdd879300db317de5e /channels/chan_zap.c | |
parent | 5aa2136eb93ceec53630cee81c40770eba1bf8b7 (diff) |
Add app to send pri keypad facility digits during a call
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@7254 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channels/chan_zap.c')
-rw-r--r-- | channels/chan_zap.c | 53 |
1 files changed, 52 insertions, 1 deletions
diff --git a/channels/chan_zap.c b/channels/chan_zap.c index 79ae6c921..4f729f8ae 100644 --- a/channels/chan_zap.c +++ b/channels/chan_zap.c @@ -58,7 +58,7 @@ #include <ctype.h> #ifdef ZAPATA_PRI #include <libpri.h> -#ifndef PRI_USER_USER_TX +#ifndef PRI_KEYPAD_FACILITY_TX #error "You need newer libpri" #endif #endif @@ -2211,6 +2211,54 @@ static int destroy_channel(struct zt_pvt *prev, struct zt_pvt *cur, int now) } #ifdef ZAPATA_PRI +static char *zap_send_keypad_facility_app = "ZapSendKeypadFacility"; + +static char *zap_send_keypad_facility_synopsis = "Send digits out of band over a PRI"; + +static char *zap_send_keypad_facility_descrip = +" ZapSendKeypadFacility(): This application will send the given string of digits in a Keypad Facility\n" +" IE over the current channel.\n"; + +static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data) +{ + /* Data will be our digit string */ + struct zt_pvt *p; + char *digits = (char *) data; + + if (ast_strlen_zero(digits)) { + ast_log(LOG_DEBUG, "No digit string sent to application!\n"); + return -1; + } + + p = (struct zt_pvt *)chan->tech_pvt; + + if (!p) { + ast_log(LOG_DEBUG, "Unable to find technology private\n"); + return -1; + } + + ast_mutex_lock(&p->lock); + + if (!p->pri || !p->call) { + ast_log(LOG_DEBUG, "Unable to find pri or call on channel!\n"); + ast_mutex_unlock(&p->lock); + return -1; + } + + if (!pri_grab(p, p->pri)) { + pri_keypad_facility(p->pri->pri, p->call, digits); + pri_rel(p->pri); + } else { + ast_log(LOG_DEBUG, "Unable to grab pri to send keypad facility!\n"); + ast_mutex_unlock(&p->lock); + return -1; + } + + ast_mutex_unlock(&p->lock); + + return 0; +} + int pri_is_up(struct zt_pri *pri) { int x; @@ -9980,6 +10028,7 @@ static int __unload_module(void) pthread_cancel(pris[i].master); } ast_cli_unregister_multiple(zap_pri_cli, sizeof(zap_pri_cli) / sizeof(zap_pri_cli[0])); + ast_unregister_application(zap_send_keypad_facility_app); #endif #ifdef ZAPATA_R2 ast_cli_unregister_multiple(zap_r2_cli, sizeof(zap_r2_cli) / sizeof(zap_r2_cli[0])); @@ -10869,6 +10918,8 @@ int load_module(void) } pri_set_error(zt_pri_error); pri_set_message(zt_pri_message); + ast_register_application(zap_send_keypad_facility_app, zap_send_keypad_facility_exec, + zap_send_keypad_facility_synopsis, zap_send_keypad_facility_descrip); #endif res = setup_zap(0); /* Make sure we can register our Zap channel type */ |