summaryrefslogtreecommitdiff
path: root/apps/app_chanisavail.c
diff options
context:
space:
mode:
authorSteve Murphy <murf@digium.com>2007-01-24 20:35:54 +0000
committerSteve Murphy <murf@digium.com>2007-01-24 20:35:54 +0000
commitad06bf844c2e9e77ad009bcc9dd86f113c65d77f (patch)
tree543f4d2ef66b545c960b2f61c3eaf53b4738a99c /apps/app_chanisavail.c
parentbf0fbdd09b79705c39c2302a761a27b02b5b9f21 (diff)
As per bug 8859 (Add option to revert old ChanIsAvail() with 's' option behavior), this update makes the 't' option available, which calls ast_parse_device_state instead of ast_device_state. This option will not dive into the channel driver to find the status of the device (which could be good if sip devicestate isn't returning full status, for various reasons).
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@52086 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_chanisavail.c')
-rw-r--r--apps/app_chanisavail.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/apps/app_chanisavail.c b/apps/app_chanisavail.c
index c6931d8db..885225557 100644
--- a/apps/app_chanisavail.c
+++ b/apps/app_chanisavail.c
@@ -61,12 +61,14 @@ static char *descrip =
" ${AVAILSTATUS} - the status code for the available channel\n"
" Options:\n"
" s - Consider the channel unavailable if the channel is in use at all\n"
+" t - Simply checks if specified channels exist in the channel list\n"
+" (implies option s) \n"
" j - Support jumping to priority n+101 if no channel is available\n";
static int chanavail_exec(struct ast_channel *chan, void *data)
{
- int res=-1, inuse=-1, option_state=0, priority_jump=0;
+ int res=-1, inuse=-1, option_state=0, priority_jump=0, string_compare=0;
int status;
struct ast_module_user *u;
char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur;
@@ -90,6 +92,8 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
if (args.options) {
if (strchr(args.options, 's'))
option_state = 1;
+ if (strchr(args.options, 't'))
+ string_compare = 1;
if (strchr(args.options, 'j'))
priority_jump = 1;
}
@@ -113,7 +117,13 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
*number = '\0';
number++;
- if (option_state) {
+ if (string_compare) {
+ /* ast_parse_device_state checks for "SIP/1234" as a channel name.
+ ast_device_state will ask the SIP driver for the channel state. */
+
+ snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
+ status = inuse = ast_parse_device_state(trychan);
+ } else if (option_state) {
/* If the pbx says in use then don't bother trying further.
This is to permit testing if someone's on a call, even if the
channel can permit more calls (ie callwaiting, sip calls, etc). */