summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_channel.c25
1 files changed, 25 insertions, 0 deletions
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 4024cdf8b..7f87f450e 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -46,6 +46,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/global_datastores.h"
#include "asterisk/bridge_basic.h"
#include "asterisk/bridge_after.h"
+#include "asterisk/max_forwards.h"
/*** DOCUMENTATION
<function name="CHANNELS" language="en_US">
@@ -388,6 +389,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<enum name="caller_url">
<para>R/0 Returns caller URL</para>
</enum>
+ <enum name="max_forwards">
+ <para>R/W Get or set the maximum number of call forwards for this channel.
+
+ This number describes the number of times a call may be forwarded by this channel
+ before the call fails. "Forwards" in this case refers to redirects by phones as well
+ as calls to local channels.
+
+ Note that this has no relation to the SIP Max-Forwards header.
+ </para>
+ </enum>
</enumlist>
</parameter>
</syntax>
@@ -577,6 +588,10 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
}
}
ast_channel_unlock(chan);
+ } else if (!strcasecmp(data, "max_forwards")) {
+ ast_channel_lock(chan);
+ snprintf(buf, len, "%d", ast_max_forwards_get(chan));
+ ast_channel_unlock(chan);
} else if (!ast_channel_tech(chan) || !ast_channel_tech(chan)->func_channel_read || ast_channel_tech(chan)->func_channel_read(chan, function, data, buf, len)) {
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n", data);
ret = -1;
@@ -737,6 +752,16 @@ static int func_channel_write_real(struct ast_channel *chan, const char *functio
store->media = ast_true(value) ? 1 : 0;
}
ast_channel_unlock(chan);
+ } else if (!strcasecmp(data, "max_forwards")) {
+ int max_forwards;
+ if (sscanf(value, "%d", &max_forwards) != 1) {
+ ast_log(LOG_WARNING, "Unable to set max forwards to '%s'\n", value);
+ ret = -1;
+ } else {
+ ast_channel_lock(chan);
+ ret = ast_max_forwards_set(chan, max_forwards);
+ ast_channel_unlock(chan);
+ }
} else if (!ast_channel_tech(chan)->func_channel_write
|| ast_channel_tech(chan)->func_channel_write(chan, function, data, value)) {
ast_log(LOG_WARNING, "Unknown or unavailable item requested: '%s'\n",