summaryrefslogtreecommitdiff
path: root/funcs
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-09-05 20:35:37 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-09-05 20:35:37 +0000
commitb06cd2f048eb7158227bb68a34760c32223778a7 (patch)
tree9f7671153652e1674af1cc197274960cad0d3afb /funcs
parentc56aa2d8f6a04dafb82cf35e69f0ea932dc864fd (diff)
func_channel.c: Add missing locking to some CHANNEL() requests.
* The CHANNEL() audionativeformat, videonativeformat, audioreadformat, and audiowriteformat now need locking since the media format rework when accessing the channel's format pointers. * Increased the buffer size for CHANNEL() audionativeformat and videonativeformat output strings since the allow=all can be a lengthy list. * Tweaked the CHANNEL() XML documentation for secure_bridge_signaling, secure_bridge_media, and state. * Ensured the output buffer is initialized for secure_bridge_signaling and secure_bridge_media. * Made use the locked_copy_string() macro instead of inlining it for trace and checkhangup. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@422700 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_channel.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/funcs/func_channel.c b/funcs/func_channel.c
index 814960ac2..0ebab2a3e 100644
--- a/funcs/func_channel.c
+++ b/funcs/func_channel.c
@@ -172,13 +172,13 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
<para>R/W set rxgain level on channel drivers that support it.</para>
</enum>
<enum name="secure_bridge_signaling">
- <para>Whether or not channels bridged to this channel require secure signaling</para>
+ <para>Whether or not channels bridged to this channel require secure signaling (1/0)</para>
</enum>
<enum name="secure_bridge_media">
- <para>Whether or not channels bridged to this channel require secure media</para>
+ <para>Whether or not channels bridged to this channel require secure media (1/0)</para>
</enum>
<enum name="state">
- <para>R/O state for channel</para>
+ <para>R/O state of the channel</para>
</enum>
<enum name="tonezone">
<para>R/W zone for indications played</para>
@@ -432,30 +432,32 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
if (!strcasecmp(data, "audionativeformat")) {
tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (tmpcap) {
- struct ast_str *codec_buf = ast_str_alloca(64);
+ struct ast_str *codec_buf = ast_str_alloca(128);
+ ast_channel_lock(chan);
ast_format_cap_append_from_cap(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_AUDIO);
+ ast_channel_unlock(chan);
ast_copy_string(buf, ast_format_cap_get_names(tmpcap, &codec_buf), len);
ao2_ref(tmpcap, -1);
}
} else if (!strcasecmp(data, "videonativeformat")) {
tmpcap = ast_format_cap_alloc(AST_FORMAT_CAP_FLAG_DEFAULT);
if (tmpcap) {
- struct ast_str *codec_buf = ast_str_alloca(64);
+ struct ast_str *codec_buf = ast_str_alloca(128);
+ ast_channel_lock(chan);
ast_format_cap_append_from_cap(tmpcap, ast_channel_nativeformats(chan), AST_MEDIA_TYPE_VIDEO);
+ ast_channel_unlock(chan);
ast_copy_string(buf, ast_format_cap_get_names(tmpcap, &codec_buf), len);
ao2_ref(tmpcap, -1);
}
} else if (!strcasecmp(data, "audioreadformat")) {
- ast_copy_string(buf, ast_format_get_name(ast_channel_readformat(chan)), len);
+ locked_copy_string(chan, buf, ast_format_get_name(ast_channel_readformat(chan)), len);
} else if (!strcasecmp(data, "audiowriteformat")) {
- ast_copy_string(buf, ast_format_get_name(ast_channel_writeformat(chan)), len);
+ locked_copy_string(chan, buf, ast_format_get_name(ast_channel_writeformat(chan)), len);
#ifdef CHANNEL_TRACE
} else if (!strcasecmp(data, "trace")) {
- ast_channel_lock(chan);
- ast_copy_string(buf, ast_channel_trace_is_enabled(chan) ? "1" : "0", len);
- ast_channel_unlock(chan);
+ locked_copy_string(chan, buf, ast_channel_trace_is_enabled(chan) ? "1" : "0", len);
#endif
} else if (!strcasecmp(data, "tonezone") && ast_channel_zone(chan)) {
locked_copy_string(chan, buf, ast_channel_zone(chan)->country, len);
@@ -478,9 +480,7 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
else if (!strcasecmp(data, "accountcode"))
locked_copy_string(chan, buf, ast_channel_accountcode(chan), len);
else if (!strcasecmp(data, "checkhangup")) {
- ast_channel_lock(chan);
- ast_copy_string(buf, ast_check_hangup(chan) ? "1" : "0", len);
- ast_channel_unlock(chan);
+ locked_copy_string(chan, buf, ast_check_hangup(chan) ? "1" : "0", len);
} else if (!strcasecmp(data, "peeraccount"))
locked_copy_string(chan, buf, ast_channel_peeraccount(chan), len);
else if (!strcasecmp(data, "hangupsource"))
@@ -553,9 +553,11 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
} else if (!strncasecmp(data, "secure_bridge_", 14)) {
struct ast_datastore *ds;
+ buf[0] = '\0';
ast_channel_lock(chan);
if ((ds = ast_channel_datastore_find(chan, &secure_call_info, NULL))) {
struct ast_secure_call_store *encrypt = ds->data;
+
if (!strcasecmp(data, "secure_bridge_signaling")) {
snprintf(buf, len, "%s", encrypt->signaling ? "1" : "");
} else if (!strcasecmp(data, "secure_bridge_media")) {