44 #include <dahdi/user.h>
75 static const char app[] =
"DAHDIBarge";
83 res = write(fd, data, len);
85 if (
errno != EAGAIN) {
100 struct dahdi_confinfo dahdic;
113 struct dahdi_bufferinfo bi;
129 retrydahdi = strcasecmp(chan->
tech->
type,
"DAHDI");
131 origfd = chan->
fds[0];
133 fd = open(
"/dev/dahdi/pseudo", O_RDWR);
139 flags = fcntl(fd, F_GETFL);
145 if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {
151 memset(&bi, 0,
sizeof(bi));
153 bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE;
154 bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE;
156 if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
167 memset(&dahdic, 0,
sizeof(dahdic));
170 if (ioctl(fd, DAHDI_GETCONF, &dahdic)) {
175 if (dahdic.confmode) {
178 ast_debug(1,
"DAHDI channel is in a conference already, retrying with pseudo\n");
183 memset(&dahdic, 0,
sizeof(dahdic));
186 dahdic.confno = confno;
187 dahdic.confmode = DAHDI_CONF_MONITORBOTH;
189 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
194 ast_debug(1,
"Placed channel %s in DAHDI channel %d monitor\n", chan->
name, confno);
201 if (c->
fds[0] != origfd) {
206 ast_debug(1,
"Ooh, something swapped out under us, starting over\n");
217 }
else if (fd != chan->
fds[0]) {
227 }
else if (outfd > -1) {
230 memset(&fr, 0,
sizeof(fr));
245 if (fd != chan->
fds[0])
253 if (ioctl(fd, DAHDI_SETCONF, &dahdic)) {
269 char confnostr[80] =
"";
272 if ((sscanf(data,
"DAHDI/%30d", &confno) != 1) &&
273 (sscanf(data,
"%30d", &confno) != 1)) {
274 ast_log(
LOG_WARNING,
"DAHDIBarge Argument (if specified) must be a channel number, not '%s'\n", (
char *)data);
282 while(!confno && (++retrycnt < 4)) {
285 res =
ast_app_getdata(chan,
"conf-getchannel",confnostr,
sizeof(confnostr) - 1, 0);
286 if (res <0)
goto out;
287 if (sscanf(confnostr,
"%30d", &confno) != 1)
293 res =
conf_run(chan, confno, confflags);
union ast_frame_subclass subclass
Main Channel structure associated with a channel.
static int unload_module(void)
#define AST_MODULE_INFO_STANDARD(keystr, desc)
Asterisk locking-related definitions:
Asterisk main include file. File version handling, generic pbx functions.
int ast_app_getdata(struct ast_channel *c, const char *prompt, char *s, int maxlen, int timeout)
Plays a stream and gets DTMF data from a channel.
static int load_module(void)
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
struct ast_frame * ast_read(struct ast_channel *chan)
Reads a frame.
Configuration File Parser.
Generic File Format Support. Should be included by clients of the file handling routines. File service providers should instead include mod_format.h.
int ast_unregister_application(const char *app)
Unregister an application.
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **chan, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
int ast_set_write_format(struct ast_channel *chan, format_t format)
Sets write format on channel chan Set write format for channel to whichever component of "format" is ...
int ast_set_read_format(struct ast_channel *chan, format_t format)
Sets read format on channel chan Set read format for channel to whichever component of "format" is be...
#define ast_debug(level,...)
Log a DEBUG message.
General Asterisk PBX channel definitions.
#define AST_FRIENDLY_OFFSET
Offset into a frame's data buffer.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Core PBX routines and definitions.
char * ast_getformatname(format_t format)
Get the name of a format.
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
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 conf_exec(struct ast_channel *chan, const char *data)
int ast_write(struct ast_channel *chan, struct ast_frame *frame)
Write a frame to a channel This function writes the given frame to the indicated channel.
static int conf_run(struct ast_channel *chan, int confno, int confflags)
Standard Command Line Interface.
static int careful_write(int fd, unsigned char *data, int len)
int ast_answer(struct ast_channel *chan)
Answer a channel.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
Data structure associated with a single frame of data.
enum ast_frame_type frametype
Say numbers and dates (maybe words one day too)
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
union ast_frame::@172 data
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.