mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
res_pjsip_pubsub: Add some type safety when generating NOTIFY bodies.
res_pjsip_pubsub has two separate checks that it makes when a SUBSCRIBE arrives. * It checks that there is a subscription handler for the Event * It checks that there are body generators for the types in the Accept header The problem is, there's nothing that ensures that these two things will actually mesh with each other. For instance, Asterisk will accept a subscription to MWI that accepts pidf+xml bodies. That doesn't make sense. With this commit, we add some type information to the mix. Subscription handlers state they generate data of type X, and body generators state that they consume data of type X. This way, Asterisk doesn't end up in some hilariously mismatched situation like the one in the previous paragraph. ASTERISK-24136 #close Reported by Mark Michelson Review: https://reviewboard.asterisk.org/r/3877 Review: https://reviewboard.asterisk.org/r/3878 ........ Merged revisions 423344 from http://svn.asterisk.org/svn/asterisk/branches/12 ........ Merged revisions 423348 from http://svn.asterisk.org/svn/asterisk/branches/13 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@423350 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -91,6 +91,7 @@ struct ast_sip_notifier dialog_notifier = {
|
||||
|
||||
struct ast_sip_subscription_handler presence_handler = {
|
||||
.event_name = "presence",
|
||||
.body_type = AST_SIP_EXTEN_STATE_DATA,
|
||||
.accept = { DEFAULT_PRESENCE_BODY, },
|
||||
.subscription_shutdown = subscription_shutdown,
|
||||
.to_ami = to_ami,
|
||||
@@ -99,6 +100,7 @@ struct ast_sip_subscription_handler presence_handler = {
|
||||
|
||||
struct ast_sip_subscription_handler dialog_handler = {
|
||||
.event_name = "dialog",
|
||||
.body_type = AST_SIP_EXTEN_STATE_DATA,
|
||||
.accept = { DEFAULT_DIALOG_BODY, },
|
||||
.subscription_shutdown = subscription_shutdown,
|
||||
.to_ami = to_ami,
|
||||
@@ -221,6 +223,10 @@ static struct notify_task_data *alloc_notify_task_data(char *exten, struct exten
|
||||
static int notify_task(void *obj)
|
||||
{
|
||||
RAII_VAR(struct notify_task_data *, task_data, obj, ao2_cleanup);
|
||||
struct ast_sip_body_data data = {
|
||||
.body_type = AST_SIP_EXTEN_STATE_DATA,
|
||||
.body_data = &task_data->exten_state_data,
|
||||
};
|
||||
|
||||
/* Pool allocation has to happen here so that we allocate within a PJLIB thread */
|
||||
task_data->exten_state_data.pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
|
||||
@@ -231,7 +237,7 @@ static int notify_task(void *obj)
|
||||
|
||||
task_data->exten_state_data.sub = task_data->exten_state_sub->sip_sub;
|
||||
|
||||
ast_sip_subscription_notify(task_data->exten_state_sub->sip_sub, &task_data->exten_state_data,
|
||||
ast_sip_subscription_notify(task_data->exten_state_sub->sip_sub, &data,
|
||||
task_data->terminate);
|
||||
|
||||
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(),
|
||||
|
Reference in New Issue
Block a user