aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile1
-rw-r--r--apps/app_dahdibarge.c85
-rw-r--r--apps/app_dahdiras.c66
-rw-r--r--apps/app_flash.c26
-rw-r--r--cdr/cdr_csv.c2
-rw-r--r--channels/chan_dahdi.c181
-rw-r--r--channels/chan_iax2.c6
-rw-r--r--contrib/utils/zones2indications.c2
-rw-r--r--doc/hardware.txt10
-rw-r--r--include/asterisk/channel.h2
-rw-r--r--include/asterisk/options.h8
-rw-r--r--main/asterisk.c26
-rw-r--r--main/channel.c5
-rw-r--r--main/file.c2
14 files changed, 271 insertions, 151 deletions
diff --git a/Makefile b/Makefile
index 1398dd5a6..b9e0d9f0e 100644
--- a/Makefile
+++ b/Makefile
@@ -607,6 +607,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 ; Channels created by chan_dahdi will be called 'DAHDI', otherwise 'Zap'" ; \
echo "" ; \
echo "; Changing the following lines may compromise your security." ; \
echo ";[files]" ; \
diff --git a/apps/app_dahdibarge.c b/apps/app_dahdibarge.c
index b807923a4..48bc0c62f 100644
--- a/apps/app_dahdibarge.c
+++ b/apps/app_dahdibarge.c
@@ -61,17 +61,23 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/dahdi_compat.h"
-static char *app = "DAHDIBarge";
-static char *deprecated_app = "ZapBarge";
+static char *dahdi_app = "DAHDIBarge";
+static char *zap_app = "ZapBarge";
-static char *synopsis = "Barge in (monitor) Zap channel";
+static char *dahdi_synopsis = "Barge in (monitor) DAHDI channel";
+static char *zap_synopsis = "Barge in (monitor) Zap channel";
-static char *descrip =
-" ZapBarge([channel]): Barges in on a specified zap\n"
+static char *dahdi_descrip =
+" 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.";
+static char *zap_descrip =
+" ZapBarge([channel]): Barges in on a specified Zaptel\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.";
#define CONF_SIZE 160
@@ -125,11 +131,15 @@ static int conf_run(struct ast_channel *chan, int confno, int confflags)
goto outrun;
}
ast_indicate(chan, -1);
- retryzap = strcasecmp(chan->tech->type, "Zap");
+ retryzap = strcasecmp(chan->tech->type, dahdi_chan_name);
zapretry:
origfd = chan->fds[0];
if (retryzap) {
+#ifdef HAVE_ZAPTEL
fd = open("/dev/zap/pseudo", O_RDWR);
+#else
+ fd = open("/dev/dahdi/pseudo", O_RDWR);
+#endif
if (fd < 0) {
ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno));
goto outrun;
@@ -174,7 +184,7 @@ zapretry:
if (ztc.confmode) {
/* Whoa, already in a conference... Retry... */
if (!retryzap) {
- ast_log(LOG_DEBUG, "Zap channel is in a conference already, retrying with pseudo\n");
+ ast_log(LOG_DEBUG, "Channel is in a conference already, retrying with pseudo\n");
retryzap = 1;
goto zapretry;
}
@@ -190,7 +200,7 @@ zapretry:
close(fd);
goto outrun;
}
- ast_log(LOG_DEBUG, "Placed channel %s in ZAP channel %d monitor\n", chan->name, confno);
+ ast_log(LOG_DEBUG, "Placed channel %s in channel %d monitor\n", chan->name, confno);
for(;;) {
outfd = -1;
@@ -259,7 +269,7 @@ outrun:
return ret;
}
-static int conf_exec(struct ast_channel *chan, void *data)
+static int exec(struct ast_channel *chan, void *data, int dahdimode)
{
int res=-1;
struct ast_module_user *u;
@@ -271,11 +281,20 @@ static int conf_exec(struct ast_channel *chan, void *data)
u = ast_module_user_add(chan);
if (!ast_strlen_zero(data)) {
- if ((sscanf(data, "Zap/%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_module_user_remove(u);
- return 0;
+ if (dahdimode) {
+ if ((sscanf(data, "DAHDI/%d", &confno) != 1) &&
+ (sscanf(data, "%d", &confno) != 1)) {
+ ast_log(LOG_WARNING, "Argument (if specified) must be a channel number, not '%s'\n", (char *) data);
+ ast_module_user_remove(u);
+ return 0;
+ }
+ } else {
+ if ((sscanf(data, "Zap/%d", &confno) != 1) &&
+ (sscanf(data, "%d", &confno) != 1)) {
+ ast_log(LOG_WARNING, "Argument (if specified) must be a channel number, not '%s'\n", (char *) data);
+ ast_module_user_remove(u);
+ return 0;
+ }
}
}
@@ -301,28 +320,44 @@ out:
return res;
}
-static int conf_exec_warn(struct ast_channel *chan, void *data)
+static int exec_zap(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);
+ ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", zap_app, dahdi_app);
+
+ return exec(chan, data, 0);
}
+static int exec_dahdi(struct ast_channel *chan, void *data)
+{
+ return exec(chan, data, 1);
+}
-static int unload_module(void)
+static int unload_module(void)
{
- int res;
-
- res = ast_unregister_application(app);
+ int res = 0;
+
+ if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ res |= ast_unregister_application(dahdi_app);
+ }
+
+ res |= ast_unregister_application(zap_app);
ast_module_user_hangup_all();
- return res;
+ return res;
}
static int load_module(void)
{
- ast_register_application(deprecated_app, conf_exec_warn, synopsis, descrip);
- return ast_register_application(app, conf_exec, synopsis, descrip);
+ int res = 0;
+
+ if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ res |= ast_register_application(dahdi_app, exec_dahdi, dahdi_synopsis, dahdi_descrip);
+ }
+
+ res |= ast_register_application(zap_app, exec_zap, zap_synopsis, zap_descrip);
+
+ return res;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on Zap channel application");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on channel application");
diff --git a/apps/app_dahdiras.c b/apps/app_dahdiras.c
index 3f9b68935..2a9875ed3 100644
--- a/apps/app_dahdiras.c
+++ b/apps/app_dahdiras.c
@@ -59,19 +59,26 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/dahdi_compat.h"
-static char *app = "DAHDIRAS";
-static char *deprecated_app = "ZapRAS";
+static char *dahdi_app = "DAHDIRAS";
+static char *zap_app = "ZapRAS";
-static char *synopsis = "Executes Zaptel ISDN RAS application";
+static char *dahdi_synopsis = "Executes DAHDI ISDN RAS application";
+static char *zap_synopsis = "Executes Zaptel ISDN RAS application";
-static char *descrip =
+static char *dahdi_descrip =
+" 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 have the DAHDI plugin available. Arguments should be\n"
+"separated by | characters.\n";
+
+static char *zap_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"
-"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"
+"channel to be able to use this function (no modem emulation is included).\n"
+"Your pppd must have the Zaptel plugin available. Arguments should be\n"
"separated by | characters.\n";
-
#define PPP_MAX_ARGS 32
#define PPP_EXEC "/usr/sbin/pppd"
@@ -117,7 +124,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";
@@ -130,7 +137,11 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
}
argv[argc++] = "plugin";
+#ifdef HAVE_ZAPTEL
argv[argc++] = "zaptel.so";
+#else
+ argv[argc++] = "dahdi.so";
+#endif
argv[argc++] = "stdin";
/* Finally launch PPP */
@@ -198,7 +209,7 @@ static void run_ras(struct ast_channel *chan, char *args)
}
}
-static int zapras_exec(struct ast_channel *chan, void *data)
+static int exec(struct ast_channel *chan, void *data)
{
int res=-1;
char *args;
@@ -215,16 +226,14 @@ 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
- seconds and then hangup... */
+ if (strcasecmp(chan->tech->type, dahdi_chan_name)) {
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Channel %s is not a Zap channel\n", chan->name);
+ ast_verbose(VERBOSE_PREFIX_2 "Channel %s is not a %s channel\n", chan->name, dahdi_chan_name);
sleep(2);
} else {
memset(&ztp, 0, sizeof(ztp));
if (ioctl(chan->fds[0], DAHDI_GET_PARAMS, &ztp)) {
- ast_log(LOG_WARNING, "Unable to get zaptel parameters\n");
+ ast_log(LOG_WARNING, "Unable to get parameters\n");
} else if (ztp.sigtype != DAHDI_SIG_CLEAR) {
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Channel %s is not a clear channel\n", chan->name);
@@ -240,18 +249,22 @@ static int zapras_exec(struct ast_channel *chan, void *data)
return res;
}
-static int zapras_exec_warn(struct ast_channel *chan, void *data)
+static int 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 zapras_exec(chan, data);
-}
+ ast_log(LOG_WARNING, "Use of the command %s is deprecated, please use %s instead.\n", zap_app, dahdi_app);
+ return exec(chan, data);
+}
static int unload_module(void)
{
- int res;
+ int res = 0;
- res = ast_unregister_application(app);
+ if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ res |= ast_unregister_application(dahdi_app);
+ }
+
+ res |= ast_unregister_application(zap_app);
ast_module_user_hangup_all();
@@ -260,9 +273,16 @@ static int unload_module(void)
static int load_module(void)
{
- ast_register_application(deprecated_app, zapras_exec_warn, synopsis, descrip);
- return ast_register_application(app, zapras_exec, synopsis, descrip);
+ int res = 0;
+
+ if (dahdi_chan_mode == DAHDI_PLUS_ZAP) {
+ res |= ast_register_application(dahdi_app, exec, dahdi_synopsis, dahdi_descrip);
+ }
+
+ res |= ast_register_application(zap_app, exec_warn, zap_synopsis, zap_descrip);
+
+ return res;
}
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Zap RAS Application");
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "DAHDI RAS Application");
diff --git a/apps/app_flash.c b/apps/app_flash.c
index 05a372f9e..98ea17d03 100644
--- a/apps/app_flash.c
+++ b/apps/app_flash.c
@@ -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>
*
@@ -53,14 +53,21 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
static char *app = "Flash";
-static char *synopsis = "Flashes a Zap Trunk";
+static char *dahdi_synopsis = "Flashes a DAHDI trunk";
-static char *descrip =
-"Performs a flash on a zap trunk. This can be used\n"
+static char *dahdi_descrip =
+"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 char *zap_synopsis = "Flashes a Zap trunk";
+
+static char *zap_descrip =
+"Performs a flash on a Zap 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)
{
@@ -79,7 +86,7 @@ static int flash_exec(struct ast_channel *chan, void *data)
struct ast_module_user *u;
DAHDI_PARAMS ztp;
u = ast_module_user_add(chan);
- if (!strcasecmp(chan->tech->type, "Zap")) {
+ if (!strcasecmp(chan->tech->type, dahdi_chan_name)) {
memset(&ztp, 0, sizeof(ztp));
res = ioctl(chan->fds[0], DAHDI_GET_PARAMS, &ztp);
if (!res) {
@@ -101,7 +108,7 @@ static int flash_exec(struct ast_channel *chan, void *data)
} else
ast_log(LOG_WARNING, "Unable to get parameters of %s: %s\n", chan->name, strerror(errno));
} else
- ast_log(LOG_WARNING, "%s is not a Zap channel\n", chan->name);
+ ast_log(LOG_WARNING, "%s is not a DAHDI channel\n", chan->name);
ast_module_user_remove(u);
return res;
}
@@ -119,8 +126,11 @@ static int unload_module(void)
static int load_module(void)
{
- return ast_register_application(app, flash_exec, synopsis, descrip);
+ if (dahdi_chan_mode == ZAP_ONLY_MODE) {
+ return ast_register_application(app, flash_exec, zap_synopsis, zap_descrip);
+ } else {
+ return ast_register_application(app, flash_exec, dahdi_synopsis, dahdi_descrip);
+ }
}
AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Flash channel application");
-
diff --git a/cdr/cdr_csv.c b/cdr/cdr_csv.c
index 527646e29..cdaef6853 100644
--- a/cdr/cdr_csv.c
+++ b/cdr/cdr_csv.c
@@ -69,7 +69,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 chan_dahdi.conf
"source",
"destination",
"destination context",
diff --git a/channels/chan_dahdi.c b/channels/chan_dahdi.c
index f74cd3169..73d528c2a 100644
--- a/channels/chan_dahdi.c
+++ b/channels/chan_dahdi.c
@@ -116,10 +116,6 @@ static struct ast_jb_conf default_jbconf =
};
static struct ast_jb_conf global_jbconf;
-#if !defined(DAHDI_SIG_EM_E1) || (defined(HAVE_PRI) && !defined(DAHDI_SIG_HARDHDLC))
-#error "Your DAHDI is too old. Please update"
-#endif
-
#ifndef DAHDI_TONEDETECT
/* Work around older code with no tone detect */
#define DAHDI_EVENT_DTMFDOWN 0
@@ -707,6 +703,29 @@ static const struct ast_channel_tech dahdi_tech = {
.func_channel_read = dahdi_func_read,
};
+static const struct ast_channel_tech zap_tech = {
+ .type = "Zap",
+ .description = tdesc,
+ .capabilities = AST_FORMAT_SLINEAR | AST_FORMAT_ULAW | AST_FORMAT_ALAW,
+ .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,
+};
+
+static const struct ast_channel_tech *chan_tech;
+
#ifdef HAVE_PRI
#define GET_CHANNEL(p) ((p)->bearer ? (p)->bearer->channel : p->channel)
#else
@@ -3813,7 +3832,7 @@ static struct ast_frame *dahdi_handle_event(struct ast_channel *ast)
do {
const char *alarm_str = alarm2str(res);
- /* hack alert! DAHDI 1.4 now exposes FXO battery as an alarm, but asterisk 1.4
+ /* hack alert! Zaptel 1.4 and DAHDI expose FXO battery as an alarm, but Asterisk 1.4
* doesn't know what to do with it. Don't confuse users with log messages. */
if (!strcasecmp(alarm_str, "No Alarm") || !strcasecmp(alarm_str, "Unknown Alarm")) {
p->unknown_alarm = 1;
@@ -5212,6 +5231,8 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
int features;
char *b2 = NULL;
DAHDI_PARAMS ps;
+ char chanprefix[strlen(dahdi_chan_name) + 4];
+
if (i->subs[index].owner) {
ast_log(LOG_WARNING, "Channel %d already has a %s call\n", i->channel,subnames[index]);
return NULL;
@@ -5235,12 +5256,14 @@ static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpb
}
y++;
} while (x < 3);
- tmp = ast_channel_alloc(0, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "DAHDI/%s", b2);
+ strcpy(chanprefix, dahdi_chan_name);
+ strcat(chanprefix, "/%s");
+ tmp = ast_channel_alloc(0, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, chanprefix, b2);
if (b2) /*!> b2 can be freed now, it's been copied into the channel structure */
free(b2);
if (!tmp)
return NULL;
- tmp->tech = &dahdi_tech;
+ tmp->tech = chan_tech;
ps.channo = i->channel;
res = ioctl(i->subs[SUB_REAL].dfd, DAHDI_GET_PARAMS, &ps);
if (res) {
@@ -5950,8 +5973,8 @@ static void *ss_thread(void *data)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Enabled DND on channel %d\n", p->channel);
manager_event(EVENT_FLAG_SYSTEM, "DNDState",
- "Channel: DAHDI/%d\r\n"
- "Status: enabled\r\n", p->channel);
+ "Channel: %s/%d\r\n"
+ "Status: enabled\r\n", dahdi_chan_name, p->channel);
res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL);
p->dnd = 1;
getforward = 0;
@@ -5962,8 +5985,8 @@ static void *ss_thread(void *data)
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Disabled DND on channel %d\n", p->channel);
manager_event(EVENT_FLAG_SYSTEM, "DNDState",
- "Channel: DAHDI/%d\r\n"
- "Status: disabled\r\n", p->channel);
+ "Channel: %s/%d\r\n"
+ "Status: disabled\r\n", dahdi_chan_name, p->channel);
res = tone_zone_play_tone(p->subs[index].dfd, DAHDI_TONE_DIALRECALL);
p->dnd = 0;
getforward = 0;
@@ -6028,8 +6051,8 @@ static void *ss_thread(void *data)
if (nbridge && ast_bridged_channel(nbridge))
pbridge = ast_bridged_channel(nbridge)->tech_pvt;
if (nbridge && pbridge &&
- (nbridge->tech == &dahdi_tech) &&
- (ast_bridged_channel(nbridge)->tech == &dahdi_tech) &&
+ (nbridge->tech == chan_tech) &&
+ (ast_bridged_channel(nbridge)->tech == chan_tech) &&
ISTRUNK(pbridge)) {
int func = DAHDI_FLASH;
/* Clear out the dial buffer */
@@ -6704,7 +6727,7 @@ static int handle_init_event(struct dahdi_pvt *i, int event)
if (!i->unknown_alarm) {
ast_log(LOG_NOTICE, "Alarm cleared on channel %d\n", i->channel);
manager_event(EVENT_FLAG_SYSTEM, "AlarmClear",
- "Channel: %d\r\n", i->channel);
+ "Channel: %d\r\n", i->channel);
} else {
i->unknown_alarm = 0;
}
@@ -8105,15 +8128,13 @@ static int pri_fixup_principle(struct dahdi_pri *pri, int principle, q931_call *
new->owner = old->owner;
old->owner = NULL;
if (new->owner) {
- ast_string_field_build(new->owner, name,
- "DAHDI/%d:%d-%d", pri->trunkgroup,
- new->channel, 1);
+ ast_string_field_build(new->owner, name, "%s/%d:%d-%d", dahdi_chan_name, pri->trunkgroup, new->channel, 1);
new->owner->tech_pvt = new;
new->owner->fds[0] = new->subs[SUB_REAL].dfd;
new->subs[SUB_REAL].owner = old->subs[SUB_REAL].owner;
old->subs[SUB_REAL].owner = NULL;
} else
- ast_log(LOG_WARNING, "Whoa, there's no owner, and we're having to fix up channel %d to channel %d\n", old->channel, new->channel);
+ ast_log(LOG_WARNING, "Whoa, there's no owner, and we're having to fix up channel %d to channel %d\n", old->channel, new->channel);
new->call = old->call;
old->call = NULL;
@@ -8471,7 +8492,7 @@ static void *pri_dchannel(void *vpri)
if (ast_tvdiff_ms(ast_tvnow(), lastidle) > 1000) {
/* Don't create a new idle call more than once per second */
snprintf(idlen, sizeof(idlen), "%d/%s", pri->pvts[nextidle]->channel, pri->idledial);
- idle = dahdi_request("DAHDI", AST_FORMAT_ULAW, idlen, &cause);
+ idle = dahdi_request(dahdi_chan_name, AST_FORMAT_ULAW, idlen, &cause);
if (idle) {
pri->pvts[nextidle]->isidlecall = 1;
if (ast_pthread_create_background(&p, NULL, do_idle_thread, idle)) {
@@ -9894,6 +9915,13 @@ static struct ast_cli_entry dahdi_pri_cli[] = {
#endif /* HAVE_PRI */
+/* Wrappers for astman operations to use proper channel name prefix */
+
+#define local_astman_ack(s, m, msg) do { if (chan_tech == &dahdi_tech) astman_send_ack(s, m, "DAHDI" msg); else astman_send_ack(s, m, "Zap" msg); } while (0)
+#define local_astman_header(m, hdr) astman_get_header(m, (chan_tech == &dahdi_tech) ? "DAHDI" hdr : "Zap" hdr)
+#define local_astman_register(a, b, c, d) do { if (chan_tech == &dahdi_tech) ast_manager_register("DAHDI" a, b, c, d); else ast_manager_register("Zap" a, b, c, d); } while (0)
+#define local_astman_unregister(a) do { if (chan_tech == &dahdi_tech) ast_manager_unregister("DAHDI" a); else ast_manager_unregister("Zap" a); } while (0)
+
static int dahdi_destroy_channel(int fd, int argc, char **argv)
{
int channel;
@@ -9910,17 +9938,17 @@ static int setup_dahdi(int reload);
static int dahdi_restart(void)
{
if (option_verbose > 0)
- ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading DAHDI configuration.\n");
+ ast_verbose(VERBOSE_PREFIX_1 "Destroying channels and reloading %s configuration.\n", dahdi_chan_name);
while (iflist) {
if (option_debug)
- ast_log(LOG_DEBUG, "Destroying DAHDI channel no. %d\n", iflist->channel);
+ ast_log(LOG_DEBUG, "Destroying %s channel no. %d\n", dahdi_chan_name, iflist->channel);
/* Also updates iflist: */
destroy_channel(NULL, iflist, 1);
}
if (option_debug)
ast_log(LOG_DEBUG, "Channels destroyed. Now re-reading config.\n");
if (setup_dahdi(0) != 0) {
- ast_log(LOG_WARNING, "Reload channels from dahdi config failed!\n");
+ ast_log(LOG_WARNING, "Reload channels from %s config failed!\n", dahdi_chan_name);
return 1;
}
return 0;
@@ -9940,10 +9968,10 @@ static int dahdi_restart_cmd(int fd, int argc, char **argv)
static int action_dahdirestart(struct mansession *s, const struct message *m)
{
if (dahdi_restart() != 0) {
- astman_send_error(s, m, "Failed rereading DAHDI configuration");
+ astman_send_error(s, m, "Failed to restart chan_dahdi");
return 1;
}
- astman_send_ack(s, m, "DAHDIRestart: Success");
+ local_astman_ack(s, m, "Restart: Success");
return 0;
}
@@ -10181,15 +10209,18 @@ static int dahdi_show_status(int fd, int argc, char *argv[]) {
DAHDI_SPANINFO s;
#ifdef HAVE_ZAPTEL
- ctl = open("/dev/zap/ctl", O_RDWR);
+ if ((ctl = open("/dev/zap/ctl", O_RDWR)) < 0) {
+ ast_log(LOG_WARNING, "Unable to open /dev/zap/ctl: %s\n", strerror(errno));
+ ast_cli(fd, "No Zaptel interface found.\n");
+ return RESULT_FAILURE;
+ }
#else
- ctl = open("/dev/dahdi/ctl", O_RDWR);
-#endif
- if (ctl < 0) {
+ if ((ctl = open("/dev/dahdi/ctl", O_RDWR)) < 0) {
ast_log(LOG_WARNING, "Unable to open /dev/dahdi/ctl: %s\n", strerror(errno));
ast_cli(fd, "No DAHDI interface found.\n");
return RESULT_FAILURE;
}
+#endif
ast_cli(fd, FORMAT2, "Description", "Alarms", "IRQ", "bpviol", "CRC4");
for (span = 1; span < DAHDI_MAX_SPANS; ++span) {
@@ -10347,7 +10378,7 @@ static struct dahdi_pvt *find_channel(int channel)
static int action_dahdidndon(struct mansession *s, const struct message *m)
{
struct dahdi_pvt *p = NULL;
- const char *channel = astman_get_header(m, "DAHDIChannel");
+ const char *channel = local_astman_header(m, "Channel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
@@ -10366,7 +10397,7 @@ static int action_dahdidndon(struct mansession *s, const struct message *m)
static int action_dahdidndoff(struct mansession *s, const struct message *m)
{
struct dahdi_pvt *p = NULL;
- const char *channel = astman_get_header(m, "DAHDIChannel");
+ const char *channel = local_astman_header(m, "Channel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
@@ -10385,7 +10416,7 @@ static int action_dahdidndoff(struct mansession *s, const struct message *m)
static int action_transfer(struct mansession *s, const struct message *m)
{
struct dahdi_pvt *p = NULL;
- const char *channel = astman_get_header(m, "DAHDIChannel");
+ const char *channel = local_astman_header(m, "Channel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
@@ -10397,14 +10428,14 @@ static int action_transfer(struct mansession *s, const struct message *m)
return 0;
}
dahdi_fake_event(p,TRANSFER);
- astman_send_ack(s, m, "DAHDITransfer");
+ local_astman_ack(s, m, "Transfer");
return 0;
}
static int action_transferhangup(struct mansession *s, const struct message *m)
{
struct dahdi_pvt *p = NULL;
- const char *channel = astman_get_header(m, "DAHDIChannel");
+ const char *channel = local_astman_header(m, "Channel");
if (ast_strlen_zero(channel)) {
astman_send_error(s, m, "No channel specified");
@@ -10416,14 +10447,14 @@ static int action_transferhangup(struct mansession *s, const struct message *m)
return 0;
}
dahdi_fake_event(p,HANGUP);
- astman_send_ack(s, m, "DAHDIHangup");
+ local_astman_ack(s, m, "Hangup");
return 0;
}
static int action_dahdidialoffhook(struct mansession *s, const struct message *m)
{
struct dahdi_pvt *p = NULL;
- const char *channel = astman_get_header(m, "DAHDIChannel");
+ const char *channel = local_astman_header(m, "Channel");
const char *number = astman_get_header(m, "Number");
int i;
@@ -10448,7 +10479,7 @@ static int action_dahdidialoffhook(struct mansession *s, const struct message *m
struct ast_frame f = { AST_FRAME_DTMF, number[i] };
dahdi_queue_frame(p, &f, NULL);
}
- astman_send_ack(s, m, "DAHDIDialOffhook");
+ local_astman_ack(s, m, "DialOffhook");
return 0;
}
@@ -10458,7 +10489,7 @@ static int action_dahdishowchannels(struct mansession *s, const struct message *
const char *id = astman_get_header(m, "ActionID");
char idText[256] = "";
- astman_send_ack(s, m, "DAHDI channel status will follow");
+ local_astman_ack(s, m, " channel status will follow");
if (!ast_strlen_zero(id))
snprintf(idText, sizeof(idText) - 1, "ActionID: %s\r\n", id);
@@ -10469,17 +10500,18 @@ static int action_dahdishowchannels(struct mansession *s, const struct message *
if (tmp->channel > 0) {
int alarm = get_alarms(tmp);
astman_append(s,
- "Event: DAHDIShowChannels\r\n"
- "Channel: %d\r\n"
- "Signalling: %s\r\n"
- "Context: %s\r\n"
- "DND: %s\r\n"
- "Alarm: %s\r\n"
- "%s"
- "\r\n",
- tmp->channel, sig2str(tmp->sig), tmp->context,
- tmp->dnd ? "Enabled" : "Disabled",
- alarm2str(alarm), idText);
+ "Event: %sShowChannels\r\n"
+ "Channel: %d\r\n"
+ "Signalling: %s\r\n"
+ "Context: %s\r\n"
+ "DND: %s\r\n"
+ "Alarm: %s\r\n"
+ "%s"
+ "\r\n",
+ dahdi_chan_name,
+ tmp->channel, sig2str(tmp->sig), tmp->context,
+ tmp->dnd ? "Enabled" : "Disabled",
+ alarm2str(alarm), idText);
}
tmp = tmp->next;
@@ -10488,10 +10520,11 @@ static int action_dahdishowchannels(struct mansession *s, const struct message *
ast_mutex_unlock(&iflock);
astman_append(s,
- "Event: DAHDIShowChannelsComplete\r\n"
- "%s"
- "\r\n",
- idText);
+ "Event: %sShowChannelsComplete\r\n"
+ "%s"
+ "\r\n",
+ dahdi_chan_name,
+ idText);
return 0;
}
@@ -10510,14 +10543,14 @@ static int __unload_module(void)
ast_unregister_application(dahdi_send_keypad_facility_app);
#endif
ast_cli_unregister_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
- ast_manager_unregister( "DAHDIDialOffhook" );
- ast_manager_unregister( "DAHDIHangup" );
- ast_manager_unregister( "DAHDITransfer" );
- ast_manager_unregister( "DAHDIDNDoff" );
- ast_manager_unregister( "DAHDIDNDon" );
- ast_manager_unregister("DAHDIShowChannels");
- ast_manager_unregister("DAHDIRestart");
- ast_channel_unregister(&dahdi_tech);
+ local_astman_unregister("DialOffhook");
+ local_astman_unregister("Hangup");
+ local_astman_unregister("Transfer");
+ local_astman_unregister("DNDoff");
+ local_astman_unregister("DNDon");
+ local_astman_unregister("ShowChannels");
+ local_astman_unregister("Restart");
+ ast_channel_unregister(chan_tech);
ast_mutex_lock(&iflock);
/* Hangup all interfaces if they have an owner */
p = iflist;
@@ -11506,12 +11539,16 @@ static int load_module(void)
ast_register_application(dahdi_send_keypad_facility_app, dahdi_send_keypad_facility_exec,
dahdi_send_keypad_facility_synopsis, dahdi_send_keypad_facility_descrip);
#endif
- res = setup_dahdi(0);
- /* Make sure we can register our DAHDI channel type */
- if (res)
+ if ((res = setup_dahdi(0))) {
return AST_MODULE_LOAD_DECLINE;
- if (ast_channel_register(&dahdi_tech)) {
- ast_log(LOG_ERROR, "Unable to register channel class 'DAHDI'\n");
+ }
+ if (!strcmp(dahdi_chan_name, "DAHDI")) {
+ chan_tech = &dahdi_tech;
+ } else {
+ chan_tech = &zap_tech;
+ }
+ if (ast_channel_register(chan_tech)) {
+ ast_log(LOG_ERROR, "Unable to register channel class '%s'\n", chan_tech->type);
__unload_module();
return -1;
}
@@ -11523,13 +11560,13 @@ static int load_module(void)
ast_cli_register_multiple(dahdi_cli, sizeof(dahdi_cli) / sizeof(struct ast_cli_entry));
memset(round_robin, 0, sizeof(round_robin));
- ast_manager_register("DAHDITransfer", 0, action_transfer, "Transfer DAHDI Channel" );
- ast_manager_register("DAHDIHangup", 0, action_transferhangup, "Hangup DAHDI Channel" );
- ast_manager_register("DAHDIDialOffhook", 0, action_dahdidialoffhook, "Dial over DAHDI channel while offhook" );
- ast_manager_register("DAHDIDNDon", 0, action_dahdidndon, "Toggle DAHDI channel Do Not Disturb status ON" );
- ast_manager_register("DAHDIDNDoff", 0, action_dahdidndoff, "Toggle DAHDI channel Do Not Disturb status OFF" );
- ast_manager_register("DAHDIShowChannels", 0, action_dahdishowchannels, "Show status DAHDI channels");
- ast_manager_register("DAHDIRestart", 0, action_dahdirestart, "Fully Restart DAHDI channels (terminates calls)");
+ local_astman_register("Transfer", 0, action_transfer, "Transfer Channel");
+ local_astman_register("Hangup", 0, action_transferhangup, "Hangup Channel");
+ local_astman_register("DialOffhook", 0, action_dahdidialoffhook, "Dial over channel while offhook");
+ local_astman_register("DNDon", 0, action_dahdidndon, "Toggle channel Do Not Disturb status ON");
+ local_astman_register("DNDoff", 0, action_dahdidndoff, "Toggle channel Do Not Disturb status OFF");
+ local_astman_register("ShowChannels", 0, action_dahdishowchannels, "Show status channels");
+ local_astman_register("Restart", 0, action_dahdirestart, "Fully Restart channels (terminates calls)");
return res;
}
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index a6f8e9824..eaa64e419 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -6580,7 +6580,7 @@ static int timing_read(int *id, int fd, short events, void *cbdata)
#ifdef DAHDI_TIMERACK
/* Great, this is a timing interface, just call the ioctl */
if (ioctl(fd, DAHDI_TIMERACK, &x)) {
- ast_log(LOG_WARNING, "Unable to acknowledge zap timer. IAX trunking will fail!\n");
+ ast_log(LOG_WARNING, "Unable to acknowledge timer. IAX trunking will fail!\n");
usleep(1);
return -1;
}
@@ -9408,7 +9408,7 @@ static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, st
} else if (!strcasecmp(v->name, "trunk")) {
ast_set2_flag(peer, ast_true(v->value), IAX_TRUNK);
if (ast_test_flag(peer, IAX_TRUNK) && (timingfd < 0)) {
- ast_log(LOG_WARNING, "Unable to support trunking on peer '%s' without zaptel timing\n", peer->name);
+ ast_log(LOG_WARNING, "Unable to support trunking on peer '%s' without timing\n", peer->name);
ast_clear_flag(peer, IAX_TRUNK);
}
} else if (!strcasecmp(v->name, "auth")) {
@@ -9666,7 +9666,7 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v, st
} else if (!strcasecmp(v->name, "trunk")) {
ast_set2_flag(user, ast_true(v->value), IAX_TRUNK);
if (ast_test_flag(user, IAX_TRUNK) && (timingfd < 0)) {
- ast_log(LOG_WARNING, "Unable to support trunking on user '%s' without zaptel timing\n", user->name);
+ ast_log(LOG_WARNING, "Unable to support trunking on user '%s' without timing\n", user->name);
ast_clear_flag(user, IAX_TRUNK);
}
} else if (!strcasecmp(v->name, "auth")) {
diff --git a/contrib/utils/zones2indications.c b/contrib/utils/zones2indications.c
index 6a3156751..c5a1e4317 100644
--- a/contrib/utils/zones2indications.c
+++ b/contrib/utils/zones2indications.c
@@ -22,7 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
-#include <zaptel/tonezone.h>
+#include <dahdi/tonezone.h>
#include <unistd.h>
#define PROGRAM "zones2indication"
diff --git a/doc/hardware.txt b/doc/hardware.txt
index 01f8f7f06..9e4e96e91 100644
--- a/doc/hardware.txt
+++ b/doc/hardware.txt
@@ -2,12 +2,12 @@ A PBX is only really useful if you can get calls into it. Of course, you
can use Asterisk with VoIP calls (SIP, H.323, IAX), but you can also talk
to the real PSTN through various cards.
-Supported Hardware is divided into two general groups: Zaptel devices and
-non-zaptel devices. The Zaptel compatible hardware supports pseudo-TDM
-conferencing and all call features through chan_zap, whereas non-zaptel
+Supported Hardware is divided into two general groups: DAHDI devices and
+non-DAHDI devices. The DAHDI compatible hardware supports pseudo-TDM
+conferencing and all call features through chan_dahdi, whereas non-DAHDI
compatible hardware may have different features.
-Zaptel compatible hardware
+DAHDI compatible hardware
==========================
-- Digium (Primary author of Asterisk)
@@ -31,7 +31,7 @@ Zaptel compatible hardware
* Wildcard TE410P - Quad T1/E1 switchable interface. Supports PRI and
RBS signalling, as well as PPP, FR, and HDLC data modes.
-Non-zaptel compatible hardware
+Non-DAHDI compatible hardware
==============================
-- QuickNet, Inc.
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 29bfbef0e..d5acaf6e4 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -1168,7 +1168,7 @@ int ast_autoservice_start(struct ast_channel *chan);
*/
int ast_autoservice_stop(struct ast_channel *chan);
-/* If built with zaptel optimizations, force a scheduled expiration on the
+/* If built with DAHDI optimizations, force a scheduled expiration on the
timer fd, at which point we call the callback function / data */
int ast_settimeout(struct ast_channel *c, int samples, int (*func)(const void *data), void *data);
diff --git a/include/asterisk/options.h b/include/asterisk/options.h
index 492feccd8..57e1374fe 100644
--- a/include/asterisk/options.h
+++ b/include/asterisk/options.h
@@ -122,8 +122,12 @@ extern pid_t ast_mainpid;
extern char record_cache_dir[AST_CACHE_DIR_LEN];
extern char debug_filename[AST_FILENAME_MAX];
-extern char dahdi_chan_name[AST_CHANNEL_NAME];
-
+extern const char *dahdi_chan_name;
+extern enum dahdi_chan_modes {
+ ZAP_ONLY_MODE,
+ DAHDI_PLUS_ZAP,
+} dahdi_chan_mode;
+
extern int ast_language_is_prefix;
#if defined(__cplusplus) || defined(c_plusplus)
diff --git a/main/asterisk.c b/main/asterisk.c
index 17b3581f1..36a65c91a 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -172,7 +172,14 @@ int option_maxcalls; /*!< Max number of active calls */
char record_cache_dir[AST_CACHE_DIR_LEN] = AST_TMP_DIR;
char debug_filename[AST_FILENAME_MAX] = "";
-char dahdi_chan_name[AST_CHANNEL_NAME] = "ZAP";
+#ifdef HAVE_ZAPTEL
+char _dahdi_chan_name[AST_CHANNEL_NAME] = "Zap";
+enum dahdi_chan_modes dahdi_chan_mode = ZAP_ONLY_MODE;
+#else
+char _dahdi_chan_name[AST_CHANNEL_NAME] = "DAHDI";
+enum dahdi_chan_modes dahdi_chan_mode = DAHDI_PLUS_ZAP;
+#endif
+const char *dahdi_chan_name;
static int ast_socket = -1; /*!< UNIX Socket for allowing remote control */
static int ast_consock = -1; /*!< UNIX Socket for controlling another asterisk */
@@ -2409,7 +2416,7 @@ static int show_cli_help(void) {
printf(" -g Dump core in case of a crash\n");
printf(" -h This help screen\n");
printf(" -i Initialize crypto keys at startup\n");
- printf(" -I Enable internal timing if Zaptel timer is available\n");
+ printf(" -I Enable internal timing if %s timer is available\n", dahdi_chan_name);
printf(" -L <load> Limit the maximum load average before rejecting new calls\n");
printf(" -M <value> Limit the maximum number of calls to the specified value\n");
printf(" -m Mute debugging and console output on the console\n");
@@ -2583,9 +2590,17 @@ static void ast_readconfig(void)
} else if (!strcasecmp(v->name, "languageprefix")) {
ast_language_is_prefix = ast_true(v->value);
} else if (!strcasecmp(v->name, "dahdichanname")) {
- if (!strcasecmp(v->value, "yes")) {
- ast_copy_string(dahdi_chan_name, "DAHDI", sizeof(dahdi_chan_name));
+#ifdef HAVE_ZAPTEL
+ if (ast_true(v->value)) {
+ strcpy(_dahdi_chan_name, "DAHDI");
+ dahdi_chan_mode = DAHDI_PLUS_ZAP;
}
+#else
+ if (ast_false(v->value)) {
+ strcpy(_dahdi_chan_name, "Zap");
+ dahdi_chan_mode = ZAP_ONLY_MODE;
+ }
+#endif
}
}
ast_config_destroy(cfg);
@@ -2966,6 +2981,9 @@ int main(int argc, char *argv[])
printf(term_quit());
exit(1);
}
+
+ dahdi_chan_name = _dahdi_chan_name;
+
#ifdef HAVE_ZAPTEL
{
int fd;
diff --git a/main/channel.c b/main/channel.c
index bdc8491f3..9a5d70125 100644
--- a/main/channel.c
+++ b/main/channel.c
@@ -3009,11 +3009,6 @@ struct ast_channel *ast_request(const char *type, int format, void *data, int *c
return NULL;
}
- if (!strcasecmp(type, "Zap")) {
- type = "DAHDI";
- ast_log(LOG_NOTICE, "Zap interface translated to DAHDI.\n");
- }
-
AST_LIST_TRAVERSE(&backends, chan, list) {
if (strcasecmp(type, chan->tech->type))
continue;
diff --git a/main/file.c b/main/file.c
index a3f14fbe6..f99b543cb 100644
--- a/main/file.c
+++ b/main/file.c
@@ -683,7 +683,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
if (s->owner->timingfd > -1) {
int zap_timer_samples = whennext;
int rate;
- /* whennext is in samples, but zaptel timers operate in 8 kHz samples. */
+ /* whennext is in samples, but DAHDI timers operate in 8 kHz samples. */
if ((rate = ast_format_rate(s->fmt->format)) != 8000) {
float factor;
factor = ((float) rate) / ((float) 8000.0);