aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_dahdiras.c
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/app_dahdiras.c
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/app_dahdiras.c')
-rw-r--r--apps/app_dahdiras.c66
1 files changed, 43 insertions, 23 deletions
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");