37 #include <sys/ioctl.h>
40 #include <sys/signal.h>
47 #include <dahdi/user.h>
77 static const char app[] =
"DAHDIRAS";
79 #define PPP_MAX_ARGS 32
80 #define PPP_EXEC "/usr/sbin/pppd"
98 dup2(chan->
fds[0], STDIN_FILENO);
108 memset(argv, 0,
sizeof(argv));
113 argv[argc++] =
"nodetach";
117 c =
strsep(&stringp,
",");
120 c =
strsep(&stringp,
",");
123 argv[argc++] =
"plugin";
124 argv[argc++] =
"dahdi.so";
125 argv[argc++] =
"stdin";
129 fprintf(stderr,
"Failed to exec PPPD!\n");
139 struct dahdi_bufferinfo savebi;
142 res = ioctl(chan->
fds[0], DAHDI_GET_BUFINFO, &savebi);
153 res = wait4(pid, &status, WNOHANG, NULL);
157 ast_debug(1,
"Channel '%s' hungup. Signalling RAS at %d to die...\n", chan->
name, pid);
170 }
else if (WIFSIGNALED(status)) {
171 ast_verb(3,
"RAS on %s terminated with signal %d\n",
172 chan->
name, WTERMSIG(status));
174 ast_verb(3,
"RAS on %s terminated weirdly.\n", chan->
name);
178 ioctl(chan->
fds[0], DAHDI_AUDIOMODE, &x);
181 res = ioctl(chan->
fds[0], DAHDI_SET_BUFINFO, &savebi);
195 struct dahdi_params dahdip;
205 if (strcasecmp(chan->
tech->
type,
"DAHDI")) {
208 ast_verb(2,
"Channel %s is not a DAHDI channel\n", chan->
name);
211 memset(&dahdip, 0,
sizeof(dahdip));
212 if (ioctl(chan->
fds[0], DAHDI_GET_PARAMS, &dahdip)) {
214 }
else if (dahdip.sigtype != DAHDI_SIG_CLEAR) {
215 ast_verb(2,
"Channel %s is not a clear channel\n", chan->
name);
static int dahdiras_exec(struct ast_channel *chan, const char *data)
Main Channel structure associated with a channel.
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
char * strsep(char **str, const char *delims)
int ast_safe_fork(int stop_reaper)
Common routine to safely fork without a chance of a signal handler firing badly in the child...
void ast_safe_fork_cleanup(void)
Common routine to cleanup after fork'ed process is complete (if reaping was stopped) ...
static pid_t spawn_ras(struct ast_channel *chan, char *args)
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
#define WIFEXITED(status)
int ast_unregister_application(const char *app)
Unregister an application.
#define ast_verb(level,...)
#define WEXITSTATUS(status)
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
static int load_module(void)
Core PBX routines and definitions.
int ast_check_hangup(struct ast_channel *chan)
Check to see if a channel is needing hang up.
int ast_set_priority(int)
We set ourselves to a high priority, that we might pre-empt everything else. If your PBX has heavy ac...
#define ast_strdupa(s)
duplicate a string in memory from the stack
enum ast_channel_state _state
const ast_string_field name
void ast_log(int level, const char *file, int line, const char *function, const char *fmt,...)
Used for sending a log message This is the standard logger function. Probably the only way you will i...
static int unload_module(void)
void ast_close_fds_above_n(int n)
Common routine for child processes, to close all fds prior to exec(2)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
static void run_ras(struct ast_channel *chan, char *args)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
struct ast_channel_tech * tech
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
#define ASTERISK_FILE_VERSION(file, version)
Register/unregister a source code file with the core.
#define ast_opt_high_priority