| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | /*
 | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * Asterisk -- An open source telephony toolkit. | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * Copyright (C) 1999 - 2005, Digium, Inc. | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * Mark Spencer <markster@digium.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Special thanks to comphealth.com for sponsoring this | 
					
						
							|  |  |  |  * GPL application. | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * See http://www.asterisk.org for more information about
 | 
					
						
							|  |  |  |  * the Asterisk project. Please do not directly contact | 
					
						
							|  |  |  |  * any of the maintainers of this project for assistance; | 
					
						
							|  |  |  |  * the project provides a web site, mailing lists and IRC | 
					
						
							|  |  |  |  * channels for your use. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * This program is free software, distributed under the terms of | 
					
						
							|  |  |  |  * the GNU General Public License Version 2. See the LICENSE file | 
					
						
							|  |  |  |  * at the top of the source tree. | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-10-24 20:12:06 +00:00
										 |  |  | /*! \file
 | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  * | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  |  * \brief DAHDI Barge support | 
					
						
							| 
									
										
										
										
											2005-12-30 21:18:06 +00:00
										 |  |  |  * | 
					
						
							|  |  |  |  * \author Mark Spencer <markster@digium.com> | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * \note Special thanks to comphealth.com for sponsoring this | 
					
						
							|  |  |  |  * GPL application. | 
					
						
							| 
									
										
										
										
											2005-09-14 20:46:50 +00:00
										 |  |  |  *  | 
					
						
							| 
									
										
										
										
											2005-11-06 15:09:47 +00:00
										 |  |  |  * \ingroup applications | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  |  */ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-04-24 17:11:45 +00:00
										 |  |  | /*** MODULEINFO
 | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	<depend>dahdi</depend> | 
					
						
							| 
									
										
										
										
											2011-07-14 20:13:06 +00:00
										 |  |  | 	<support_level>deprecated</support_level> | 
					
						
							|  |  |  | 	<replacement>app_chanspy</replacement> | 
					
						
							| 
									
										
										
										
											2006-04-24 17:11:45 +00:00
										 |  |  |  ***/ | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-06-07 18:54:56 +00:00
										 |  |  | #include "asterisk.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | ASTERISK_FILE_VERSION(__FILE__, "$Revision$") | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-25 23:05:28 +00:00
										 |  |  | #include <dahdi/user.h>
 | 
					
						
							| 
									
										
										
										
											2004-06-04 15:44:14 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-06-06 22:39:32 +00:00
										 |  |  | #include "asterisk/lock.h"
 | 
					
						
							|  |  |  | #include "asterisk/file.h"
 | 
					
						
							|  |  |  | #include "asterisk/channel.h"
 | 
					
						
							|  |  |  | #include "asterisk/pbx.h"
 | 
					
						
							|  |  |  | #include "asterisk/module.h"
 | 
					
						
							|  |  |  | #include "asterisk/config.h"
 | 
					
						
							|  |  |  | #include "asterisk/app.h"
 | 
					
						
							|  |  |  | #include "asterisk/cli.h"
 | 
					
						
							|  |  |  | #include "asterisk/say.h"
 | 
					
						
							|  |  |  | #include "asterisk/utils.h"
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-11-01 21:10:07 +00:00
										 |  |  | /*** DOCUMENTATION
 | 
					
						
							|  |  |  | 	<application name="DAHDIBarge" language="en_US"> | 
					
						
							|  |  |  | 		<synopsis> | 
					
						
							|  |  |  | 			Barge in (monitor) DAHDI channel. | 
					
						
							|  |  |  | 		</synopsis> | 
					
						
							|  |  |  | 		<syntax> | 
					
						
							|  |  |  | 			<parameter name="channel"> | 
					
						
							|  |  |  | 				<para>Channel to barge.</para> | 
					
						
							|  |  |  | 			</parameter> | 
					
						
							|  |  |  | 		</syntax> | 
					
						
							|  |  |  | 		<description> | 
					
						
							|  |  |  | 			<para>Barges in on a specified DAHDI <replaceable>channel</replaceable> or prompts | 
					
						
							|  |  |  | 			if one is not specified. Returns <literal>-1</literal> when caller user hangs | 
					
						
							|  |  |  | 			up and is independent of the state of the channel being monitored. | 
					
						
							|  |  |  | 			</para> | 
					
						
							|  |  |  | 		</description> | 
					
						
							|  |  |  | 	</application> | 
					
						
							|  |  |  |  ***/ | 
					
						
							| 
									
										
										
										
											2009-06-07 14:55:51 +00:00
										 |  |  | static const char app[] = "DAHDIBarge"; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | #define CONF_SIZE 160
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int careful_write(int fd, unsigned char *data, int len) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int res; | 
					
						
							|  |  |  | 	while(len) { | 
					
						
							|  |  |  | 		res = write(fd, data, len); | 
					
						
							|  |  |  | 		if (res < 1) { | 
					
						
							|  |  |  | 			if (errno != EAGAIN) { | 
					
						
							|  |  |  | 				ast_log(LOG_WARNING, "Failed to write audio data to conference: %s\n", strerror(errno)); | 
					
						
							|  |  |  | 				return -1; | 
					
						
							|  |  |  | 			} else | 
					
						
							|  |  |  | 				return 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		len -= res; | 
					
						
							|  |  |  | 		data += res; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	return 0; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | static int conf_run(struct ast_channel *chan, int confno, int confflags) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  | 	int fd; | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	struct dahdi_confinfo dahdic; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	struct ast_frame *f; | 
					
						
							|  |  |  | 	struct ast_channel *c; | 
					
						
							|  |  |  | 	struct ast_frame fr; | 
					
						
							|  |  |  | 	int outfd; | 
					
						
							|  |  |  | 	int ms; | 
					
						
							|  |  |  | 	int nfds; | 
					
						
							|  |  |  | 	int res; | 
					
						
							|  |  |  | 	int flags; | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	int retrydahdi; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	int origfd; | 
					
						
							|  |  |  | 	int ret = -1; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-07-29 22:22:13 +00:00
										 |  |  | 	struct dahdi_bufferinfo bi; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	char __buf[CONF_SIZE + AST_FRIENDLY_OFFSET]; | 
					
						
							|  |  |  | 	char *buf = __buf + AST_FRIENDLY_OFFSET; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Set it into U-law mode (write) */ | 
					
						
							| 
									
										
										
										
											2004-04-06 22:17:32 +00:00
										 |  |  | 	if (ast_set_write_format(chan, AST_FORMAT_ULAW) < 0) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		ast_log(LOG_WARNING, "Unable to set '%s' to write ulaw mode\n", chan->name); | 
					
						
							|  |  |  | 		goto outrun; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	/* Set it into U-law mode (read) */ | 
					
						
							| 
									
										
										
										
											2004-04-06 22:17:32 +00:00
										 |  |  | 	if (ast_set_read_format(chan, AST_FORMAT_ULAW) < 0) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		ast_log(LOG_WARNING, "Unable to set '%s' to read ulaw mode\n", chan->name); | 
					
						
							|  |  |  | 		goto outrun; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	ast_indicate(chan, -1); | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	retrydahdi = strcasecmp(chan->tech->type, "DAHDI"); | 
					
						
							|  |  |  | dahdiretry: | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	origfd = chan->fds[0]; | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	if (retrydahdi) { | 
					
						
							|  |  |  | 		fd = open("/dev/dahdi/pseudo", O_RDWR); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		if (fd < 0) { | 
					
						
							|  |  |  | 			ast_log(LOG_WARNING, "Unable to open pseudo channel: %s\n", strerror(errno)); | 
					
						
							|  |  |  | 			goto outrun; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		/* Make non-blocking */ | 
					
						
							|  |  |  | 		flags = fcntl(fd, F_GETFL); | 
					
						
							|  |  |  | 		if (flags < 0) { | 
					
						
							|  |  |  | 			ast_log(LOG_WARNING, "Unable to get flags: %s\n", strerror(errno)); | 
					
						
							|  |  |  | 			close(fd); | 
					
						
							|  |  |  | 			goto outrun; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		if (fcntl(fd, F_SETFL, flags | O_NONBLOCK)) { | 
					
						
							|  |  |  | 			ast_log(LOG_WARNING, "Unable to set flags: %s\n", strerror(errno)); | 
					
						
							|  |  |  | 			close(fd); | 
					
						
							|  |  |  | 			goto outrun; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		/* Setup buffering information */ | 
					
						
							|  |  |  | 		memset(&bi, 0, sizeof(bi)); | 
					
						
							|  |  |  | 		bi.bufsize = CONF_SIZE; | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 		bi.txbufpolicy = DAHDI_POLICY_IMMEDIATE; | 
					
						
							|  |  |  | 		bi.rxbufpolicy = DAHDI_POLICY_IMMEDIATE; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		bi.numbufs = 4; | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 		if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 			ast_log(LOG_WARNING, "Unable to set buffering information: %s\n", strerror(errno)); | 
					
						
							|  |  |  | 			close(fd); | 
					
						
							|  |  |  | 			goto outrun; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 		nfds = 1; | 
					
						
							|  |  |  | 	} else { | 
					
						
							|  |  |  | 		/* XXX Make sure we're not running on a pseudo channel XXX */ | 
					
						
							|  |  |  | 		fd = chan->fds[0]; | 
					
						
							|  |  |  | 		nfds = 0; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	memset(&dahdic, 0, sizeof(dahdic)); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	/* Check to see if we're in a conference... */ | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	dahdic.chan = 0;	 | 
					
						
							|  |  |  | 	if (ioctl(fd, DAHDI_GETCONF, &dahdic)) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		ast_log(LOG_WARNING, "Error getting conference\n"); | 
					
						
							|  |  |  | 		close(fd); | 
					
						
							|  |  |  | 		goto outrun; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	if (dahdic.confmode) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		/* Whoa, already in a conference...  Retry... */ | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 		if (!retrydahdi) { | 
					
						
							|  |  |  | 			ast_debug(1, "DAHDI channel is in a conference already, retrying with pseudo\n"); | 
					
						
							|  |  |  | 			retrydahdi = 1; | 
					
						
							|  |  |  | 			goto dahdiretry; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	memset(&dahdic, 0, sizeof(dahdic)); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	/* Add us to the conference */ | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	dahdic.chan = 0;	 | 
					
						
							|  |  |  | 	dahdic.confno = confno; | 
					
						
							|  |  |  | 	dahdic.confmode = DAHDI_CONF_MONITORBOTH; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		ast_log(LOG_WARNING, "Error setting conference\n"); | 
					
						
							|  |  |  | 		close(fd); | 
					
						
							|  |  |  | 		goto outrun; | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 	ast_debug(1, "Placed channel %s in DAHDI channel %d monitor\n", chan->name, confno); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	for(;;) { | 
					
						
							|  |  |  | 		outfd = -1; | 
					
						
							|  |  |  | 		ms = -1; | 
					
						
							|  |  |  | 		c = ast_waitfor_nandfds(&chan, 1, &fd, nfds, NULL, &outfd, &ms); | 
					
						
							|  |  |  | 		if (c) { | 
					
						
							|  |  |  | 			if (c->fds[0] != origfd) { | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 				if (retrydahdi) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 					/* Kill old pseudo */ | 
					
						
							|  |  |  | 					close(fd); | 
					
						
							|  |  |  | 				} | 
					
						
							| 
									
										
										
										
											2007-06-14 19:39:12 +00:00
										 |  |  | 				ast_debug(1, "Ooh, something swapped out under us, starting over\n"); | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 				retrydahdi = 0; | 
					
						
							|  |  |  | 				goto dahdiretry; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 			} | 
					
						
							|  |  |  | 			f = ast_read(c); | 
					
						
							|  |  |  | 			if (!f)  | 
					
						
							|  |  |  | 				break; | 
					
						
							| 
									
										
										
										
											2009-11-04 14:05:12 +00:00
										 |  |  | 			if ((f->frametype == AST_FRAME_DTMF) && (f->subclass.integer == '#')) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 				ret = 0; | 
					
						
							| 
									
										
										
										
											2006-06-11 14:48:25 +00:00
										 |  |  | 				ast_frfree(f); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 				break; | 
					
						
							|  |  |  | 			} else if (fd != chan->fds[0]) { | 
					
						
							|  |  |  | 				if (f->frametype == AST_FRAME_VOICE) { | 
					
						
							| 
									
										
										
										
											2009-11-04 14:05:12 +00:00
										 |  |  | 					if (f->subclass.codec == AST_FORMAT_ULAW) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 						/* Carefully write */ | 
					
						
							| 
									
										
										
										
											2008-05-22 16:29:54 +00:00
										 |  |  | 						careful_write(fd, f->data.ptr, f->datalen); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 					} else | 
					
						
							| 
									
										
										
										
											2009-11-04 14:05:12 +00:00
										 |  |  | 						ast_log(LOG_WARNING, "Huh?  Got a non-ulaw (%s) frame in the conference\n", ast_getformatname(f->subclass.codec)); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 				} | 
					
						
							|  |  |  | 			} | 
					
						
							|  |  |  | 			ast_frfree(f); | 
					
						
							|  |  |  | 		} else if (outfd > -1) { | 
					
						
							|  |  |  | 			res = read(outfd, buf, CONF_SIZE); | 
					
						
							|  |  |  | 			if (res > 0) { | 
					
						
							|  |  |  | 				memset(&fr, 0, sizeof(fr)); | 
					
						
							|  |  |  | 				fr.frametype = AST_FRAME_VOICE; | 
					
						
							| 
									
										
										
										
											2009-11-04 14:05:12 +00:00
										 |  |  | 				fr.subclass.codec = AST_FORMAT_ULAW; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 				fr.datalen = res; | 
					
						
							|  |  |  | 				fr.samples = res; | 
					
						
							| 
									
										
										
										
											2008-05-22 16:29:54 +00:00
										 |  |  | 				fr.data.ptr = buf; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 				fr.offset = AST_FRIENDLY_OFFSET; | 
					
						
							|  |  |  | 				if (ast_write(chan, &fr) < 0) { | 
					
						
							|  |  |  | 					ast_log(LOG_WARNING, "Unable to write frame to channel: %s\n", strerror(errno)); | 
					
						
							|  |  |  | 					/* break; */ | 
					
						
							|  |  |  | 				} | 
					
						
							|  |  |  | 			} else  | 
					
						
							|  |  |  | 				ast_log(LOG_WARNING, "Failed to read frame: %s\n", strerror(errno)); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (fd != chan->fds[0]) | 
					
						
							|  |  |  | 		close(fd); | 
					
						
							|  |  |  | 	else { | 
					
						
							|  |  |  | 		/* Take out of conference */ | 
					
						
							|  |  |  | 		/* Add us to the conference */ | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 		dahdic.chan = 0;	 | 
					
						
							|  |  |  | 		dahdic.confno = 0; | 
					
						
							|  |  |  | 		dahdic.confmode = 0; | 
					
						
							|  |  |  | 		if (ioctl(fd, DAHDI_SETCONF, &dahdic)) { | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 			ast_log(LOG_WARNING, "Error setting conference\n"); | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | outrun: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	return ret; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2009-05-21 21:13:09 +00:00
										 |  |  | static int conf_exec(struct ast_channel *chan, const char *data) | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-08-10 14:45:25 +00:00
										 |  |  | 	int res = -1; | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	int retrycnt = 0; | 
					
						
							|  |  |  | 	int confflags = 0; | 
					
						
							|  |  |  | 	int confno = 0; | 
					
						
							| 
									
										
										
										
											2008-08-10 14:45:25 +00:00
										 |  |  | 	char confnostr[80] = ""; | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2005-10-26 19:48:14 +00:00
										 |  |  | 	if (!ast_strlen_zero(data)) { | 
					
						
							| 
									
										
										
										
											2009-08-10 19:20:57 +00:00
										 |  |  | 		if ((sscanf(data, "DAHDI/%30d", &confno) != 1) && | 
					
						
							|  |  |  | 		    (sscanf(data, "%30d", &confno) != 1)) { | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | 			ast_log(LOG_WARNING, "DAHDIBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 			return 0; | 
					
						
							|  |  |  | 		} | 
					
						
							|  |  |  | 	} | 
					
						
							| 
									
										
										
										
											2005-10-19 18:19:02 +00:00
										 |  |  | 	 | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 	if (chan->_state != AST_STATE_UP) | 
					
						
							|  |  |  | 		ast_answer(chan); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	while(!confno && (++retrycnt < 4)) { | 
					
						
							|  |  |  | 		/* Prompt user for conference number */ | 
					
						
							| 
									
										
										
										
											2008-08-10 14:45:25 +00:00
										 |  |  | 		confnostr[0] = '\0'; | 
					
						
							|  |  |  | 		res = ast_app_getdata(chan, "conf-getchannel",confnostr, sizeof(confnostr) - 1, 0); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 		if (res <0) goto out; | 
					
						
							| 
									
										
										
										
											2009-08-10 19:20:57 +00:00
										 |  |  | 		if (sscanf(confnostr, "%30d", &confno) != 1) | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | 			confno = 0; | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | 	if (confno) { | 
					
						
							|  |  |  | 		/* XXX Should prompt user for pin if pin is required XXX */ | 
					
						
							|  |  |  | 		/* Run the conference */ | 
					
						
							|  |  |  | 		res = conf_run(chan, confno, confflags); | 
					
						
							|  |  |  | 	} | 
					
						
							|  |  |  | out: | 
					
						
							|  |  |  | 	/* Do the conference */ | 
					
						
							|  |  |  | 	return res; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int unload_module(void) | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2007-07-16 13:35:20 +00:00
										 |  |  | 	return ast_unregister_application(app); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-08-21 02:11:39 +00:00
										 |  |  | static int load_module(void) | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2008-11-01 21:10:07 +00:00
										 |  |  | 	return ((ast_register_application_xml(app, conf_exec)) ? AST_MODULE_LOAD_FAILURE : AST_MODULE_LOAD_SUCCESS); | 
					
						
							| 
									
										
										
										
											2003-02-04 15:48:42 +00:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2008-06-12 17:27:55 +00:00
										 |  |  | AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Barge in on DAHDI channel application"); |