Goodbye Zaptel, hello DAHDI. Removes Zaptel driver support with DAHDI. Configuration...
authorJeff Peeler <jpeeler@digium.com>
Thu, 12 Jun 2008 17:27:55 +0000 (17:27 +0000)
committerJeff Peeler <jpeeler@digium.com>
Thu, 12 Jun 2008 17:27:55 +0000 (17:27 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@122234 65c4cc65-6c06-0410-ace0-fbb531ad65f3

77 files changed:
Makefile
README
apps/app_chanisavail.c
apps/app_chanspy.c
apps/app_dahdibarge.c [moved from apps/app_zapbarge.c with 76% similarity]
apps/app_dahdiras.c [moved from apps/app_zapras.c with 72% similarity]
apps/app_dahdiscan.c [moved from apps/app_zapscan.c with 77% similarity]
apps/app_dial.c
apps/app_fax.c [deleted file]
apps/app_flash.c
apps/app_getcpeid.c
apps/app_meetme.c
apps/app_page.c
apps/app_queue.c
apps/app_rpt.c
build_tools/menuselect-deps.in
cdr/cdr_csv.c
channels/chan_dahdi.c [moved from channels/chan_zap.c with 86% similarity]
channels/chan_iax2.c
channels/chan_mgcp.c
codecs/codec_dahdi.c [moved from codecs/codec_zap.c with 75% similarity]
configs/extensions.ael.sample
configs/extensions.conf.sample
configs/extensions.lua.sample
configs/meetme.conf.sample
configs/muted.conf.sample
configs/queues.conf.sample
configs/rpt.conf.sample
configs/sla.conf.sample
configs/smdi.conf.sample
configs/users.conf.sample
configs/vpb.conf.sample
configs/zapata.conf.sample
configure
configure.ac
contrib/init.d/rc.mandrake.asterisk
contrib/init.d/rc.mandrake.zaptel
contrib/init.d/rc.suse.asterisk
contrib/scripts/autosupport
contrib/scripts/loadtest.tcl
contrib/utils/zones2indications.c
doc/asterisk.8
doc/asterisk.sgml
doc/backtrace.txt
doc/janitor-projects.txt
doc/manager_1_1.txt
doc/osp.txt
doc/sms.txt
doc/ss7.txt
doc/tex/ael.tex
doc/tex/app-sms.tex
doc/tex/backtrace.tex
doc/tex/channelvariables.tex
doc/tex/configuration.tex
doc/tex/enum.tex
doc/tex/hardware.tex
doc/tex/localchannel.tex
doc/tex/manager.tex
doc/tex/privacy.tex
doc/tex/queues-with-callback-members.tex
doc/tex/security.tex
doc/tex/sla.tex
include/asterisk/autoconfig.h.in
include/asterisk/channel.h
include/asterisk/dahdi.h [moved from include/asterisk/zapata.h with 51% similarity]
include/asterisk/doxyref.h
include/asterisk/dsp.h
include/asterisk/options.h
main/asterisk.c
main/channel.c
main/features.c
main/file.c
main/loader.c
makeopts.in
pbx/pbx_config.c
res/res_musiconhold.c
utils/extconf.c

index 65e0a5f..639ffbb 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -680,6 +680,7 @@ samples: adsi
                echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
                echo ";runuser = asterisk ; The user to run as" ; \
                echo ";rungroup = asterisk ; The group to run as" ; \
+               echo "dahdichanname = yes" ; Set channel name as DAHDI\
                echo "" ; \
                echo "; Changing the following lines may compromise your security." ; \
                echo ";[files]" ; \
diff --git a/README b/README
index aa2b248..e132db8 100644 (file)
--- a/README
+++ b/README
@@ -175,7 +175,7 @@ they're used only to help make the configuration file easier to
 understand, and do not affect how it is actually parsed.
 
   Entries of the form 'variable=value' set the value of some parameter in
-asterisk.  For example, in zapata.conf, one might specify:
+asterisk.  For example, in dahdi.conf, one might specify:
 
        switchtype=national
 
index 6a9cd81..68cab31 100644 (file)
@@ -75,7 +75,7 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
        );
 
        if (ast_strlen_zero(data)) {
-               ast_log(LOG_WARNING, "ChanIsAvail requires an argument (Zap/1&Zap/2)\n");
+               ast_log(LOG_WARNING, "ChanIsAvail requires an argument (DAHDI/1&DAHDI/2)\n");
                return -1;
        }
 
index cd00a25..2f5a997 100644 (file)
@@ -47,6 +47,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/translate.h"
 #include "asterisk/module.h"
 #include "asterisk/lock.h"
+#include "asterisk/options.h"
 
 #define AST_NAME_STRLEN 256
 #define NUM_SPYGROUPS 128
@@ -587,6 +588,7 @@ static struct chanspy_ds *next_channel(struct ast_channel *chan,
        const char *exten, const char *context, struct chanspy_ds *chanspy_ds)
 {
        struct ast_channel *next;
+       char channel_name[AST_CHANNEL_NAME];
 
 redo:
        if (!ast_strlen_zero(spec))
@@ -599,7 +601,8 @@ redo:
        if (!next)
                return NULL;
 
-       if (!strncmp(next->name, "Zap/pseudo", 10)) {
+       snprintf(channel_name, AST_CHANNEL_NAME, "%s/pseudo", dahdi_chan_name);
+       if (!strncmp(next->name, channel_name, 10)) {
                ast_channel_unlock(next);
                goto redo;
        } else if (next == chan) {
similarity index 76%
rename from apps/app_zapbarge.c
rename to apps/app_dahdibarge.c
index 892dd1e..b70b57b 100644 (file)
@@ -21,7 +21,7 @@
 
 /*! \file
  *
- * \brief Zap Barge support
+ * \brief DAHDI Barge support
  *
  * \author Mark Spencer <markster@digium.com>
  *
  */
 
 /*** MODULEINFO
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
  ***/
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/zapata.h"
+#include "asterisk/dahdi.h"
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -52,12 +52,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/say.h"
 #include "asterisk/utils.h"
 
-static char *app = "ZapBarge";
+static char *app = "DAHDIBarge";
+static char *deprecated_app = "ZapBarge";
 
-static char *synopsis = "Barge in (monitor) Zap channel";
+static char *synopsis = "Barge in (monitor) DAHDI channel";
 
 static char *descrip = 
-"  ZapBarge([channel]): Barges in on a specified zap\n"
+"  DAHDIBarge([channel]): Barges in on a specified DAHDI\n"
 "channel or prompts if one is not specified.  Returns\n"
 "-1 when caller user hangs up and is independent of the\n"
 "state of the channel being monitored.";
@@ -86,7 +87,7 @@ static int careful_write(int fd, unsigned char *data, int len)
 static int conf_run(struct ast_channel *chan, int confno, int confflags)
 {
        int fd;
-       struct zt_confinfo ztc;
+       struct dahdi_confinfo dahdic;
        struct ast_frame *f;
        struct ast_channel *c;
        struct ast_frame fr;
@@ -95,11 +96,11 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
        int nfds;
        int res;
        int flags;
-       int retryzap;
+       int retrydahdi;
        int origfd;
        int ret = -1;
 
-       ZT_BUFFERINFO bi;
+       DAHDI_BUFFERINFO bi;
        char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
        char *buf = __buf + AST_FRIENDLY_OFFSET;
 
@@ -115,11 +116,11 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
                goto outrun;
        }
        ast_indicate(chan, -1);
-       retryzap = strcasecmp(chan->tech->type, "Zap");
-zapretry:
+       retrydahdi = strcasecmp(chan->tech->type, "DAHDI");
+dahdiretry:
        origfd = chan->fds[0];
-       if (retryzap) {
-               fd = open("/dev/zap/pseudo", O_RDWR);
+       if (retrydahdi) {
+               fd = open("/dev/dahdi/pseudo", O_RDWR);
                if (fd < 0) {
                        ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
                        goto outrun;
@@ -139,10 +140,10 @@ zapretry:
                /* Setup buffering information */
                memset(&bi, 0, sizeof(bi));
                bi.bufsize = CONF_SIZE;
-               bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-               bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+               bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
+               bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
                bi.numbufs = 4;
-               if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
+               if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
                        ast_log(LOG_WARNING, "Unable to set buffering information: %s\n", strerror(errno));
                        close(fd);
                        goto outrun;
@@ -153,34 +154,34 @@ zapretry:
                fd = chan->fds[0];
                nfds = 0;
        }
-       memset(&ztc, 0, sizeof(ztc));
+       memset(&dahdic, 0, sizeof(dahdic));
        /* Check to see if we're in a conference... */
-       ztc.chan = 0;   
-       if (ioctl(fd, ZT_GETCONF, &ztc)) {
+       dahdic.chan = 0;        
+       if (ioctl(fd, DAHDI_GETCONF, &dahdic)) {
                ast_log(LOG_WARNING, "Error getting conference\n");
                close(fd);
                goto outrun;
        }
-       if (ztc.confmode) {
+       if (dahdic.confmode) {
                /* Whoa, already in a conference...  Retry... */
-               if (!retryzap) {
-                       ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
-                       retryzap = 1;
-                       goto zapretry;
+               if (!retrydahdi) {
+                       ast_debug(1, "DAHDI channel is in a conference already, retrying with pseudo\n");
+                       retrydahdi = 1;
+                       goto dahdiretry;
                }
        }
-       memset(&ztc, 0, sizeof(ztc));
+       memset(&dahdic, 0, sizeof(dahdic));
        /* Add us to the conference */
-       ztc.chan = 0;   
-       ztc.confno = confno;
-       ztc.confmode = ZT_CONF_MONITORBOTH;
+       dahdic.chan = 0;        
+       dahdic.confno = confno;
+       dahdic.confmode = DAHDI_CONF_MONITORBOTH;
 
-       if (ioctl(fd, ZT_SETCONF, &ztc)) {
+       if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                ast_log(LOG_WARNING, "Error setting conference\n");
                close(fd);
                goto outrun;
        }
-       ast_debug(1, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+       ast_debug(1, "Placed channel %s in DAHDI channel %d monitor\n", chan->name, confno);
 
        for(;;) {
                outfd = -1;
@@ -188,13 +189,13 @@ zapretry:
                c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms);
                if (c) {
                        if (c->fds[0] != origfd) {
-                               if (retryzap) {
+                               if (retrydahdi) {
                                        /* Kill old pseudo */
                                        close(fd);
                                }
                                ast_debug(1, "Ooh, something swapped out under us, starting over\n");
-                               retryzap = 0;
-                               goto zapretry;
+                               retrydahdi = 0;
+                               goto dahdiretry;
                        }
                        f = ast_read(c);
                        if (!f) 
@@ -236,10 +237,10 @@ zapretry:
        else {
                /* Take out of conference */
                /* Add us to the conference */
-               ztc.chan = 0;   
-               ztc.confno = 0;
-               ztc.confmode = 0;
-               if (ioctl(fd, ZT_SETCONF, &ztc)) {
+               dahdic.chan = 0;        
+               dahdic.confno = 0;
+               dahdic.confmode = 0;
+               if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                        ast_log(LOG_WARNING, "Error setting conference\n");
                }
        }
@@ -258,9 +259,9 @@ static int conf_exec(struct ast_channel *chan, void *data)
        char confstr[80] = "";
        
        if (!ast_strlen_zero(data)) {
-               if ((sscanf(data, "Zap/%d", &confno) != 1) &&
+               if ((sscanf(data, "DAHDI/%d", &confno) != 1) &&
                    (sscanf(data, "%d", &confno) != 1)) {
-                       ast_log(LOG_WARNING, "ZapBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data);
+                       ast_log(LOG_WARNING, "DAHDIBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data);
                        return 0;
                }
        }
@@ -286,6 +287,12 @@ out:
        return res;
 }
 
+static int conf_exec_warn(struct ast_channel *chan, void *data)
+{
+       ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", deprecated_app, app);
+       return conf_exec(chan, data);
+}
+
 static int unload_module(void)
 {
        return ast_unregister_application(app);
@@ -293,7 +300,8 @@ static int unload_module(void)
 
 static int load_module(void)
 {
+       ast_register_application(deprecated_app, conf_exec_warn, synopsis, descrip);
        return ((ast_register_application(app, conf_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on Zap channel application");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on DAHDI channel application");
similarity index 72%
rename from apps/app_zapras.c
rename to apps/app_dahdiras.c
index 6e079e3..384607d 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 /*** MODULEINFO
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
  ***/
 
 #include "asterisk.h"
@@ -43,7 +43,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include <fcntl.h>
 
-#include "asterisk/zapata.h"
+#include "asterisk/dahdi.h"
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -52,15 +52,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/module.h"
 #include "asterisk/app.h"
 
-static char *app = "ZapRAS";
+static char *app = "DAHDIRAS";
+static char *deprecated_app = "ZapRAS";
 
-static char *synopsis = "Executes Zaptel ISDN RAS application";
+static char *synopsis = "Executes DAHDI ISDN RAS application";
 
 static char *descrip =
-"  ZapRAS(args): Executes a RAS server using pppd on the given channel.\n"
-"The channel must be a clear channel (i.e. PRI source) and a Zaptel\n"
+"  DAHDIRAS(args): Executes a RAS server using pppd on the given channel.\n"
+"The channel must be a clear channel (i.e. PRI source) and a DAHDI\n"
 "channel to be able to use this function (No modem emulation is included).\n"
-"Your pppd must be patched to be zaptel aware. Arguments should be\n"
+"Your pppd must be patched to be DAHDI aware. Arguments should be\n"
 "separated by , characters.\n";
 
 
@@ -96,7 +97,7 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
        memset(argv, 0, sizeof(argv));
 
        /* First argument is executable, followed by standard
-          arguments for zaptel PPP */
+          arguments for DAHDI PPP */
        argv[argc++] = PPP_EXEC;
        argv[argc++] = "nodetach";
 
@@ -109,7 +110,7 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
        }
 
        argv[argc++] = "plugin";
-       argv[argc++] = "zaptel.so";
+       argv[argc++] = "dahdi.so";
        argv[argc++] = "stdin";
 
        /* Finally launch PPP */
@@ -124,10 +125,10 @@ static void run_ras(struct ast_channel *chan, char *args)
        int status;
        int res;
        int signalled = 0;
-       struct zt_bufferinfo savebi;
+       struct dahdi_bufferinfo savebi;
        int x;
        
-       res = ioctl(chan->fds[0], ZT_GET_BUFINFO, &savebi);
+       res = ioctl(chan->fds[0], DAHDI_GET_BUFINFO, &savebi);
        if(res) {
                ast_log(LOG_WARNING, "Unable to check buffer policy on channel %s\n", chan->name);
                return;
@@ -163,10 +164,10 @@ static void run_ras(struct ast_channel *chan, char *args)
                        }
                        /* Throw back into audio mode */
                        x = 1;
-                       ioctl(chan->fds[0], ZT_AUDIOMODE, &x);
+                       ioctl(chan->fds[0], DAHDI_AUDIOMODE, &x);
 
                        /* Restore saved values */
-                       res = ioctl(chan->fds[0], ZT_SET_BUFINFO, &savebi);
+                       res = ioctl(chan->fds[0], DAHDI_SET_BUFINFO, &savebi);
                        if (res < 0) {
                                ast_log(LOG_WARNING, "Unable to set buffer policy on channel %s\n", chan->name);
                        }
@@ -176,11 +177,11 @@ static void run_ras(struct ast_channel *chan, char *args)
        ast_safe_fork_cleanup();
 }
 
-static int zapras_exec(struct ast_channel *chan, void *data)
+static int dahdiras_exec(struct ast_channel *chan, void *data)
 {
        int res=-1;
        char *args;
-       ZT_PARAMS ztp;
+       DAHDI_PARAMS dahdip;
 
        if (!data) 
                data = "";
@@ -190,16 +191,16 @@ static int zapras_exec(struct ast_channel *chan, void *data)
        /* Answer the channel if it's not up */
        if (chan->_state != AST_STATE_UP)
                ast_answer(chan);
-       if (strcasecmp(chan->tech->type, "Zap")) {
-               /* If it's not a zap channel, we're done.  Wait a couple of
+       if (strcasecmp(chan->tech->type, "DAHDI")) {
+               /* If it's not a DAHDI channel, we're done.  Wait a couple of
                   seconds and then hangup... */
-               ast_verb(2, "Channel %s is not a Zap channel\n", chan->name);
+               ast_verb(2, "Channel %s is not a DAHDI channel\n", chan->name);
                sleep(2);
        } else {
-               memset(&ztp, 0, sizeof(ztp));
-               if (ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp)) {
-                       ast_log(LOG_WARNING, "Unable to get zaptel parameters\n");
-               } else if (ztp.sigtype != ZT_SIG_CLEAR) {
+               memset(&dahdip, 0, sizeof(dahdip));
+               if (ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip)) {
+                       ast_log(LOG_WARNING, "Unable to get DAHDI parameters\n");
+               } else if (dahdip.sigtype != DAHDI_SIG_CLEAR) {
                        ast_verb(2, "Channel %s is not a clear channel\n", chan->name);
                } else {
                        /* Everything should be okay.  Run PPP. */
@@ -211,6 +212,12 @@ static int zapras_exec(struct ast_channel *chan, void *data)
        return res;
 }
 
+static int dahdiras_exec_warn(struct ast_channel *chan, void *data)
+{
+       ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", deprecated_app, app);
+       return dahdiras_exec(chan, data);
+}
+
 static int unload_module(void) 
 {
        return ast_unregister_application(app);
@@ -218,8 +225,9 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-       return ((ast_register_application(app, zapras_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
+    ast_register_application(deprecated_app, dahdiras_exec_warn, synopsis, descrip);
+       return ((ast_register_application(app, dahdiras_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Zaptel ISDN Remote Access Server");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "DAHDI ISDN Remote Access Server");
 
similarity index 77%
rename from apps/app_zapscan.c
rename to apps/app_dahdiscan.c
index 3724675..b760613 100644 (file)
@@ -23,7 +23,7 @@
 
 /*! \file
  *
- * \brief Zap Scanner
+ * \brief DAHDI Scanner
  *
  * \author Mark Spencer <markster@digium.com>
  *
  */
 
 /*** MODULEINFO
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
  ***/
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/zapata.h"
+#include "asterisk/dahdi.h"
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -50,23 +50,25 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/utils.h"
 #include "asterisk/cli.h"
 #include "asterisk/say.h"
+#include "asterisk/options.h"
 
-static char *app = "ZapScan";
+static char *app = "DAHDIScan";
+static char *deprecated_app = "ZapScan";
 
-static char *synopsis = "Scan Zap channels to monitor calls";
+static char *synopsis = "Scan DAHDI channels to monitor calls";
 
 static char *descrip =
-"  ZapScan([group]) allows a call center manager to monitor Zap channels in\n"
+"  DAHDIScan([group]) allows a call center manager to monitor DAHDI channels in\n"
 "a convenient way.  Use '#' to select the next channel and use '*' to exit\n"
 "Limit scanning to a channel GROUP by setting the option group argument.\n";
 
 
 #define CONF_SIZE 160
 
-static struct ast_channel *get_zap_channel_locked(int num) {
+static struct ast_channel *get_dahdi_channel_locked(int num) {
        char name[80];
        
-       snprintf(name, sizeof(name), "Zap/%d-1", num);
+       snprintf(name, sizeof(name), "%s/%d-1", dahdi_chan_name, num);
        return ast_get_channel_by_name_locked(name);
 }
 
@@ -92,7 +94,7 @@ static int careful_write(int fd, unsigned char *data, int len)
 static int conf_run(struct ast_channel *chan, int confno, int confflags)
 {
        int fd;
-       struct zt_confinfo ztc;
+       struct dahdi_confinfo dahdic;
        struct ast_frame *f;
        struct ast_channel *c;
        struct ast_frame fr;
@@ -101,13 +103,13 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
        int nfds;
        int res;
        int flags;
-       int retryzap;
+       int retrydahdi;
        int origfd;
        int ret = -1;
        char input[4];
        int ic = 0;
        
-       ZT_BUFFERINFO bi;
+       DAHDI_BUFFERINFO bi;
        char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
        char *buf = __buf + AST_FRIENDLY_OFFSET;
        
@@ -123,11 +125,11 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
                goto outrun;
        }
        ast_indicate(chan, -1);
-       retryzap = strcasecmp(chan->tech->type, "Zap");
- zapretry:
+       retrydahdi = strcasecmp(chan->tech->type, "DAHDI");
+ dahdiretry:
        origfd = chan->fds[0];
-       if (retryzap) {
-               fd = open("/dev/zap/pseudo", O_RDWR);
+       if (retrydahdi) {
+               fd = open("/dev/dahdi/pseudo", O_RDWR);
                if (fd < 0) {
                        ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
                        goto outrun;
@@ -147,10 +149,10 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
                /* Setup buffering information */
                memset(&bi, 0, sizeof(bi));
                bi.bufsize = CONF_SIZE;
-               bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-               bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+               bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
+               bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
                bi.numbufs = 4;
-               if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
+               if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
                        ast_log(LOG_WARNING, "Unable to set buffering information: %s\n", strerror(errno));
                        close(fd);
                        goto outrun;
@@ -161,34 +163,34 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
                fd = chan->fds[0];
                nfds = 0;
        }
-       memset(&ztc, 0, sizeof(ztc));
+       memset(&dahdic, 0, sizeof(dahdic));
        /* Check to see if we're in a conference... */
-       ztc.chan = 0;
-       if (ioctl(fd, ZT_GETCONF, &ztc)) {
+       dahdic.chan = 0;
+       if (ioctl(fd, DAHDI_GETCONF, &dahdic)) {
                ast_log(LOG_WARNING, "Error getting conference\n");
                close(fd);
                goto outrun;
        }
-       if (ztc.confmode) {
+       if (dahdic.confmode) {
                /* Whoa, already in a conference...  Retry... */
-               if (!retryzap) {
-                       ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
-                       retryzap = 1;
-                       goto zapretry;
+               if (!retrydahdi) {
+                       ast_debug(1, "DAHDI channel is in a conference already, retrying with pseudo\n");
+                       retrydahdi = 1;
+                       goto dahdiretry;
                }
        }
-       memset(&ztc, 0, sizeof(ztc));
+       memset(&dahdic, 0, sizeof(dahdic));
        /* Add us to the conference */
-       ztc.chan = 0;
-       ztc.confno = confno;
-       ztc.confmode = ZT_CONF_MONITORBOTH;
+       dahdic.chan = 0;
+       dahdic.confno = confno;
+       dahdic.confmode = DAHDI_CONF_MONITORBOTH;
 
-       if (ioctl(fd, ZT_SETCONF, &ztc)) {
+       if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                ast_log(LOG_WARNING, "Error setting conference\n");
                close(fd);
                goto outrun;
        }
-       ast_debug(1, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+       ast_debug(1, "Placed channel %s in DAHDI channel %d monitor\n", chan->name, confno);
 
        for (;;) {
                outfd = -1;
@@ -196,13 +198,13 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
                c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms);
                if (c) {
                        if (c->fds[0] != origfd) {
-                               if (retryzap) {
+                               if (retrydahdi) {
                                        /* Kill old pseudo */
                                        close(fd);
                                }
                                ast_debug(1, "Ooh, something swapped out under us, starting over\n");
-                               retryzap = 0;
-                               goto zapretry;
+                               retrydahdi = 0;
+                               goto dahdiretry;
                        }
                        f = ast_read(c);
                        if (!f) {
@@ -222,7 +224,7 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
                                        input[ic++] = '\0';
                                        ic = 0;
                                        ret = atoi(input);
-                                       ast_verb(3, "Zapscan: change channel to %d\n", ret);
+                                       ast_verb(3, "DAHDIScan: change channel to %d\n", ret);
                                        break;
                                }
                        }
@@ -265,10 +267,10 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
        } else {
                /* Take out of conference */
                /* Add us to the conference */
-               ztc.chan = 0;
-               ztc.confno = 0;
-               ztc.confmode = 0;
-               if (ioctl(fd, ZT_SETCONF, &ztc)) {
+               dahdic.chan = 0;
+               dahdic.confno = 0;
+               dahdic.confmode = 0;
+               if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                        ast_log(LOG_WARNING, "Error setting conference\n");
                }
        }
@@ -312,7 +314,7 @@ static int conf_exec(struct ast_channel *chan, void *data)
                ast_frfree(f);
                ichan = NULL;
                if(input) {
-                       ichan = get_zap_channel_locked(input);
+                       ichan = get_dahdi_channel_locked(input);
                        input = 0;
                }
 
@@ -332,8 +334,8 @@ static int conf_exec(struct ast_channel *chan, void *data)
                                continue;
                        }
                }
-               if (tempchan && (!strcmp(tempchan->tech->type, "Zap")) && (tempchan != chan)) {
-                       ast_verb(3, "Zap channel %s is in-use, monitoring...\n", tempchan->name);
+               if (tempchan && (!strcmp(tempchan->tech->type, "DAHDI")) && (tempchan != chan)) {
+                       ast_verb(3, "DAHDI channel %s is in-use, monitoring...\n", tempchan->name);
                        ast_copy_string(confstr, tempchan->name, sizeof(confstr));
                        ast_channel_unlock(tempchan);
                        if ((tmp = strchr(confstr, '-'))) {
@@ -355,6 +357,12 @@ static int conf_exec(struct ast_channel *chan, void *data)
        return res;
 }
 
+static int conf_exec_warn(struct ast_channel *chan, void *data)
+{
+    ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", deprecated_app, app);
+    return conf_exec(chan, data);
+}
+
 static int unload_module(void)
 {
        return ast_unregister_application(app);
@@ -362,8 +370,9 @@ static int unload_module(void)
 
 static int load_module(void)
 {
+       ast_register_application(deprecated_app, conf_exec_warn, synopsis, descrip);
        return ((ast_register_application(app, conf_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Scan Zap channels application");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Scan DAHDI channels application");
 
index d3a2aed..490fa34 100644 (file)
@@ -171,8 +171,8 @@ static char *descrip =
 "    o    - Specify that the CallerID that was present on the *calling* channel\n"
 "           be set as the CallerID on the *called* channel. This was the\n"
 "           behavior of Asterisk 1.0 and earlier.\n"
-"    O([x]) - \"Operator Services\" mode (Zaptel channel to Zaptel channel\n"
-"             only, if specified on non-Zaptel interface, it will be ignored).\n"
+"    O([x]) - \"Operator Services\" mode (DAHDI channel to DAHDI channel\n"
+"             only, if specified on non-DAHDI interface, it will be ignored).\n"
 "             When the destination answers (presumably an operator services\n"
 "             station), the originator no longer has control of their line.\n"
 "             They may hang up, but the switch will not release their line\n"
@@ -1895,9 +1895,9 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                                res = -1;
                                goto done;
                        }
-                       if (opermode && !strncmp(chan->name, "Zap", 3) && !strncmp(peer->name, "Zap", 3)) {
-                               /* what's this special handling for Zap <-> Zap ?
-                                * A: Zap to Zap calls are natively bridged at the kernel driver
+                       if (opermode && !strncmp(chan->tech->type, "DAHDI", 3) && !strncmp(peer->name, "DAHDI", 3)) {
+                               /* what's this special handling for dahdi <-> dahdi ?
+                                * A: dahdi to dahdi calls are natively bridged at the kernel driver
                                 * level, so we need to ensure that this mode gets propagated
                                 * all the way down. */
                                struct oprmode oprmode;
diff --git a/apps/app_fax.c b/apps/app_fax.c
deleted file mode 100644 (file)
index cf98cc9..0000000
+++ /dev/null
@@ -1,741 +0,0 @@
-/*
- * Asterisk -- A telephony toolkit for Linux.
- *
- * Simple fax applications
- * 
- * 2007-2008, Dmitry Andrianov <asterisk@dima.spb.ru>
- *
- * Code based on original implementation by Steve Underwood <steveu@coppice.org>
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License
- *
- */
-
-/*** MODULEINFO
-        <depend>spandsp</depend>
-***/
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <inttypes.h>
-#include <pthread.h>
-#include <errno.h>
-#include <tiffio.h>
-
-#include <spandsp.h>
-
-#include "asterisk/lock.h"
-#include "asterisk/file.h"
-#include "asterisk/logger.h"
-#include "asterisk/channel.h"
-#include "asterisk/pbx.h"
-#include "asterisk/app.h"
-#include "asterisk/dsp.h"
-#include "asterisk/module.h"
-#include "asterisk/manager.h"
-
-static char *app_sndfax_name = "SendFAX";
-static char *app_sndfax_synopsis = "Send a FAX";
-static char *app_sndfax_desc = 
-"  SendFAX(filename[|options]):\n"
-"Send a given TIFF file to the channel as a FAX.\n"
-"The option string may contain zero or more of the following characters:\n"
-"     'a' -- makes the application behave as an answering machine\n"
-"          The default behaviour is to behave as a calling machine.\n"
-"\n"
-"This application uses following variables:\n"
-"     LOCALSTATIONID to identify itself to the remote end.\n"
-"     LOCALHEADERINFO to generate a header line on each page.\n"
-"\n"
-"This application sets the following channel variables upon completion:\n"
-"     FAXSTATUS       - status of operation:\n"
-"                         SUCCESS | FAILED\n"
-"     FAXERROR - Error when FAILED\n"
-"     REMOTESTATIONID - CSID of the remote side.\n"
-"     FAXPAGES - number of pages sent.\n"
-"     FAXBITRATE      - transmition rate.\n"
-"     FAXRESOLUTION   - resolution.\n"
-"\n"
-"Returns -1 in case of user hang up or any channel error.\n"
-"Returns 0 on success.\n";
-
-static char *app_rcvfax_name = "ReceiveFAX";
-static char *app_rcvfax_synopsis = "Receive a FAX";
-static char *app_rcvfax_desc = 
-"  ReceiveFAX(filename[|options]):\n"
-"Receives a fax from the channel into the given filename overwriting\n"
-"the file if it already exists. File created will have TIFF format.\n"
-"The option string may contain zero or more of the following characters:\n"
-"     'c' -- makes the application behave as a calling machine\n"
-"          The default behaviour is to behave as an answering machine.\n"
-"\n"
-"This application uses following variables:\n"
-"     LOCALSTATIONID to identify itself to the remote end.\n"
-"     LOCALHEADERINFO to generate a header line on each page.\n"
-"\n"
-"This application sets the following channel variables upon completion:\n"
-"     FAXSTATUS       - status of operation:\n"
-"                         SUCCESS | FAILED\n"
-"     FAXERROR - Error when FAILED\n"
-"     REMOTESTATIONID - CSID of the remote side.\n"
-"     FAXPAGES - number of pages sent.\n"
-"     FAXBITRATE      - transmition rate.\n"
-"     FAXRESOLUTION   - resolution.\n"
-"\n"
-"Returns -1 in case of user hang up or any channel error.\n"
-"Returns 0 on success.\n";
-
-#define MAX_SAMPLES 240
-
-/* Watchdog. I have seen situations when remote fax disconnects (because of poor line
-   quality) while SpanDSP continues staying in T30_STATE_IV_CTC state forever.
-   To avoid this, we terminate when we see that T30 state does not change for 5 minutes.
-   We also terminate application when more than 30 minutes passed regardless of
-   state changes. This is just a precaution measure - no fax should take that long */
-
-#define WATCHDOG_TOTAL_TIMEOUT 30 * 60
-#define WATCHDOG_STATE_TIMEOUT 5 * 60
-
-typedef struct {
-       struct ast_channel *chan;
-       enum ast_t38_state t38state;    /* T38 state of the channel */
-       int direction;                  /* Fax direction: 0 - receiving, 1 - sending */
-       int caller_mode;
-       char *file_name;
-       
-       volatile int finished;
-} fax_session;
-
-static void span_message(int level, const char *msg)
-{
-       if (level == SPAN_LOG_ERROR) {
-               ast_log(LOG_ERROR, "%s", msg);
-       } else if (level == SPAN_LOG_WARNING) {
-               ast_log(LOG_WARNING, "%s", msg);
-       } else {
-               ast_log(LOG_DEBUG, "%s", msg);
-       }
-}
-
-static int t38_tx_packet_handler(t38_core_state_t *s, void *user_data, const uint8_t *buf, int len, int count)
-{
-       struct ast_channel *chan = (struct ast_channel *) user_data;
-
-       struct ast_frame outf = {
-               .frametype = AST_FRAME_MODEM,
-               .subclass = AST_MODEM_T38,
-               .src = __FUNCTION__,
-       };
-
-       /* TODO: Asterisk does not provide means of resending the same packet multiple
-         times so count is ignored at the moment */
-
-       AST_FRAME_SET_BUFFER(&outf, buf, 0, len);
-
-       if (ast_write(chan, &outf) < 0) {
-               ast_log(LOG_WARNING, "Unable to write frame to channel; %s\n", strerror(errno));
-               return -1;
-       }
-
-       return 0;
-}
-
-static void phase_e_handler(t30_state_t *f, void *user_data, int result)
-{
-       const char *local_ident;
-       const char *far_ident;
-       char buf[20];
-       fax_session *s = (fax_session *) user_data;
-       t30_stats_t stat;
-
-       ast_debug(1, "Fax phase E handler. result=%d\n", result);
-
-       t30_get_transfer_statistics(f, &stat);
-
-       s = (fax_session *) user_data;
-
-       if (result != T30_ERR_OK) {
-               s->finished = -1;
-
-               /* FAXSTATUS is already set to FAILED */
-               pbx_builtin_setvar_helper(s->chan, "FAXERROR", t30_completion_code_to_str(result));
-
-               ast_log(LOG_WARNING, "Error transmitting fax. result=%d: %s.\n", result, t30_completion_code_to_str(result));
-
-               return;
-       }
-       
-       s->finished = 1; 
-       
-       local_ident = t30_get_tx_ident(f);
-       far_ident = t30_get_rx_ident(f);
-       pbx_builtin_setvar_helper(s->chan, "FAXSTATUS", "SUCCESS"); 
-       pbx_builtin_setvar_helper(s->chan, "FAXERROR", NULL); 
-       pbx_builtin_setvar_helper(s->chan, "REMOTESTATIONID", far_ident);
-       snprintf(buf, sizeof(buf), "%d", stat.pages_transferred);
-       pbx_builtin_setvar_helper(s->chan, "FAXPAGES", buf);
-       snprintf(buf, sizeof(buf), "%d", stat.y_resolution);
-       pbx_builtin_setvar_helper(s->chan, "FAXRESOLUTION", buf);
-       snprintf(buf, sizeof(buf), "%d", stat.bit_rate);
-       pbx_builtin_setvar_helper(s->chan, "FAXBITRATE", buf); 
-       
-       ast_debug(1, "Fax transmitted successfully.\n");
-       ast_debug(1, "  Remote station ID: %s\n", far_ident);
-       ast_debug(1, "  Pages transferred: %d\n", stat.pages_transferred);
-       ast_debug(1, "  Image resolution:  %d x %d\n", stat.x_resolution, stat.y_resolution);
-       ast_debug(1, "  Transfer Rate:     %d\n", stat.bit_rate);
-       
-       manager_event(EVENT_FLAG_CALL,
-                     s->direction ? "FaxSent" : "FaxReceived", 
-                     "Channel: %s\r\n"
-                     "Exten: %s\r\n"
-                     "CallerID: %s\r\n"
-                     "RemoteStationID: %s\r\n"
-                     "LocalStationID: %s\r\n"
-                     "PagesTransferred: %d\r\n"
-                     "Resolution: %d\r\n"
-                     "TransferRate: %d\r\n"
-                     "FileName: %s\r\n",
-                     s->chan->name,
-                     s->chan->exten,
-                     S_OR(s->chan->cid.cid_num, ""),
-                     far_ident,
-                     local_ident,
-                     stat.pages_transferred,
-                     stat.y_resolution,
-                     stat.bit_rate,
-                     s->file_name);
-}
-
-/* === Helper functions to configure fax === */
-
-/* Setup SPAN logging according to Asterisk debug level */
-static int set_logging(logging_state_t *state)
-{
-       int level = SPAN_LOG_WARNING + option_debug;
-
-       span_log_set_message_handler(state, span_message);
-       span_log_set_level(state, SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | level); 
-
-       return 0;
-}
-
-static void set_local_info(t30_state_t *state, fax_session *s)
-{
-       const char *x;
-
-       x = pbx_builtin_getvar_helper(s->chan, "LOCALSTATIONID");
-       if (!ast_strlen_zero(x))
-               t30_set_tx_ident(state, x);
-
-       x = pbx_builtin_getvar_helper(s->chan, "LOCALHEADERINFO");
-       if (!ast_strlen_zero(x))
-               t30_set_tx_page_header_info(state, x);
-}
-
-static void set_file(t30_state_t *state, fax_session *s)
-{
-       if (s->direction)
-               t30_set_tx_file(state, s->file_name, -1, -1);
-       else
-               t30_set_rx_file(state, s->file_name, -1);
-}
-
-static void set_ecm(t30_state_t *state, int ecm)
-{
-       t30_set_ecm_capability(state, ecm);
-       t30_set_supported_compressions(state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
-}
-
-/* === Generator === */
-
-/* This function is only needed to return passed params so
-   generator_activate will save it to channel's generatordata */
-static void *fax_generator_alloc(struct ast_channel *chan, void *params)
-{
-       return params;
-}
-
-static int fax_generator_generate(struct ast_channel *chan, void *data, int len, int samples)
-{
-       fax_state_t *fax = (fax_state_t*) data;
-       uint8_t buffer[AST_FRIENDLY_OFFSET + MAX_SAMPLES * sizeof(uint16_t)];
-       int16_t *buf = (int16_t *) (buffer + AST_FRIENDLY_OFFSET);
-    
-       struct ast_frame outf = {
-               .frametype = AST_FRAME_VOICE,
-               .subclass = AST_FORMAT_SLINEAR,
-               .src = __FUNCTION__,
-       };
-
-       if (samples > MAX_SAMPLES) {
-               ast_log(LOG_WARNING, "Only generating %d samples, where %d requested\n", MAX_SAMPLES, samples);
-               samples = MAX_SAMPLES;
-       }
-       
-       if ((len = fax_tx(fax, buf, samples)) > 0) {
-               outf.samples = len;
-               AST_FRAME_SET_BUFFER(&outf, buffer, AST_FRIENDLY_OFFSET, len * sizeof(int16_t));
-
-               if (ast_write(chan, &outf) < 0) {
-                       ast_log(LOG_WARNING, "Failed to write frame to '%s': %s\n", chan->name, strerror(errno));
-                       return -1;
-               }
-       }
-
-       return 0;
-}
-
-struct ast_generator generator = {
-       alloc:          fax_generator_alloc,
-       generate:       fax_generator_generate,
-};
-
-
-/* === Transmission === */
-
-static int transmit_audio(fax_session *s)
-{
-       int res = -1;
-       int original_read_fmt = AST_FORMAT_SLINEAR;
-       int original_write_fmt = AST_FORMAT_SLINEAR;
-       fax_state_t fax;
-       struct ast_dsp *dsp = NULL;
-       int detect_tone = 0;
-       struct ast_frame *inf = NULL;
-       struct ast_frame *fr;
-       int last_state = 0;
-       struct timeval now, start, state_change;
-       enum ast_control_t38 t38control;
-
-       original_read_fmt = s->chan->readformat;
-       if (original_read_fmt != AST_FORMAT_SLINEAR) {
-               res = ast_set_read_format(s->chan, AST_FORMAT_SLINEAR);
-               if (res < 0) {
-                       ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n");
-                       goto done;
-               }
-       }
-
-       original_write_fmt = s->chan->writeformat;
-       if (original_write_fmt != AST_FORMAT_SLINEAR) {
-               res = ast_set_write_format(s->chan, AST_FORMAT_SLINEAR);
-               if (res < 0) {
-                       ast_log(LOG_WARNING, "Unable to set to linear write mode, giving up\n");
-                       goto done;
-               }
-       }
-
-       /* Initialize T30 terminal */
-       fax_init(&fax, s->caller_mode);
-
-       /* Setup logging */
-       set_logging(&fax.logging);
-       set_logging(&fax.t30_state.logging);
-
-       /* Configure terminal */
-       set_local_info(&fax.t30_state, s);
-       set_file(&fax.t30_state, s);
-       set_ecm(&fax.t30_state, TRUE);
-
-       fax_set_transmit_on_idle(&fax, TRUE);
-
-       t30_set_phase_e_handler(&fax.t30_state, phase_e_handler, s);
-
-       if (s->t38state == T38_STATE_UNAVAILABLE) {
-               ast_debug(1, "T38 is unavailable on %s\n", s->chan->name);
-       } else if (!s->direction) {
-               /* We are receiving side and this means we are the side which should
-                  request T38 when the fax is detected. Use DSP to detect fax tone */
-               ast_debug(1, "Setting up CNG detection on %s\n", s->chan->name);
-               dsp = ast_dsp_new();
-               ast_dsp_set_features(dsp, DSP_FEATURE_FAX_DETECT);
-               ast_dsp_set_faxmode(dsp, DSP_FAXMODE_DETECT_CNG);
-               detect_tone = 1;
-       }
-
-       start = state_change = ast_tvnow();
-
-       ast_activate_generator(s->chan, &generator, &fax);
-
-       while (!s->finished) {
-               res = ast_waitfor(s->chan, 20);
-               if (res < 0)
-                       break;
-               else if (res > 0)
-                       res = 0;
-
-               inf = ast_read(s->chan);
-               if (inf == NULL) {
-                       ast_debug(1, "Channel hangup\n");
-                       res = -1;
-                       break;
-               }
-
-               ast_debug(10, "frame %d/%d, len=%d\n", inf->frametype, inf->subclass, inf->datalen);
-
-               /* Detect fax tone */
-               if (detect_tone && inf->frametype == AST_FRAME_VOICE) {
-                       /* Duplicate frame because ast_dsp_process may free the frame passed */
-                       fr = ast_frdup(inf);
-
-                       /* Do not pass channel to ast_dsp_process otherwise it may queue modified audio frame back */
-                       fr = ast_dsp_process(NULL, dsp, fr);
-                       if (fr && fr->frametype == AST_FRAME_DTMF && fr->subclass == 'f') {
-                               ast_debug(1, "Fax tone detected. Requesting T38\n");
-                               t38control = AST_T38_REQUEST_NEGOTIATE;
-                               ast_indicate_data(s->chan, AST_CONTROL_T38, &t38control, sizeof(t38control));
-                               detect_tone = 0;
-                       }
-
-                       ast_frfree(fr);
-               }
-
-
-               /* Check the frame type. Format also must be checked because there is a chance
-                  that a frame in old format was already queued before we set chanel format
-                  to slinear so it will still be received by ast_read */
-               if (inf->frametype == AST_FRAME_VOICE && inf->subclass == AST_FORMAT_SLINEAR) {
-
-                       if (fax_rx(&fax, inf->data.ptr, inf->samples) < 0) {
-                               /* I know fax_rx never returns errors. The check here is for good style only */
-                               ast_log(LOG_WARNING, "fax_rx returned error\n");
-                               res = -1;
-                               break;
-                       }
-
-                       /* Watchdog */
-                       if (last_state != fax.t30_state.state) {
-                               state_change = ast_tvnow();
-                               last_state = fax.t30_state.state;
-                       }
-               } else if (inf->frametype == AST_FRAME_CONTROL && inf->subclass == AST_CONTROL_T38 &&
-                               inf->datalen == sizeof(enum ast_control_t38)) {
-                       t38control =*((enum ast_control_t38 *) inf->data.ptr);
-                       if (t38control == AST_T38_NEGOTIATED) {
-                               /* T38 switchover completed */
-                               ast_debug(1, "T38 negotiated, finishing audio loop\n");
-                               res = 1;
-                               break;
-                       }
-               }
-
-               ast_frfree(inf);
-               inf = NULL;
-
-               /* Watchdog */
-               now = ast_tvnow();
-               if (ast_tvdiff_sec(now, start) > WATCHDOG_TOTAL_TIMEOUT || ast_tvdiff_sec(now, state_change) > WATCHDOG_STATE_TIMEOUT) {
-                       ast_log(LOG_WARNING, "It looks like we hung. Aborting.\n");
-                       res = -1;
-                       break;
-               }
-       }
-
-       ast_debug(1, "Loop finished, res=%d\n", res);
-
-       if (inf)
-               ast_frfree(inf);
-
-       if (dsp)
-               ast_dsp_free(dsp);
-
-       ast_deactivate_generator(s->chan);
-
-       /* Remove phase E handler because we do not want it to be executed
-          only because we called t30_terminate */
-       t30_set_phase_e_handler(&fax.t30_state, NULL, NULL);
-
-       t30_terminate(&fax.t30_state);
-       fax_release(&fax);
-
-done:
-       if (original_write_fmt != AST_FORMAT_SLINEAR) {
-               if (ast_set_write_format(s->chan, original_write_fmt) < 0)
-                       ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", s->chan->name);
-       }
-
-       if (original_read_fmt != AST_FORMAT_SLINEAR) {
-               if (ast_set_read_format(s->chan, original_read_fmt) < 0)
-                       ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", s->chan->name);
-       }
-
-       return res;
-
-}
-
-static int transmit_t38(fax_session *s)
-{
-       int res = 0;
-       t38_terminal_state_t t38;
-       struct ast_frame *inf = NULL;
-       int last_state = 0;
-       struct timeval now, start, state_change, last_frame;
-       enum ast_control_t38 t38control;
-
-       /* Initialize terminal */
-       memset(&t38, 0, sizeof(t38));
-       if (t38_terminal_init(&t38, s->caller_mode, t38_tx_packet_handler, s->chan) == NULL) {
-               ast_log(LOG_WARNING, "Unable to start T.38 termination.\n");
-               return -1;
-       }
-
-       /* Setup logging */
-       set_logging(&t38.logging);
-       set_logging(&t38.t30_state.logging);
-       set_logging(&t38.t38.logging);
-
-       /* Configure terminal */
-       set_local_info(&t38.t30_state, s);
-       set_file(&t38.t30_state, s);
-       set_ecm(&t38.t30_state, TRUE);
-
-       t30_set_phase_e_handler(&t38.t30_state, phase_e_handler, s);
-
-       now = start = state_change = ast_tvnow();
-
-       while (!s->finished) {
-
-               res = ast_waitfor(s->chan, 20);
-               if (res < 0)
-                       break;
-               else if (res > 0)
-                       res = 0;
-
-               last_frame = now;
-               now = ast_tvnow();
-               t38_terminal_send_timeout(&t38, ast_tvdiff_us(now, last_frame) / (1000000 / 8000));
-
-               inf = ast_read(s->chan);
-               if (inf == NULL) {
-                       ast_debug(1, "Channel hangup\n");
-                       res = -1;
-                       break;
-               }
-
-               ast_debug(10, "frame %d/%d, len=%d\n", inf->frametype, inf->subclass, inf->datalen);
-
-               if (inf->frametype == AST_FRAME_MODEM && inf->subclass == AST_MODEM_T38) {
-                       t38_core_rx_ifp_packet(&t38.t38, inf->data.ptr, inf->datalen, inf->seqno);
-
-                       /* Watchdog */
-                       if (last_state != t38.t30_state.state) {
-                               state_change = ast_tvnow();
-                               last_state = t38.t30_state.state;
-                       }
-               } else if (inf->frametype == AST_FRAME_CONTROL && inf->subclass == AST_CONTROL_T38 &&
-                               inf->datalen == sizeof(enum ast_control_t38)) {
-
-                       t38control = *((enum ast_control_t38 *) inf->data.ptr);
-
-                       if (t38control == AST_T38_TERMINATED || t38control == AST_T38_REFUSED) {
-                               ast_debug(1, "T38 down, terminating\n");
-                               res = -1;
-                               break;
-                       }
-               }
-
-               ast_frfree(inf);
-               inf = NULL;
-
-               /* Watchdog */
-               if (ast_tvdiff_sec(now, start) > WATCHDOG_TOTAL_TIMEOUT || ast_tvdiff_sec(now, state_change) > WATCHDOG_STATE_TIMEOUT) {
-                       ast_log(LOG_WARNING, "It looks like we hung. Aborting.\n");
-                       res = -1;
-                       break;
-               }
-       }
-
-       ast_debug(1, "Loop finished, res=%d\n", res);
-
-       if (inf)
-               ast_frfree(inf);
-
-       /* Remove phase E handler because we do not want it to be executed
-          only because we called t30_terminate */
-       t30_set_phase_e_handler(&t38.t30_state, NULL, NULL);
-
-       t30_terminate(&t38.t30_state);
-
-       return res;
-}
-
-static int transmit(fax_session *s)
-{
-       int res = 0;
-
-       /* Clear all channel variables which to be set by the application.
-          Pre-set status to error so in case of any problems we can just leave */
-       pbx_builtin_setvar_helper(s->chan, "FAXSTATUS", "FAILED"); 
-       pbx_builtin_setvar_helper(s->chan, "FAXERROR", "Channel problems"); 
-
-       pbx_builtin_setvar_helper(s->chan, "REMOTESTATIONID", NULL);
-       pbx_builtin_setvar_helper(s->chan, "FAXPAGES", NULL);
-       pbx_builtin_setvar_helper(s->chan, "FAXRESOLUTION", NULL);
-       pbx_builtin_setvar_helper(s->chan, "FAXBITRATE", NULL); 
-
-       if (s->chan->_state != AST_STATE_UP) {
-               /* Shouldn't need this, but checking to see if channel is already answered
-                * Theoretically asterisk should already have answered before running the app */
-               res = ast_answer(s->chan);
-               if (res) {
-                       ast_log(LOG_WARNING, "Could not answer channel '%s'\n", s->chan->name);
-                       return res;
-               }
-       }
-
-       s->t38state = ast_channel_get_t38_state(s->chan);
-       if (s->t38state != T38_STATE_NEGOTIATED) {
-               /* T38 is not negotiated on the channel yet. First start regular transmission. If it switches to T38, follow */ 
-               res = transmit_audio(s);
-               if (res > 0) {
-                       /* transmit_audio reports switchover to T38. Update t38state */
-                       s->t38state = ast_channel_get_t38_state(s->chan);
-                       if (s->t38state != T38_STATE_NEGOTIATED) {
-                               ast_log(LOG_ERROR, "Audio loop reports T38 switchover but t38state != T38_STATE_NEGOTIATED\n");
-                       }
-               }
-       }
-
-       if (s->t38state == T38_STATE_NEGOTIATED) {
-               res = transmit_t38(s);
-       }
-
-       if (res) {
-               ast_log(LOG_WARNING, "Transmission error\n");
-               res = -1;
-       } else if (s->finished < 0) {
-               ast_log(LOG_WARNING, "Transmission failed\n");
-       } else if (s->finished > 0) {
-               ast_debug(1, "Transmission finished Ok\n");
-       }
-
-       return res;
-}
-
-/* === Application functions === */
-
-static int sndfax_exec(struct ast_channel *chan, void *data)
-{
-       int res = 0;
-       char *parse;
-       fax_session session;
-
-       AST_DECLARE_APP_ARGS(args,
-               AST_APP_ARG(file_name);
-               AST_APP_ARG(options);
-       );
-
-       if (chan == NULL) {
-               ast_log(LOG_ERROR, "Fax channel is NULL. Giving up.\n");
-               return -1;
-       }
-
-       /* The next few lines of code parse out the filename and header from the input string */
-       if (ast_strlen_zero(data)) {
-               /* No data implies no filename or anything is present */
-               ast_log(LOG_ERROR, "SendFAX requires an argument (filename)\n");
-               return -1;
-       }
-
-       parse = ast_strdupa(data);
-       AST_STANDARD_APP_ARGS(args, parse);
-       
-       session.caller_mode = TRUE;
-
-       if (args.options) {
-               if (strchr(args.options, 'a'))
-                       session.caller_mode = FALSE;
-       }
-
-       /* Done parsing */
-       session.direction = 1;
-       session.file_name = args.file_name;
-       session.chan = chan;
-       session.finished = 0;
-
-       res = transmit(&session);
-
-       return res;
-}
-
-static int rcvfax_exec(struct ast_channel *chan, void *data)
-{
-       int res = 0;
-       char *parse;
-       fax_session session;
-
-       AST_DECLARE_APP_ARGS(args,
-               AST_APP_ARG(file_name);
-               AST_APP_ARG(options);
-       );
-
-       if (chan == NULL) {
-               ast_log(LOG_ERROR, "Fax channel is NULL. Giving up.\n");
-               return -1;
-       }
-
-       /* The next few lines of code parse out the filename and header from the input string */
-       if (ast_strlen_zero(data)) {
-               /* No data implies no filename or anything is present */
-               ast_log(LOG_ERROR, "ReceiveFAX requires an argument (filename)\n");
-               return -1;
-       }
-
-       parse = ast_strdupa(data);
-       AST_STANDARD_APP_ARGS(args, parse);
-       
-       session.caller_mode = FALSE;
-
-       if (args.options) {
-               if (strchr(args.options, 'c'))
-                       session.caller_mode = TRUE;
-       }
-
-       /* Done parsing */
-       session.direction = 0;
-       session.file_name = args.file_name;
-       session.chan = chan;
-       session.finished = 0;
-
-       res = transmit(&session);
-
-       return res;
-}
-
-static int unload_module(void)
-{
-       int res;
-
-       res = ast_unregister_application(app_sndfax_name);      
-       res |= ast_unregister_application(app_rcvfax_name);     
-
-       return res;
-}
-
-static int load_module(void)
-{
-       int res ;
-
-       res = ast_register_application(app_sndfax_name, sndfax_exec, app_sndfax_synopsis, app_sndfax_desc);
-       res |= ast_register_application(app_rcvfax_name, rcvfax_exec, app_rcvfax_synopsis, app_rcvfax_desc);
-
-       /* The default SPAN message handler prints to stderr. It is something we do not want */
-       span_set_message_handler(NULL);
-
-       return res;
-}
-
-
-AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Simple FAX Application",
-               .load = load_module,
-               .unload = unload_module,
-               );
-
-
index d57feeb..dd13f41 100644 (file)
@@ -18,7 +18,7 @@
 
 /*! \file
  *
- * \brief App to flash a zap trunk
+ * \brief App to flash a DAHDI trunk
  *
  * \author Mark Spencer <markster@digium.com>
  * 
  */
  
 /*** MODULEINFO
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
  ***/
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/zapata.h"
+#include "asterisk/dahdi.h"
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -45,22 +45,22 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 static char *app = "Flash";
 
-static char *synopsis = "Flashes a Zap Trunk";
+static char *synopsis = "Flashes a DAHDI Trunk";
 
 static char *descrip = 
-"Performs a flash on a zap trunk.  This can be used\n"
+"Performs a flash on a DAHDI trunk.  This can be used\n"
 "to access features provided on an incoming analogue circuit\n"
 "such as conference and call waiting. Use with SendDTMF() to\n"
 "perform external transfers\n";
 
 
-static inline int zt_wait_event(int fd)
+static inline int dahdi_wait_event(int fd)
 {
-       /* Avoid the silly zt_waitevent which ignores a bunch of events */
+       /* Avoid the silly dahdi_waitevent which ignores a bunch of events */
        int i,j=0;
-       i = ZT_IOMUX_SIGEVENT;
-       if (ioctl(fd, ZT_IOMUX, &i) == -1) return -1;
-       if (ioctl(fd, ZT_GETEVENT, &j) == -1) return -1;
+       i = DAHDI_IOMUX_SIGEVENT;
+       if (ioctl(fd, DAHDI_IOMUX, &i) == -1) return -1;
+       if (ioctl(fd, DAHDI_GETEVENT, &j) == -1) return -1;
        return j;
 }
 
@@ -68,23 +68,23 @@ static int flash_exec(struct ast_channel *chan, void *data)
 {
        int res = -1;
        int x;
-       struct zt_params ztp;
+       struct dahdi_params dahdip;
 
-       if (strcasecmp(chan->tech->type, "Zap")) {
-               ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
+       if (strcasecmp(chan->tech->type, "DAHDI")) {
+               ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", chan->name);
                return -1;
        }
        
-       memset(&ztp, 0, sizeof(ztp));
-       res = ioctl(chan->fds[0], ZT_GET_PARAMS, &ztp);
+       memset(&dahdip, 0, sizeof(dahdip));
+       res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip);
        if (!res) {
-               if (ztp.sigtype & __ZT_SIG_FXS) {
-                       x = ZT_FLASH;
-                       res = ioctl(chan->fds[0], ZT_HOOK, &x);
+               if (dahdip.sigtype & __DAHDI_SIG_FXS) {
+                       x = DAHDI_FLASH;
+                       res = ioctl(chan->fds[0], DAHDI_HOOK, &x);
                        if (!res || (errno == EINPROGRESS)) {
                                if (res) {
                                        /* Wait for the event to finish */
-                                       zt_wait_event(chan->fds[0]);
+                                       dahdi_wait_event(chan->fds[0]);
                                }
                                res = ast_safe_sleep(chan, 1000);
                                ast_verb(3, "Flashed channel %s\n", chan->name);
index 1bab819..6ff0518 100644 (file)
@@ -42,7 +42,7 @@ static char *synopsis = "Get ADSI CPE ID";
 
 static char *descrip =
 "  GetCPEID(): Obtains and displays ADSI CPE ID and other information in order\n"
-"to properly setup zapata.conf for on-hook operations.\n";
+"to properly setup dahdi.conf for on-hook operations.\n";
 
 
 static int cpeid_setstatus(struct ast_channel *chan, char *stuff[], int voice)
index 8b017ff..fc0a08a 100644 (file)
  */
 
 /*** MODULEINFO
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
  ***/
 
 #include "asterisk.h"
 
 ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
-#include "asterisk/zapata.h"
+#include "asterisk/dahdi.h"
 
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
@@ -228,15 +228,15 @@ static const char *descrip =
 "conference.  If the conference number is omitted, the user will be prompted\n"
 "to enter one.  User can exit the conference by hangup, or if the 'p' option\n"
 "is specified, by pressing '#'.\n"
-"Please note: The Zaptel kernel modules and at least one hardware driver (or ztdummy)\n"
-"             must be present for conferencing to operate properly. In addition, the chan_zap\n"
+"Please note: The DAHDI kernel modules and at least one hardware driver (or dahdi_dummy)\n"
+"             must be present for conferencing to operate properly. In addition, the chan_dahdi\n"
 "             channel driver must be loaded for the 'i' and 'r' options to operate at all.\n\n"
 "The option string may contain zero or more of the following characters:\n"
 "      'a' -- set admin mode\n"
 "      'A' -- set marked mode\n"
 "      'b' -- run AGI script specified in ${MEETME_AGI_BACKGROUND}\n"
 "             Default: conf-background.agi  (Note: This does not work with\n"
-"             non-Zap channels in the same conference)\n"
+"             non-DAHDI channels in the same conference)\n"
 "      'c' -- announce user(s) count on joining a conference\n"
 "      'C' -- continue in dialplan when kicked out of conference\n"
 "      'd' -- dynamically add conference\n"
@@ -361,7 +361,7 @@ struct ast_conference {
        struct ast_channel *chan;               /*!< Announcements channel */
        struct ast_channel *lchan;              /*!< Listen/Record channel */
        int fd;                                 /*!< Announcements fd */
-       int zapconf;                            /*!< Zaptel Conf # */
+       int dahdiconf;                            /*!< DAHDI Conf # */
        int users;                              /*!< Number of active users */
        int markedusers;                        /*!< Number of marked users */
        int maxusers;                           /*!< Participant limit if scheduled */
@@ -403,7 +403,7 @@ struct ast_conf_user {
        int adminflags;                         /*!< Flags set by the Admin */
        struct ast_channel *chan;               /*!< Connected channel */
        int talking;                            /*!< Is user talking */
-       int zapchannel;                         /*!< Is a Zaptel channel */
+       int dahdichannel;                         /*!< Is a DAHDI channel */
        char usrvalue[50];                      /*!< Custom User Value */
        char namerecloc[PATH_MAX];                              /*!< Name Recorded file Location */
        time_t jointime;                        /*!< Time the user joined the conference */
@@ -639,8 +639,8 @@ static int careful_write(int fd, unsigned char *data, int len, int block)
 
        while (len) {
                if (block) {
-                       x = ZT_IOMUX_WRITE | ZT_IOMUX_SIGEVENT;
-                       res = ioctl(fd, ZT_IOMUX, &x);
+                       x = DAHDI_IOMUX_WRITE | DAHDI_IOMUX_SIGEVENT;
+                       res = ioctl(fd, DAHDI_IOMUX, &x);
                } else
                        res = 0;
                if (res >= 0)
@@ -801,7 +801,7 @@ static void conf_play(struct ast_channel *chan, struct ast_conference *conf, enu
 static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin, int make, int dynamic, int refcount, const struct ast_channel *chan)
 {
        struct ast_conference *cnf;
-       struct zt_confinfo ztc = { 0, };
+       struct dahdi_confinfo dahdic = { 0, };
        int confno_int = 0;
 
        AST_LIST_LOCK(&confs);
@@ -827,11 +827,11 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
        ast_copy_string(cnf->pinadmin, pinadmin, sizeof(cnf->pinadmin));
        ast_copy_string(cnf->uniqueid, chan->uniqueid, sizeof(cnf->uniqueid));
 
-       /* Setup a new zap conference */
-       ztc.confno = -1;
-       ztc.confmode = ZT_CONF_CONFANN | ZT_CONF_CONFANNMON;
-       cnf->fd = open("/dev/zap/pseudo", O_RDWR);
-       if (cnf->fd < 0 || ioctl(cnf->fd, ZT_SETCONF, &ztc)) {
+       /* Setup a new dahdi conference */
+       dahdic.confno = -1;
+       dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
+       cnf->fd = open("/dev/dahdi/pseudo", O_RDWR);
+       if (cnf->fd < 0 || ioctl(cnf->fd, DAHDI_SETCONF, &dahdic)) {
                ast_log(LOG_WARNING, "Unable to open pseudo device\n");
                if (cnf->fd >= 0)
                        close(cnf->fd);
@@ -840,17 +840,17 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
                goto cnfout;
        }
 
-       cnf->zapconf = ztc.confno;
+       cnf->dahdiconf = dahdic.confno;
 
        /* Setup a new channel for playback of audio files */
-       cnf->chan = ast_request("zap", AST_FORMAT_SLINEAR, "pseudo", NULL);
+       cnf->chan = ast_request("DAHDI", AST_FORMAT_SLINEAR, "pseudo", NULL);
        if (cnf->chan) {
                ast_set_read_format(cnf->chan, AST_FORMAT_SLINEAR);
                ast_set_write_format(cnf->chan, AST_FORMAT_SLINEAR);
-               ztc.chan = 0;
-               ztc.confno = cnf->zapconf;
-               ztc.confmode = ZT_CONF_CONFANN | ZT_CONF_CONFANNMON;
-               if (ioctl(cnf->chan->fds[0], ZT_SETCONF, &ztc)) {
+               dahdic.chan = 0;
+               dahdic.confno = cnf->dahdiconf;
+               dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
+               if (ioctl(cnf->chan->fds[0], DAHDI_SETCONF, &dahdic)) {
                        ast_log(LOG_WARNING, "Error setting conference\n");
                        if (cnf->chan)
                                ast_hangup(cnf->chan);
@@ -867,7 +867,7 @@ static struct ast_conference *build_conf(char *confno, char *pin, char *pinadmin
        cnf->start = time(NULL);
        cnf->maxusers = 0x7fffffff;
        cnf->isdynamic = dynamic ? 1 : 0;
-       ast_verb(3, "Created MeetMe conference %d for conference '%s'\n", cnf->zapconf, cnf->confno);
+       ast_verb(3, "Created MeetMe conference %d for conference '%s'\n", cnf->dahdiconf, cnf->confno);
        AST_LIST_INSERT_HEAD(&confs, cnf, list);
 
        /* Reserve conference number in map */
@@ -1309,8 +1309,8 @@ static void conf_flush(int fd, struct ast_channel *chan)
        }
 
        /* flush any data sitting in the pseudo channel */
-       x = ZT_FLUSH_ALL;
-       if (ioctl(fd, ZT_FLUSH, &x))
+       x = DAHDI_FLUSH_ALL;
+       if (ioctl(fd, DAHDI_FLUSH, &x))
                ast_log(LOG_WARNING, "Error flushing channel\n");
 
 }
@@ -1484,7 +1484,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
        struct ast_conf_user *user = NULL;
        struct ast_conf_user *usr = NULL;
        int fd;
-       struct zt_confinfo ztc, ztc_empty;
+       struct dahdi_confinfo dahdic, dahdic_empty;
        struct ast_frame *f;
        struct ast_channel *c;
        struct ast_frame fr;
@@ -1493,7 +1493,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
        int nfds;
        int res;
        int flags;
-       int retryzap;
+       int retrydahdi;
        int origfd;
        int musiconhold = 0;
        int firstpass = 0;
@@ -1520,7 +1520,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
        char members[10] = "";
        int dtmf, opt_waitmarked_timeout = 0;
        time_t timeout = 0;
-       ZT_BUFFERINFO bi;
+       DAHDI_BUFFERINFO bi;
        char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET];
        char *buf = __buf + AST_FRIENDLY_OFFSET;
        char *exitkeys = NULL;
@@ -1645,13 +1645,13 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
        }
 
        ast_mutex_lock(&conf->recordthreadlock);
-       if ((conf->recordthread == AST_PTHREADT_NULL) && (confflags & CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("zap", AST_FORMAT_SLINEAR, "pseudo", NULL)))) {
+       if ((conf->recordthread == AST_PTHREADT_NULL) && (confflags & CONFFLAG_RECORDCONF) && ((conf->lchan = ast_request("DAHDI", AST_FORMAT_SLINEAR, "pseudo", NULL)))) {
                ast_set_read_format(conf->lchan, AST_FORMAT_SLINEAR);
                ast_set_write_format(conf->lchan, AST_FORMAT_SLINEAR);
-               ztc.chan = 0;
-               ztc.confno = conf->zapconf;
-               ztc.confmode = ZT_CONF_CONFANN | ZT_CONF_CONFANNMON;
-               if (ioctl(conf->lchan->fds[0], ZT_SETCONF, &ztc)) {
+               dahdic.chan = 0;
+               dahdic.confno = conf->dahdiconf;
+               dahdic.confmode = DAHDI_CONF_CONFANN | DAHDI_CONF_CONFANNMON;
+               if (ioctl(conf->lchan->fds[0], DAHDI_SETCONF, &dahdic)) {
                        ast_log(LOG_WARNING, "Error starting listen channel\n");
                        ast_hangup(conf->lchan);
                        conf->lchan = NULL;
@@ -1832,13 +1832,13 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                goto outrun;
        }
 
-       retryzap = (strcasecmp(chan->tech->type, "Zap") || (chan->audiohooks || chan->monitor) ? 1 : 0);
-       user->zapchannel = !retryzap;
+       retrydahdi = (strcasecmp(chan->tech->type, "DAHDI") || (chan->audiohooks || chan->monitor) ? 1 : 0);
+       user->dahdichannel = !retrydahdi;
 
- zapretry:
+ dahdiretry:
        origfd = chan->fds[0];
-       if (retryzap) {
-               fd = open("/dev/zap/pseudo", O_RDWR);
+       if (retrydahdi) {
+               fd = open("/dev/dahdi/pseudo", O_RDWR);
                if (fd < 0) {
                        ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
                        goto outrun;
@@ -1859,16 +1859,16 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                /* Setup buffering information */
                memset(&bi, 0, sizeof(bi));
                bi.bufsize = CONF_SIZE / 2;
-               bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-               bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+               bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
+               bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
                bi.numbufs = audio_buffers;
-               if (ioctl(fd, ZT_SET_BUFINFO, &bi)) {
+               if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
                        ast_log(LOG_WARNING, "Unable to set buffering information: %s\n", strerror(errno));
                        close(fd);
                        goto outrun;
                }
                x = 1;
-               if (ioctl(fd, ZT_SETLINEAR, &x)) {
+               if (ioctl(fd, DAHDI_SETLINEAR, &x)) {
                        ast_log(LOG_WARNING, "Unable to set linear mode: %s\n", strerror(errno));
                        close(fd);
                        goto outrun;
@@ -1879,27 +1879,27 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                fd = chan->fds[0];
                nfds = 0;
        }
-       memset(&ztc, 0, sizeof(ztc));
-       memset(&ztc_empty, 0, sizeof(ztc_empty));
+       memset(&dahdic, 0, sizeof(dahdic));
+       memset(&dahdic_empty, 0, sizeof(dahdic_empty));
        /* Check to see if we're in a conference... */
-       ztc.chan = 0;   
-       if (ioctl(fd, ZT_GETCONF, &ztc)) {
+       dahdic.chan = 0;        
+       if (ioctl(fd, DAHDI_GETCONF, &dahdic)) {
                ast_log(LOG_WARNING, "Error getting conference\n");
                close(fd);
                goto outrun;
        }
-       if (ztc.confmode) {
+       if (dahdic.confmode) {
                /* Whoa, already in a conference...  Retry... */
-               if (!retryzap) {
-                       ast_debug(1, "Zap channel is in a conference already, retrying with pseudo\n");
-                       retryzap = 1;
-                       goto zapretry;
+               if (!retrydahdi) {
+                       ast_debug(1, "DAHDI channel is in a conference already, retrying with pseudo\n");
+                       retrydahdi = 1;
+                       goto dahdiretry;
                }
        }
-       memset(&ztc, 0, sizeof(ztc));
+       memset(&dahdic, 0, sizeof(dahdic));
        /* Add us to the conference */
-       ztc.chan = 0;   
-       ztc.confno = conf->zapconf;
+       dahdic.chan = 0;        
+       dahdic.confno = conf->dahdiconf;
 
        ast_mutex_lock(&conf->playlock);
 
@@ -1913,21 +1913,21 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
        }
 
        if (confflags & CONFFLAG_WAITMARKED && !conf->markedusers)
-               ztc.confmode = ZT_CONF_CONF;
+               dahdic.confmode = DAHDI_CONF_CONF;
        else if (confflags & CONFFLAG_MONITOR)
-               ztc.confmode = ZT_CONF_CONFMON | ZT_CONF_LISTENER;
+               dahdic.confmode = DAHDI_CONF_CONFMON | DAHDI_CONF_LISTENER;
        else if (confflags & CONFFLAG_TALKER)
-               ztc.confmode = ZT_CONF_CONF | ZT_CONF_TALKER;
+               dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER;
        else 
-               ztc.confmode = ZT_CONF_CONF | ZT_CONF_TALKER | ZT_CONF_LISTENER;
+               dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER;
 
-       if (ioctl(fd, ZT_SETCONF, &ztc)) {
+       if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                ast_log(LOG_WARNING, "Error setting conference\n");
                close(fd);
                ast_mutex_unlock(&conf->playlock);
                goto outrun;
        }
-       ast_debug(1, "Placed channel %s in ZAP conf %d\n", chan->name, conf->zapconf);
+       ast_debug(1, "Placed channel %s in ZAP conf %d\n", chan->name, conf->dahdiconf);
 
        if (!sent_event) {
                manager_event(EVENT_FLAG_CALL, "MeetmeJoin", 
@@ -1968,8 +1968,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                }
                ast_channel_unlock(chan);
                
-               if (user->zapchannel) {
-                       /*  Set CONFMUTE mode on Zap channel to mute DTMF tones */
+               if (user->dahdichannel) {
+                       /*  Set CONFMUTE mode on DAHDI channel to mute DTMF tones */
                        x = 1;
                        ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
                }
@@ -1981,14 +1981,14 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                        ast_log(LOG_WARNING, "Could not find application (agi)\n");
                        ret = -2;
                }
-               if (user->zapchannel) {
-                       /*  Remove CONFMUTE mode on Zap channel */
+               if (user->dahdichannel) {
+                       /*  Remove CONFMUTE mode on DAHDI channel */
                        x = 0;
                        ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
                }
        } else {
-               if (user->zapchannel && (confflags & CONFFLAG_STARMENU)) {
-                       /*  Set CONFMUTE mode on Zap channel to mute DTMF tones when the menu is enabled */
+               if (user->dahdichannel && (confflags & CONFFLAG_STARMENU)) {
+                       /*  Set CONFMUTE mode on DAHDI channel to mute DTMF tones when the menu is enabled */
                        x = 1;
                        ast_channel_setoption(chan, AST_OPTION_TONE_VERIFY, &x, sizeof(char), 0);
                }       
@@ -2139,8 +2139,8 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                                                ret = 0;
                                                        break;
                                                } else {
-                                                       ztc.confmode = ZT_CONF_CONF;
-                                                       if (ioctl(fd, ZT_SETCONF, &ztc)) {
+                                                       dahdic.confmode = DAHDI_CONF_CONF;
+                                                       if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                                                                ast_log(LOG_WARNING, "Error setting conference\n");
                                                                close(fd);
                                                                goto outrun;
@@ -2155,12 +2155,12 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                        /* Marked user entered, so cancel timeout */
                                        timeout = 0;
                                        if (confflags & CONFFLAG_MONITOR)
-                                               ztc.confmode = ZT_CONF_CONFMON | ZT_CONF_LISTENER;
+                                               dahdic.confmode = DAHDI_CONF_CONFMON | DAHDI_CONF_LISTENER;
                                        else if (confflags & CONFFLAG_TALKER)
-                                               ztc.confmode = ZT_CONF_CONF | ZT_CONF_TALKER;
+                                               dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER;
                                        else
-                                               ztc.confmode = ZT_CONF_CONF | ZT_CONF_TALKER | ZT_CONF_LISTENER;
-                                       if (ioctl(fd, ZT_SETCONF, &ztc)) {
+                                               dahdic.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER;
+                                       if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                                                ast_log(LOG_WARNING, "Error setting conference\n");
                                                close(fd);
                                                goto outrun;
@@ -2204,9 +2204,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                        /* Check if my modes have changed */
 
                        /* If I should be muted but am still talker, mute me */
-                       if ((user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && (ztc.confmode & ZT_CONF_TALKER)) {
-                               ztc.confmode ^= ZT_CONF_TALKER;
-                               if (ioctl(fd, ZT_SETCONF, &ztc)) {
+                       if ((user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && (dahdic.confmode & DAHDI_CONF_TALKER)) {
+                               dahdic.confmode ^= DAHDI_CONF_TALKER;
+                               if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                                        ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n");
                                        ret = -1;
                                        break;
@@ -2222,9 +2222,9 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                        }
 
                        /* If I should be un-muted but am not talker, un-mute me */
-                       if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && !(confflags & CONFFLAG_MONITOR) && !(ztc.confmode & ZT_CONF_TALKER)) {
-                               ztc.confmode |= ZT_CONF_TALKER;
-                               if (ioctl(fd, ZT_SETCONF, &ztc)) {
+                       if (!(user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)) && !(confflags & CONFFLAG_MONITOR) && !(dahdic.confmode & DAHDI_CONF_TALKER)) {
+                               dahdic.confmode |= DAHDI_CONF_TALKER;
+                               if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                                        ast_log(LOG_WARNING, "Error setting conference - Un/Mute \n");
                                        ret = -1;
                                        break;
@@ -2283,16 +2283,16 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                        if (c) {
                                char dtmfstr[2] = "";
 
-                               if (c->fds[0] != origfd || (user->zapchannel && (c->audiohooks || c->monitor))) {
+                               if (c->fds[0] != origfd || (user->dahdichannel && (c->audiohooks || c->monitor))) {
                                        if (using_pseudo) {
                                                /* Kill old pseudo */
                                                close(fd);
                                                using_pseudo = 0;
                                        }
                                        ast_debug(1, "Ooh, something swapped out under us, starting over\n");
-                                       retryzap = (strcasecmp(c->tech->type, "Zap") || (c->audiohooks || c->monitor) ? 1 : 0);
-                                       user->zapchannel = !retryzap;
-                                       goto zapretry;
+                                       retrydahdi = (strcasecmp(c->tech->type, "DAHDI") || (c->audiohooks || c->monitor) ? 1 : 0);
+                                       user->dahdichannel = !retrydahdi;
+                                       goto dahdiretry;
                                }
                                if ((confflags & CONFFLAG_MONITOR) || (user->adminflags & (ADMINFLAG_MUTED | ADMINFLAG_SELFMUTED)))
                                        f = ast_read_noaudio(c);
@@ -2358,7 +2358,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                } else if (((f->frametype == AST_FRAME_DTMF) && (f->subclass == '*') && (confflags & CONFFLAG_STARMENU)) || ((f->frametype == AST_FRAME_DTMF) && menu_active)) {
                                        if (confflags & CONFFLAG_PASS_DTMF)
                                                conf_queue_dtmf(conf, user, f);
-                                       if (ioctl(fd, ZT_SETCONF, &ztc_empty)) {
+                                       if (ioctl(fd, DAHDI_SETCONF, &dahdic_empty)) {
                                                ast_log(LOG_WARNING, "Error setting conference\n");
                                                close(fd);
                                                ast_frfree(f);
@@ -2513,7 +2513,7 @@ static int conf_run(struct ast_channel *chan, struct ast_conference *conf, int c
                                        if (musiconhold)
                                                conf_start_moh(chan, optargs[OPT_ARG_MOH_CLASS]);
 
-                                       if (ioctl(fd, ZT_SETCONF, &ztc)) {
+                                       if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                                                ast_log(LOG_WARNING, "Error setting conference\n");
                                                close(fd);
                                                ast_frfree(f);
@@ -2625,10 +2625,10 @@ bailoutandtrynormal:
                close(fd);
        else {
                /* Take out of conference */
-               ztc.chan = 0;   
-               ztc.confno = 0;
-               ztc.confmode = 0;
-               if (ioctl(fd, ZT_SETCONF, &ztc)) {
+               dahdic.chan = 0;        
+               dahdic.confno = 0;
+               dahdic.confmode = 0;
+               if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
                        ast_log(LOG_WARNING, "Error setting conference\n");
                }
        }
@@ -2834,13 +2834,13 @@ static struct ast_conference *find_conf_realtime(struct ast_channel *chan, char
                if (confflags && !cnf->chan &&
                    !ast_test_flag(confflags, CONFFLAG_QUIET) &&
                    ast_test_flag(confflags, CONFFLAG_INTROUSER)) {
-                       ast_log(LOG_WARNING, "No Zap channel available for conference, user introduction disabled (is chan_zap loaded?)\n");
+                       ast_log(LOG_WARNING, "No DAHDI channel available for conference, user introduction disabled (is chan_dahdi loaded?)\n");
                        ast_clear_flag(confflags, CONFFLAG_INTROUSER);
                }
                
                if (confflags && !cnf->chan &&
                    ast_test_flag(confflags, CONFFLAG_RECORDCONF)) {
-                       ast_log(LOG_WARNING, "No Zap channel available for conference, conference recording disabled (is chan_zap loaded?)\n");
+                       ast_log(LOG_WARNING, "No DAHDI channel available for conference, conference recording disabled (is chan_dahdi loaded?)\n");
                        ast_clear_flag(confflags, CONFFLAG_RECORDCONF);
                }
        }
@@ -2932,13 +2932,13 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
                if (confflags && !cnf->chan &&
                    !ast_test_flag(confflags, CONFFLAG_QUIET) &&
                    ast_test_flag(confflags, CONFFLAG_INTROUSER)) {
-                       ast_log(LOG_WARNING, "No Zap channel available for conference, user introduction disabled (is chan_zap loaded?)\n");
+                       ast_log(LOG_WARNING, "No DAHDI channel available for conference, user introduction disabled (is chan_dahdi loaded?)\n");
                        ast_clear_flag(confflags, CONFFLAG_INTROUSER);
                }
                
                if (confflags && !cnf->chan &&
                    ast_test_flag(confflags, CONFFLAG_RECORDCONF)) {
-                       ast_log(LOG_WARNING, "No Zap channel available for conference, conference recording disabled (is chan_zap loaded?)\n");
+                       ast_log(LOG_WARNING, "No DAHDI channel available for conference, conference recording disabled (is chan_dahdi loaded?)\n");
                        ast_clear_flag(confflags, CONFFLAG_RECORDCONF);
                }
        }
@@ -3722,9 +3722,9 @@ static void load_config_meetme(void)
                if ((sscanf(val, "%d", &audio_buffers) != 1)) {
                        ast_log(LOG_WARNING, "audiobuffers setting must be a number, not '%s'\n", val);
                        audio_buffers = DEFAULT_AUDIO_BUFFERS;
-               } else if ((audio_buffers < ZT_DEFAULT_NUM_BUFS) || (audio_buffers > ZT_MAX_NUM_BUFS)) {
+               } else if ((audio_buffers < DAHDI_DEFAULT_NUM_BUFS) || (audio_buffers > DAHDI_MAX_NUM_BUFS)) {
                        ast_log(LOG_WARNING, "audiobuffers setting must be between %d and %d\n",
-                               ZT_DEFAULT_NUM_BUFS, ZT_MAX_NUM_BUFS);
+                               DAHDI_DEFAULT_NUM_BUFS, DAHDI_MAX_NUM_BUFS);
                        audio_buffers = DEFAULT_AUDIO_BUFFERS;
                }
                if (audio_buffers != DEFAULT_AUDIO_BUFFERS)
index 5db858c..9f94b49 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 /*** MODULEINFO
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
        <depend>app_meetme</depend>
  ***/
 
index fef86f3..d8471a1 100644 (file)
@@ -529,7 +529,6 @@ static struct ao2_container *queues;
 static void update_realtime_members(struct call_queue *q);
 static int set_member_paused(const char *queuename, const char *interface, const char *reason, int paused);
 
-static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan); 
 /*! \brief sets the QUEUESTATUS channel variable */
 static void set_queue_result(struct ast_channel *chan, enum queue_result res)
 {
@@ -3043,82 +3042,6 @@ static void send_agent_complete(const struct queue_ent *qe, const char *queuenam
                qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, vars_len) : "");
 }
 
-struct queue_transfer_ds {
-       struct queue_ent *qe;
-       struct member *member;
-       int starttime;
-};
-
-/*! \brief a datastore used to help correctly log attended transfers of queue callers
- */
-static const struct ast_datastore_info queue_transfer_info = {
-       .type = "queue_transfer",
-       .chan_fixup = queue_transfer_fixup,
-};
-
-/*! \brief Log an attended transfer when a queue caller channel is masqueraded
- *
- * When a caller is masqueraded, we want to log a transfer. Fixup time is the closest we can come to when
- * the actual transfer occurs. This happens during the masquerade after datastores are moved from old_chan
- * to new_chan. This is why new_chan is referenced for exten, context, and datastore information.
- *
- * At the end of this, we want to remove the datastore so that this fixup function is not called on any
- * future masquerades of the caller during the current call.
- */
-static void queue_transfer_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan) 
-{
-       struct queue_transfer_ds *qtds = data;
-       struct queue_ent *qe = qtds->qe;
-       struct member *member = qtds->member;
-       int callstart = qtds->starttime;
-       struct ast_datastore *datastore;
-       
-       ast_queue_log(qe->parent->name, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
-                               new_chan->exten, new_chan->context, (long) (callstart - qe->start),
-                               (long) (time(NULL) - callstart));
-       
-       if (!(datastore = ast_channel_datastore_find(new_chan, &queue_transfer_info, NULL))) {
-               ast_log(LOG_WARNING, "Can't find the queue_transfer datastore.\n");
-               return;
-       }
-
-       ast_channel_datastore_remove(new_chan, datastore);
-}
-
-/*! \brief mechanism to tell if a queue caller was atxferred by a queue member.
- *
- * When a caller is atxferred, then the queue_transfer_info datastore
- * is removed from the channel. If it's still there after the bridge is
- * broken, then the caller was not atxferred.
- */
-static int attended_transfer_occurred(struct ast_channel *chan)
-{
-       return ast_channel_datastore_find(chan, &queue_transfer_info, NULL) ? 0 : 1;
-}
-
-/*! \brief create a datastore for storing relevant info to log attended transfers in the queue_log
- */
-static void setup_transfer_datastore(struct queue_ent *qe, struct member *member, int starttime)
-{
-       struct ast_datastore *ds;
-       struct queue_transfer_ds qtds;
-
-       ast_channel_lock(qe->chan);
-       if (!(ds = ast_channel_datastore_alloc(&queue_transfer_info, NULL))) {
-               ast_channel_unlock(qe->chan);
-               ast_log(LOG_WARNING, "Unable to create transfer datastore. queue_log will not show attended transfer\n");
-               return;
-       }
-
-       qtds.qe = qe;
-       /* This member is refcounted in try_calling, so no need to add it here, too */
-       qtds.member = member;
-       qtds.starttime = starttime;
-       ds->data = &qtds;
-       ast_channel_datastore_add(qe->chan, ds);
-       ast_channel_unlock(qe->chan);
-}
-
 /*! \brief A large function which calls members, updates statistics, and bridges the caller and a member
  * 
  * Here is the process of this function
@@ -3396,9 +3319,9 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                /* Ah ha!  Someone answered within the desired timeframe.  Of course after this
                   we will always return with -1 so that it is hung up properly after the
                   conversation.  */
-               if (!strcmp(qe->chan->tech->type, "Zap"))
+               if (!strcmp(qe->chan->tech->type, "DAHDI"))
                        ast_channel_setoption(qe->chan, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
-               if (!strcmp(peer->tech->type, "Zap"))
+               if (!strcmp(peer->tech->type, "DAHDI"))
                        ast_channel_setoption(peer, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0);
                /* Update parameters for the queue */
                time(&now);
@@ -3758,27 +3681,22 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
                ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext));
                ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten));
                time(&callstart);
-               setup_transfer_datastore(qe, member, callstart);
+
                bridge = ast_bridge_call(qe->chan,peer, &bridge_config);
 
-               /* If the queue member did an attended transfer, then the TRANSFER already was logged in the queue_log
-                * when the masquerade occurred. These other "ending" queue_log messages are unnecessary
-                */
-               if (!attended_transfer_occurred(qe->chan)) {
-                       if (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten)) {
-                               ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
-                                       qe->chan->exten, qe->chan->context, (long) (callstart - qe->start),
-                                       (long) (time(NULL) - callstart));
-                               send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER);
-                       } else if (ast_check_hangup(qe->chan)) {
-                               ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETECALLER", "%ld|%ld|%d",
-                                       (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
-                               send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), CALLER);
-                       } else {
-                               ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETEAGENT", "%ld|%ld|%d",
-                                       (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
-                               send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), AGENT);
-                       }
+               if (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten)) {
+                       ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld",
+                               qe->chan->exten, qe->chan->context, (long) (callstart - qe->start),
+                               (long) (time(NULL) - callstart));
+                       send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER);
+               } else if (ast_check_hangup(qe->chan)) {
+                       ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETECALLER", "%ld|%ld|%d",
+                               (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
+                       send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), CALLER);
+               } else {
+                       ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETEAGENT", "%ld|%ld|%d",
+                               (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos);
+                       send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), AGENT);
                }
 
                if (bridge != AST_PBX_NO_HANGUP_PEER)
index d34abd4..0a8ee00 100644 (file)
 */
 
 /*** MODULEINFO
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
        <depend>tonezone</depend>
        <defaultenabled>no</defaultenabled>
  ***/
@@ -763,7 +763,7 @@ static struct rpt
        int  parrottimer;
        unsigned int parrotcnt;
        struct ast_channel *rxchannel,*txchannel, *monchannel, *parrotchannel;
-       struct ast_channel *pchannel,*txpchannel, *zaprxchannel, *zaptxchannel;
+       struct ast_channel *pchannel,*txpchannel, *dahdirxchannel, *dahditxchannel;
        struct ast_channel *voxchannel;
        struct ast_frame *lastf1,*lastf2;
        struct rpt_tele tele;
@@ -3601,13 +3601,13 @@ static struct morse_bits mbits[] = {
        ast_stopstream(chan);
        
        /*
-       * Wait for the zaptel driver to physically write the tone blocks to the hardware
+       * Wait for the DAHDI driver to physically write the tone blocks to the hardware
        */
 
        for(i = 0; i < 20 ; i++){
-               flags =  ZT_IOMUX_WRITEEMPTY | ZT_IOMUX_NOWAIT; 
-               res = ioctl(chan->fds[0], ZT_IOMUX, &flags);
-               if(flags & ZT_IOMUX_WRITEEMPTY)
+               flags =  DAHDI_IOMUX_WRITEEMPTY | DAHDI_IOMUX_NOWAIT; 
+               res = ioctl(chan->fds[0], DAHDI_IOMUX, &flags);
+               if(flags & DAHDI_IOMUX_WRITEEMPTY)
                        break;
                if( ast_safe_sleep(chan, 50)){
                        res = -1;
@@ -3658,13 +3658,13 @@ static int send_tone_telemetry(struct ast_channel *chan, char *tonestring)
        ast_stopstream(chan);
 
        /*
-       * Wait for the zaptel driver to physically write the tone blocks to the hardware
+       * Wait for the DAHDI driver to physically write the tone blocks to the hardware
        */
 
        for(i = 0; i < 20 ; i++){
-               flags =  ZT_IOMUX_WRITEEMPTY | ZT_IOMUX_NOWAIT; 
-               res = ioctl(chan->fds[0], ZT_IOMUX, &flags);
-               if(flags & ZT_IOMUX_WRITEEMPTY)
+               flags =  DAHDI_IOMUX_WRITEEMPTY | DAHDI_IOMUX_NOWAIT; 
+               res = ioctl(chan->fds[0], DAHDI_IOMUX, &flags);
+               if(flags & DAHDI_IOMUX_WRITEEMPTY)
                        break;
                if( ast_safe_sleep(chan, 50)){
                        res = -1;
@@ -3934,7 +3934,7 @@ static int split_freq(char *mhz, char *decimals, char *freq);
 
 static void *rpt_tele_thread(void *this)
 {
-ZT_CONFINFO ci;  /* conference info */
+DAHDI_CONFINFO ci;  /* conference info */
 int    res = 0,haslink,hastx,hasremote,imdone = 0, unkeys_queued, x;
 struct rpt_tele *mytele = (struct rpt_tele *)this;
 struct  rpt_tele *tlist;
@@ -3954,7 +3954,7 @@ int       i,ns,rbimode;
 char mhz[MAXREMSTR];
 char decimals[MAXREMSTR];
 char   mystr[200];
-struct zt_params par;
+struct dahdi_params par;
 
 
        /* get a pointer to myrpt */
@@ -4002,7 +4002,7 @@ struct zt_params par;
 
 
        /* allocate a pseudo-channel thru asterisk */
-       mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       mychannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!mychannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -4047,9 +4047,9 @@ struct zt_params par;
                (mytele->mode == TAILMSG) || (mytele->mode == LINKUNKEY) || (mytele->mode == TIMEOUT) || 
                (mytele->mode == PARROT) || (mytele->mode == STATS_TIME_LOCAL)) ? 
                        myrpt->txconf : myrpt->conf);
-       ci.confmode = ZT_CONF_CONFANN;
+       ci.confmode = DAHDI_CONF_CONFANN;
        /* first put the channel on the conference in announce mode */
-       if (ioctl(mychannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(mychannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                rpt_mutex_lock(&myrpt->lock);
@@ -4242,9 +4242,9 @@ struct zt_params par;
                        /* set for all to hear */
                        ci.chan = 0;
                        ci.confno = myrpt->conf;
-                       ci.confmode = ZT_CONF_CONFANN;
+                       ci.confmode = DAHDI_CONF_CONFANN;
                        /* first put the channel on the conference in announce mode */
-                       if (ioctl(mychannel->fds[0],ZT_SETCONF,&ci) == -1)
+                       if (ioctl(mychannel->fds[0],DAHDI_SETCONF,&ci) == -1)
                        {
                                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                                rpt_mutex_lock(&myrpt->lock);
@@ -4283,9 +4283,9 @@ struct zt_params par;
                        /* set for all to hear */
                        ci.chan = 0;
                        ci.confno = myrpt->txconf;
-                       ci.confmode = ZT_CONF_CONFANN;
+                       ci.confmode = DAHDI_CONF_CONFANN;
                        /* first put the channel on the conference in announce mode */
-                       if (ioctl(mychannel->fds[0],ZT_SETCONF,&ci) == -1)
+                       if (ioctl(mychannel->fds[0],DAHDI_SETCONF,&ci) == -1)
                        {
                                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                                rpt_mutex_lock(&myrpt->lock);
@@ -4512,15 +4512,15 @@ struct zt_params par;
                        }
                        if (myrpt->iofd < 0)
                        {
-                               i = ZT_FLUSH_EVENT;
-                               if (ioctl(myrpt->zaptxchannel->fds[0],ZT_FLUSH,&i) == -1)
+                               i = DAHDI_FLUSH_EVENT;
+                               if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_FLUSH,&i) == -1)
                                {
                                        ast_mutex_unlock(&myrpt->remlock);
                                        ast_log(LOG_ERROR,"Cant flush events");
                                        res = -1;
                                        break;
                                }
-                               if (ioctl(myrpt->zaprxchannel->fds[0],ZT_GET_PARAMS,&par) == -1)
+                               if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_GET_PARAMS,&par) == -1)
                                {
                                        ast_mutex_unlock(&myrpt->remlock);
                                        ast_log(LOG_ERROR,"Cant get params");
@@ -5285,7 +5285,7 @@ char *v1, *v2;
 
 static void *rpt_call(void *this)
 {
-ZT_CONFINFO ci;  /* conference info */
+DAHDI_CONFINFO ci;  /* conference info */
 struct rpt *myrpt = (struct rpt *)this;
 int    res;
 int stopped,congstarted,dialtimer,lastcidx,aborted;
@@ -5293,7 +5293,7 @@ struct ast_channel *mychannel,*genchannel;
 
        myrpt->mydtmf = 0;
        /* allocate a pseudo-channel thru asterisk */
-       mychannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       mychannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!mychannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -5306,12 +5306,12 @@ struct ast_channel *mychannel,*genchannel;
        ci.chan = 0;
        ci.confno = myrpt->conf; /* use the pseudo conference */
 #if    0
-       ci.confmode = ZT_CONF_REALANDPSEUDO | ZT_CONF_TALKER | ZT_CONF_LISTENER
-               | ZT_CONF_PSEUDO_TALKER | ZT_CONF_PSEUDO_LISTENER; 
+       ci.confmode = DAHDI_CONF_REALANDPSEUDO | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER
+               | DAHDI_CONF_PSEUDO_TALKER | DAHDI_CONF_PSEUDO_LISTENER; 
 #endif
-       ci.confmode = ZT_CONF_CONF | ZT_CONF_TALKER | ZT_CONF_LISTENER;
+       ci.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER;
        /* first put the channel on the conference */
-       if (ioctl(mychannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(mychannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                ast_hangup(mychannel);
@@ -5319,7 +5319,7 @@ struct ast_channel *mychannel,*genchannel;
                pthread_exit(NULL);
        }
        /* allocate a pseudo-channel thru asterisk */
-       genchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       genchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!genchannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -5332,10 +5332,10 @@ struct ast_channel *mychannel,*genchannel;
 #endif
        ci.chan = 0;
        ci.confno = myrpt->conf;
-       ci.confmode = ZT_CONF_REALANDPSEUDO | ZT_CONF_TALKER | ZT_CONF_LISTENER
-               | ZT_CONF_PSEUDO_TALKER | ZT_CONF_PSEUDO_LISTENER; 
+       ci.confmode = DAHDI_CONF_REALANDPSEUDO | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER
+               | DAHDI_CONF_PSEUDO_TALKER | DAHDI_CONF_PSEUDO_LISTENER; 
        /* first put the channel on the conference */
-       if (ioctl(genchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(genchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                ast_hangup(mychannel);
@@ -5360,7 +5360,7 @@ struct ast_channel *mychannel,*genchannel;
                pthread_exit(NULL);
        }
        /* start dialtone if patchquiet is 0. Special patch modes don't send dial tone */
-       if ((!myrpt->patchquiet) && (tone_zone_play_tone(genchannel->fds[0],ZT_TONE_DIALTONE) < 0))
+       if ((!myrpt->patchquiet) && (tone_zone_play_tone(genchannel->fds[0],DAHDI_TONE_DIALTONE) < 0))
        {
                ast_log(LOG_WARNING, "Cannot start dialtone\n");
                ast_hangup(mychannel);
@@ -5414,7 +5414,7 @@ struct ast_channel *mychannel,*genchannel;
                        if(!congstarted){
                                congstarted = 1;
                                /* start congestion tone */
-                               tone_zone_play_tone(genchannel->fds[0],ZT_TONE_CONGESTION);
+                               tone_zone_play_tone(genchannel->fds[0],DAHDI_TONE_CONGESTION);
                        }
                }
                res = ast_safe_sleep(mychannel, MSWAIT);
@@ -5492,10 +5492,10 @@ struct ast_channel *mychannel,*genchannel;
        /* set appropriate conference for the pseudo */
        ci.chan = 0;
        ci.confno = myrpt->conf;
-       ci.confmode = (myrpt->p.duplex == 2) ? ZT_CONF_CONFANNMON :
-               (ZT_CONF_CONF | ZT_CONF_LISTENER | ZT_CONF_TALKER);
+       ci.confmode = (myrpt->p.duplex == 2) ? DAHDI_CONF_CONFANNMON :
+               (DAHDI_CONF_CONF | DAHDI_CONF_LISTENER | DAHDI_CONF_TALKER);
        /* first put the channel on the conference in announce mode */
-       if (ioctl(myrpt->pchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->pchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                ast_hangup(mychannel);
@@ -5504,7 +5504,7 @@ struct ast_channel *mychannel,*genchannel;
                pthread_exit(NULL);
        }
        /* get its channel number */
-       if (ioctl(mychannel->fds[0],ZT_CHANNO,&res) == -1)
+       if (ioctl(mychannel->fds[0],DAHDI_CHANNO,&res) == -1)
        {
                ast_log(LOG_WARNING, "Unable to get autopatch channel number\n");
                ast_hangup(mychannel);
@@ -5513,9 +5513,9 @@ struct ast_channel *mychannel,*genchannel;
        }
        ci.chan = 0;
        ci.confno = res;
-       ci.confmode = ZT_CONF_MONITOR;
+       ci.confmode = DAHDI_CONF_MONITOR;
        /* put vox channel monitoring on the channel  */
-       if (ioctl(myrpt->voxchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->voxchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                ast_hangup(mychannel);
@@ -5542,7 +5542,7 @@ struct ast_channel *mychannel,*genchannel;
                                myrpt->callmode = 4;
                                rpt_mutex_unlock(&myrpt->lock);
                                /* start congestion tone */
-                               tone_zone_play_tone(genchannel->fds[0],ZT_TONE_CONGESTION);
+                               tone_zone_play_tone(genchannel->fds[0],DAHDI_TONE_CONGESTION);
                                rpt_mutex_lock(&myrpt->lock);
                        }
                }
@@ -5578,10 +5578,10 @@ struct ast_channel *mychannel,*genchannel;
        /* set appropriate conference for the pseudo */
        ci.chan = 0;
        ci.confno = myrpt->conf;
-       ci.confmode = ((myrpt->p.duplex == 2) || (myrpt->p.duplex == 4)) ? ZT_CONF_CONFANNMON :
-               (ZT_CONF_CONF | ZT_CONF_LISTENER | ZT_CONF_TALKER);
+       ci.confmode = ((myrpt->p.duplex == 2) || (myrpt->p.duplex == 4)) ? DAHDI_CONF_CONFANNMON :
+               (DAHDI_CONF_CONF | DAHDI_CONF_LISTENER | DAHDI_CONF_TALKER);
        /* first put the channel on the conference in announce mode */
-       if (ioctl(myrpt->pchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->pchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
        }
@@ -5690,7 +5690,7 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
        struct rpt_link *l;
        int reconnects = 0;
        int i,n;
-       ZT_CONFINFO ci;  /* conference info */
+       DAHDI_CONFINFO ci;  /* conference info */
 
        val = node_lookup(myrpt,node);
        if (!val){
@@ -5829,7 +5829,7 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
                return -1;
        }
        /* allocate a pseudo-channel thru asterisk */
-       l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       l->pchan = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!l->pchan){
                ast_log(LOG_WARNING,"rpt connect: Sorry unable to obtain pseudo channel\n");
                ast_hangup(l->chan);
@@ -5845,9 +5845,9 @@ static int connect_link(struct rpt *myrpt, char* node, int mode, int perma)
        /* make a conference for the tx */
        ci.chan = 0;
        ci.confno = myrpt->conf;
-       ci.confmode = ZT_CONF_CONF | ZT_CONF_LISTENER | ZT_CONF_TALKER;
+       ci.confmode = DAHDI_CONF_CONF | DAHDI_CONF_LISTENER | DAHDI_CONF_TALKER;
        /* first put the channel on the conference in proper mode */
-       if (ioctl(l->pchan->fds[0], ZT_SETCONF, &ci) == -1)
+       if (ioctl(l->pchan->fds[0], DAHDI_SETCONF, &ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                ast_hangup(l->chan);
@@ -7384,22 +7384,22 @@ static void rbi_out_parallel(struct rpt *myrpt,unsigned char *data)
 
 static void rbi_out(struct rpt *myrpt,unsigned char *data)
 {
-struct zt_radio_param r;
+struct dahdi_radio_param r;
 
-       memset(&r,0,sizeof(struct zt_radio_param));
-       r.radpar = ZT_RADPAR_REMMODE;
-       r.data = ZT_RADPAR_REM_RBI1;
+       memset(&r,0,sizeof(struct dahdi_radio_param));
+       r.radpar = DAHDI_RADPAR_REMMODE;
+       r.data = DAHDI_RADPAR_REM_RBI1;
        /* if setparam ioctl fails, its probably not a pciradio card */
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_SETPARAM,&r) == -1)
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&r) == -1)
        {
                rbi_out_parallel(myrpt,data);
                return;
        }
-       r.radpar = ZT_RADPAR_REMCOMMAND;
+       r.radpar = DAHDI_RADPAR_REMCOMMAND;
        memcpy(&r.data,data,5);
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_SETPARAM,&r) == -1)
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&r) == -1)
        {
-               ast_log(LOG_WARNING,"Cannot send RBI command for channel %s\n",myrpt->zaprxchannel->name);
+               ast_log(LOG_WARNING,"Cannot send RBI command for channel %s\n",myrpt->dahdirxchannel->name);
                return;
        }
 }
@@ -7408,7 +7408,7 @@ static int serial_remote_io(struct rpt *myrpt, unsigned char *txbuf, int txbytes
        unsigned char *rxbuf, int rxmaxbytes, int asciiflag)
 {
        int i,j,index,oldmode,olddata;
-       struct zt_radio_param prm;
+       struct dahdi_radio_param prm;
        char c;
 
         if(debug) {
@@ -7453,50 +7453,50 @@ static int serial_remote_io(struct rpt *myrpt, unsigned char *txbuf, int txbytes
                return(i);
        }
 
-       /* if not a zap channel, cant use pciradio stuff */
-       if (myrpt->rxchannel != myrpt->zaprxchannel) return -1; 
+       /* if not a DAHDI channel, cant use pciradio stuff */
+       if (myrpt->rxchannel != myrpt->dahdirxchannel) return -1;       
 
-       prm.radpar = ZT_RADPAR_UIOMODE;
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_GETPARAM,&prm) == -1) return -1;
+       prm.radpar = DAHDI_RADPAR_UIOMODE;
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_GETPARAM,&prm) == -1) return -1;
        oldmode = prm.data;
-       prm.radpar = ZT_RADPAR_UIODATA;
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_GETPARAM,&prm) == -1) return -1;
+       prm.radpar = DAHDI_RADPAR_UIODATA;
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_GETPARAM,&prm) == -1) return -1;
        olddata = prm.data;
-        prm.radpar = ZT_RADPAR_REMMODE;
-        if (asciiflag & 1)  prm.data = ZT_RADPAR_REM_SERIAL_ASCII;
-        else prm.data = ZT_RADPAR_REM_SERIAL;
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_SETPARAM,&prm) == -1) return -1;
+        prm.radpar = DAHDI_RADPAR_REMMODE;
+        if (asciiflag & 1)  prm.data = DAHDI_RADPAR_REM_SERIAL_ASCII;
+        else prm.data = DAHDI_RADPAR_REM_SERIAL;
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1;
        if (asciiflag & 2)
        {
-               i = ZT_ONHOOK;
-               if (ioctl(myrpt->zaprxchannel->fds[0],ZT_HOOK,&i) == -1) return -1;
+               i = DAHDI_ONHOOK;
+               if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_HOOK,&i) == -1) return -1;
                usleep(100000);
        }
-        prm.radpar = ZT_RADPAR_REMCOMMAND;
+        prm.radpar = DAHDI_RADPAR_REMCOMMAND;
         prm.data = rxmaxbytes;
         memcpy(prm.buf,txbuf,txbytes);
         prm.index = txbytes;
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_SETPARAM,&prm) == -1) return -1;
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1;
         if (rxbuf)
         {
                 *rxbuf = 0;
                 memcpy(rxbuf,prm.buf,prm.index);
         }
        index = prm.index;
-        prm.radpar = ZT_RADPAR_REMMODE;
-        prm.data = ZT_RADPAR_REM_NONE;
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_SETPARAM,&prm) == -1) return -1;
+        prm.radpar = DAHDI_RADPAR_REMMODE;
+        prm.data = DAHDI_RADPAR_REM_NONE;
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1;
        if (asciiflag & 2)
        {
-               i = ZT_OFFHOOK;
-               if (ioctl(myrpt->zaprxchannel->fds[0],ZT_HOOK,&i) == -1) return -1;
+               i = DAHDI_OFFHOOK;
+               if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_HOOK,&i) == -1) return -1;
        }
-       prm.radpar = ZT_RADPAR_UIOMODE;
+       prm.radpar = DAHDI_RADPAR_UIOMODE;
        prm.data = oldmode;
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_SETPARAM,&prm) == -1) return -1;
-       prm.radpar = ZT_RADPAR_UIODATA;
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1;
+       prm.radpar = DAHDI_RADPAR_UIODATA;
        prm.data = olddata;
-       if (ioctl(myrpt->zaprxchannel->fds[0],ZT_RADIO_SETPARAM,&prm) == -1) return -1;
+       if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_RADIO_SETPARAM,&prm) == -1) return -1;
         return(index);
 }
 
@@ -10726,7 +10726,7 @@ char *tele,*idtalkover,c,myfirst,*p;
 int ms = MSWAIT,i,lasttx=0,val,remrx=0,identqueued,othertelemqueued;
 int tailmessagequeued,ctqueued,dtmfed,lastmyrx,localmsgqueued;
 struct ast_channel *who;
-ZT_CONFINFO ci;  /* conference info */
+DAHDI_CONFINFO ci;  /* conference info */
 time_t t;
 struct rpt_link *l,*m;
 struct rpt_tele *telem;
@@ -10782,9 +10782,9 @@ char tmpstr[300],lstr[MAXLINKLIST];
        }
        *tele++ = 0;
        myrpt->rxchannel = ast_request(tmpstr,AST_FORMAT_SLINEAR,tele,NULL);
-       myrpt->zaprxchannel = NULL;
-       if (!strcasecmp(tmpstr,"Zap"))
-               myrpt->zaprxchannel = myrpt->rxchannel;
+       myrpt->dahdirxchannel = NULL;
+       if (!strcasecmp(tmpstr,"DAHDI"))
+               myrpt->dahdirxchannel = myrpt->rxchannel;
        if (myrpt->rxchannel)
        {
                if (myrpt->rxchannel->_state == AST_STATE_BUSY)
@@ -10825,7 +10825,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                myrpt->rpt_thread = AST_PTHREADT_STOP;
                pthread_exit(NULL);
        }
-       myrpt->zaptxchannel = NULL;
+       myrpt->dahditxchannel = NULL;
        if (myrpt->txchanname)
        {
                strncpy(tmpstr,myrpt->txchanname,sizeof(tmpstr) - 1);
@@ -10840,8 +10840,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
                }
                *tele++ = 0;
                myrpt->txchannel = ast_request(tmpstr,AST_FORMAT_SLINEAR,tele,NULL);
-               if (!strcasecmp(tmpstr,"Zap"))
-                       myrpt->zaptxchannel = myrpt->txchannel;
+               if (!strcasecmp(tmpstr,"DAHDI"))
+                       myrpt->dahditxchannel = myrpt->txchannel;
                if (myrpt->txchannel)
                {
                        if (myrpt->txchannel->_state == AST_STATE_BUSY)
@@ -10889,13 +10889,13 @@ char tmpstr[300],lstr[MAXLINKLIST];
        else
        {
                myrpt->txchannel = myrpt->rxchannel;
-               if (!strncasecmp(myrpt->rxchanname,"Zap",3))
-                       myrpt->zaptxchannel = myrpt->txchannel;
+               if (!strncasecmp(myrpt->rxchanname,"DAHDI",3))
+                       myrpt->dahditxchannel = myrpt->txchannel;
        }
        ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_KEY);
        ast_indicate(myrpt->txchannel,AST_CONTROL_RADIO_UNKEY);
        /* allocate a pseudo-channel thru asterisk */
-       myrpt->pchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       myrpt->pchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!myrpt->pchannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -10910,12 +10910,12 @@ char tmpstr[300],lstr[MAXLINKLIST];
        if (myrpt->pchannel->cdr)
                ast_set_flag(myrpt->pchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
 #endif
-       if (!myrpt->zaprxchannel) myrpt->zaprxchannel = myrpt->pchannel;
-       if (!myrpt->zaptxchannel)
+       if (!myrpt->dahdirxchannel) myrpt->dahdirxchannel = myrpt->pchannel;
+       if (!myrpt->dahditxchannel)
        {
                /* allocate a pseudo-channel thru asterisk */
-               myrpt->zaptxchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
-               if (!myrpt->zaptxchannel)
+               myrpt->dahditxchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
+               if (!myrpt->dahditxchannel)
                {
                        fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
                        rpt_mutex_unlock(&myrpt->lock);
@@ -10925,15 +10925,15 @@ char tmpstr[300],lstr[MAXLINKLIST];
                        myrpt->rpt_thread = AST_PTHREADT_STOP;
                        pthread_exit(NULL);
                }
-               ast_set_read_format(myrpt->zaptxchannel,AST_FORMAT_SLINEAR);
-               ast_set_write_format(myrpt->zaptxchannel,AST_FORMAT_SLINEAR);
+               ast_set_read_format(myrpt->dahditxchannel,AST_FORMAT_SLINEAR);
+               ast_set_write_format(myrpt->dahditxchannel,AST_FORMAT_SLINEAR);
 #ifdef AST_CDR_FLAG_POST_DISABLED
-               if (myrpt->zaptxchannel->cdr)
-                       ast_set_flag(myrpt->zaptxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
+               if (myrpt->dahditxchannel->cdr)
+                       ast_set_flag(myrpt->dahditxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
 #endif
        }
        /* allocate a pseudo-channel thru asterisk */
-       myrpt->monchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       myrpt->monchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!myrpt->monchannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -10953,9 +10953,9 @@ char tmpstr[300],lstr[MAXLINKLIST];
        /* make a conference for the tx */
        ci.chan = 0;
        ci.confno = -1; /* make a new conf */
-       ci.confmode = ZT_CONF_CONF | ZT_CONF_LISTENER;
+       ci.confmode = DAHDI_CONF_CONF | DAHDI_CONF_LISTENER;
        /* first put the channel on the conference in proper mode */
-       if (ioctl(myrpt->zaptxchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                rpt_mutex_unlock(&myrpt->lock);
@@ -10972,10 +10972,10 @@ char tmpstr[300],lstr[MAXLINKLIST];
        /* make a conference for the pseudo */
        ci.chan = 0;
        ci.confno = -1; /* make a new conf */
-       ci.confmode = ((myrpt->p.duplex == 2) || (myrpt->p.duplex == 4)) ? ZT_CONF_CONFANNMON :
-               (ZT_CONF_CONF | ZT_CONF_LISTENER | ZT_CONF_TALKER);
+       ci.confmode = ((myrpt->p.duplex == 2) || (myrpt->p.duplex == 4)) ? DAHDI_CONF_CONFANNMON :
+               (DAHDI_CONF_CONF | DAHDI_CONF_LISTENER | DAHDI_CONF_TALKER);
        /* first put the channel on the conference in announce mode */
-       if (ioctl(myrpt->pchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->pchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                rpt_mutex_unlock(&myrpt->lock);
@@ -10992,10 +10992,10 @@ char tmpstr[300],lstr[MAXLINKLIST];
        /* make a conference for the pseudo */
        ci.chan = 0;
        if ((strstr(myrpt->txchannel->name,"pseudo") == NULL) &&
-               (myrpt->zaptxchannel == myrpt->txchannel))
+               (myrpt->dahditxchannel == myrpt->txchannel))
        {
                /* get tx channel's port number */
-               if (ioctl(myrpt->txchannel->fds[0],ZT_CHANNO,&ci.confno) == -1)
+               if (ioctl(myrpt->txchannel->fds[0],DAHDI_CHANNO,&ci.confno) == -1)
                {
                        ast_log(LOG_WARNING, "Unable to set tx channel's chan number\n");
                        rpt_mutex_unlock(&myrpt->lock);
@@ -11007,15 +11007,15 @@ char tmpstr[300],lstr[MAXLINKLIST];
                        myrpt->rpt_thread = AST_PTHREADT_STOP;
                        pthread_exit(NULL);
                }
-               ci.confmode = ZT_CONF_MONITORTX;
+               ci.confmode = DAHDI_CONF_MONITORTX;
        }
        else
        {
                ci.confno = myrpt->txconf;
-               ci.confmode = ZT_CONF_CONFANNMON;
+               ci.confmode = DAHDI_CONF_CONFANNMON;
        }
        /* first put the channel on the conference in announce mode */
-       if (ioctl(myrpt->monchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->monchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode for monitor\n");
                rpt_mutex_unlock(&myrpt->lock);
@@ -11028,7 +11028,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                pthread_exit(NULL);
        }
        /* allocate a pseudo-channel thru asterisk */
-       myrpt->parrotchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       myrpt->parrotchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!myrpt->parrotchannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -11046,7 +11046,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                ast_set_flag(myrpt->parrotchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
 #endif
        /* allocate a pseudo-channel thru asterisk */
-       myrpt->voxchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       myrpt->voxchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!myrpt->voxchannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -11064,7 +11064,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                ast_set_flag(myrpt->voxchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
 #endif
        /* allocate a pseudo-channel thru asterisk */
-       myrpt->txpchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       myrpt->txpchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!myrpt->txpchannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -11084,9 +11084,9 @@ char tmpstr[300],lstr[MAXLINKLIST];
        /* make a conference for the tx */
        ci.chan = 0;
        ci.confno = myrpt->txconf;
-       ci.confmode = ZT_CONF_CONF | ZT_CONF_TALKER ;
+       ci.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER ;
        /* first put the channel on the conference in proper mode */
-       if (ioctl(myrpt->txpchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->txpchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                rpt_mutex_unlock(&myrpt->lock);
@@ -11179,8 +11179,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
 
                /* DEBUG Dump */
                if((myrpt->disgorgetime) && (time(NULL) >= myrpt->disgorgetime)){
-                       struct rpt_link *zl;
-                       struct rpt_tele *zt;
+                       struct rpt_link *dl;
+                       struct rpt_tele *dt;
 
                        myrpt->disgorgetime = 0;
                        ast_log(LOG_NOTICE,"********** Variable Dump Start (app_rpt) **********\n");
@@ -11201,30 +11201,30 @@ char tmpstr[300],lstr[MAXLINKLIST];
                        ast_log(LOG_NOTICE,"myrpt->tailtimer = %d\n",myrpt->tailtimer);
                        ast_log(LOG_NOTICE,"myrpt->tailevent = %d\n",myrpt->tailevent);
 
-                       zl = myrpt->links.next;
-                       while(zl != &myrpt->links){
-                               ast_log(LOG_NOTICE,"*** Link Name: %s ***\n",zl->name);
-                               ast_log(LOG_NOTICE,"        link->lasttx %d\n",zl->lasttx);
-                               ast_log(LOG_NOTICE,"        link->lastrx %d\n",zl->lastrx);
-                               ast_log(LOG_NOTICE,"        link->connected %d\n",zl->connected);
-                               ast_log(LOG_NOTICE,"        link->hasconnected %d\n",zl->hasconnected);
-                               ast_log(LOG_NOTICE,"        link->outbound %d\n",zl->outbound);
-                               ast_log(LOG_NOTICE,"        link->disced %d\n",zl->disced);
-                               ast_log(LOG_NOTICE,"        link->killme %d\n",zl->killme);
-                               ast_log(LOG_NOTICE,"        link->disctime %ld\n",zl->disctime);
-                               ast_log(LOG_NOTICE,"        link->retrytimer %ld\n",zl->retrytimer);
-                               ast_log(LOG_NOTICE,"        link->retries = %d\n",zl->retries);
-                               ast_log(LOG_NOTICE,"        link->reconnects = %d\n",zl->reconnects);
-                               ast_log(LOG_NOTICE,"        link->newkey = %d\n",zl->newkey);
-                               zl = zl->next;
+                       dl = myrpt->links.next;
+                       while(dl != &myrpt->links){
+                               ast_log(LOG_NOTICE,"*** Link Name: %s ***\n",dl->name);
+                               ast_log(LOG_NOTICE,"        link->lasttx %d\n",dl->lasttx);
+                               ast_log(LOG_NOTICE,"        link->lastrx %d\n",dl->lastrx);
+                               ast_log(LOG_NOTICE,"        link->connected %d\n",dl->connected);
+                               ast_log(LOG_NOTICE,"        link->hasconnected %d\n",dl->hasconnected);
+                               ast_log(LOG_NOTICE,"        link->outbound %d\n",dl->outbound);
+                               ast_log(LOG_NOTICE,"        link->disced %d\n",dl->disced);
+                               ast_log(LOG_NOTICE,"        link->killme %d\n",dl->killme);
+                               ast_log(LOG_NOTICE,"        link->disctime %ld\n",dl->disctime);
+                               ast_log(LOG_NOTICE,"        link->retrytimer %ld\n",dl->retrytimer);
+                               ast_log(LOG_NOTICE,"        link->retries = %d\n",dl->retries);
+                               ast_log(LOG_NOTICE,"        link->reconnects = %d\n",dl->reconnects);
+                               ast_log(LOG_NOTICE,"        link->newkey = %d\n",dl->newkey);
+                               dl = dl->next;
                        }
                                                                                                                                
-                       zt = myrpt->tele.next;
-                       if(zt != &myrpt->tele)
+                       dt = myrpt->tele.next;
+                       if(dt != &myrpt->tele)
                                ast_log(LOG_NOTICE,"*** Telemetry Queue ***\n");
-                       while(zt != &myrpt->tele){
-                               ast_log(LOG_NOTICE,"        Telemetry mode: %d\n",zt->mode);
-                               zt = zt->next;
+                       while(dt != &myrpt->tele){
+                               ast_log(LOG_NOTICE,"        Telemetry mode: %d\n",dt->mode);
+                               dt = dt->next;
                        }
                        ast_log(LOG_NOTICE,"******* Variable Dump End (app_rpt) *******\n");
 
@@ -11266,7 +11266,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                if (myrpt->voxchannel && 
                        ast_check_hangup(myrpt->voxchannel)) break;
                if (ast_check_hangup(myrpt->txpchannel)) break;
-               if (myrpt->zaptxchannel && ast_check_hangup(myrpt->zaptxchannel)) break;
+               if (myrpt->dahditxchannel && ast_check_hangup(myrpt->dahditxchannel)) break;
 
                /* Set local tx with keyed */
                myrpt->localtx = myrpt->keyed;
@@ -11547,11 +11547,11 @@ char tmpstr[300],lstr[MAXLINKLIST];
                        char myfname[300];
 
                        ci.confno = myrpt->conf;
-                       ci.confmode = ZT_CONF_CONFANNMON;
+                       ci.confmode = DAHDI_CONF_CONFANNMON;
                        ci.chan = 0;
 
                        /* first put the channel on the conference in announce mode */
-                       if (ioctl(myrpt->parrotchannel->fds[0],ZT_SETCONF,&ci) == -1)
+                       if (ioctl(myrpt->parrotchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
                        {
                                ast_log(LOG_WARNING, "Unable to set conference mode for parrot\n");
                                break;
@@ -11601,8 +11601,8 @@ char tmpstr[300],lstr[MAXLINKLIST];
                if (myrpt->voxchannel) cs[n++] = myrpt->voxchannel;
                cs[n++] = myrpt->txpchannel;
                if (myrpt->txchannel != myrpt->rxchannel) cs[n++] = myrpt->txchannel;
-               if (myrpt->zaptxchannel != myrpt->txchannel)
-                       cs[n++] = myrpt->zaptxchannel;
+               if (myrpt->dahditxchannel != myrpt->txchannel)
+                       cs[n++] = myrpt->dahditxchannel;
                l = myrpt->links.next;
                while(l != &myrpt->links)
                {
@@ -11977,7 +11977,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                        ci.chan = 0;
 
                        /* first put the channel on the conference in announce mode */
-                       if (ioctl(myrpt->parrotchannel->fds[0],ZT_SETCONF,&ci) == -1)
+                       if (ioctl(myrpt->parrotchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
                        {
                                ast_log(LOG_WARNING, "Unable to set conference mode for parrot\n");
                                break;
@@ -12088,7 +12088,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                                /* apply inbound filters, if any */
                                rpt_filter(myrpt,f->data,f->datalen / 2);
 #endif
-                               if (ioctl(myrpt->zaprxchannel->fds[0], ZT_GETCONFMUTE, &ismuted) == -1)
+                               if (ioctl(myrpt->dahdirxchannel->fds[0], DAHDI_GETCONFMUTE, &ismuted) == -1)
                                {
                                        ismuted = 0;
                                }
@@ -12276,9 +12276,9 @@ char tmpstr[300],lstr[MAXLINKLIST];
                        ast_frfree(f);
                        continue;
                }
-               if (who == myrpt->zaptxchannel) /* if it was a read from pseudo-tx */
+               if (who == myrpt->dahditxchannel) /* if it was a read from pseudo-tx */
                {
-                       f = ast_read(myrpt->zaptxchannel);
+                       f = ast_read(myrpt->dahditxchannel);
                        if (!f)
                        {
                                if (debug) printf("@@@@ rpt:Hung Up\n");
@@ -12517,7 +12517,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
                                                        ast_frfree(f);
                                                        f = AST_LIST_REMOVE_HEAD(&l->rxq,frame_list);
                                                }
-                                               if (ioctl(l->chan->fds[0], ZT_GETCONFMUTE, &ismuted) == -1)
+                                               if (ioctl(l->chan->fds[0], DAHDI_GETCONFMUTE, &ismuted) == -1)
                                                {
                                                        ismuted = 0;
                                                }
@@ -12878,7 +12878,7 @@ char tmpstr[300],lstr[MAXLINKLIST];
        if (myrpt->voxchannel) ast_hangup(myrpt->voxchannel);
        ast_hangup(myrpt->txpchannel);
        if (myrpt->txchannel != myrpt->rxchannel) ast_hangup(myrpt->txchannel);
-       if (myrpt->zaptxchannel != myrpt->txchannel) ast_hangup(myrpt->zaptxchannel);
+       if (myrpt->dahditxchannel != myrpt->txchannel) ast_hangup(myrpt->dahditxchannel);
        if (myrpt->lastf1) ast_frfree(myrpt->lastf1);
        myrpt->lastf1 = NULL;
        if (myrpt->lastf2) ast_frfree(myrpt->lastf2);
@@ -13125,11 +13125,11 @@ static int rpt_exec(struct ast_channel *chan, void *data)
        struct ast_channel *who;
        struct ast_channel *cs[20];
        struct  rpt_link *l;
-       ZT_CONFINFO ci;  /* conference info */
-       ZT_PARAMS par;
+       DAHDI_CONFINFO ci;  /* conference info */
+       DAHDI_PARAMS par;
        int ms,elap,nullfd;
        time_t t,last_timeout_warning;
-       struct  zt_radio_param z;
+       struct  dahdi_radio_param z;
        struct rpt_tele *telem;
        int     numlinks;
 
@@ -13617,7 +13617,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                ast_set_read_format(l->chan,AST_FORMAT_SLINEAR);
                ast_set_write_format(l->chan,AST_FORMAT_SLINEAR);
                /* allocate a pseudo-channel thru asterisk */
-               l->pchan = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+               l->pchan = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
                if (!l->pchan)
                {
                        fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -13632,9 +13632,9 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                /* make a conference for the tx */
                ci.chan = 0;
                ci.confno = myrpt->conf;
-               ci.confmode = ZT_CONF_CONF | ZT_CONF_LISTENER | ZT_CONF_TALKER;
+               ci.confmode = DAHDI_CONF_CONF | DAHDI_CONF_LISTENER | DAHDI_CONF_TALKER;
                /* first put the channel on the conference in proper mode */
-               if (ioctl(l->pchan->fds[0],ZT_SETCONF,&ci) == -1)
+               if (ioctl(l->pchan->fds[0],DAHDI_SETCONF,&ci) == -1)
                {
                        ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                        pthread_exit(NULL);
@@ -13760,9 +13760,9 @@ static int rpt_exec(struct ast_channel *chan, void *data)
        }
        *tele++ = 0;
        myrpt->rxchannel = ast_request(myrpt->rxchanname,AST_FORMAT_SLINEAR,tele,NULL);
-       myrpt->zaprxchannel = NULL;
-       if (!strcasecmp(myrpt->rxchanname,"Zap"))
-               myrpt->zaprxchannel = myrpt->rxchannel;
+       myrpt->dahdirxchannel = NULL;
+       if (!strcasecmp(myrpt->rxchanname,"DAHDI"))
+               myrpt->dahdirxchannel = myrpt->rxchannel;
        if (myrpt->rxchannel)
        {
                ast_set_read_format(myrpt->rxchannel,AST_FORMAT_SLINEAR);
@@ -13790,7 +13790,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                pthread_exit(NULL);
        }
        *--tele = '/';
-       myrpt->zaptxchannel = NULL;
+       myrpt->dahditxchannel = NULL;
        if (myrpt->txchanname)
        {
                tele = strchr(myrpt->txchanname,'/');
@@ -13803,8 +13803,8 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                }
                *tele++ = 0;
                myrpt->txchannel = ast_request(myrpt->txchanname,AST_FORMAT_SLINEAR,tele,NULL);
-               if (!strncasecmp(myrpt->txchanname,"Zap",3))
-                       myrpt->zaptxchannel = myrpt->txchannel;
+               if (!strncasecmp(myrpt->txchanname,"DAHDI",3))
+                       myrpt->dahditxchannel = myrpt->txchannel;
                if (myrpt->txchannel)
                {
                        ast_set_read_format(myrpt->txchannel,AST_FORMAT_SLINEAR);
@@ -13837,11 +13837,11 @@ static int rpt_exec(struct ast_channel *chan, void *data)
        else
        {
                myrpt->txchannel = myrpt->rxchannel;
-               if (!strncasecmp(myrpt->rxchanname,"Zap",3))
-                       myrpt->zaptxchannel = myrpt->rxchannel;
+               if (!strncasecmp(myrpt->rxchanname,"DAHDI",3))
+                       myrpt->dahditxchannel = myrpt->rxchannel;
        }
        /* allocate a pseudo-channel thru asterisk */
-       myrpt->pchannel = ast_request("zap",AST_FORMAT_SLINEAR,"pseudo",NULL);
+       myrpt->pchannel = ast_request("DAHDI",AST_FORMAT_SLINEAR,"pseudo",NULL);
        if (!myrpt->pchannel)
        {
                fprintf(stderr,"rpt:Sorry unable to obtain pseudo channel\n");
@@ -13857,14 +13857,14 @@ static int rpt_exec(struct ast_channel *chan, void *data)
        if (myrpt->pchannel->cdr)
                ast_set_flag(myrpt->pchannel->cdr,AST_CDR_FLAG_POST_DISABLED);
 #endif
-       if (!myrpt->zaprxchannel) myrpt->zaprxchannel = myrpt->pchannel;
-       if (!myrpt->zaptxchannel) myrpt->zaptxchannel = myrpt->pchannel;
+       if (!myrpt->dahdirxchannel) myrpt->dahdirxchannel = myrpt->pchannel;
+       if (!myrpt->dahditxchannel) myrpt->dahditxchannel = myrpt->pchannel;
        /* make a conference for the pseudo */
        ci.chan = 0;
        ci.confno = -1; /* make a new conf */
-       ci.confmode = ZT_CONF_CONFANNMON ;
+       ci.confmode = DAHDI_CONF_CONFANNMON ;
        /* first put the channel on the conference in announce/monitor mode */
-       if (ioctl(myrpt->pchannel->fds[0],ZT_SETCONF,&ci) == -1)
+       if (ioctl(myrpt->pchannel->fds[0],DAHDI_SETCONF,&ci) == -1)
        {
                ast_log(LOG_WARNING, "Unable to set conference mode to Announce\n");
                rpt_mutex_unlock(&myrpt->lock);
@@ -13889,30 +13889,30 @@ static int rpt_exec(struct ast_channel *chan, void *data)
        }
        iskenwood_pci4 = 0;
        memset(&z,0,sizeof(z));
-       if ((myrpt->iofd < 1) && (myrpt->txchannel == myrpt->zaptxchannel))
+       if ((myrpt->iofd < 1) && (myrpt->txchannel == myrpt->dahditxchannel))
        {
-               z.radpar = ZT_RADPAR_REMMODE;
-               z.data = ZT_RADPAR_REM_NONE;
-               res = ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z);
+               z.radpar = DAHDI_RADPAR_REMMODE;
+               z.data = DAHDI_RADPAR_REM_NONE;
+               res = ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z);
                /* if PCIRADIO and kenwood selected */
                if ((!res) && (!strcmp(myrpt->remoterig,remote_rig_kenwood)))
                {
-                       z.radpar = ZT_RADPAR_UIOMODE;
+                       z.radpar = DAHDI_RADPAR_UIOMODE;
                        z.data = 1;
-                       if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+                       if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                        {
                                ast_log(LOG_ERROR,"Cannot set UIOMODE\n");
                                return -1;
                        }
-                       z.radpar = ZT_RADPAR_UIODATA;
+                       z.radpar = DAHDI_RADPAR_UIODATA;
                        z.data = 3;
-                       if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+                       if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                        {
                                ast_log(LOG_ERROR,"Cannot set UIODATA\n");
                                return -1;
                        }
-                       i = ZT_OFFHOOK;
-                       if (ioctl(myrpt->zaptxchannel->fds[0],ZT_HOOK,&i) == -1)
+                       i = DAHDI_OFFHOOK;
+                       if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_HOOK,&i) == -1)
                        {
                                ast_log(LOG_ERROR,"Cannot set hook\n");
                                return -1;
@@ -13920,26 +13920,26 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                        iskenwood_pci4 = 1;
                }
        }
-       if (myrpt->txchannel == myrpt->zaptxchannel)
+       if (myrpt->txchannel == myrpt->dahditxchannel)
        {
-               i = ZT_ONHOOK;
-               ioctl(myrpt->zaptxchannel->fds[0],ZT_HOOK,&i);
+               i = DAHDI_ONHOOK;
+               ioctl(myrpt->dahditxchannel->fds[0],DAHDI_HOOK,&i);
                /* if PCIRADIO and Yaesu ft897/ICOM IC-706 selected */
                if ((myrpt->iofd < 1) && (!res) &&
                   ((!strcmp(myrpt->remoterig,remote_rig_ft897)) ||
                      (!strcmp(myrpt->remoterig,remote_rig_ic706)) ||
                         (!strcmp(myrpt->remoterig,remote_rig_tm271))))
                {
-                       z.radpar = ZT_RADPAR_UIOMODE;
+                       z.radpar = DAHDI_RADPAR_UIOMODE;
                        z.data = 1;
-                       if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+                       if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                        {
                                ast_log(LOG_ERROR,"Cannot set UIOMODE\n");
                                return -1;
                        }
-                       z.radpar = ZT_RADPAR_UIODATA;
+                       z.radpar = DAHDI_RADPAR_UIODATA;
                        z.data = 3;
-                       if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+                       if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                        {
                                ast_log(LOG_ERROR,"Cannot set UIODATA\n");
                                return -1;
@@ -13976,16 +13976,16 @@ static int rpt_exec(struct ast_channel *chan, void *data)
        if (myrpt->remote && (myrpt->rxchannel == myrpt->txchannel))
        {
                i = 128;
-               ioctl(myrpt->zaprxchannel->fds[0],ZT_ECHOCANCEL,&i);
+               ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_ECHOCANCEL,&i);
        }
        if (chan->_state != AST_STATE_UP) {
                ast_answer(chan);
                if (!phone_mode) send_newkey(chan);
        }
 
-       if (myrpt->rxchannel == myrpt->zaprxchannel)
+       if (myrpt->rxchannel == myrpt->dahdirxchannel)
        {
-               if (ioctl(myrpt->zaprxchannel->fds[0],ZT_GET_PARAMS,&par) != -1)
+               if (ioctl(myrpt->dahdirxchannel->fds[0],DAHDI_GET_PARAMS,&par) != -1)
                {
                        if (par.rxisoffhook)
                        {
@@ -14255,11 +14255,11 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                                if((myrpt->remtxfreqok = check_tx_freq(myrpt)))
                                {
                                        time(&myrpt->last_activity_time);
-                                       if ((iskenwood_pci4) && (myrpt->txchannel == myrpt->zaptxchannel))
+                                       if ((iskenwood_pci4) && (myrpt->txchannel == myrpt->dahditxchannel))
                                        {
-                                               z.radpar = ZT_RADPAR_UIODATA;
+                                               z.radpar = DAHDI_RADPAR_UIODATA;
                                                z.data = 1;
-                                               if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+                                               if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                                                {
                                                        ast_log(LOG_ERROR,"Cannot set UIODATA\n");
                                                        return -1;
@@ -14279,11 +14279,11 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                        if(!myrpt->remtxfreqok){
                                rpt_telemetry(myrpt,UNAUTHTX,NULL);
                        }
-                       if ((iskenwood_pci4) && (myrpt->txchannel == myrpt->zaptxchannel))
+                       if ((iskenwood_pci4) && (myrpt->txchannel == myrpt->dahditxchannel))
                        {
-                               z.radpar = ZT_RADPAR_UIODATA;
+                               z.radpar = DAHDI_RADPAR_UIODATA;
                                z.data = 3;
-                               if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+                               if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                                {
                                        ast_log(LOG_ERROR,"Cannot set UIODATA\n");
                                        return -1;
@@ -14333,7 +14333,7 @@ static int rpt_exec(struct ast_channel *chan, void *data)
                        }
                        if (f->frametype == AST_FRAME_VOICE)
                        {
-                               if (ioctl(chan->fds[0], ZT_GETCONFMUTE, &ismuted) == -1)
+                               if (ioctl(chan->fds[0], DAHDI_GETCONFMUTE, &ismuted) == -1)
                                {
                                        ismuted = 0;
                                }
@@ -14556,24 +14556,24 @@ static int rpt_exec(struct ast_channel *chan, void *data)
        myrpt->lastf1 = NULL;
        if (myrpt->lastf2) ast_frfree(myrpt->lastf2);
        myrpt->lastf2 = NULL;
-       if ((iskenwood_pci4) && (myrpt->txchannel == myrpt->zaptxchannel))
+       if ((iskenwood_pci4) && (myrpt->txchannel == myrpt->dahditxchannel))
        {
-               z.radpar = ZT_RADPAR_UIOMODE;
+               z.radpar = DAHDI_RADPAR_UIOMODE;
                z.data = 3;
-               if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+               if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                {
                        ast_log(LOG_ERROR,"Cannot set UIOMODE\n");
                        return -1;
                }
-               z.radpar = ZT_RADPAR_UIODATA;
+               z.radpar = DAHDI_RADPAR_UIODATA;
                z.data = 3;
-               if (ioctl(myrpt->zaptxchannel->fds[0],ZT_RADIO_SETPARAM,&z) == -1)
+               if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_RADIO_SETPARAM,&z) == -1)
                {
                        ast_log(LOG_ERROR,"Cannot set UIODATA\n");
                        return -1;
                }
-               i = ZT_OFFHOOK;
-               if (ioctl(myrpt->zaptxchannel->fds[0],ZT_HOOK,&i) == -1)
+               i = DAHDI_OFFHOOK;
+               if (ioctl(myrpt->dahditxchannel->fds[0],DAHDI_HOOK,&i) == -1)
                {
                        ast_log(LOG_ERROR,"Cannot set hook\n");
                        return -1;
index 3fff728..fba1dd3 100644 (file)
@@ -1,6 +1,7 @@
 ASOUND=@PBX_ALSA@
 CRYPTO=@PBX_CRYPTO@
 CURL=@PBX_CURL@
+DAHDI=@PBX_DAHDI@
 FREETDS=@PBX_FREETDS@
 GMIME=@PBX_GMIME@
 GNU_LD=@GNU_LD@
@@ -47,7 +48,4 @@ USB=@PBX_USB@
 VORBIS=@PBX_VORBIS@
 VPBAPI=@PBX_VPB@
 WINARCH=@WINARCH@
-ZAPTEL=@PBX_ZAPTEL@
-ZAPTEL_TRANSCODE=@PBX_ZAPTEL_TRANSCODE@
-ZAPTEL_VLDTMF=@PBX_ZAPTEL_VLDTMF@
 ZLIB=@PBX_ZLIB@
index cb872f1..236292d 100644 (file)
@@ -62,7 +62,7 @@ static char *config = "cdr.conf";
 
   "accountcode",       accountcode is the account name of detail records, Master.csv contains all records *
                        Detail records are configured on a channel basis, IAX and SIP are determined by user *
-                       Zap is determined by channel in zaptel.conf 
+                       DAHDI is determined by channel in dahdi.conf 
   "source",
   "destination",
   "destination context", 
similarity index 86%
rename from channels/chan_zap.c
rename to channels/chan_dahdi.c
index 228499d..d0d5fba 100644 (file)
 
 /*! \file
  *
- * \brief Zaptel Pseudo TDM interface 
+ * \brief DAHDI for Pseudo TDM
  *
  * \author Mark Spencer <markster@digium.com>
  * 
- * Connects to the Zaptel telephony library as well as 
+ * Connects to the DAHDI telephony library as well as 
  * libpri. Libpri is optional and needed only if you are
  * going to use ISDN connections.
  *
  * You need to install libraries before you attempt to compile
- * and install the Zaptel channel.
+ * and install the DAHDI channel.
  *
  * \par See also
- * \arg \ref Config_zap
+ * \arg \ref Config_dahdi
  *
  * \ingroup channel_drivers
  *
@@ -39,8 +39,7 @@
 
 /*** MODULEINFO
        <depend>res_smdi</depend>
-       <depend>zaptel_vldtmf</depend>
-       <depend>zaptel</depend>
+       <depend>dahdi</depend>
        <depend>tonezone</depend>
        <use>pri</use>
        <use>ss7</use>
@@ -59,7 +58,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <sys/ioctl.h>
 #include <math.h>
 #include <ctype.h>
-#include "asterisk/zapata.h"
+#include "asterisk/dahdi.h"
 
 #ifdef HAVE_PRI
 #include <libpri.h>
@@ -102,7 +101,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #define SMDI_MD_WAIT_TIMEOUT 1500 /* 1.5 seconds */
 
-#ifdef ZT_SPANINFO_HAS_LINECONFIG
+#ifdef DAHDI_SPANINFO_HAS_LINECONFIG
 static const char *lbostr[] = {
 "0 db (CSU)/0-133 feet (DSX-1)",
 "133-266 feet (DSX-1)",
@@ -125,14 +124,14 @@ static struct ast_jb_conf default_jbconf =
 };
 static struct ast_jb_conf global_jbconf;
 
-#if !defined(ZT_SIG_EM_E1) || (defined(HAVE_PRI) && !defined(ZT_SIG_HARDHDLC))
-#error "Your Zaptel is too old.  Please update"
+#if !defined(DAHDI_SIG_EM_E1) || (defined(HAVE_PRI) && !defined(DAHDI_SIG_HARDHDLC))
+#error "Your DAHDI is too old.  Please update"
 #endif
 
-#ifndef ZT_TONEDETECT
+#ifndef DAHDI_TONEDETECT
 /* Work around older code with no tone detect */
-#define ZT_EVENT_DTMFDOWN 0
-#define ZT_EVENT_DTMFUP 0
+#define DAHDI_EVENT_DTMFDOWN 0
+#define DAHDI_EVENT_DTMFUP 0
 #endif
 
 /* define this to send PRI user-user information elements */
@@ -154,20 +153,20 @@ static struct ast_jb_conf global_jbconf;
  * before dialing on it.  Certain FXO interfaces always think they're out of
  * service with this method however.
  */
-/* #define ZAP_CHECK_HOOKSTATE */
+/* #define DAHDI_CHECK_HOOKSTATE */
 
 /*! \brief Typically, how many rings before we should send Caller*ID */
 #define DEFAULT_CIDRINGS 1
 
 #define CHANNEL_PSEUDO -12
 
-#define AST_LAW(p) (((p)->law == ZT_LAW_ALAW) ? AST_FORMAT_ALAW : AST_FORMAT_ULAW)
+#define AST_LAW(p) (((p)->law == DAHDI_LAW_ALAW) ? AST_FORMAT_ALAW : AST_FORMAT_ULAW)
 
 
 /*! \brief Signaling types that need to use MF detection should be placed in this macro */
 #define NEED_MFDETECT(p) (((p)->sig == SIG_FEATDMF) || ((p)->sig == SIG_FEATDMF_TA) || ((p)->sig == SIG_E911) || ((p)->sig == SIG_FGC_CAMA) || ((p)->sig == SIG_FGC_CAMAMF) || ((p)->sig == SIG_FEATB)) 
 
-static const char tdesc[] = "Zapata Telephony Driver"
+static const char tdesc[] = "DAHDI Telephony Driver"
 #ifdef HAVE_PRI
                " w/PRI"
 #endif
@@ -176,38 +175,38 @@ static const char tdesc[] = "Zapata Telephony Driver"
 #endif
 ;
 
-static const char config[] = "zapata.conf";
-
-#define SIG_EM         ZT_SIG_EM
-#define SIG_EMWINK     (0x0100000 | ZT_SIG_EM)
-#define SIG_FEATD      (0x0200000 | ZT_SIG_EM)
-#define        SIG_FEATDMF     (0x0400000 | ZT_SIG_EM)
-#define        SIG_FEATB       (0x0800000 | ZT_SIG_EM)
-#define        SIG_E911        (0x1000000 | ZT_SIG_EM)
-#define        SIG_FEATDMF_TA  (0x2000000 | ZT_SIG_EM)
-#define        SIG_FGC_CAMA    (0x4000000 | ZT_SIG_EM)
-#define        SIG_FGC_CAMAMF  (0x8000000 | ZT_SIG_EM)
-#define SIG_FXSLS      ZT_SIG_FXSLS
-#define SIG_FXSGS      ZT_SIG_FXSGS
-#define SIG_FXSKS      ZT_SIG_FXSKS
-#define SIG_FXOLS      ZT_SIG_FXOLS
-#define SIG_FXOGS      ZT_SIG_FXOGS
-#define SIG_FXOKS      ZT_SIG_FXOKS
-#define SIG_PRI                ZT_SIG_CLEAR
-#define SIG_BRI                (0x2000000 | ZT_SIG_CLEAR)
-#define SIG_BRI_PTMP   (0X4000000 | ZT_SIG_CLEAR)
-#define SIG_SS7                (0x1000000 | ZT_SIG_CLEAR)
-#define        SIG_SF          ZT_SIG_SF
-#define SIG_SFWINK     (0x0100000 | ZT_SIG_SF)
-#define SIG_SF_FEATD   (0x0200000 | ZT_SIG_SF)
-#define        SIG_SF_FEATDMF  (0x0400000 | ZT_SIG_SF)
-#define        SIG_SF_FEATB    (0x0800000 | ZT_SIG_SF)
-#define SIG_EM_E1      ZT_SIG_EM_E1
-#define SIG_GR303FXOKS (0x0100000 | ZT_SIG_FXOKS)
-#define SIG_GR303FXSKS (0x0100000 | ZT_SIG_FXSKS)
+static const char config[] = "chan_dahdi.conf";
+
+#define SIG_EM         DAHDI_SIG_EM
+#define SIG_EMWINK     (0x0100000 | DAHDI_SIG_EM)
+#define SIG_FEATD      (0x0200000 | DAHDI_SIG_EM)
+#define        SIG_FEATDMF     (0x0400000 | DAHDI_SIG_EM)
+#define        SIG_FEATB       (0x0800000 | DAHDI_SIG_EM)
+#define        SIG_E911        (0x1000000 | DAHDI_SIG_EM)
+#define        SIG_FEATDMF_TA  (0x2000000 | DAHDI_SIG_EM)
+#define        SIG_FGC_CAMA    (0x4000000 | DAHDI_SIG_EM)
+#define        SIG_FGC_CAMAMF  (0x8000000 | DAHDI_SIG_EM)
+#define SIG_FXSLS      DAHDI_SIG_FXSLS
+#define SIG_FXSGS      DAHDI_SIG_FXSGS
+#define SIG_FXSKS      DAHDI_SIG_FXSKS
+#define SIG_FXOLS      DAHDI_SIG_FXOLS
+#define SIG_FXOGS      DAHDI_SIG_FXOGS
+#define SIG_FXOKS      DAHDI_SIG_FXOKS
+#define SIG_PRI                DAHDI_SIG_CLEAR
+#define SIG_BRI                (0x2000000 | DAHDI_SIG_CLEAR)
+#define SIG_BRI_PTMP   (0X4000000 | DAHDI_SIG_CLEAR)
+#define SIG_SS7                (0x1000000 | DAHDI_SIG_CLEAR)
+#define        SIG_SF          DAHDI_SIG_SF
+#define SIG_SFWINK     (0x0100000 | DAHDI_SIG_SF)
+#define SIG_SF_FEATD   (0x0200000 | DAHDI_SIG_SF)
+#define        SIG_SF_FEATDMF  (0x0400000 | DAHDI_SIG_SF)
+#define        SIG_SF_FEATB    (0x0800000 | DAHDI_SIG_SF)
+#define SIG_EM_E1      DAHDI_SIG_EM_E1
+#define SIG_GR303FXOKS (0x0100000 | DAHDI_SIG_FXOKS)
+#define SIG_GR303FXSKS (0x0100000 | DAHDI_SIG_FXSKS)
 
 #ifdef LOTS_OF_SPANS
-#define NUM_SPANS      ZT_MAX_SPANS
+#define NUM_SPANS      DAHDI_MAX_SPANS
 #else
 #define NUM_SPANS              32
 #endif
@@ -223,10 +222,10 @@ static const char config[] = "zapata.conf";
 #define DCHAN_AVAILABLE        (DCHAN_PROVISIONED | DCHAN_NOTINALARM | DCHAN_UP)
 
 /* Overlap dialing option types */
-#define ZAP_OVERLAPDIAL_NONE 0
-#define ZAP_OVERLAPDIAL_OUTGOING 1
-#define ZAP_OVERLAPDIAL_INCOMING 2
-#define ZAP_OVERLAPDIAL_BOTH (ZAP_OVERLAPDIAL_INCOMING|ZAP_OVERLAPDIAL_OUTGOING)
+#define DAHDI_OVERLAPDIAL_NONE 0
+#define DAHDI_OVERLAPDIAL_OUTGOING 1
+#define DAHDI_OVERLAPDIAL_INCOMING 2
+#define DAHDI_OVERLAPDIAL_BOTH (DAHDI_OVERLAPDIAL_INCOMING|DAHDI_OVERLAPDIAL_OUTGOING)
 
 
 #define CALLPROGRESS_PROGRESS          1
@@ -269,7 +268,7 @@ static int gendigittimeout = 8000;
 /*! \brief How long to wait for an extra digit, if there is an ambiguous match */
 static int matchdigittimeout = 3000;
 
-/*! \brief Protect the interface list (of zt_pvt's) */
+/*! \brief Protect the interface list (of dahdi_pvt's) */
 AST_MUTEX_DEFINE_STATIC(iflock);
 
 
@@ -289,35 +288,35 @@ static pthread_t monitor_thread = AST_PTHREADT_NULL;
 
 static int restart_monitor(void);
 
-static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
+static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms);
 
-static int zt_sendtext(struct ast_channel *c, const char *text);
+static int dahdi_sendtext(struct ast_channel *c, const char *text);
 
 static void mwi_event_cb(const struct ast_event *event, void *userdata)
 {
        /* This module does not handle MWI in an event-based manner.  However, it
         * subscribes to MWI for each mailbox that is configured so that the core
-        * knows that we care about it.  Then, chan_zap will get the MWI from the
+        * knows that we care about it.  Then, chan_dahdi will get the MWI from the
         * event cache instead of checking the mailbox directly. */
 }
 
-/*! \brief Avoid the silly zt_getevent which ignores a bunch of events */
-static inline int zt_get_event(int fd)
+/*! \brief Avoid the silly dahdi_getevent which ignores a bunch of events */
+static inline int dahdi_get_event(int fd)
 {
        int j;
-       if (ioctl(fd, ZT_GETEVENT, &j) == -1)
+       if (ioctl(fd, DAHDI_GETEVENT, &j) == -1)
                return -1;
        return j;
 }
 
-/*! \brief Avoid the silly zt_waitevent which ignores a bunch of events */
-static inline int zt_wait_event(int fd)
+/*! \brief Avoid the silly dahdi_waitevent which ignores a bunch of events */
+static inline int dahdi_wait_event(int fd)
 {
        int i, j = 0;
-       i = ZT_IOMUX_SIGEVENT;
-       if (ioctl(fd, ZT_IOMUX, &i) == -1)
+       i = DAHDI_IOMUX_SIGEVENT;
+       if (ioctl(fd, DAHDI_IOMUX, &i) == -1)
                return -1;
-       if (ioctl(fd, ZT_GETEVENT, &j) == -1)
+       if (ioctl(fd, DAHDI_GETEVENT, &j) == -1)
                return -1;
        return j;
 }
@@ -334,7 +333,7 @@ static inline int zt_wait_event(int fd)
 #define MIN_MS_SINCE_FLASH                     ( (2000) )      /*!< 2000 ms */
 #define DEFAULT_RINGT                          ( (8000 * 8) / READ_SIZE) /*!< 8,000 ms */
 
-struct zt_pvt;
+struct dahdi_pvt;
 
 static int ringt_base = DEFAULT_RINGT;
 
@@ -347,7 +346,7 @@ static int ringt_base = DEFAULT_RINGT;
 
 #define SS7_NAI_DYNAMIC                -1
 
-struct zt_ss7 {
+struct dahdi_ss7 {
        pthread_t master;                                               /*!< Thread of master */
        ast_mutex_t lock;
        int fds[NUM_DCHANS];
@@ -366,10 +365,10 @@ struct zt_ss7 {
        char subscriberprefix[20];                                      /*!< area access code + area code ('0'+area code for european dialplans) */
        char unknownprefix[20];                                         /*!< for unknown dialplans */
        struct ss7 *ss7;
-       struct zt_pvt *pvts[MAX_CHANNELS];                              /*!< Member channel pvt structs */
+       struct dahdi_pvt *pvts[MAX_CHANNELS];                           /*!< Member channel pvt structs */
 };
 
-static struct zt_ss7 linksets[NUM_SPANS];
+static struct dahdi_ss7 linksets[NUM_SPANS];
 
 static int cur_ss7type = -1;
 static int cur_linkset = -1;
@@ -387,7 +386,7 @@ static int cur_defaultdpc = -1;
 #define PRI_SPAN(p) (((p) >> 8) & 0xff)
 #define PRI_EXPLICIT(p) (((p) >> 16) & 0x01)
 
-struct zt_pri {
+struct dahdi_pri {
        pthread_t master;                                               /*!< Thread of master */
        ast_mutex_t lock;                                               /*!< Mutex */
        char idleext[AST_MAX_EXTENSION];                                /*!< Where to idle extra calls */
@@ -424,13 +423,13 @@ struct zt_pri {
        time_t lastreset;                                               /*!< time when unused channels were last reset */
        long resetinterval;                                             /*!< Interval (in seconds) for resetting unused channels */
        int sig;
-       struct zt_pvt *pvts[MAX_CHANNELS];                              /*!< Member channel pvt structs */
-       struct zt_pvt *crvs;                                            /*!< Member CRV structs */
-       struct zt_pvt *crvend;                                          /*!< Pointer to end of CRV structs */
+       struct dahdi_pvt *pvts[MAX_CHANNELS];                           /*!< Member channel pvt structs */
+       struct dahdi_pvt *crvs;                                         /*!< Member CRV structs */
+       struct dahdi_pvt *crvend;                                               /*!< Pointer to end of CRV structs */
 };
 
 
-static struct zt_pri pris[NUM_SPANS];
+static struct dahdi_pri pris[NUM_SPANS];
 
 #if 0
 #define DEFAULT_PRI_DEBUG (PRI_DEBUG_Q931_DUMP | PRI_DEBUG_Q921_DUMP | PRI_DEBUG_Q921_RAW | PRI_DEBUG_Q921_STATE)
@@ -438,14 +437,14 @@ static struct zt_pri pris[NUM_SPANS];
 #define DEFAULT_PRI_DEBUG 0
 #endif
 
-static inline void pri_rel(struct zt_pri *pri)
+static inline void pri_rel(struct dahdi_pri *pri)
 {
        ast_mutex_unlock(&pri->lock);
 }
 
 #else
 /*! Shut up the compiler */
-struct zt_pri;
+struct dahdi_pri;
 #endif
 
 #define SUB_REAL       0                       /*!< Active call */
@@ -464,7 +463,7 @@ struct distRingData {
 struct ringContextData {
        char contextData[AST_MAX_CONTEXT];
 };
-struct zt_distRings {
+struct dahdi_distRings {
        struct distRingData ringnum[3];
        struct ringContextData ringContext[3];
 };
@@ -475,7 +474,7 @@ static char *subnames[] = {
        "Threeway"
 };
 
-struct zt_subchannel {
+struct dahdi_subchannel {
        int zfd;
        struct ast_channel *owner;
        int chan;
@@ -491,7 +490,7 @@ struct zt_subchannel {
        unsigned int needunhold:1;
        unsigned int linear:1;
        unsigned int inthreeway:1;
-       ZT_CONFINFO curconf;
+       DAHDI_CONFINFO curconf;
 };
 
 #define CONF_USER_REAL         (1 << 0)
@@ -499,30 +498,30 @@ struct zt_subchannel {
 
 #define MAX_SLAVES     4
 
-static struct zt_pvt {
+static struct dahdi_pvt {
        ast_mutex_t lock;
        struct ast_channel *owner;                      /*!< Our current active owner (if applicable) */
                                                        /*!< Up to three channels can be associated with this call */
                
-       struct zt_subchannel sub_unused;                /*!< Just a safety precaution */
-       struct zt_subchannel subs[3];                   /*!< Sub-channels */
-       struct zt_confinfo saveconf;                    /*!< Saved conference info */
+       struct dahdi_subchannel sub_unused;             /*!< Just a safety precaution */
+       struct dahdi_subchannel subs[3];                        /*!< Sub-channels */
+       struct dahdi_confinfo saveconf;                 /*!< Saved conference info */
 
-       struct zt_pvt *slaves[MAX_SLAVES];              /*!< Slave to us (follows our conferencing) */
-       struct zt_pvt *master;                          /*!< Master to us (we follow their conferencing) */
+       struct dahdi_pvt *slaves[MAX_SLAVES];           /*!< Slave to us (follows our conferencing) */
+       struct dahdi_pvt *master;                               /*!< Master to us (we follow their conferencing) */
        int inconference;                               /*!< If our real should be in the conference */
        
        int sig;                                        /*!< Signalling style */
        int radio;                                      /*!< radio type */
        int outsigmod;                                  /*!< Outbound Signalling style (modifier) */
        int oprmode;                                    /*!< "Operator Services" mode */
-       struct zt_pvt *oprpeer;                         /*!< "Operator Services" peer tech_pvt ptr */
+       struct dahdi_pvt *oprpeer;                              /*!< "Operator Services" peer tech_pvt ptr */
        float cid_rxgain;                                       /*!< "Gain to apply during caller id */
        float rxgain;
        float txgain;
        int tonezone;                                   /*!< tone zone for this chan, or -1 for default */
-       struct zt_pvt *next;                            /*!< Next channel in list */
-       struct zt_pvt *prev;                            /*!< Prev channel in list */
+       struct dahdi_pvt *next;                         /*!< Next channel in list */
+       struct dahdi_pvt *prev;                         /*!< Prev channel in list */
 
        /* flags */
        unsigned int adsi:1;
@@ -567,7 +566,7 @@ static struct zt_pvt {
        unsigned int use_callerid:1;                    /*!< Whether or not to use caller id on this channel */
        unsigned int use_callingpres:1;                 /*!< Whether to use the callingpres the calling switch sends */
        unsigned int usedistinctiveringdetection:1;
-       unsigned int zaptrcallerid:1;                   /*!< should we use the callerid from incoming call on zap transfer or not */
+       unsigned int dahditrcallerid:1;                 /*!< should we use the callerid from incoming call on dahdi transfer or not */
        unsigned int transfertobusy:1;                  /*!< allow flash-transfers to busy channels */
        unsigned int mwimonitor_neon:1;                 /*!< monitor this FXO port for neon type MWI indication from other end */
        unsigned int mwimonitor_fsk:1;                  /*!< monitor this FXO port for fsk MWI indication from other end */
@@ -589,7 +588,7 @@ static struct zt_pvt {
        unsigned int use_smdi:1;                /* Whether to use SMDI on this channel */
        struct ast_smdi_interface *smdi_iface;  /* The serial port to listen for SMDI data on */
 
-       struct zt_distRings drings;
+       struct dahdi_distRings drings;
 
        char context[AST_MAX_CONTEXT];
        char defcontext[AST_MAX_CONTEXT];
@@ -637,14 +636,10 @@ static struct zt_pvt {
        int stripmsd;
        int callwaitcas;
        int callwaitrings;
-#if defined(HAVE_ZAPTEL_ECHOCANPARAMS)
        struct {
-               struct zt_echocanparams head;
-               struct zt_echocanparam params[ZT_MAX_ECHOCANPARAMS];
+               struct dahdi_echocanparams head;
+               struct dahdi_echocanparam params[DAHDI_MAX_ECHOCANPARAMS];
        } echocancel;
-#else
-       int echocancel;
-#endif
        int echotraining;
        char echorest[20];
        int busycount;
@@ -654,7 +649,7 @@ static struct zt_pvt {
        struct timeval flashtime;                       /*!< Last flash-hook time */
        struct ast_dsp *dsp;
        int cref;                                       /*!< Call reference number */
-       ZT_DIAL_OPERATION dop;
+       DAHDI_DIAL_OPERATION dop;
        int whichwink;                                  /*!< SIG_FEATDMF_TA Which wink are we on? */
        char finaldial[64];
        char accountcode[AST_MAX_ACCOUNT_CODE];         /*!< Account code */
@@ -674,9 +669,9 @@ static struct zt_pvt {
        struct timeval polaritydelaytv;
        int sendcalleridafter;
 #ifdef HAVE_PRI
-       struct zt_pri *pri;
-       struct zt_pvt *bearer;
-       struct zt_pvt *realcall;
+       struct dahdi_pri *pri;
+       struct dahdi_pvt *bearer;
+       struct dahdi_pvt *realcall;
        q931_call *call;
        int prioffset;
        int logicalspan;
@@ -684,7 +679,7 @@ static struct zt_pvt {
        int polarity;
        int dsp_features;
 #ifdef HAVE_SS7
-       struct zt_ss7 *ss7;
+       struct dahdi_ss7 *ss7;
        struct isup_call *ss7call;
        char charge_number[50];
        char gen_add_number[50];
@@ -715,37 +710,37 @@ static struct zt_pvt {
        int muting;
 } *iflist = NULL, *ifend = NULL;
 
-/*! \brief Channel configuration from zapata.conf .
- * This struct is used for parsing the [channels] section of zapata.conf.
+/*! \brief Channel configuration from chan_dahdi.conf .
+ * This struct is used for parsing the [channels] section of chan_dahdi.conf.
  * Generally there is a field here for every possible configuration item.
  *
  * The state of fields is saved along the parsing and whenever a 'channel'
- * statement is reached, the current zt_chan_conf is used to configure the 
- * channel (struct zt_pvt)
+ * statement is reached, the current dahdi_chan_conf is used to configure the 
+ * channel (struct dahdi_pvt)
  *
- * \see zt_chan_init for the default values.
+ * \see dahdi_chan_init for the default values.
  */
-struct zt_chan_conf {
-       struct zt_pvt chan;
+struct dahdi_chan_conf {
+       struct dahdi_pvt chan;
 #ifdef HAVE_PRI
-       struct zt_pri pri;
+       struct dahdi_pri pri;
 #endif
 
 #ifdef HAVE_SS7
-       struct zt_ss7 ss7;
+       struct dahdi_ss7 ss7;
 #endif
-       ZT_PARAMS timing;
-       int is_sig_auto; /*!< Use channel signalling from Zaptel? */
+       DAHDI_PARAMS timing;
+       int is_sig_auto; /*!< Use channel signalling from DAHDI? */
 
        char smdi_port[SMDI_MAX_FILENAME_LEN];
 };
 
-/*! returns a new zt_chan_conf with default values (by-value) */
-static struct zt_chan_conf zt_chan_conf_default(void) {
+/*! returns a new dahdi_chan_conf with default values (by-value) */
+static struct dahdi_chan_conf dahdi_chan_conf_default(void) {
        /* recall that if a field is not included here it is initialized
         * to 0 or equivalent
         */
-       struct zt_chan_conf conf = {
+       struct dahdi_chan_conf conf = {
 #ifdef HAVE_PRI
                .pri = {
                        .nsf = PRI_NSF_NONE,
@@ -786,7 +781,7 @@ static struct zt_chan_conf zt_chan_conf_default(void) {
 
                        .cid_signalling = CID_SIG_BELL,
                        .cid_start = CID_START_RING,
-                       .zaptrcallerid = 0,
+                       .dahditrcallerid = 0,
                        .use_callerid = 1,
                        .sig = -1,
                        .outsigmod = -1,
@@ -795,11 +790,7 @@ static struct zt_chan_conf zt_chan_conf_default(void) {
 
                        .tonezone = -1,
 
-#if defined(HAVE_ZAPTEL_ECHOCANPARAMS)
                        .echocancel.head.tap_length = 1,
-#else
-                       .echocancel = 1,
-#endif
 
                        .busycount = 3,
 
@@ -830,40 +821,40 @@ static struct zt_chan_conf zt_chan_conf_default(void) {
 }
 
 
-static struct ast_channel *zt_request(const char *type, int format, void *data, int *cause);
-static int zt_digit_begin(struct ast_channel *ast, char digit);
-static int zt_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
-static int zt_sendtext(struct ast_channel *c, const char *text);
-static int zt_call(struct ast_channel *ast, char *rdest, int timeout);
-static int zt_hangup(struct ast_channel *ast);
-static int zt_answer(struct ast_channel *ast);
-static struct ast_frame *zt_read(struct ast_channel *ast);
-static int zt_write(struct ast_channel *ast, struct ast_frame *frame);
-static struct ast_frame *zt_exception(struct ast_channel *ast);
-static int zt_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen);
-static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
-static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen);
-static int zt_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
-
-static const struct ast_channel_tech zap_tech = {
-       .type = "Zap",
+static struct ast_channel *dahdi_request(const char *type, int format, void *data, int *cause);
+static int dahdi_digit_begin(struct ast_channel *ast, char digit);
+static int dahdi_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
+static int dahdi_sendtext(struct ast_channel *c, const char *text);
+static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout);
+static int dahdi_hangup(struct ast_channel *ast);
+static int dahdi_answer(struct ast_channel *ast);
+static struct ast_frame *dahdi_read(struct ast_channel *ast);
+static int dahdi_write(struct ast_channel *ast, struct ast_frame *frame);
+static struct ast_frame *dahdi_exception(struct ast_channel *ast);
+static int dahdi_indicate(struct ast_channel *chan, int condition, const void *data, size_t datalen);
+static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
+static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int datalen);
+static int dahdi_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
+
+static const struct ast_channel_tech dahdi_tech = {
+       .type = "DAHDI",
        .description = tdesc,
        .capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
-       .requester = zt_request,
-       .send_digit_begin = zt_digit_begin,
-       .send_digit_end = zt_digit_end,
-       .send_text = zt_sendtext,
-       .call = zt_call,
-       .hangup = zt_hangup,
-       .answer = zt_answer,
-       .read = zt_read,
-       .write = zt_write,
-       .bridge = zt_bridge,
-       .exception = zt_exception,
-       .indicate = zt_indicate,
-       .fixup = zt_fixup,
-       .setoption = zt_setoption,
-       .func_channel_read = zt_func_read,
+       .requester = dahdi_request,
+       .send_digit_begin = dahdi_digit_begin,
+       .send_digit_end = dahdi_digit_end,
+       .send_text = dahdi_sendtext,
+       .call = dahdi_call,
+       .hangup = dahdi_hangup,
+       .answer = dahdi_answer,
+       .read = dahdi_read,
+       .write = dahdi_write,
+       .bridge = dahdi_bridge,
+       .exception = dahdi_exception,
+       .indicate = dahdi_indicate,
+       .fixup = dahdi_fixup,
+       .setoption = dahdi_setoption,
+       .func_channel_read = dahdi_func_read,
 };
 
 #ifdef HAVE_PRI
@@ -872,10 +863,10 @@ static const struct ast_channel_tech zap_tech = {
 #define GET_CHANNEL(p) ((p)->channel)
 #endif
 
-struct zt_pvt *round_robin[32];
+struct dahdi_pvt *round_robin[32];
 
 #ifdef HAVE_PRI
-static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
+static inline int pri_grab(struct dahdi_pvt *pvt, struct dahdi_pri *pri)
 {
        int res;
        /* Grab the lock first */
@@ -892,12 +883,12 @@ static inline int pri_grab(struct zt_pvt *pvt, struct zt_pri *pri)
 #endif
 
 #ifdef HAVE_SS7
-static inline void ss7_rel(struct zt_ss7 *ss7)
+static inline void ss7_rel(struct dahdi_ss7 *ss7)
 {
        ast_mutex_unlock(&ss7->lock);
 }
 
-static inline int ss7_grab(struct zt_pvt *pvt, struct zt_ss7 *pri)
+static inline int ss7_grab(struct dahdi_pvt *pvt, struct dahdi_ss7 *pri)
 {
        int res;
        /* Grab the lock first */
@@ -919,7 +910,7 @@ static inline int ss7_grab(struct zt_pvt *pvt, struct zt_ss7 *pri)
 static int num_cadence = 4;
 static int user_has_defined_cadences = 0;
 
-static struct zt_ring_cadence cadences[NUM_CADENCE_MAX] = {
+static struct dahdi_ring_cadence cadences[NUM_CADENCE_MAX] = {
        { { 125, 125, 2000, 4000 } },                   /*!< Quick chirp followed by normal ring */
        { { 250, 250, 500, 1000, 250, 250, 500, 4000 } }, /*!< British style ring */
        { { 125, 125, 125, 125, 125, 4000 } },  /*!< Three short bursts */
@@ -940,10 +931,10 @@ static int cidrings[NUM_CADENCE_MAX] = {
 #define ISTRUNK(p) ((p->sig == SIG_FXSLS) || (p->sig == SIG_FXSKS) || \
                        (p->sig == SIG_FXSGS) || (p->sig == SIG_PRI))
 
-#define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
-#define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __ZT_SIG_FXO) */)
+#define CANBUSYDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */)
+#define CANPROGRESSDETECT(p) (ISTRUNK(p) || (p->sig & (SIG_EM | SIG_EM_E1 | SIG_SF)) /* || (p->sig & __DAHDI_SIG_FXO) */)
 
-static int zt_get_index(struct ast_channel *ast, struct zt_pvt *p, int nullok)
+static int dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok)
 {
        int res;
        if (p->subs[0].owner == ast)
@@ -961,9 +952,9 @@ static int zt_get_index(struct ast_channel *ast, struct zt_pvt *p, int nullok)
 }
 
 #ifdef HAVE_PRI
-static void wakeup_sub(struct zt_pvt *p, int a, struct zt_pri *pri)
+static void wakeup_sub(struct dahdi_pvt *p, int a, struct dahdi_pri *pri)
 #else
-static void wakeup_sub(struct zt_pvt *p, int a, void *pri)
+static void wakeup_sub(struct dahdi_pvt *p, int a, void *pri)
 #endif
 {
 #ifdef HAVE_PRI
@@ -988,13 +979,13 @@ static void wakeup_sub(struct zt_pvt *p, int a, void *pri)
 #endif                 
 }
 
-static void zap_queue_frame(struct zt_pvt *p, struct ast_frame *f, void *data)
+static void dahdi_queue_frame(struct dahdi_pvt *p, struct ast_frame *f, void *data)
 {
 #ifdef HAVE_PRI
-       struct zt_pri *pri = (struct zt_pri*) data;
+       struct dahdi_pri *pri = (struct dahdi_pri*) data;
 #endif
 #ifdef HAVE_SS7
-       struct zt_ss7 *ss7 = (struct zt_ss7*) data;
+       struct dahdi_ss7 *ss7 = (struct dahdi_ss7*) data;
 #endif
        /* We must unlock the PRI to avoid the possibility of a deadlock */
 #if defined(HAVE_PRI) || defined(HAVE_SS7)
@@ -1052,9 +1043,9 @@ static void zap_queue_frame(struct zt_pvt *p, struct ast_frame *f, void *data)
 #endif         
 }
 
-static int restore_gains(struct zt_pvt *p);
+static int restore_gains(struct dahdi_pvt *p);
 
-static void swap_subs(struct zt_pvt *p, int a, int b)
+static void swap_subs(struct dahdi_pvt *p, int a, int b)
 {
        int tchan;
        int tinthreeway;
@@ -1082,7 +1073,7 @@ static void swap_subs(struct zt_pvt *p, int a, int b)
        wakeup_sub(p, b, NULL);
 }
 
-static int zt_open(char *fn)
+static int dahdi_open(char *fn)
 {
        int fd;
        int isnum;
@@ -1102,7 +1093,7 @@ static int zt_open(char *fn)
                        ast_log(LOG_WARNING, "Invalid channel number '%s'\n", fn);
                        return -1;
                }
-               fn = "/dev/zap/channel";
+               fn = "/dev/dahdi/channel";
        }
        fd = open(fn, O_RDWR | O_NONBLOCK);
        if (fd < 0) {
@@ -1110,7 +1101,7 @@ static int zt_open(char *fn)
                return -1;
        }
        if (chan) {
-               if (ioctl(fd, ZT_SPECIFY, &chan)) {
+               if (ioctl(fd, DAHDI_SPECIFY, &chan)) {
                        x = errno;
                        close(fd);
                        errno = x;
@@ -1119,7 +1110,7 @@ static int zt_open(char *fn)
                }
        }
        bs = READ_SIZE;
-       if (ioctl(fd, ZT_SET_BLOCKSIZE, &bs) == -1) {
+       if (ioctl(fd, DAHDI_SET_BLOCKSIZE, &bs) == -1) {
                ast_log(LOG_WARNING, "Unable to set blocksize '%d': %s\n", bs,  strerror(errno));
                x = errno;
                close(fd);
@@ -1129,52 +1120,52 @@ static int zt_open(char *fn)
        return fd;
 }
 
-static void zt_close(int fd)
+static void dahdi_close(int fd)
 {
        if (fd > 0)
                close(fd);
 }
 
-static int zt_setlinear(int zfd, int linear)
+static int dahdi_setlinear(int zfd, int linear)
 {
        int res;
-       res = ioctl(zfd, ZT_SETLINEAR, &linear);
+       res = ioctl(zfd, DAHDI_SETLINEAR, &linear);
        if (res)
                return res;
        return 0;
 }
 
 
-static int alloc_sub(struct zt_pvt *p, int x)
+static int alloc_sub(struct dahdi_pvt *p, int x)
 {
-       ZT_BUFFERINFO bi;
+       DAHDI_BUFFERINFO bi;
        int res;
        if (p->subs[x].zfd >= 0) {
                ast_log(LOG_WARNING, "%s subchannel of %d already in use\n", subnames[x], p->channel);
                return -1;
        }
 
-       p->subs[x].zfd = zt_open("/dev/zap/pseudo");
+       p->subs[x].zfd = dahdi_open("/dev/dahdi/pseudo");
        if (p->subs[x].zfd <= -1) {
                ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
                return -1;
        }
 
-       res = ioctl(p->subs[x].zfd, ZT_GET_BUFINFO, &bi);
+       res = ioctl(p->subs[x].zfd, DAHDI_GET_BUFINFO, &bi);
        if (!res) {
-               bi.txbufpolicy = ZT_POLICY_IMMEDIATE;
-               bi.rxbufpolicy = ZT_POLICY_IMMEDIATE;
+               bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
+               bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
                bi.numbufs = numbufs;
-               res = ioctl(p->subs[x].zfd, ZT_SET_BUFINFO, &bi);
+               res = ioctl(p->subs[x].zfd, DAHDI_SET_BUFINFO, &bi);
                if (res < 0) {
                        ast_log(LOG_WARNING, "Unable to set buffer policy on channel %d\n", x);
                }
        } else 
                ast_log(LOG_WARNING, "Unable to check buffer policy on channel %d\n", x);
 
-       if (ioctl(p->subs[x].zfd, ZT_CHANNO, &p->subs[x].chan) == 1) {
+       if (ioctl(p->subs[x].zfd, DAHDI_CHANNO, &p->subs[x].chan) == 1) {
                ast_log(LOG_WARNING, "Unable to get channel number for pseudo channel on FD %d\n", p->subs[x].zfd);
-               zt_close(p->subs[x].zfd);
+               dahdi_close(p->subs[x].zfd);
                p->subs[x].zfd = -1;
                return -1;
        }
@@ -1182,7 +1173,7 @@ static int alloc_sub(struct zt_pvt *p, int x)
        return 0;
 }
 
-static int unalloc_sub(struct zt_pvt *p, int x)
+static int unalloc_sub(struct dahdi_pvt *p, int x)
 {
        if (!x) {
                ast_log(LOG_WARNING, "Trying to unalloc the real channel %d?!?\n", p->channel);
@@ -1190,7 +1181,7 @@ static int unalloc_sub(struct zt_pvt *p, int x)
        }
        ast_debug(1, "Released sub %d of channel %d\n", x, p->channel);
        if (p->subs[x].zfd > -1) {
-               zt_close(p->subs[x].zfd);
+               dahdi_close(p->subs[x].zfd);
        }
        p->subs[x].zfd = -1;
        p->subs[x].linear = 0;
@@ -1205,22 +1196,22 @@ static int unalloc_sub(struct zt_pvt *p, int x)
 static int digit_to_dtmfindex(char digit)
 {
        if (isdigit(digit))
-               return ZT_TONE_DTMF_BASE + (digit - '0');
+               return DAHDI_TONE_DTMF_BASE + (digit - '0');
        else if (digit >= 'A' && digit <= 'D')
-               return ZT_TONE_DTMF_A + (digit - 'A');
+               return DAHDI_TONE_DTMF_A + (digit - 'A');
        else if (digit >= 'a' && digit <= 'd')
-               return ZT_TONE_DTMF_A + (digit - 'a');
+               return DAHDI_TONE_DTMF_A + (digit - 'a');
        else if (digit == '*')
-               return ZT_TONE_DTMF_s;
+               return DAHDI_TONE_DTMF_s;
        else if (digit == '#')
-               return ZT_TONE_DTMF_p;
+               return DAHDI_TONE_DTMF_p;
        else
                return -1;
 }
 
-static int zt_digit_begin(struct ast_channel *chan, char digit)
+static int dahdi_digit_begin(struct ast_channel *chan, char digit)
 {
-       struct zt_pvt *pvt;
+       struct dahdi_pvt *pvt;
        int index;
        int dtmf = -1;
        
@@ -1228,7 +1219,7 @@ static int zt_digit_begin(struct ast_channel *chan, char digit)
 
        ast_mutex_lock(&pvt->lock);
 
-       index = zt_get_index(chan, pvt, 0);
+       index = dahdi_get_index(chan, pvt, 0);
 
        if ((index != SUB_REAL) || !pvt->owner)
                goto out;
@@ -1255,16 +1246,16 @@ static int zt_digit_begin(struct ast_channel *chan, char digit)
        if ((dtmf = digit_to_dtmfindex(digit)) == -1)
                goto out;
 
-       if (pvt->pulse || ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &dtmf)) {
+       if (pvt->pulse || ioctl(pvt->subs[SUB_REAL].zfd, DAHDI_SENDTONE, &dtmf)) {
                int res;
-               ZT_DIAL_OPERATION zo = {
-                       .op = ZT_DIAL_OP_APPEND,
+               DAHDI_DIAL_OPERATION zo = {
+                       .op = DAHDI_DIAL_OP_APPEND,
                };
 
                zo.dialstr[0] = 'T';
                zo.dialstr[1] = digit;
                zo.dialstr[2] = '\0';
-               if ((res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_DIAL, &zo)))
+               if ((res = ioctl(pvt->subs[SUB_REAL].zfd, DAHDI_DIAL, &zo)))
                        ast_log(LOG_WARNING, "Couldn't dial digit %c\n", digit);
                else
                        pvt->dialing = 1;
@@ -1280,9 +1271,9 @@ out:
        return 0;
 }
 
-static int zt_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
+static int dahdi_digit_end(struct ast_channel *chan, char digit, unsigned int duration)
 {
-       struct zt_pvt *pvt;
+       struct dahdi_pvt *pvt;
        int res = 0;
        int index;
        int x;
@@ -1291,7 +1282,7 @@ static int zt_digit_end(struct ast_channel *chan, char digit, unsigned int durat
 
        ast_mutex_lock(&pvt->lock);
        
-       index = zt_get_index(chan, pvt, 0);
+       index = dahdi_get_index(chan, pvt, 0);
 
        if ((index != SUB_REAL) || !pvt->owner || pvt->pulse)
                goto out;
@@ -1306,7 +1297,7 @@ static int zt_digit_end(struct ast_channel *chan, char digit, unsigned int durat
        if (pvt->begindigit) {
                x = -1;
                ast_debug(1, "Ending VLDTMF digit '%c'\n", digit);
-               res = ioctl(pvt->subs[SUB_REAL].zfd, ZT_SENDTONE, &x);
+               res = ioctl(pvt->subs[SUB_REAL].zfd, DAHDI_SENDTONE, &x);
                pvt->dialing = 0;
                pvt->begindigit = 0;
        }
@@ -1343,13 +1334,13 @@ static struct {
        int alarm;
        char *name;
 } alarms[] = {
-       { ZT_ALARM_RED, "Red Alarm" },
-       { ZT_ALARM_YELLOW, "Yellow Alarm" },
-       { ZT_ALARM_BLUE, "Blue Alarm" },
-       { ZT_ALARM_RECOVER, "Recovering" },
-       { ZT_ALARM_LOOPBACK, "Loopback" },
-       { ZT_ALARM_NOTOPEN, "Not Open" },
-       { ZT_ALARM_NONE, "None" },
+       { DAHDI_ALARM_RED, "Red Alarm" },
+       { DAHDI_ALARM_YELLOW, "Yellow Alarm" },
+       { DAHDI_ALARM_BLUE, "Blue Alarm" },
+       { DAHDI_ALARM_RECOVER, "Recovering" },
+       { DAHDI_ALARM_LOOPBACK, "Loopback" },
+       { DAHDI_ALARM_NOTOPEN, "Not Open" },
+       { DAHDI_ALARM_NONE, "None" },
 };
 
 static char *alarm2str(int alarm)
@@ -1381,7 +1372,7 @@ static char *dialplan2str(int dialplan)
 }
 #endif
 
-static char *zap_sig2str(int sig)
+static char *dahdi_sig2str(int sig)
 {
        static char buf[256];
        switch (sig) {
@@ -1447,35 +1438,35 @@ static char *zap_sig2str(int sig)
        }
 }
 
-#define sig2str zap_sig2str
+#define sig2str dahdi_sig2str
 
-static int conf_add(struct zt_pvt *p, struct zt_subchannel *c, int index, int slavechannel)
+static int conf_add(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index, int slavechannel)
 {
        /* If the conference already exists, and we're already in it
           don't bother doing anything */
-       ZT_CONFINFO zi;
+       DAHDI_CONFINFO zi;
        
        memset(&zi, 0, sizeof(zi));
        zi.chan = 0;
 
        if (slavechannel > 0) {
                /* If we have only one slave, do a digital mon */
-               zi.confmode = ZT_CONF_DIGITALMON;
+               zi.confmode = DAHDI_CONF_DIGITALMON;
                zi.confno = slavechannel;
        } else {
                if (!index) {
                        /* Real-side and pseudo-side both participate in conference */
-                       zi.confmode = ZT_CONF_REALANDPSEUDO | ZT_CONF_TALKER | ZT_CONF_LISTENER |
-                               ZT_CONF_PSEUDO_TALKER | ZT_CONF_PSEUDO_LISTENER;
+                       zi.confmode = DAHDI_CONF_REALANDPSEUDO | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER |
+                               DAHDI_CONF_PSEUDO_TALKER | DAHDI_CONF_PSEUDO_LISTENER;
                } else
-                       zi.confmode = ZT_CONF_CONF | ZT_CONF_TALKER | ZT_CONF_LISTENER;
+                       zi.confmode = DAHDI_CONF_CONF | DAHDI_CONF_TALKER | DAHDI_CONF_LISTENER;
                zi.confno = p->confno;
        }
        if ((zi.confno == c->curconf.confno) && (zi.confmode == c->curconf.confmode))
                return 0;
        if (c->zfd < 0)
                return 0;
-       if (ioctl(c->zfd, ZT_SETCONF, &zi)) {
+       if (ioctl(c->zfd, DAHDI_SETCONF, &zi)) {
                ast_log(LOG_WARNING, "Failed to add %d to conference %d/%d\n", c->zfd, zi.confmode, zi.confno);
                return -1;
        }
@@ -1487,20 +1478,20 @@ static int conf_add(struct zt_pvt *p, struct zt_subchannel *c, int index, int sl
        return 0;
 }
 
-static int isourconf(struct zt_pvt *p, struct zt_subchannel *c)
+static int isourconf(struct dahdi_pvt *p, struct dahdi_subchannel *c)
 {
        /* If they're listening to our channel, they're ours */ 
-       if ((p->channel == c->curconf.confno) && (c->curconf.confmode == ZT_CONF_DIGITALMON))
+       if ((p->channel == c->curconf.confno) && (c->curconf.confmode == DAHDI_CONF_DIGITALMON))
                return 1;
        /* If they're a talker on our (allocated) conference, they're ours */
-       if ((p->confno > 0) && (p->confno == c->curconf.confno) && (c->curconf.confmode & ZT_CONF_TALKER))
+       if ((p->confno > 0) && (p->confno == c->curconf.confno) && (c->curconf.confmode & DAHDI_CONF_TALKER))
                return 1;
        return 0;
 }
 
-static int conf_del(struct zt_pvt *p, struct zt_subchannel *c, int index)
+static int conf_del(struct dahdi_pvt *p, struct dahdi_subchannel *c, int index)
 {
-       ZT_CONFINFO zi;
+       DAHDI_CONFINFO zi;
        if (/* Can't delete if there's no zfd */
                (c->zfd < 0) ||
                /* Don't delete from the conference if it's not our conference */
@@ -1511,7 +1502,7 @@ static int conf_del(struct zt_pvt *p, struct zt_subchannel *c, int index)
        zi.chan = 0;
        zi.confno = 0;
        zi.confmode = 0;
-       if (ioctl(c->zfd, ZT_SETCONF, &zi)) {
+       if (ioctl(c->zfd, DAHDI_SETCONF, &zi)) {
                ast_log(LOG_WARNING, "Failed to drop %d from conference %d/%d\n", c->zfd, c->curconf.confmode, c->curconf.confno);
                return -1;
        }
@@ -1520,11 +1511,11 @@ static int conf_del(struct zt_pvt *p, struct zt_subchannel *c, int index)
        return 0;
 }
 
-static int isslavenative(struct zt_pvt *p, struct zt_pvt **out)
+static int isslavenative(struct dahdi_pvt *p, struct dahdi_pvt **out)
 {
        int x;
        int useslavenative;
-       struct zt_pvt *slave = NULL;
+       struct dahdi_pvt *slave = NULL;
        /* Start out optimistic */
        useslavenative = 1;
        /* Update conference state in a stateless fashion */
@@ -1564,25 +1555,25 @@ static int isslavenative(struct zt_pvt *p, struct zt_pvt **out)
        return useslavenative;
 }
 
-static int reset_conf(struct zt_pvt *p)
+static int reset_conf(struct dahdi_pvt *p)
 {
-       ZT_CONFINFO zi;
+       DAHDI_CONFINFO zi;
        memset(&zi, 0, sizeof(zi));
        p->confno = -1;
        memset(&p->subs[SUB_REAL].curconf, 0, sizeof(p->subs[SUB_REAL].curconf));
        if (p->subs[SUB_REAL].zfd > -1) {
-               if (ioctl(p->subs[SUB_REAL].zfd, ZT_SETCONF, &zi))
+               if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCONF, &zi))
                        ast_log(LOG_WARNING, "Failed to reset conferencing on channel %d!\n", p->channel);
        }
        return 0;
 }
 
-static int update_conf(struct zt_pvt *p)
+static int update_conf(struct dahdi_pvt *p)
 {
        int needconf = 0;
        int x;
        int useslavenative;
-       struct zt_pvt *slave = NULL;
+       struct dahdi_pvt *slave = NULL;
 
        useslavenative = isslavenative(p, &slave);
        /* Start with the obvious, general stuff */
@@ -1633,7 +1624,7 @@ static int update_conf(struct zt_pvt *p)
        return 0;
 }
 
-static void zt_enable_ec(struct zt_pvt *p)
+static void dahdi_enable_ec(struct dahdi_pvt *p)
 {
        int x;
        int res;
@@ -1647,23 +1638,14 @@ static void zt_enable_ec(struct zt_pvt *p)
                ast_debug(1, "Echo cancellation isn't required on digital connection\n");
                return;
        }
-#if defined(HAVE_ZAPTEL_ECHOCANPARAMS)
        if (p->echocancel.head.tap_length) {
-#else
-       if (p->echocancel) {
-#endif
                if ((p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP) || (p->sig == SIG_PRI) || (p->sig == SIG_SS7)) {
                        x = 1;
-                       res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x);
+                       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_AUDIOMODE, &x);
                        if (res)
                                ast_log(LOG_WARNING, "Unable to enable audio mode on channel %d (%s)\n", p->channel, strerror(errno));
                }
-#if defined(HAVE_ZAPTEL_ECHOCANPARAMS)
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL_PARAMS, &p->echocancel);
-#else
-               x = p->echocancel;
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
-#endif
+               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_ECHOCANCEL_PARAMS, &p->echocancel);
                if (res)  {
                        ast_log(LOG_WARNING, "Unable to enable echo cancellation on channel %d (%s)\n", p->channel, strerror(errno));
                } else {
@@ -1674,14 +1656,14 @@ static void zt_enable_ec(struct zt_pvt *p)
                ast_debug(1, "No echo cancellation requested\n");
 }
 
-static void zt_train_ec(struct zt_pvt *p)
+static void dahdi_train_ec(struct dahdi_pvt *p)
 {
        int x;
        int res;
        
        if (p && p->echocanon && p->echotraining) {
                x = p->echotraining;
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOTRAIN, &x);
+               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_ECHOTRAIN, &x);
                if (res)
                        ast_log(LOG_WARNING, "Unable to request echo training on channel %d\n", p->channel);
                else
@@ -1691,20 +1673,14 @@ static void zt_train_ec(struct zt_pvt *p)
        }
 }
 
-static void zt_disable_ec(struct zt_pvt *p)
+static void dahdi_disable_ec(struct dahdi_pvt *p)
 {
        int res;
 
        if (p->echocanon) {
-#if defined(HAVE_ZAPTEL_ECHOCANPARAMS)
-               struct zt_echocanparams ecp = { .tap_length = 0 };
-
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL_PARAMS, &ecp);
-#else
-               int x = 0;
+               struct dahdi_echocanparams ecp = { .tap_length = 0 };
 
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_ECHOCANCEL, &x);
-#endif
+               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_ECHOCANCEL_PARAMS, &ecp);
 
                if (res)
                        ast_log(LOG_WARNING, "Unable to disable echo cancellation on channel %d\n", p->channel);
@@ -1715,14 +1691,14 @@ static void zt_disable_ec(struct zt_pvt *p)
        p->echocanon = 0;
 }
 
-static void fill_txgain(struct zt_gains *g, float gain, int law)
+static void fill_txgain(struct dahdi_gains *g, float gain, int law)
 {
        int j;
        int k;
        float linear_gain = pow(10.0, gain / 20.0);
 
        switch (law) {
-       case ZT_LAW_ALAW:
+       case DAHDI_LAW_ALAW:
                for (j = 0; j < (sizeof(g->txgain) / sizeof(g->txgain[0])); j++) {
                        if (gain) {
                                k = (int) (((float) AST_ALAW(j)) * linear_gain);
@@ -1734,7 +1710,7 @@ static void fill_txgain(struct zt_gains *g, float gain, int law)
                        }
                }
                break;
-       case ZT_LAW_MULAW:
+       case DAHDI_LAW_MULAW:
                for (j = 0; j < (sizeof(g->txgain) / sizeof(g->txgain[0])); j++) {
                        if (gain) {
                                k = (int) (((float) AST_MULAW(j)) * linear_gain);
@@ -1749,14 +1725,14 @@ static void fill_txgain(struct zt_gains *g, float gain, int law)
        }
 }
 
-static void fill_rxgain(struct zt_gains *g, float gain, int law)
+static void fill_rxgain(struct dahdi_gains *g, float gain, int law)
 {
        int j;
        int k;
        float linear_gain = pow(10.0, gain / 20.0);
 
        switch (law) {
-       case ZT_LAW_ALAW:
+       case DAHDI_LAW_ALAW:
                for (j = 0; j < (sizeof(g->rxgain) / sizeof(g->rxgain[0])); j++) {
                        if (gain) {
                                k = (int) (((float) AST_ALAW(j)) * linear_gain);
@@ -1768,7 +1744,7 @@ static void fill_rxgain(struct zt_gains *g, float gain, int law)
                        }
                }
                break;
-       case ZT_LAW_MULAW:
+       case DAHDI_LAW_MULAW:
                for (j = 0; j < (sizeof(g->rxgain) / sizeof(g->rxgain[0])); j++) {
                        if (gain) {
                                k = (int) (((float) AST_MULAW(j)) * linear_gain);
@@ -1785,12 +1761,12 @@ static void fill_rxgain(struct zt_gains *g, float gain, int law)
 
 static int set_actual_txgain(int fd, int chan, float gain, int law)
 {
-       struct zt_gains g;
+       struct dahdi_gains g;
        int res;
 
        memset(&g, 0, sizeof(g));
        g.chan = chan;
-       res = ioctl(fd, ZT_GETGAINS, &g);
+       res = ioctl(fd, DAHDI_GETGAINS, &g);
        if (res) {
                ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
                return res;
@@ -1798,17 +1774,17 @@ static int set_actual_txgain(int fd, int chan, float gain, int law)
 
        fill_txgain(&g, gain, law);
 
-       return ioctl(fd, ZT_SETGAINS, &g);
+       return ioctl(fd, DAHDI_SETGAINS, &g);
 }
 
 static int set_actual_rxgain(int fd, int chan, float gain, int law)
 {
-       struct zt_gains g;
+       struct dahdi_gains g;
        int res;
 
        memset(&g, 0, sizeof(g));
        g.chan = chan;
-       res = ioctl(fd, ZT_GETGAINS, &g);
+       res = ioctl(fd, DAHDI_GETGAINS, &g);
        if (res) {
                ast_debug(1, "Failed to read gains: %s\n", strerror(errno));
                return res;
@@ -1816,7 +1792,7 @@ static int set_actual_rxgain(int fd, int chan, float gain, int law)
 
        fill_rxgain(&g, gain, law);
 
-       return ioctl(fd, ZT_SETGAINS, &g);
+       return ioctl(fd, DAHDI_SETGAINS, &g);
 }
 
 static int set_actual_gain(int fd, int chan, float rxgain, float txgain, int law)
@@ -1824,7 +1800,7 @@ static int set_actual_gain(int fd, int chan, float rxgain, float txgain, int law
        return set_actual_txgain(fd, chan, txgain, law) | set_actual_rxgain(fd, chan, rxgain, law);
 }
 
-static int bump_gains(struct zt_pvt *p)
+static int bump_gains(struct dahdi_pvt *p)
 {
        int res;
 
@@ -1838,7 +1814,7 @@ static int bump_gains(struct zt_pvt *p)
        return 0;
 }
 
-static int restore_gains(struct zt_pvt *p)
+static int restore_gains(struct dahdi_pvt *p)
 {
        int res;
 
@@ -1851,48 +1827,48 @@ static int restore_gains(struct zt_pvt *p)
        return 0;
 }
 
-static inline int zt_set_hook(int fd, int hs)
+static inline int dahdi_set_hook(int fd, int hs)
 {
        int x, res;
 
        x = hs;
-       res = ioctl(fd, ZT_HOOK, &x);
+       res = ioctl(fd, DAHDI_HOOK, &x);
 
        if (res < 0) {
                if (errno == EINPROGRESS)
                        return 0;
-               ast_log(LOG_WARNING, "zt hook failed: %s\n", strerror(errno));
+               ast_log(LOG_WARNING, "DAHDI hook failed: %s\n", strerror(errno));
        }
 
        return res;
 }
 
-static inline int zt_confmute(struct zt_pvt *p, int muted)
+static inline int dahdi_confmute(struct dahdi_pvt *p, int muted)
 {
        int x, y, res;
        x = muted;
        if ((p->sig == SIG_PRI) || (p->sig == SIG_SS7) || (p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP)) {
                y = 1;
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &y);
+               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_AUDIOMODE, &y);
                if (res)
                        ast_log(LOG_WARNING, "Unable to set audio mode on '%d'\n", p->channel);
        }
-       res = ioctl(p->subs[SUB_REAL].zfd, ZT_CONFMUTE, &x);
+       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_CONFMUTE, &x);
        if (res < 0)
-               ast_log(LOG_WARNING, "zt confmute(%d) failed on channel %d: %s\n", muted, p->channel, strerror(errno));
+               ast_log(LOG_WARNING, "DAHDI confmute(%d) failed on channel %d: %s\n", muted, p->channel, strerror(errno));
        return res;
 }
 
-static int save_conference(struct zt_pvt *p)
+static int save_conference(struct dahdi_pvt *p)
 {
-       struct zt_confinfo c;
+       struct dahdi_confinfo c;
        int res;
        if (p->saveconf.confmode) {
                ast_log(LOG_WARNING, "Can't save conference -- already in use\n");
                return -1;
        }
        p->saveconf.chan = 0;
-       res = ioctl(p->subs[SUB_REAL].zfd, ZT_GETCONF, &p->saveconf);
+       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_GETCONF, &p->saveconf);
        if (res) {
                ast_log(LOG_WARNING, "Unable to get conference info: %s\n", strerror(errno));
                p->saveconf.confmode = 0;
@@ -1900,8 +1876,8 @@ static int save_conference(struct zt_pvt *p)
        }
        c.chan = 0;
        c.confno = 0;
-       c.confmode = ZT_CONF_NORMAL;
-       res = ioctl(p->subs[SUB_REAL].zfd, ZT_SETCONF, &c);
+       c.confmode = DAHDI_CONF_NORMAL;
+       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCONF, &c);
        if (res) {
                ast_log(LOG_WARNING, "Unable to set conference info: %s\n", strerror(errno));
                return -1;
@@ -1960,11 +1936,11 @@ static void notify_message(char *mailbox_full, int thereornot)
        }
 }
 
-static int restore_conference(struct zt_pvt *p)
+static int restore_conference(struct dahdi_pvt *p)
 {
        int res;
        if (p->saveconf.confmode) {
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_SETCONF, &p->saveconf);
+               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCONF, &p->saveconf);
                p->saveconf.confmode = 0;
                if (res) {
                        ast_log(LOG_WARNING, "Unable to restore conference info: %s\n", strerror(errno));
@@ -1975,9 +1951,9 @@ static int restore_conference(struct zt_pvt *p)
        return 0;
 }
 
-static int send_callerid(struct zt_pvt *p);
+static int send_callerid(struct dahdi_pvt *p);
 
-static int send_cwcidspill(struct zt_pvt *p)
+static int send_cwcidspill(struct dahdi_pvt *p)
 {
        p->callwaitcas = 0;
        p->cidcwexpire = 0;
@@ -1992,7 +1968,7 @@ static int send_cwcidspill(struct zt_pvt *p)
        return 0;
 }
 
-static int has_voicemail(struct zt_pvt *p)
+static int has_voicemail(struct dahdi_pvt *p)
 {
        int new_msgs;
        struct ast_event *event;
@@ -2018,14 +1994,14 @@ static int has_voicemail(struct zt_pvt *p)
        return new_msgs;
 }
 
-static int send_callerid(struct zt_pvt *p)
+static int send_callerid(struct dahdi_pvt *p)
 {
        /* Assumes spill in p->cidspill, p->cidlen in length and we're p->cidpos into it */
        int res;
        /* Take out of linear mode if necessary */
        if (p->subs[SUB_REAL].linear) {
                p->subs[SUB_REAL].linear = 0;
-               zt_setlinear(p->subs[SUB_REAL].zfd, 0);
+               dahdi_setlinear(p->subs[SUB_REAL].zfd, 0);
        }
        while (p->cidpos < p->cidlen) {
                res = write(p->subs[SUB_REAL].zfd, p->cidspill + p->cidpos, p->cidlen - p->cidpos);
@@ -2051,9 +2027,9 @@ static int send_callerid(struct zt_pvt *p)
        return 0;
 }
 
-static int zt_callwait(struct ast_channel *ast)
+static int dahdi_callwait(struct ast_channel *ast)
 {
-       struct zt_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast->tech_pvt;
        p->callwaitingrepeat = CALLWAITING_REPEAT_SAMPLES;
        if (p->cidspill) {
                ast_log(LOG_WARNING, "Spill already exists?!?\n");
@@ -2091,9 +2067,9 @@ static unsigned char cid_pres2ss7screen(int cid_pres)
 }
 #endif
 
-static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
+static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
 {
-       struct zt_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast->tech_pvt;
        int x, res, index,mysig;
        char *c, *n, *l;
 #ifdef HAVE_PRI
@@ -2109,7 +2085,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                return 0;
        }
        if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
-               ast_log(LOG_WARNING, "zt_call called on %s, neither down nor reserved\n", ast->name);
+               ast_log(LOG_WARNING, "dahdi_call called on %s, neither down nor reserved\n", ast->name);
                ast_mutex_unlock(&p->lock);
                return -1;
        }
@@ -2121,8 +2097,8 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                ast_mutex_unlock(&p->lock);
                return 0;
        }
-       x = ZT_FLUSH_READ | ZT_FLUSH_WRITE;
-       res = ioctl(p->subs[SUB_REAL].zfd, ZT_FLUSH, &x);
+       x = DAHDI_FLUSH_READ | DAHDI_FLUSH_WRITE;
+       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_FLUSH, &x);
        if (res)
                ast_log(LOG_WARNING, "Unable to flush input on channel %d\n", p->channel);
        p->outgoing = 1;
@@ -2157,11 +2133,11 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                        }
                        /* Choose proper cadence */
                        if ((p->distinctivering > 0) && (p->distinctivering <= num_cadence)) {
-                               if (ioctl(p->subs[SUB_REAL].zfd, ZT_SETCADENCE, &cadences[p->distinctivering - 1]))
+                               if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCADENCE, &cadences[p->distinctivering - 1]))
                                        ast_log(LOG_WARNING, "Unable to set distinctive ring cadence %d on '%s'\n", p->distinctivering, ast->name);
                                p->cidrings = cidrings[p->distinctivering - 1];
                        } else {
-                               if (ioctl(p->subs[SUB_REAL].zfd, ZT_SETCADENCE, NULL))
+                               if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETCADENCE, NULL))
                                        ast_log(LOG_WARNING, "Unable to reset default ring on '%s'\n", ast->name);
                                p->cidrings = p->sendcalleridafter;
                        }
@@ -2175,14 +2151,14 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                                c = NULL;
                        }
                        if (c) {
-                               p->dop.op = ZT_DIAL_OP_REPLACE;
+                               p->dop.op = DAHDI_DIAL_OP_REPLACE;
                                snprintf(p->dop.dialstr, sizeof(p->dop.dialstr), "Tw%s", c);
                                ast_debug(1, "FXO: setup deferred dialstring: %s\n", c);
                        } else {
                                p->dop.dialstr[0] = '\0';
                        }
-                       x = ZT_RING;
-                       if (ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x) && (errno != EINPROGRESS)) {
+                       x = DAHDI_RING;
+                       if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x) && (errno != EINPROGRESS)) {
                                ast_log(LOG_WARNING, "Unable to ring phone: %s\n", strerror(errno));
                                ast_mutex_unlock(&p->lock);
                                return -1;
@@ -2200,12 +2176,12 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                        else
                                p->callwait_name[0] = '\0';
                        /* Call waiting tone instead */
-                       if (zt_callwait(ast)) {
+                       if (dahdi_callwait(ast)) {
                                ast_mutex_unlock(&p->lock);
                                return -1;
                        }
                        /* Make ring-back */
-                       if (tone_zone_play_tone(p->subs[SUB_CALLWAIT].zfd, ZT_TONE_RINGTONE))
+                       if (tone_zone_play_tone(p->subs[SUB_CALLWAIT].zfd, DAHDI_TONE_RINGTONE))
                                ast_log(LOG_WARNING, "Unable to generate call-wait ring-back on channel %s\n", ast->name);
                                
                }
@@ -2220,7 +2196,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                else
                        p->lastcid_name[0] = '\0';
                ast_setstate(ast, AST_STATE_RINGING);
-               index = zt_get_index(ast, p, 0);
+               index = dahdi_get_index(ast, p, 0);
                if (index > -1) {
                        p->subs[index].needringing = 1;
                }
@@ -2257,8 +2233,8 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                /* Start the trunk, if not GR-303 */
                if (!p->pri) {
 #endif
-                       x = ZT_START;
-                       res = ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x);
+                       x = DAHDI_START;
+                       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x);
                        if (res < 0) {
                                if (errno != EINPROGRESS) {
                                        ast_log(LOG_WARNING, "Unable to start channel: %s\n", strerror(errno));
@@ -2270,7 +2246,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                }
 #endif
                ast_debug(1, "Dialing '%s'\n", c);
-               p->dop.op = ZT_DIAL_OP_REPLACE;
+               p->dop.op = DAHDI_DIAL_OP_REPLACE;
 
                c += p->stripmsd;
 
@@ -2337,9 +2313,9 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                } else
                        p->echobreak = 0;
                if (!res) {
-                       if (ioctl(p->subs[SUB_REAL].zfd, ZT_DIAL, &p->dop)) {
-                               x = ZT_ONHOOK;
-                               ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x);
+                       if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop)) {
+                               x = DAHDI_ONHOOK;
+                               ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x);
                                ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(errno));
                                ast_mutex_unlock(&p->lock);
                                return -1;
@@ -2536,7 +2512,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                        return -1;
                }
                if (mysig != SIG_FXSKS) {
-                       p->dop.op = ZT_DIAL_OP_REPLACE;
+                       p->dop.op = DAHDI_DIAL_OP_REPLACE;
                        s = strchr(c + p->stripmsd, 'w');
                        if (s) {
                                if (strlen(s) > 1)
@@ -2561,11 +2537,8 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                }
                if (!(sr = pri_sr_new())) {
                        ast_log(LOG_WARNING, "Failed to allocate setup request channel %d\n", p->channel);
-                       pri_destroycall(p->pri->pri, p->call);
-                       p->call = NULL;
                        pri_rel(p->pri);
                        ast_mutex_unlock(&p->lock);
-                       return -1;
                }
                if (p->bearer || (mysig == SIG_FXSKS)) {
                        if (p->bearer) {
@@ -2591,7 +2564,7 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
                pri_sr_set_channel(sr, p->bearer ? PVT_TO_CHANNEL(p->bearer) : PVT_TO_CHANNEL(p), exclusive, 1);
                pri_sr_set_bearer(sr, p->digital ? PRI_TRANS_CAP_DIGITAL : ast->transfercapability, 
                                        (p->digital ? -1 : 
-                                               ((p->law == ZT_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW)));
+                                               ((p->law == DAHDI_LAW_ALAW) ? PRI_LAYER_1_ALAW : PRI_LAYER_1_ULAW)));
                if (p->pri->facilityenable)
                        pri_facility_enable(p->pri->pri);
 
@@ -2776,9 +2749,9 @@ static int zt_call(struct ast_channel *ast, char *rdest, int timeout)
        return 0;
 }
 
-static void destroy_zt_pvt(struct zt_pvt **pvt)
+static void destroy_dahdi_pvt(struct dahdi_pvt **pvt)
 {
-       struct zt_pvt *p = *pvt;
+       struct dahdi_pvt *p = *pvt;
        /* Remove channel from the list */
        if (p->prev)
                p->prev->next = p->next;
@@ -2795,7 +2768,7 @@ static void destroy_zt_pvt(struct zt_pvt **pvt)
        *pvt = NULL;
 }
 
-static int destroy_channel(struct zt_pvt *prev, struct zt_pvt *cur, int now)
+static int destroy_channel(struct dahdi_pvt *prev, struct dahdi_pvt *cur, int now)
 {
        int owned = 0;
        int i = 0;
@@ -2825,9 +2798,9 @@ static int destroy_channel(struct zt_pvt *prev, struct zt_pvt *cur, int now)
                                        ifend = NULL;
                        }
                        if (cur->subs[SUB_REAL].zfd > -1) {
-                               zt_close(cur->subs[SUB_REAL].zfd);
+                               dahdi_close(cur->subs[SUB_REAL].zfd);
                        }
-                       destroy_zt_pvt(&cur);
+                       destroy_dahdi_pvt(&cur);
                }
        } else {
                if (prev) {
@@ -2844,26 +2817,26 @@ static int destroy_channel(struct zt_pvt *prev, struct zt_pvt *cur, int now)
                                ifend = NULL;
                }
                if (cur->subs[SUB_REAL].zfd > -1) {
-                       zt_close(cur->subs[SUB_REAL].zfd);
+                       dahdi_close(cur->subs[SUB_REAL].zfd);
                }
-               destroy_zt_pvt(&cur);
+               destroy_dahdi_pvt(&cur);
        }
        return 0;
 }
 
 #ifdef HAVE_PRI
-static char *zap_send_keypad_facility_app = "ZapSendKeypadFacility";
+static char *dahdi_send_keypad_facility_app = "DAHDISendKeypadFacility";
 
-static char *zap_send_keypad_facility_synopsis = "Send digits out of band over a PRI";
+static char *dahdi_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"
+static char *dahdi_send_keypad_facility_descrip = 
+"  DAHDISendKeypadFacility(): 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)
+static int dahdi_send_keypad_facility_exec(struct ast_channel *chan, void *data)
 {
        /* Data will be our digit string */
-       struct zt_pvt *p;
+       struct dahdi_pvt *p;
        char *digits = (char *) data;
 
        if (ast_strlen_zero(digits)) {
@@ -2871,7 +2844,7 @@ static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data)
                return -1;
        }
 
-       p = (struct zt_pvt *)chan->tech_pvt;
+       p = (struct dahdi_pvt *)chan->tech_pvt;
 
        if (!p) {
                ast_debug(1, "Unable to find technology private\n");
@@ -2900,7 +2873,7 @@ static int zap_send_keypad_facility_exec(struct ast_channel *chan, void *data)
        return 0;
 }
 
-static int pri_is_up(struct zt_pri *pri)
+static int pri_is_up(struct dahdi_pri *pri)
 {
        int x;
        for (x = 0; x < NUM_DCHANS; x++) {
@@ -2910,7 +2883,7 @@ static int pri_is_up(struct zt_pri *pri)
        return 0;
 }
 
-static int pri_assign_bearer(struct zt_pvt *crv, struct zt_pri *pri, struct zt_pvt *bearer)
+static int pri_assign_bearer(struct dahdi_pvt *crv, struct dahdi_pri *pri, struct dahdi_pvt *bearer)
 {
        bearer->owner = &inuse;
        bearer->realcall = crv;
@@ -2940,7 +2913,7 @@ static char *pri_order(int level)
 }
 
 /* Returns fd of the active dchan */
-static int pri_active_dchan_fd(struct zt_pri *pri)
+static int pri_active_dchan_fd(struct dahdi_pri *pri)
 {
        int x = -1;
 
@@ -2952,7 +2925,7 @@ static int pri_active_dchan_fd(struct zt_pri *pri)
        return pri->fds[x];
 }
 
-static int pri_find_dchan(struct zt_pri *pri)
+static int pri_find_dchan(struct dahdi_pri *pri)
 {
        int oldslot = -1;
        struct pri *old;
@@ -2979,17 +2952,17 @@ static int pri_find_dchan(struct zt_pri *pri)
 }
 #endif
 
-static int zt_hangup(struct ast_channel *ast)
+static int dahdi_hangup(struct ast_channel *ast)
 {
        int res;
        int index,x, law;
-       /*static int restore_gains(struct zt_pvt *p);*/
-       struct zt_pvt *p = ast->tech_pvt;
-       struct zt_pvt *tmp = NULL;
-       struct zt_pvt *prev = NULL;
-       ZT_PARAMS par;
+       /*static int restore_gains(struct dahdi_pvt *p);*/
+       struct dahdi_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *tmp = NULL;
+       struct dahdi_pvt *prev = NULL;
+       DAHDI_PARAMS par;
 
-       ast_debug(1, "zt_hangup(%s)\n", ast->name);
+       ast_debug(1, "dahdi_hangup(%s)\n", ast->name);
        if (!ast->tech_pvt) {
                ast_log(LOG_WARNING, "Asked to hangup channel not connected\n");
                return 0;
@@ -2997,7 +2970,7 @@ static int zt_hangup(struct ast_channel *ast)
        
        ast_mutex_lock(&p->lock);
        
-       index = zt_get_index(ast, p, 1);
+       index = dahdi_get_index(ast, p, 1);
 
        if ((p->sig == SIG_PRI) || (p->sig == SIG_SS7) || (p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP)) {
                x = 1;
@@ -3005,7 +2978,7 @@ static int zt_hangup(struct ast_channel *ast)
        }
 
        x = 0;
-       zt_confmute(p, 0);
+       dahdi_confmute(p, 0);
        p->muting = 0;
        restore_gains(p);
        if (p->origcid_num) {
@@ -3038,7 +3011,7 @@ static int zt_hangup(struct ast_channel *ast)
                p->subs[index].linear = 0;
                p->subs[index].needcallerid = 0;
                p->polarity = POLARITY_IDLE;
-               zt_setlinear(p->subs[index].zfd, 0);
+               dahdi_setlinear(p->subs[index].zfd, 0);
                if (index == SUB_REAL) {
                        if ((p->subs[SUB_CALLWAIT].zfd > -1) && (p->subs[SUB_THREEWAY].zfd > -1)) {
                                ast_debug(1, "Normal call hung up with both three way call and a call waiting call in place?\n");
@@ -3150,8 +3123,8 @@ static int zt_hangup(struct ast_channel *ast)
                        p->dsp = NULL;
                }
 
-               law = ZT_LAW_DEFAULT;
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_SETLAW, &law);
+               law = DAHDI_LAW_DEFAULT;
+               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_SETLAW, &law);
                if (res < 0) 
                        ast_log(LOG_WARNING, "Unable to set law on channel %d to default\n", p->channel);
                /* Perform low level hangup if no owner left */
@@ -3233,7 +3206,7 @@ static int zt_hangup(struct ast_channel *ast)
                }
 #endif
                if (p->sig && ((p->sig != SIG_PRI) && (p->sig != SIG_SS7) && (p->sig != SIG_BRI) && (p->sig != SIG_BRI_PTMP)))
-                       res = zt_set_hook(p->subs[SUB_REAL].zfd, ZT_ONHOOK);
+                       res = dahdi_set_hook(p->subs[SUB_REAL].zfd, DAHDI_ONHOOK);
                if (res < 0) {
                        ast_log(LOG_WARNING, "Unable to hangup line %s\n", ast->name);
                }
@@ -3241,14 +3214,14 @@ static int zt_hangup(struct ast_channel *ast)
                case SIG_FXOGS:
                case SIG_FXOLS:
                case SIG_FXOKS:
-                       res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &par);
+                       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_GET_PARAMS, &par);
                        if (!res) {
 #if 0
                                ast_debug(1, "Hanging up channel %d, offhook = %d\n", p->channel, par.rxisoffhook);
 #endif
                                /* If they're off hook, try playing congestion */
                                if ((par.rxisoffhook) && (!(p->radio || (p->oprmode < 0))))
-                                       tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_CONGESTION);
+                                       tone_zone_play_tone(p->subs[SUB_REAL].zfd, DAHDI_TONE_CONGESTION);
                                else
                                        tone_zone_play_tone(p->subs[SUB_REAL].zfd, -1);
                        }
@@ -3269,7 +3242,7 @@ static int zt_hangup(struct ast_channel *ast)
                if (p->cidspill)
                        ast_free(p->cidspill);
                if (p->sig)
-                       zt_disable_ec(p);
+                       dahdi_disable_ec(p);
                x = 0;
                ast_channel_setoption(ast,AST_OPTION_TONE_VERIFY,&x,sizeof(char),0);
                ast_channel_setoption(ast,AST_OPTION_TDD,&x,sizeof(char),0);
@@ -3330,15 +3303,15 @@ static int zt_hangup(struct ast_channel *ast)
        return 0;
 }
 
-static int zt_answer(struct ast_channel *ast)
+static int dahdi_answer(struct ast_channel *ast)
 {
-       struct zt_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast->tech_pvt;
        int res = 0;
        int index;
        int oldstate = ast->_state;
        ast_setstate(ast, AST_STATE_UP);
        ast_mutex_lock(&p->lock);
-       index = zt_get_index(ast, p, 0);
+       index = dahdi_get_index(ast, p, 0);
        if (index < 0)
                index = SUB_REAL;
        /* nothing to do if a radio channel */
@@ -3375,7 +3348,7 @@ static int zt_answer(struct ast_channel *ast)
                if (p->hanguponpolarityswitch) {
                        p->polaritydelaytv = ast_tvnow();
                }
-               res = zt_set_hook(p->subs[SUB_REAL].zfd, ZT_OFFHOOK);
+               res = dahdi_set_hook(p->subs[SUB_REAL].zfd, DAHDI_OFFHOOK);
                tone_zone_play_tone(p->subs[index].zfd, -1);
                p->dialing = 0;
                if ((index == SUB_REAL) && p->subs[SUB_THREEWAY].inthreeway) {
@@ -3386,9 +3359,9 @@ static int zt_answer(struct ast_channel *ast)
                                p->owner = p->subs[SUB_REAL].owner;
                        }
                }
-               if (p->sig & __ZT_SIG_FXS) {
-                       zt_enable_ec(p);
-                       zt_train_ec(p);
+               if (p->sig & __DAHDI_SIG_FXS) {
+                       dahdi_enable_ec(p);
+                       dahdi_train_ec(p);
                }
                break;
 #ifdef HAVE_PRI
@@ -3429,13 +3402,13 @@ static int zt_answer(struct ast_channel *ast)
        return res;
 }
 
-static int zt_setoption(struct ast_channel *chan, int option, void *data, int datalen)
+static int dahdi_setoption(struct ast_channel *chan, int option, void *data, int datalen)
 {
        char *cp;
        signed char *scp;
        int x;
        int index;
-       struct zt_pvt *p = chan->tech_pvt, *pp;
+       struct dahdi_pvt *p = chan->tech_pvt, *pp;
        struct oprmode *oprmode;
        
 
@@ -3448,7 +3421,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
        switch (option) {
        case AST_OPTION_TXGAIN:
                scp = (signed char *) data;
-               index = zt_get_index(chan, p, 0);
+               index = dahdi_get_index(chan, p, 0);
                if (index < 0) {
                        ast_log(LOG_WARNING, "No index in TXGAIN?\n");
                        return -1;
@@ -3457,7 +3430,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
                return set_actual_txgain(p->subs[index].zfd, 0, p->txgain + (float) *scp, p->law);
        case AST_OPTION_RXGAIN:
                scp = (signed char *) data;
-               index = zt_get_index(chan, p, 0);
+               index = dahdi_get_index(chan, p, 0);
                if (index < 0) {
                        ast_log(LOG_WARNING, "No index in RXGAIN?\n");
                        return -1;
@@ -3496,7 +3469,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
                }
                ast_debug(1, "Set option TDD MODE, value: %s(%d) on %s\n",
                        (*cp == 2) ? "MATE" : "ON", (int) *cp, chan->name);
-               zt_disable_ec(p);
+               dahdi_disable_ec(p);
                /* otherwise, turn it on */
                if (!p->didtdd) { /* if havent done it yet */
                        unsigned char mybuf[41000], *buf;
@@ -3507,7 +3480,7 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
                        memset(buf, 0x7f, sizeof(mybuf)); /* set to silence */
                        ast_tdd_gen_ecdisa(buf + 16000, 16000);  /* put in tone */
                        len = 40000;
-                       index = zt_get_index(chan, p, 0);
+                       index = dahdi_get_index(chan, p, 0);
                        if (index < 0) {
                                ast_log(LOG_WARNING, "No index in TDD?\n");
                                return -1;
@@ -3569,12 +3542,12 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
                if (!*cp) {             
                        ast_debug(1, "Set option AUDIO MODE, value: OFF(0) on %s\n", chan->name);
                        x = 0;
-                       zt_disable_ec(p);
+                       dahdi_disable_ec(p);
                } else {                
                        ast_debug(1, "Set option AUDIO MODE, value: ON(1) on %s\n", chan->name);
                        x = 1;
                }
-               if (ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x) == -1)
+               if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_AUDIOMODE, &x) == -1)
                        ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", p->channel, x);
                break;
        case AST_OPTION_OPRMODE:  /* Operator services mode */
@@ -3597,10 +3570,10 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
                cp = (char *) data;
                if (*cp) {
                        ast_debug(1, "Enabling echo cancelation on %s\n", chan->name);
-                       zt_enable_ec(p);
+                       dahdi_enable_ec(p);
                } else {
                        ast_debug(1, "Disabling echo cancelation on %s\n", chan->name);
-                       zt_disable_ec(p);
+                       dahdi_disable_ec(p);
                }
                break;
        }
@@ -3609,9 +3582,9 @@ static int zt_setoption(struct ast_channel *chan, int option, void *data, int da
        return 0;
 }
 
-static int zt_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
+static int dahdi_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len)
 {
-       struct zt_pvt *p = chan->tech_pvt;
+       struct dahdi_pvt *p = chan->tech_pvt;
        
        if (!strcasecmp(data, "rxgain")) {
                ast_mutex_lock(&p->lock);
@@ -3628,7 +3601,7 @@ static int zt_func_read(struct ast_channel *chan, const char *function, char *da
 }
 
 
-static void zt_unlink(struct zt_pvt *slave, struct zt_pvt *master, int needlock)
+static void dahdi_unlink(struct dahdi_pvt *slave, struct dahdi_pvt *master, int needlock)
 {
        /* Unlink a specific slave or all slaves/masters from a given master */
        int x;
@@ -3684,7 +3657,7 @@ static void zt_unlink(struct zt_pvt *slave, struct zt_pvt *master, int needlock)
        }
 }
 
-static void zt_link(struct zt_pvt *slave, struct zt_pvt *master) {
+static void dahdi_link(struct dahdi_pvt *slave, struct dahdi_pvt *master) {
        int x;
        if (!slave || !master) {
                ast_log(LOG_WARNING, "Tried to link to/from NULL??\n");
@@ -3707,17 +3680,17 @@ static void zt_link(struct zt_pvt *slave, struct zt_pvt *master) {
        ast_debug(1, "Making %d slave to master %d at %d\n", slave->channel, master->channel, x);
 }
 
-static void disable_dtmf_detect(struct zt_pvt *p)
+static void disable_dtmf_detect(struct dahdi_pvt *p)
 {
-#ifdef ZT_TONEDETECT
+#ifdef DAHDI_TONEDETECT
        int val;
 #endif
 
        p->ignoredtmf = 1;
 
-#ifdef ZT_TONEDETECT
+#ifdef DAHDI_TONEDETECT
        val = 0;
-       ioctl(p->subs[SUB_REAL].zfd, ZT_TONEDETECT, &val);
+       ioctl(p->subs[SUB_REAL].zfd, DAHDI_TONEDETECT, &val);
 #endif         
        if (!p->hardwaredtmf && p->dsp) {
                p->dsp_features &= ~DSP_FEATURE_DIGIT_DETECT;
@@ -3725,9 +3698,9 @@ static void disable_dtmf_detect(struct zt_pvt *p)
        }
 }
 
-static void enable_dtmf_detect(struct zt_pvt *p)
+static void enable_dtmf_detect(struct dahdi_pvt *p)
 {
-#ifdef ZT_TONEDETECT
+#ifdef DAHDI_TONEDETECT
        int val;
 #endif
 
@@ -3736,9 +3709,9 @@ static void enable_dtmf_detect(struct zt_pvt *p)
 
        p->ignoredtmf = 0;
 
-#ifdef ZT_TONEDETECT
-       val = ZT_TONEDETECT_ON | ZT_TONEDETECT_MUTE;
-       ioctl(p->subs[SUB_REAL].zfd, ZT_TONEDETECT, &val);
+#ifdef DAHDI_TONEDETECT
+       val = DAHDI_TONEDETECT_ON | DAHDI_TONEDETECT_MUTE;
+       ioctl(p->subs[SUB_REAL].zfd, DAHDI_TONEDETECT, &val);
 #endif         
        if (!p->hardwaredtmf && p->dsp) {
                p->dsp_features |= DSP_FEATURE_DIGIT_DETECT;
@@ -3746,11 +3719,11 @@ static void enable_dtmf_detect(struct zt_pvt *p)
        }
 }
 
-static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
+static enum ast_bridge_result dahdi_bridge(struct ast_channel *c0, struct ast_channel *c1, int flags, struct ast_frame **fo, struct ast_channel **rc, int timeoutms)
 {
        struct ast_channel *who;
-       struct zt_pvt *p0, *p1, *op0, *op1;
-       struct zt_pvt *master = NULL, *slave = NULL;
+       struct dahdi_pvt *p0, *p1, *op0, *op1;
+       struct dahdi_pvt *master = NULL, *slave = NULL;
        struct ast_frame *f;
        int inconf = 0;
        int nothingok = 1;
@@ -3790,8 +3763,8 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
                return AST_BRIDGE_FAILED_NOWARN;
        }
 
-       oi0 = zt_get_index(c0, p0, 0);
-       oi1 = zt_get_index(c1, p1, 0);
+       oi0 = dahdi_get_index(c0, p0, 0);
+       oi1 = dahdi_get_index(c1, p1, 0);
        if ((oi0 < 0) || (oi1 < 0)) {
                ast_channel_unlock(c0);
                ast_channel_unlock(c1);
@@ -3883,7 +3856,7 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
                    p1->subs[SUB_REAL].inthreeway && 
                    (p1->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
                        ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c0->name, c1->name);
-                       tone_zone_play_tone(p0->subs[oi0].zfd, ZT_TONE_RINGTONE);
+                       tone_zone_play_tone(p0->subs[oi0].zfd, DAHDI_TONE_RINGTONE);
                        os1 = p1->subs[SUB_REAL].owner->_state;
                } else {
                        ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p0->channel, oi0, p1->channel, oi1);
@@ -3895,7 +3868,7 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
                    p0->subs[SUB_REAL].inthreeway && 
                    (p0->subs[SUB_REAL].owner->_state == AST_STATE_RINGING)) {
                        ast_debug(1, "Playing ringback on %s since %s is in a ringing three-way\n", c1->name, c0->name);
-                       tone_zone_play_tone(p1->subs[oi1].zfd, ZT_TONE_RINGTONE);
+                       tone_zone_play_tone(p1->subs[oi1].zfd, DAHDI_TONE_RINGTONE);
                        os0 = p0->subs[SUB_REAL].owner->_state;
                } else {
                        ast_debug(1, "Stopping tones on %d/%d talking to %d/%d\n", p1->channel, oi1, p0->channel, oi0);
@@ -3904,11 +3877,11 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
                if ((oi0 == SUB_REAL) && (oi1 == SUB_REAL)) {
                        if (!p0->echocanbridged || !p1->echocanbridged) {
                                /* Disable echo cancellation if appropriate */
-                               zt_disable_ec(p0);
-                               zt_disable_ec(p1);
+                               dahdi_disable_ec(p0);
+                               dahdi_disable_ec(p1);
                        }
                }
-               zt_link(slave, master);
+               dahdi_link(slave, master);
                master->inconference = inconf;
        } else if (!nothingok)
                ast_log(LOG_WARNING, "Can't link %d/%s with %d/%s\n", p0->channel, subnames[oi0], p1->channel, subnames[oi1]);
@@ -3926,8 +3899,8 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
 
        /* Native bridge failed */
        if ((!master || !slave) && !nothingok) {
-               zt_enable_ec(p0);
-               zt_enable_ec(p1);
+               dahdi_enable_ec(p0);
+               dahdi_enable_ec(p1);
                return AST_BRIDGE_FAILED;
        }
        
@@ -3957,9 +3930,9 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
                p1 = c1->tech_pvt;
 
                if (op0 == p0)
-                       i0 = zt_get_index(c0, p0, 1);
+                       i0 = dahdi_get_index(c0, p0, 1);
                if (op1 == p1)
-                       i1 = zt_get_index(c1, p1, 1);
+                       i1 = dahdi_get_index(c1, p1, 1);
 
                ast_channel_unlock(c0);
                ast_channel_unlock(c1);
@@ -4026,10 +3999,10 @@ static enum ast_bridge_result zt_bridge(struct ast_channel *c0, struct ast_chann
 
 return_from_bridge:
        if (op0 == p0)
-               zt_enable_ec(p0);
+               dahdi_enable_ec(p0);
 
        if (op1 == p1)
-               zt_enable_ec(p1);
+               dahdi_enable_ec(p1);
 
        if (!(flags & AST_BRIDGE_DTMF_CHANNEL_0) && (oi0 == SUB_REAL))
                enable_dtmf_detect(op0);
@@ -4037,14 +4010,14 @@ return_from_bridge:
        if (!(flags & AST_BRIDGE_DTMF_CHANNEL_1) && (oi1 == SUB_REAL))
                enable_dtmf_detect(op1);
 
-       zt_unlink(slave, master, 1);
+       dahdi_unlink(slave, master, 1);
 
        return res;
 }
 
-static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
+static int dahdi_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
 {
-       struct zt_pvt *p = newchan->tech_pvt;
+       struct dahdi_pvt *p = newchan->tech_pvt;
        int x;
        ast_mutex_lock(&p->lock);
        ast_debug(1, "New owner for channel %d is %s\n", p->channel, newchan->name);
@@ -4054,27 +4027,27 @@ static int zt_fixup(struct ast_channel *oldchan, struct ast_channel *newchan)
        for (x = 0; x < 3; x++)
                if (p->subs[x].owner == oldchan) {
                        if (!x)
-                               zt_unlink(NULL, p, 0);
+                               dahdi_unlink(NULL, p, 0);
                        p->subs[x].owner = newchan;
                }
        if (newchan->_state == AST_STATE_RINGING) 
-               zt_indicate(newchan, AST_CONTROL_RINGING, NULL, 0);
+               dahdi_indicate(newchan, AST_CONTROL_RINGING, NULL, 0);
        update_conf(p);
        ast_mutex_unlock(&p->lock);
        return 0;
 }
 
-static int zt_ring_phone(struct zt_pvt *p)
+static int dahdi_ring_phone(struct dahdi_pvt *p)
 {
        int x;
        int res;
        /* Make sure our transmit state is on hook */
        x = 0;
-       x = ZT_ONHOOK;
-       res = ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x);
+       x = DAHDI_ONHOOK;
+       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x);
        do {
-               x = ZT_RING;
-               res = ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x);
+               x = DAHDI_RING;
+               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x);
                if (res) {
                        switch (errno) {
                        case EBUSY:
@@ -4096,9 +4069,9 @@ static int zt_ring_phone(struct zt_pvt *p)
 
 static void *ss_thread(void *data);
 
-static struct ast_channel *zt_new(struct zt_pvt *, int, int, int, int, int);
+static struct ast_channel *dahdi_new(struct dahdi_pvt *, int, int, int, int, int);
 
-static int attempt_transfer(struct zt_pvt *p)
+static int attempt_transfer(struct dahdi_pvt *p)
 {
        /* In order to transfer, we need at least one of the channels to
           actually be in a call bridge.  We can't conference two applications
@@ -4112,7 +4085,7 @@ static int attempt_transfer(struct zt_pvt *p)
                        ast_indicate(ast_bridged_channel(p->subs[SUB_REAL].owner), AST_CONTROL_RINGING);
                }
                if (p->subs[SUB_THREEWAY].owner->_state == AST_STATE_RING) {
-                       tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, ZT_TONE_RINGTONE);
+                       tone_zone_play_tone(p->subs[SUB_THREEWAY].zfd, DAHDI_TONE_RINGTONE);
                }
                if (p->subs[SUB_REAL].owner->cdr) {
                        /* Move CDR from second channel to current one */
@@ -4140,7 +4113,7 @@ static int attempt_transfer(struct zt_pvt *p)
                        ast_indicate(ast_bridged_channel(p->subs[SUB_THREEWAY].owner), AST_CONTROL_RINGING);
                }
                if (p->subs[SUB_REAL].owner->_state == AST_STATE_RING) {
-                       tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
+                       tone_zone_play_tone(p->subs[SUB_REAL].zfd, DAHDI_TONE_RINGTONE);
                }
                if (p->subs[SUB_THREEWAY].owner->cdr) {
                        /* Move CDR from second channel to current one */
@@ -4174,14 +4147,14 @@ static int attempt_transfer(struct zt_pvt *p)
        return 0;
 }
 
-static int check_for_conference(struct zt_pvt *p)
+static int check_for_conference(struct dahdi_pvt *p)
 {
-       ZT_CONFINFO ci;
+       DAHDI_CONFINFO ci;
        /* Fine if we already have a master, etc */
        if (p->master || (p->confno > -1))
                return 0;
        memset(&ci, 0, sizeof(ci));
-       if (ioctl(p->subs[SUB_REAL].zfd, ZT_GETCONF, &ci)) {
+       if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_GETCONF, &ci)) {
                ast_log(LOG_WARNING, "Failed to get conference info on channel %d\n", p->channel);
                return 0;
        }
@@ -4200,35 +4173,31 @@ static int check_for_conference(struct zt_pvt *p)
  * \returns the alarms on the span to which the channel belongs, or alarms on
  *          the channel if no span alarms.
  */
-static int get_alarms(struct zt_pvt *p)
+static int get_alarms(struct dahdi_pvt *p)
 {
        int res;
-       ZT_SPANINFO zi;
-#if defined(HAVE_ZAPTEL_CHANALARMS)
-       struct zt_params params;
-#endif
+       DAHDI_SPANINFO zi;
+       struct dahdi_params params;
 
        memset(&zi, 0, sizeof(zi));
        zi.spanno = p->span;
-       if ((res = ioctl(p->subs[SUB_REAL].zfd, ZT_SPANSTAT, &zi)) >= 0) {
-               if (zi.alarms != ZT_ALARM_NONE)
+       if ((res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_SPANSTAT, &zi)) >= 0) {
+               if (zi.alarms != DAHDI_ALARM_NONE)
                        return zi.alarms;
        }
 
-#if defined(HAVE_ZAPTEL_CHANALARMS)
        /* No alarms on the span. Check for channel alarms. */
-       if ((res = ioctl(p->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &params)) >= 0)
+       if ((res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_GET_PARAMS, &params)) >= 0)
                return params.chan_alarms;
-#endif
 
        ast_log(LOG_WARNING, "Unable to determine alarm on channel %d\n", p->channel);
 
-       return ZT_ALARM_NONE;
+       return DAHDI_ALARM_NONE;
 }
 
-static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_frame **dest)
+static void dahdi_handle_dtmfup(struct ast_channel *ast, int index, struct ast_frame **dest)
 {
-       struct zt_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast->tech_pvt;
        struct ast_frame *f = *dest;
 
        ast_debug(1, "DTMF digit: %c on %s\n", f->subclass, ast->name);
@@ -4272,24 +4241,24 @@ static void zt_handle_dtmfup(struct ast_channel *ast, int index, struct ast_fram
                                ast_debug(1, "Already in a fax extension, not redirecting\n");
                } else
                        ast_debug(1, "Fax already handled\n");
-               zt_confmute(p, 0);
+               dahdi_confmute(p, 0);
                p->subs[index].f.frametype = AST_FRAME_NULL;
                p->subs[index].f.subclass = 0;
                *dest = &p->subs[index].f;
        }
 }
                        
-static struct ast_frame *zt_handle_event(struct ast_channel *ast)
+static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
 {
        int res, x;
        int index, mysig;
        char *c;
-       struct zt_pvt *p = ast->tech_pvt;
+       struct dahdi_pvt *p = ast->tech_pvt;
        pthread_t threadid;
        struct ast_channel *chan;
        struct ast_frame *f;
 
-       index = zt_get_index(ast, p, 0);
+       index = dahdi_get_index(ast, p, 0);
        mysig = p->sig;
        if (p->outsigmod > -1)
                mysig = p->outsigmod;
@@ -4299,7 +4268,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
        p->subs[index].f.samples = 0;
        p->subs[index].f.mallocd = 0;
        p->subs[index].f.offset = 0;
-       p->subs[index].f.src = "zt_handle_event";
+       p->subs[index].f.src = "dahdi_handle_event";
        p->subs[index].f.data.ptr = NULL;
        f = &p->subs[index].f;
 
@@ -4309,15 +4278,15 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                res = p->fake_event;
                p->fake_event = 0;
        } else
-               res = zt_get_event(p->subs[index].zfd);
+               res = dahdi_get_event(p->subs[index].zfd);
 
        ast_debug(1, "Got event %s(%d) on channel %d (index %d)\n", event2str(res), res, p->channel, index);
 
-       if (res & (ZT_EVENT_PULSEDIGIT | ZT_EVENT_DTMFUP)) {
-               p->pulsedial =  (res & ZT_EVENT_PULSEDIGIT) ? 1 : 0;
+       if (res & (DAHDI_EVENT_PULSEDIGIT | DAHDI_EVENT_DTMFUP)) {
+               p->pulsedial =  (res & DAHDI_EVENT_PULSEDIGIT) ? 1 : 0;
                ast_debug(1, "Detected %sdigit '%c'\n", p->pulsedial ? "pulse ": "", res & 0xff);
 #ifdef HAVE_PRI
-               if (!p->proceeding && ((p->sig == SIG_PRI) || (p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP)) && p->pri && (p->pri->overlapdial & ZAP_OVERLAPDIAL_INCOMING)) {
+               if (!p->proceeding && ((p->sig == SIG_PRI) || (p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP)) && p->pri && (p->pri->overlapdial & DAHDI_OVERLAPDIAL_INCOMING)) {
                        /* absorb event */
                } else {
 #endif
@@ -4326,47 +4295,47 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
 #ifdef HAVE_PRI
                }
 #endif
-               zt_handle_dtmfup(ast, index, &f);
+               dahdi_handle_dtmfup(ast, index, &f);
                return f;
        }
 
-       if (res & ZT_EVENT_DTMFDOWN) {
+       if (res & DAHDI_EVENT_DTMFDOWN) {
                ast_debug(1, "DTMF Down '%c'\n", res & 0xff);
                /* Mute conference */
-               zt_confmute(p, 1);
+               dahdi_confmute(p, 1);
                p->subs[index].f.frametype = AST_FRAME_DTMF_BEGIN;
                p->subs[index].f.subclass = res & 0xff;
                return &p->subs[index].f;
        }
 
        switch (res) {
-#ifdef ZT_EVENT_EC_DISABLED
-               case ZT_EVENT_EC_DISABLED:
+#ifdef DAHDI_EVENT_EC_DISABLED
+               case DAHDI_EVENT_EC_DISABLED:
                        ast_verb(3, "Channel %d echo canceler disabled due to CED detection\n", p->channel);
                        p->echocanon = 0;
                        break;
 #endif
-               case ZT_EVENT_BITSCHANGED:
+               case DAHDI_EVENT_BITSCHANGED:
                        ast_log(LOG_WARNING, "Recieved bits changed on %s signalling?\n", sig2str(p->sig));
-               case ZT_EVENT_PULSE_START:
+               case DAHDI_EVENT_PULSE_START:
                        /* Stop tone if there's a pulse start and the PBX isn't started */
                        if (!ast->pbx)
                                tone_zone_play_tone(p->subs[index].zfd, -1);
                        break;  
-               case ZT_EVENT_DIALCOMPLETE:
+               case DAHDI_EVENT_DIALCOMPLETE:
                        if (p->inalarm) break;
                        if ((p->radio || (p->oprmode < 0))) break;
-                       if (ioctl(p->subs[index].zfd,ZT_DIALING,&x) == -1) {
-                               ast_debug(1, "ZT_DIALING ioctl failed on %s\n",ast->name);
+                       if (ioctl(p->subs[index].zfd,DAHDI_DIALING,&x) == -1) {
+                               ast_debug(1, "DAHDI_DIALING ioctl failed on %s\n",ast->name);
                                return NULL;
                        }
                        if (!x) { /* if not still dialing in driver */
-                               zt_enable_ec(p);
+                               dahdi_enable_ec(p);
                                if (p->echobreak) {
-                                       zt_train_ec(p);
+                                       dahdi_train_ec(p);
                                        ast_copy_string(p->dop.dialstr, p->echorest, sizeof(p->dop.dialstr));
-                                       p->dop.op = ZT_DIAL_OP_REPLACE;
-                                       res = ioctl(p->subs[SUB_REAL].zfd, ZT_DIAL, &p->dop);
+                                       p->dop.op = DAHDI_DIAL_OP_REPLACE;
+                                       res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop);
                                        p->echobreak = 0;
                                } else {
                                        p->dialing = 0;
@@ -4401,7 +4370,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                }
                        }
                        break;
-               case ZT_EVENT_ALARM:
+               case DAHDI_EVENT_ALARM:
 #ifdef HAVE_PRI
                        if ((p->sig == SIG_PRI) || (p->sig == SIG_BRI) || (p->sig == SIG_BRI_PTMP)) {
                                if (!p->pri || !p->pri->pri || (pri_get_timer(p->pri->pri, PRI_TIMER_T309) < 0)) {
@@ -4444,7 +4413,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                        if (p->sig == SIG_SS7)
                                break;
 #endif
-               case ZT_EVENT_ONHOOK:
+               case DAHDI_EVENT_ONHOOK:
                        if (p->radio) {
                                p->subs[index].f.frametype = AST_FRAME_CONTROL;
                                p->subs[index].f.subclass = AST_CONTROL_RADIO_UNKEY;
@@ -4456,10 +4425,10 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                if ((p->sig == SIG_FXOLS) || (p->sig == SIG_FXOKS) || (p->sig == SIG_FXOGS))
                                {
                                        /* Make sure it starts ringing */
-                                       zt_set_hook(p->subs[SUB_REAL].zfd, ZT_RINGOFF);
-                                       zt_set_hook(p->subs[SUB_REAL].zfd, ZT_RING);
+                                       dahdi_set_hook(p->subs[SUB_REAL].zfd, DAHDI_RINGOFF);
+                                       dahdi_set_hook(p->subs[SUB_REAL].zfd, DAHDI_RING);
                                        save_conference(p->oprpeer);
-                                       tone_zone_play_tone(p->oprpeer->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
+                                       tone_zone_play_tone(p->oprpeer->subs[SUB_REAL].zfd, DAHDI_TONE_RINGTONE);
                                }
                                break;
                        }
@@ -4487,7 +4456,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                                /* Don't start streaming audio yet if the incoming call isn't up yet */
                                                if (p->subs[SUB_REAL].owner->_state != AST_STATE_UP)
                                                        p->dialing = 1;
-                                               zt_ring_phone(p);
+                                               dahdi_ring_phone(p);
                                        } else if (p->subs[SUB_THREEWAY].owner) {
                                                unsigned int mssinceflash;
                                                /* Here we have to retain the lock on both the main channel, the 3-way channel, and
@@ -4533,7 +4502,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                                                        swap_subs(p, SUB_THREEWAY, SUB_REAL);
                                                                        p->owner = NULL;
                                                                        /* Ring the phone */
-                                                                       zt_ring_phone(p);
+                                                                       dahdi_ring_phone(p);
                                                                } else {
                                                                        if ((res = attempt_transfer(p)) < 0) {
                                                                                p->subs[SUB_THREEWAY].owner->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -4557,7 +4526,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                                        swap_subs(p, SUB_THREEWAY, SUB_REAL);
                                                        p->owner = NULL;
                                                        /* Ring the phone */
-                                                       zt_ring_phone(p);
+                                                       dahdi_ring_phone(p);
                                                }
                                        }
                                } else {
@@ -4565,18 +4534,18 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                }
                                /* Fall through */
                        default:
-                               zt_disable_ec(p);
+                               dahdi_disable_ec(p);
                                return NULL;
                        }
                        break;
-               case ZT_EVENT_RINGOFFHOOK:
+               case DAHDI_EVENT_RINGOFFHOOK:
                        if (p->inalarm) break;
                        if (p->oprmode < 0)
                        {
                                if ((p->sig == SIG_FXOLS) || (p->sig == SIG_FXOKS) || (p->sig == SIG_FXOGS))
                                {
                                        /* Make sure it stops ringing */
-                                       zt_set_hook(p->subs[SUB_REAL].zfd, ZT_RINGOFF);
+                                       dahdi_set_hook(p->subs[SUB_REAL].zfd, DAHDI_RINGOFF);
                                        tone_zone_play_tone(p->oprpeer->subs[SUB_REAL].zfd, -1);
                                        restore_conference(p->oprpeer);
                                }
@@ -4606,9 +4575,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                        p->dop.dialstr[strlen(p->dop.dialstr)-2] = '\0';
                                } else
                                        p->echobreak = 0;
-                               if (ioctl(p->subs[SUB_REAL].zfd, ZT_DIAL, &p->dop)) {
-                                       x = ZT_ONHOOK;
-                                       ioctl(p->subs[SUB_REAL].zfd, ZT_HOOK, &x);
+                               if (ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop)) {
+                                       x = DAHDI_ONHOOK;
+                                       ioctl(p->subs[SUB_REAL].zfd, DAHDI_HOOK, &x);
                                        ast_log(LOG_WARNING, "Dialing failed on channel %d: %s\n", p->channel, strerror(errno));
                                        return NULL;
                                        }
@@ -4621,12 +4590,12 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                        case SIG_FXOKS:
                                switch (ast->_state) {
                                case AST_STATE_RINGING:
-                                       zt_enable_ec(p);
-                                       zt_train_ec(p);
+                                       dahdi_enable_ec(p);
+                                       dahdi_train_ec(p);
                                        p->subs[index].f.frametype = AST_FRAME_CONTROL;
                                        p->subs[index].f.subclass = AST_CONTROL_ANSWER;
                                        /* Make sure it stops ringing */
-                                       zt_set_hook(p->subs[index].zfd, ZT_OFFHOOK);
+                                       dahdi_set_hook(p->subs[index].zfd, DAHDI_OFFHOOK);
                                        ast_debug(1, "channel %d answered\n", p->channel);
                                        if (p->cidspill) {
                                                /* Cancel any running CallerID spill */
@@ -4641,7 +4610,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                                p->subs[index].f.subclass = 0;
                                        } else if (!ast_strlen_zero(p->dop.dialstr)) {
                                                /* nick@dccinc.com 4/3/03 - fxo should be able to do deferred dialing */
-                                               res = ioctl(p->subs[SUB_REAL].zfd, ZT_DIAL, &p->dop);
+                                               res = ioctl(p->subs[SUB_REAL].zfd, DAHDI_DIAL, &p->dop);
                                                if (res < 0) {
                                                        ast_log(LOG_WARNING, "Unable to initiate dialing on trunk channel %d\n", p->channel);
                                                        p->dop.dialstr[0] = '\0';
@@ -4666,7 +4635,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                        return &p->subs[index].f;
                                case AST_STATE_UP:
                                        /* Make sure it stops ringing */
-                                       zt_set_hook(p->subs[index].zfd, ZT_OFFHOOK);
+                                       dahdi_set_hook(p->subs[index].zfd, DAHDI_OFFHOOK);
                                        /* Okay -- probably call waiting*/
                                        if (ast_bridged_channel(p->owner))
                                                ast_queue_control(p->owner, AST_CONTROL_UNHOLD);
@@ -4675,9 +4644,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                case AST_STATE_RESERVED:
                                        /* Start up dialtone */
                                        if (has_voicemail(p))
-                                               res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_STUTTER);
+                                               res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, DAHDI_TONE_STUTTER);
                                        else
-                                               res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_DIALTONE);
+                                               res = tone_zone_play_tone(p->subs[SUB_REAL].zfd, DAHDI_TONE_DIALTONE);
                                        break;
                                default:
                                        ast_log(LOG_WARNING, "FXO phone off hook in weird state %d??\n", ast->_state);
@@ -4736,8 +4705,8 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                                ast_log(LOG_WARNING, "Don't know how to handle ring/off hook for signalling %d\n", p->sig);
                        }
                        break;
-#ifdef ZT_EVENT_RINGBEGIN
-               case ZT_EVENT_RINGBEGIN:
+#ifdef DAHDI_EVENT_RINGBEGIN
+               case DAHDI_EVENT_RINGBEGIN:
                        switch (p->sig) {
                        case SIG_FXSLS:
                        case SIG_FXSGS:
@@ -4749,7 +4718,7 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                        }
                        break;
 #endif                 
-               case ZT_EVENT_RINGEROFF:
+               case DAHDI_EVENT_RINGEROFF:
                        if (p->inalarm) break;
                        if ((p->radio || (p->oprmode < 0))) break;
                        ast->rings++;
@@ -4762,9 +4731,9 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                        p->subs[index].f.frametype = AST_FRAME_CONTROL;
                        p->subs[index].f.subclass = AST_CONTROL_RINGING;
                        break;
-               case ZT_EVENT_RINGERON:
+               case DAHDI_EVENT_RINGERON:
                        break;
-               case ZT_EVENT_NOALARM:
+               case DAHDI_EVENT_NOALARM:
                        p->inalarm = 0;
 #ifdef HAVE_PRI
                        /* Extremely unlikely but just in case */
@@ -4775,23 +4744,23 @@ static struct ast_frame *zt_handle_event(struct ast_channel *ast)
                        manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
                                                                "Channel: %d\r\n", p->channel);
                        break;
-               case ZT_EVENT_WINKFLASH:
+               case DAHDI_EVENT_WINKFLASH:
                        if (p->inalarm) break;
                        if (p->radio) break;
                        if (p->oprmode < 0) break;
                        if (p->oprmode > 1)
                        {
-                               struct zt_params par;
+                               struct dahdi_params par;
 
-                               if (ioctl(p->oprpeer->subs[SUB_REAL].zfd, ZT_GET_PARAMS, &par) != -1)
+                               if (ioctl(p->oprpeer->subs[SUB_REAL].zfd, DAHDI_GET_PARAMS, &par) != -1)
                                {
                                        if (!par.rxisoffhook)
                                        {
                                                /* Make sure it stops ringing */
-                                               zt_set_hook(p->oprpeer->subs[SUB_REAL].zfd, ZT_RINGOFF);
-                                               zt_set_hook(p->oprpeer->subs[SUB_REAL].zfd, ZT_RING);
+                                               dahdi_set_hook(p->oprpeer->subs[SUB_REAL].zfd, DAHDI_RINGOFF);
+                                               dahdi_set_hook(p->oprpeer->subs[SUB_REAL].zfd, DAHDI_RING);
                                                save_conference(p);
-                                               tone_zone_play_tone(p->subs[SUB_REAL].zfd, ZT_TONE_RINGTONE);
+                                               tone_zone_play_tone(p->subs[SUB_REAL].zfd, DAHDI_TONE_RINGTONE);
                                        }
                                }
                    &