codec_dahdi: Cannot use struct ast_translator.core_{src,src}_codec.
[asterisk/asterisk.git] / apps / app_dahdiras.c
index 1671f8b..701904b 100644 (file)
@@ -27,6 +27,7 @@
 
 /*** MODULEINFO
        <depend>dahdi</depend>
+       <support_level>extended</support_level>
  ***/
 
 #include "asterisk.h"
@@ -52,17 +53,28 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/module.h"
 #include "asterisk/app.h"
 
-static char *app = "DAHDIRAS";
+/*** DOCUMENTATION
+       <application name="DAHDIRAS" language="en_US">
+               <synopsis>
+                       Executes DAHDI ISDN RAS application.
+               </synopsis>
+               <syntax>
+                       <parameter name="args" required="true">
+                               <para>A list of parameters to pass to the pppd daemon,
+                               separated by <literal>,</literal> characters.</para>
+                       </parameter>
+               </syntax>
+               <description>
+                       <para>Executes a RAS server using pppd on the given channel.
+                       The channel must be a clear channel (i.e. PRI source) and a DAHDI
+                       channel to be able to use this function (No modem emulation is included).</para>
+                       <para>Your pppd must be patched to be DAHDI aware.</para>
+               </description>
+       </application>
 
-static char *synopsis = "Executes DAHDI ISDN RAS application";
-
-static char *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 be patched to be DAHDI aware. Arguments should be\n"
-"separated by , characters.\n";
+ ***/
 
+static const char app[] = "DAHDIRAS";
 
 #define PPP_MAX_ARGS   32
 #define PPP_EXEC       "/usr/sbin/pppd"
@@ -83,7 +95,7 @@ static pid_t spawn_ras(struct ast_channel *chan, char *args)
        }
 
        /* Execute RAS on File handles */
-       dup2(chan->fds[0], STDIN_FILENO);
+       dup2(ast_channel_fd(chan, 0), STDIN_FILENO);
 
        /* Drop high priority */
        if (ast_opt_high_priority)
@@ -127,9 +139,9 @@ static void run_ras(struct ast_channel *chan, char *args)
        struct dahdi_bufferinfo savebi;
        int x;
        
-       res = ioctl(chan->fds[0], DAHDI_GET_BUFINFO, &savebi);
+       res = ioctl(ast_channel_fd(chan, 0), DAHDI_GET_BUFINFO, &savebi);
        if(res) {
-               ast_log(LOG_WARNING, "Unable to check buffer policy on channel %s\n", chan->name);
+               ast_log(LOG_WARNING, "Unable to check buffer policy on channel %s\n", ast_channel_name(chan));
                return;
        }
 
@@ -138,11 +150,11 @@ static void run_ras(struct ast_channel *chan, char *args)
                ast_log(LOG_WARNING, "Failed to spawn RAS\n");
        } else {
                for (;;) {
-                       res = wait4(pid, &status, WNOHANG, NULL);
+                       res = waitpid(pid, &status, WNOHANG);
                        if (!res) {
                                /* Check for hangup */
                                if (ast_check_hangup(chan) && !signalled) {
-                                       ast_debug(1, "Channel '%s' hungup.  Signalling RAS at %d to die...\n", chan->name, pid);
+                                       ast_debug(1, "Channel '%s' hungup.  Signalling RAS at %d to die...\n", ast_channel_name(chan), pid);
                                        kill(pid, SIGTERM);
                                        signalled=1;
                                }
@@ -151,24 +163,24 @@ static void run_ras(struct ast_channel *chan, char *args)
                                continue;
                        }
                        if (res < 0) {
-                               ast_log(LOG_WARNING, "wait4 returned %d: %s\n", res, strerror(errno));
+                               ast_log(LOG_WARNING, "waitpid returned %d: %s\n", res, strerror(errno));
                        }
                        if (WIFEXITED(status)) {
-                               ast_verb(3, "RAS on %s terminated with status %d\n", chan->name, WEXITSTATUS(status));
+                               ast_verb(3, "RAS on %s terminated with status %d\n", ast_channel_name(chan), WEXITSTATUS(status));
                        } else if (WIFSIGNALED(status)) {
                                ast_verb(3, "RAS on %s terminated with signal %d\n", 
-                                        chan->name, WTERMSIG(status));
+                                        ast_channel_name(chan), WTERMSIG(status));
                        } else {
-                               ast_verb(3, "RAS on %s terminated weirdly.\n", chan->name);
+                               ast_verb(3, "RAS on %s terminated weirdly.\n", ast_channel_name(chan));
                        }
                        /* Throw back into audio mode */
                        x = 1;
-                       ioctl(chan->fds[0], DAHDI_AUDIOMODE, &x);
+                       ioctl(ast_channel_fd(chan, 0), DAHDI_AUDIOMODE, &x);
 
                        /* Restore saved values */
-                       res = ioctl(chan->fds[0], DAHDI_SET_BUFINFO, &savebi);
+                       res = ioctl(ast_channel_fd(chan, 0), DAHDI_SET_BUFINFO, &savebi);
                        if (res < 0) {
-                               ast_log(LOG_WARNING, "Unable to set buffer policy on channel %s\n", chan->name);
+                               ast_log(LOG_WARNING, "Unable to set buffer policy on channel %s\n", ast_channel_name(chan));
                        }
                        break;
                }
@@ -176,7 +188,7 @@ static void run_ras(struct ast_channel *chan, char *args)
        ast_safe_fork_cleanup();
 }
 
-static int dahdiras_exec(struct ast_channel *chan, void *data)
+static int dahdiras_exec(struct ast_channel *chan, const char *data)
 {
        int res=-1;
        char *args;
@@ -188,22 +200,22 @@ static int dahdiras_exec(struct ast_channel *chan, void *data)
        args = ast_strdupa(data);
        
        /* Answer the channel if it's not up */
-       if (chan->_state != AST_STATE_UP)
+       if (ast_channel_state(chan) != AST_STATE_UP)
                ast_answer(chan);
-       if (strcasecmp(chan->tech->type, "DAHDI")) {
+       if (strcasecmp(ast_channel_tech(chan)->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 DAHDI channel\n", chan->name);
+               ast_verb(2, "Channel %s is not a DAHDI channel\n", ast_channel_name(chan));
                sleep(2);
        } else {
                memset(&dahdip, 0, sizeof(dahdip));
-               if (ioctl(chan->fds[0], DAHDI_GET_PARAMS, &dahdip)) {
+               if (ioctl(ast_channel_fd(chan, 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);
+                       ast_verb(2, "Channel %s is not a clear channel\n", ast_channel_name(chan));
                } else {
                        /* Everything should be okay.  Run PPP. */
-                       ast_verb(3, "Starting RAS on %s\n", chan->name);
+                       ast_verb(3, "Starting RAS on %s\n", ast_channel_name(chan));
                        /* Execute RAS */
                        run_ras(chan, args);
                }
@@ -218,8 +230,9 @@ static int unload_module(void)
 
 static int load_module(void)
 {
-       return ((ast_register_application(app, dahdiras_exec, synopsis, descrip)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
+       return ((ast_register_application_xml(app, dahdiras_exec)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS);
 }
 
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "DAHDI ISDN Remote Access Server");
+AST_MODULE_INFO_STANDARD_EXTENDED(ASTERISK_GPL_KEY, "DAHDI ISDN Remote Access Server");
+