aboutsummaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-11 22:12:26 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2008-07-11 22:12:26 +0000
commit6d24d82f63425210f28b104b68324475163fd542 (patch)
tree84040a4ee9d4cb5ae7278c79140a6ff782d84388 /apps
parentdd3bdbadeb89c8ddcb28dce2799f3ac9857ad370 (diff)
a whole pile of Zaptel/DAHDI compatibility work, with lots more to come... this tree is not yet ready for users to be easily upgrading or switching, but it needs to be :-)
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@130298 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r--apps/app_dahdibarge.c85
-rw-r--r--apps/app_dahdiras.c66
-rw-r--r--apps/app_flash.c26
3 files changed, 121 insertions, 56 deletions
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");
-