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
This commit is contained in:
Kinsey Moore
2014-08-06 12:55:28 +00:00
parent ac5c75b45d
commit f1036f40dc
39 changed files with 708 additions and 73 deletions

View File

@@ -557,13 +557,14 @@ static void publish_chanspy_message(struct ast_channel *spyer,
RAII_VAR(struct ast_json *, blob, NULL, ast_json_unref);
RAII_VAR(struct ast_multi_channel_blob *, payload, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
struct stasis_message_type *type = start ? ast_channel_chanspy_start_type(): ast_channel_chanspy_stop_type();
if (!spyer) {
ast_log(AST_LOG_WARNING, "Attempt to publish ChanSpy message for NULL spyer channel\n");
return;
}
blob = ast_json_null();
if (!blob) {
if (!blob || !type) {
return;
}
@@ -582,9 +583,7 @@ static void publish_chanspy_message(struct ast_channel *spyer,
}
}
message = stasis_message_create(
start ? ast_channel_chanspy_start_type(): ast_channel_chanspy_stop_type(),
payload);
message = stasis_message_create(type, payload);
if (!message) {
return;
}

View File

@@ -136,7 +136,7 @@ static void forkcdr_callback(void *data, struct stasis_subscription *sub, struct
static int forkcdr_exec(struct ast_channel *chan, const char *data)
{
RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
RAII_VAR(struct fork_cdr_message_payload *, payload, ao2_alloc(sizeof(*payload), NULL), ao2_cleanup);
RAII_VAR(struct fork_cdr_message_payload *, payload, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
char *parse;
@@ -153,6 +153,13 @@ static int forkcdr_exec(struct ast_channel *chan, const char *data)
ast_app_parse_options(forkcdr_exec_options, &flags, NULL, args.options);
}
if (!forkcdr_message_type()) {
ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message type\n",
ast_channel_name(chan));
return -1;
}
payload = ao2_alloc(sizeof(*payload), NULL);
if (!payload) {
return -1;
}

View File

@@ -2066,6 +2066,10 @@ static void queue_publish_multi_channel_snapshot_blob(struct stasis_topic *topic
RAII_VAR(struct ast_multi_channel_blob *, payload, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
if (!type) {
return;
}
payload = ast_multi_channel_blob_create(blob);
if (!payload) {
return;
@@ -2122,7 +2126,7 @@ static void queue_publish_member_blob(struct stasis_message_type *type, struct a
RAII_VAR(struct ast_json_payload *, payload, NULL, ao2_cleanup);
RAII_VAR(struct stasis_message *, msg, NULL, ao2_cleanup);
if (!blob) {
if (!blob || !type) {
return;
}