diff options
author | Kinsey Moore <kmoore@digium.com> | 2014-08-06 12:55:28 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2014-08-06 12:55:28 +0000 |
commit | f1036f40dc22c4d4b30cc2ab36199cd749ead9c5 (patch) | |
tree | 4fd17b406cb14b5eee97cf0be44382b792ccbff9 /funcs | |
parent | ac5c75b45d9d7fe047ccd9d1d094cb9d30df8b51 (diff) |
Stasis: Allow message types to be blocked
This introduces stasis.conf and a mechanism to prevent certain message
types from being published. Internally, this works by preventing the
chosen message types from being created which ensures that those
message types can never be published. This patch also adjusts message
publishers such that message payloads are not created if the related
message type is not available.
ASTERISK-23943 #close
Review: https://reviewboard.asterisk.org/r/3823/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'funcs')
-rw-r--r-- | funcs/func_cdr.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c index 44ecf4d6b..c9fce23d2 100644 --- a/funcs/func_cdr.c +++ b/funcs/func_cdr.c @@ -437,8 +437,7 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len) { RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup); - RAII_VAR(struct cdr_func_payload *, payload, - ao2_alloc(sizeof(*payload), NULL), ao2_cleanup); + RAII_VAR(struct cdr_func_payload *, payload, NULL, ao2_cleanup); struct cdr_func_data output = { 0, }; if (!chan) { @@ -446,6 +445,13 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse, return -1; } + if (!cdr_read_message_type()) { + ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: message type not available\n", + ast_channel_name(chan)); + return -1; + } + + payload = ao2_alloc(sizeof(*payload), NULL); if (!payload) { return -1; } @@ -489,8 +495,7 @@ static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse, const char *value) { RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup); - RAII_VAR(struct cdr_func_payload *, payload, - ao2_alloc(sizeof(*payload), NULL), ao2_cleanup); + RAII_VAR(struct cdr_func_payload *, payload, NULL, ao2_cleanup); RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup); @@ -505,6 +510,13 @@ static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse, return -1; } + if (!cdr_write_message_type()) { + ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: message type not available\n", + ast_channel_name(chan)); + return -1; + } + + payload = ao2_alloc(sizeof(*payload), NULL); if (!payload) { return -1; } @@ -543,6 +555,13 @@ static int cdr_prop_write(struct ast_channel *chan, const char *cmd, char *parse return -1; } + if (!cdr_write_message_type()) { + ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: message type not available\n", + ast_channel_name(chan)); + return -1; + } + + payload = ao2_alloc(sizeof(*payload), NULL); if (!payload) { return -1; } |