mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-19 00:00:09 +00:00
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: https://origsvn.digium.com/svn/asterisk/branches/1.4@130298 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -59,18 +59,25 @@ 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 =
|
||||
" 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"
|
||||
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 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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user