2013-06-22 14:03:22 +00:00
|
|
|
/*
|
|
|
|
* Asterisk -- An open source telephony toolkit.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2013, Digium, Inc.
|
|
|
|
*
|
|
|
|
* Kevin Harwell <kharwell@digium.com>
|
|
|
|
*
|
|
|
|
* See http://www.asterisk.org for more information about
|
|
|
|
* the Asterisk project. Please do not directly contact
|
|
|
|
* any of the maintainers of this project for assistance;
|
|
|
|
* the project provides a web site, mailing lists and IRC
|
|
|
|
* channels for your use.
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*** MODULEINFO
|
|
|
|
<depend>pjproject</depend>
|
2013-07-30 18:14:50 +00:00
|
|
|
<depend>res_pjsip</depend>
|
|
|
|
<depend>res_pjsip_pubsub</depend>
|
2016-04-14 12:03:24 +00:00
|
|
|
<depend>res_pjsip_outbound_publish</depend>
|
2013-06-22 14:03:22 +00:00
|
|
|
<support_level>core</support_level>
|
|
|
|
***/
|
|
|
|
|
|
|
|
#include "asterisk.h"
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
#include <regex.h>
|
|
|
|
|
2013-06-22 14:03:22 +00:00
|
|
|
#include <pjsip.h>
|
|
|
|
#include <pjsip_simple.h>
|
|
|
|
#include <pjlib.h>
|
|
|
|
|
2013-07-30 18:14:50 +00:00
|
|
|
#include "asterisk/res_pjsip.h"
|
2016-04-14 12:03:24 +00:00
|
|
|
#include "asterisk/res_pjsip_outbound_publish.h"
|
2013-07-30 18:14:50 +00:00
|
|
|
#include "asterisk/res_pjsip_pubsub.h"
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
#include "asterisk/res_pjsip_body_generator_types.h"
|
2013-06-22 14:03:22 +00:00
|
|
|
#include "asterisk/module.h"
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
#include "asterisk/astobj2.h"
|
|
|
|
#include "asterisk/sorcery.h"
|
|
|
|
#include "asterisk/app.h"
|
2015-05-06 18:24:29 +00:00
|
|
|
#include "asterisk/taskprocessor.h"
|
2013-06-22 14:03:22 +00:00
|
|
|
|
|
|
|
#define BODY_SIZE 1024
|
|
|
|
#define EVENT_TYPE_SIZE 50
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
/*!
|
|
|
|
* \brief The number of buckets to use for storing publishers
|
|
|
|
*/
|
|
|
|
#define PUBLISHER_BUCKETS 31
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Container of active outbound extension state publishers
|
|
|
|
*/
|
|
|
|
static struct ao2_container *publishers;
|
|
|
|
|
2016-04-27 22:19:53 +00:00
|
|
|
/*! Serializer for outbound extension state publishing. */
|
|
|
|
static struct ast_taskprocessor *publish_exten_state_serializer;
|
|
|
|
|
2013-06-22 14:03:22 +00:00
|
|
|
/*!
|
|
|
|
* \brief A subscription for extension state
|
|
|
|
*
|
|
|
|
* This structure acts as the owner for the underlying SIP subscription. It
|
|
|
|
* also keeps a pointer to an associated "provider" so when a state changes
|
|
|
|
* a notify data creator is quickly accessible.
|
|
|
|
*/
|
|
|
|
struct exten_state_subscription {
|
|
|
|
/*! Watcher id when registering for extension state changes */
|
|
|
|
int id;
|
|
|
|
/*! The SIP subscription */
|
|
|
|
struct ast_sip_subscription *sip_sub;
|
2015-05-06 18:24:29 +00:00
|
|
|
/*! The serializer to use for notifications */
|
|
|
|
struct ast_taskprocessor *serializer;
|
2013-06-22 14:03:22 +00:00
|
|
|
/*! Context in which subscription looks for updates */
|
|
|
|
char context[AST_MAX_CONTEXT];
|
|
|
|
/*! Extension within the context to receive updates from */
|
|
|
|
char exten[AST_MAX_EXTENSION];
|
2014-02-25 17:51:51 +00:00
|
|
|
/*! The subscription's user agent */
|
|
|
|
char *user_agent;
|
2013-06-22 14:03:22 +00:00
|
|
|
/*! The last known extension state */
|
|
|
|
enum ast_extension_states last_exten_state;
|
2014-02-25 17:51:51 +00:00
|
|
|
/*! The last known presence state */
|
|
|
|
enum ast_presence_state last_presence_state;
|
2013-06-22 14:03:22 +00:00
|
|
|
};
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
/*!
|
|
|
|
* \brief An extension state publisher
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
struct exten_state_publisher {
|
|
|
|
/*! Regular expression for context filtering */
|
|
|
|
regex_t context_regex;
|
|
|
|
/*! Regular expression for extension filtering */
|
|
|
|
regex_t exten_regex;
|
|
|
|
/*! Publish client to use for sending publish messages */
|
|
|
|
struct ast_sip_outbound_publish_client *client;
|
2016-05-05 14:14:00 +00:00
|
|
|
/*! Datastores container to hold persistent information */
|
|
|
|
struct ao2_container *datastores;
|
2016-04-14 12:03:24 +00:00
|
|
|
/*! Whether context filtering is active */
|
|
|
|
unsigned int context_filter;
|
|
|
|
/*! Whether extension filtering is active */
|
|
|
|
unsigned int exten_filter;
|
|
|
|
/*! The body type to use for this publisher - stored after the name */
|
|
|
|
char *body_type;
|
|
|
|
/*! The body subtype to use for this publisher - stored after the body type */
|
|
|
|
char *body_subtype;
|
|
|
|
/*! The name of this publisher */
|
|
|
|
char name[0];
|
|
|
|
};
|
|
|
|
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
#define DEFAULT_PRESENCE_BODY "application/pidf+xml"
|
2014-07-07 16:08:47 +00:00
|
|
|
#define DEFAULT_DIALOG_BODY "application/dialog-info+xml"
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
|
|
|
|
static void subscription_shutdown(struct ast_sip_subscription *sub);
|
2014-06-25 20:57:28 +00:00
|
|
|
static int new_subscribe(struct ast_sip_endpoint *endpoint, const char *resource);
|
2014-08-07 19:26:32 +00:00
|
|
|
static int subscription_established(struct ast_sip_subscription *sub);
|
|
|
|
static void *get_notify_data(struct ast_sip_subscription *sub);
|
2022-02-01 15:59:02 +00:00
|
|
|
static int get_resource_display_name(struct ast_sip_endpoint *endpoint, const char *resource, char *display_name, int display_name_size);
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
static void to_ami(struct ast_sip_subscription *sub,
|
|
|
|
struct ast_str **buf);
|
2016-04-14 12:03:24 +00:00
|
|
|
static int publisher_start(struct ast_sip_outbound_publish *configuration,
|
|
|
|
struct ast_sip_outbound_publish_client *client);
|
|
|
|
static int publisher_stop(struct ast_sip_outbound_publish_client *client);
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
|
2014-06-25 20:57:28 +00:00
|
|
|
struct ast_sip_notifier presence_notifier = {
|
|
|
|
.default_accept = DEFAULT_PRESENCE_BODY,
|
|
|
|
.new_subscribe = new_subscribe,
|
2014-08-07 19:26:32 +00:00
|
|
|
.subscription_established = subscription_established,
|
|
|
|
.get_notify_data = get_notify_data,
|
2022-02-01 15:59:02 +00:00
|
|
|
.get_resource_display_name = get_resource_display_name,
|
2014-08-07 19:26:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct ast_sip_notifier dialog_notifier = {
|
|
|
|
.default_accept = DEFAULT_DIALOG_BODY,
|
|
|
|
.new_subscribe = new_subscribe,
|
|
|
|
.subscription_established = subscription_established,
|
|
|
|
.get_notify_data = get_notify_data,
|
2022-02-01 15:59:02 +00:00
|
|
|
.get_resource_display_name = get_resource_display_name,
|
2014-06-25 20:57:28 +00:00
|
|
|
};
|
|
|
|
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
struct ast_sip_subscription_handler presence_handler = {
|
|
|
|
.event_name = "presence",
|
2014-09-18 16:09:25 +00:00
|
|
|
.body_type = AST_SIP_EXTEN_STATE_DATA,
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
.accept = { DEFAULT_PRESENCE_BODY, },
|
|
|
|
.subscription_shutdown = subscription_shutdown,
|
|
|
|
.to_ami = to_ami,
|
2014-06-25 20:57:28 +00:00
|
|
|
.notifier = &presence_notifier,
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
};
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
struct ast_sip_event_publisher_handler presence_publisher = {
|
|
|
|
.event_name = "presence",
|
|
|
|
.start_publishing = publisher_start,
|
|
|
|
.stop_publishing = publisher_stop,
|
|
|
|
};
|
|
|
|
|
2014-07-07 16:08:47 +00:00
|
|
|
struct ast_sip_subscription_handler dialog_handler = {
|
|
|
|
.event_name = "dialog",
|
2014-09-18 16:09:25 +00:00
|
|
|
.body_type = AST_SIP_EXTEN_STATE_DATA,
|
2014-07-07 16:08:47 +00:00
|
|
|
.accept = { DEFAULT_DIALOG_BODY, },
|
|
|
|
.subscription_shutdown = subscription_shutdown,
|
|
|
|
.to_ami = to_ami,
|
2014-08-07 19:26:32 +00:00
|
|
|
.notifier = &dialog_notifier,
|
2014-07-07 16:08:47 +00:00
|
|
|
};
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
struct ast_sip_event_publisher_handler dialog_publisher = {
|
|
|
|
.event_name = "dialog",
|
|
|
|
.start_publishing = publisher_start,
|
|
|
|
.stop_publishing = publisher_stop,
|
|
|
|
};
|
|
|
|
|
2013-06-22 14:03:22 +00:00
|
|
|
static void exten_state_subscription_destructor(void *obj)
|
|
|
|
{
|
|
|
|
struct exten_state_subscription *sub = obj;
|
|
|
|
|
2014-02-25 17:51:51 +00:00
|
|
|
ast_free(sub->user_agent);
|
res_pjsip_pubsub: Solidify lifetime and ownership of objects.
There have been crashes and general instability seen in the pubsub code,
so this patch introduces three changes to increase the stability.
First, the ownership model for subscriptions has been modified. Due to
RLS, subscriptions are stored in memory as a tree structure. Prior to my
patch, the PJSIP subscription was the owner of the subscription tree.
When the PJSIP subscription told us that it was terminating, we started
destroying the subscription tree along with all of the individual leaf
subscriptions that belong to the tree. The problem with this model is
that the two actors in play here, the PJSIP subscription and the
individual leaf subscriptions, need to have joint ownership of the
subscription tree. So now, the PJSIP subscription and the individual
leaf subscriptions each have a reference to the subscription tree. This
way, we will not actually free memory until no players are left that
care. The PJSIP subscription is a bigger stakeholder, in that if the
PJSIP subscription's reference to the subscription tree is removed, the
subscription tree instructs the leaf subscriptions to shut down and drop
their references to the subscription tree when possible. The individual
leaf subscriptions, upon being told to shut down, can drop their stasis
subscriptions or whatever they use to learn of new state, and then drop
their reference to the subscription tree once they are ready to die.
Second, the lifetime of a PJSIP subscription's reference to our
subscription tree has been altered. As I learned from doing a deep dive,
the PJSIP evsub code can tell Asterisk multiple times that the
subscription has been terminated, and not all of these times
are especially helpful. I have altered the message flow that we use for
SIP subscriptions such that we will always drop the PJSIP subscription's
reference to the subscription tree when we send the NOTIFY that
terminates a SIP subscription. This also means that we will now queue
NOTIFY requests to be sent after responding to incoming SUBSCRIBEs so
that we can have predictable state changes from the PJSIP evsub code.
Third, the synchronization of operations has been improved. PJSIP can
call into our code from a serializer thread (e.g. upon receiving an
incoming request) or from the monitor thread (e.g. when a subscription
times out). Because of this, there is the possibility of competing
threads stepping on each other. PJSIP attempts to do some
synchronization on its own by always keeping the dialog lock held when
it calls into us. However, since we end up pushing tasks into the
serializer, the result was that serialized operations were not grabbing
the dialog lock and could, as a result, step on something that was being
attempted by a different thread. Now we ensure that serialized
operations grab the dialog lock, then check for extenuating
circumstances, then proceed with their operation if they can.
Change-Id: Iff2990c40178dad9cc5f6a5c7f76932ec644b2e5
2015-09-01 20:47:19 +00:00
|
|
|
ast_sip_subscription_destroy(sub->sip_sub);
|
2015-05-06 18:24:29 +00:00
|
|
|
ast_taskprocessor_unreference(sub->serializer);
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 20:57:28 +00:00
|
|
|
static char *get_user_agent(const struct ast_sip_subscription *sip_sub)
|
2014-02-25 17:51:51 +00:00
|
|
|
{
|
|
|
|
size_t size;
|
|
|
|
char *user_agent = NULL;
|
2014-06-25 20:57:28 +00:00
|
|
|
pjsip_user_agent_hdr *user_agent_hdr = ast_sip_subscription_get_header(
|
|
|
|
sip_sub, "User-Agent");
|
2014-02-25 17:51:51 +00:00
|
|
|
|
|
|
|
if (!user_agent_hdr) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = pj_strlen(&user_agent_hdr->hvalue) + 1;
|
|
|
|
user_agent = ast_malloc(size);
|
|
|
|
ast_copy_pj_str(user_agent, &user_agent_hdr->hvalue, size);
|
|
|
|
return ast_str_to_lower(user_agent);
|
|
|
|
}
|
|
|
|
|
2013-06-22 14:03:22 +00:00
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Initialize the last extension state to something outside
|
|
|
|
* its usual states.
|
|
|
|
*/
|
|
|
|
#define INITIAL_LAST_EXTEN_STATE -3
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Allocates an exten_state_subscription object.
|
|
|
|
*
|
|
|
|
* Creates the underlying SIP subscription for the given request. First makes
|
|
|
|
* sure that there are registered handler and provider objects available.
|
|
|
|
*/
|
|
|
|
static struct exten_state_subscription *exten_state_subscription_alloc(
|
2014-06-25 20:57:28 +00:00
|
|
|
struct ast_sip_subscription *sip_sub, struct ast_sip_endpoint *endpoint)
|
2013-06-22 14:03:22 +00:00
|
|
|
{
|
2014-06-25 20:57:28 +00:00
|
|
|
struct exten_state_subscription * exten_state_sub;
|
2013-06-22 14:03:22 +00:00
|
|
|
|
2014-06-25 20:57:28 +00:00
|
|
|
exten_state_sub = ao2_alloc(sizeof(*exten_state_sub), exten_state_subscription_destructor);
|
2013-06-22 14:03:22 +00:00
|
|
|
if (!exten_state_sub) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
res_pjsip_pubsub: Solidify lifetime and ownership of objects.
There have been crashes and general instability seen in the pubsub code,
so this patch introduces three changes to increase the stability.
First, the ownership model for subscriptions has been modified. Due to
RLS, subscriptions are stored in memory as a tree structure. Prior to my
patch, the PJSIP subscription was the owner of the subscription tree.
When the PJSIP subscription told us that it was terminating, we started
destroying the subscription tree along with all of the individual leaf
subscriptions that belong to the tree. The problem with this model is
that the two actors in play here, the PJSIP subscription and the
individual leaf subscriptions, need to have joint ownership of the
subscription tree. So now, the PJSIP subscription and the individual
leaf subscriptions each have a reference to the subscription tree. This
way, we will not actually free memory until no players are left that
care. The PJSIP subscription is a bigger stakeholder, in that if the
PJSIP subscription's reference to the subscription tree is removed, the
subscription tree instructs the leaf subscriptions to shut down and drop
their references to the subscription tree when possible. The individual
leaf subscriptions, upon being told to shut down, can drop their stasis
subscriptions or whatever they use to learn of new state, and then drop
their reference to the subscription tree once they are ready to die.
Second, the lifetime of a PJSIP subscription's reference to our
subscription tree has been altered. As I learned from doing a deep dive,
the PJSIP evsub code can tell Asterisk multiple times that the
subscription has been terminated, and not all of these times
are especially helpful. I have altered the message flow that we use for
SIP subscriptions such that we will always drop the PJSIP subscription's
reference to the subscription tree when we send the NOTIFY that
terminates a SIP subscription. This also means that we will now queue
NOTIFY requests to be sent after responding to incoming SUBSCRIBEs so
that we can have predictable state changes from the PJSIP evsub code.
Third, the synchronization of operations has been improved. PJSIP can
call into our code from a serializer thread (e.g. upon receiving an
incoming request) or from the monitor thread (e.g. when a subscription
times out). Because of this, there is the possibility of competing
threads stepping on each other. PJSIP attempts to do some
synchronization on its own by always keeping the dialog lock held when
it calls into us. However, since we end up pushing tasks into the
serializer, the result was that serialized operations were not grabbing
the dialog lock and could, as a result, step on something that was being
attempted by a different thread. Now we ensure that serialized
operations grab the dialog lock, then check for extenuating
circumstances, then proceed with their operation if they can.
Change-Id: Iff2990c40178dad9cc5f6a5c7f76932ec644b2e5
2015-09-01 20:47:19 +00:00
|
|
|
exten_state_sub->sip_sub = sip_sub;
|
2015-05-06 18:24:29 +00:00
|
|
|
|
|
|
|
/* We keep our own reference to the serializer as there is no guarantee in state_changed
|
|
|
|
* that the subscription tree is still valid when it is called. This can occur when
|
|
|
|
* the subscription is terminated at around the same time as the state_changed
|
|
|
|
* callback is invoked.
|
|
|
|
*/
|
|
|
|
exten_state_sub->serializer = ao2_bump(ast_sip_subscription_get_serializer(sip_sub));
|
2013-06-22 14:03:22 +00:00
|
|
|
exten_state_sub->last_exten_state = INITIAL_LAST_EXTEN_STATE;
|
2014-02-25 17:51:51 +00:00
|
|
|
exten_state_sub->last_presence_state = AST_PRESENCE_NOT_SET;
|
2014-06-25 20:57:28 +00:00
|
|
|
exten_state_sub->user_agent = get_user_agent(sip_sub);
|
2013-06-22 14:03:22 +00:00
|
|
|
return exten_state_sub;
|
|
|
|
}
|
|
|
|
|
|
|
|
struct notify_task_data {
|
|
|
|
struct ast_sip_exten_state_data exten_state_data;
|
|
|
|
struct exten_state_subscription *exten_state_sub;
|
2014-06-25 20:57:28 +00:00
|
|
|
int terminate;
|
2013-06-22 14:03:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static void notify_task_data_destructor(void *obj)
|
|
|
|
{
|
|
|
|
struct notify_task_data *task_data = obj;
|
|
|
|
|
|
|
|
ao2_ref(task_data->exten_state_sub, -1);
|
|
|
|
ao2_cleanup(task_data->exten_state_data.device_state_info);
|
2014-02-25 17:51:51 +00:00
|
|
|
ast_free(task_data->exten_state_data.presence_subtype);
|
|
|
|
ast_free(task_data->exten_state_data.presence_message);
|
|
|
|
ast_free(task_data->exten_state_data.user_agent);
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2016-04-06 22:57:20 +00:00
|
|
|
static struct notify_task_data *alloc_notify_task_data(const char *exten,
|
|
|
|
struct exten_state_subscription *exten_state_sub,
|
|
|
|
struct ast_state_cb_info *info)
|
2013-06-22 14:03:22 +00:00
|
|
|
{
|
|
|
|
struct notify_task_data *task_data =
|
|
|
|
ao2_alloc(sizeof(*task_data), notify_task_data_destructor);
|
|
|
|
|
|
|
|
if (!task_data) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to create notify task data\n");
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
task_data->exten_state_sub = exten_state_sub;
|
|
|
|
task_data->exten_state_sub->last_exten_state = info->exten_state;
|
2014-02-25 17:51:51 +00:00
|
|
|
task_data->exten_state_sub->last_presence_state = info->presence_state;
|
2013-06-22 14:03:22 +00:00
|
|
|
ao2_ref(task_data->exten_state_sub, +1);
|
|
|
|
|
|
|
|
task_data->exten_state_data.exten = exten_state_sub->exten;
|
|
|
|
task_data->exten_state_data.exten_state = info->exten_state;
|
|
|
|
task_data->exten_state_data.presence_state = info->presence_state;
|
2014-02-25 17:51:51 +00:00
|
|
|
task_data->exten_state_data.presence_subtype = ast_strdup(info->presence_subtype);
|
|
|
|
task_data->exten_state_data.presence_message = ast_strdup(info->presence_message);
|
|
|
|
task_data->exten_state_data.user_agent = ast_strdup(exten_state_sub->user_agent);
|
2014-08-07 19:26:32 +00:00
|
|
|
task_data->exten_state_data.device_state_info = ao2_bump(info->device_state_info);
|
|
|
|
task_data->exten_state_data.sub = exten_state_sub->sip_sub;
|
2016-05-05 14:14:00 +00:00
|
|
|
task_data->exten_state_data.datastores = ast_sip_subscription_get_datastores(exten_state_sub->sip_sub);
|
2013-06-22 14:03:22 +00:00
|
|
|
|
|
|
|
if ((info->exten_state == AST_EXTENSION_DEACTIVATED) ||
|
|
|
|
(info->exten_state == AST_EXTENSION_REMOVED)) {
|
2015-01-29 16:47:28 +00:00
|
|
|
ast_verb(2, "Watcher for hint %s %s\n", exten, info->exten_state
|
2013-06-22 14:03:22 +00:00
|
|
|
== AST_EXTENSION_REMOVED ? "removed" : "deactivated");
|
2014-06-25 20:57:28 +00:00
|
|
|
task_data->terminate = 1;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return task_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int notify_task(void *obj)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct notify_task_data *, task_data, obj, ao2_cleanup);
|
2014-09-18 16:09:25 +00:00
|
|
|
struct ast_sip_body_data data = {
|
|
|
|
.body_type = AST_SIP_EXTEN_STATE_DATA,
|
|
|
|
.body_data = &task_data->exten_state_data,
|
|
|
|
};
|
2013-06-22 14:03:22 +00:00
|
|
|
|
2022-08-03 14:55:47 +00:00
|
|
|
/* The subscription was terminated while notify_task was in queue.
|
|
|
|
Terminated subscriptions are no longer associated with a valid tree, and sending
|
2015-05-06 18:24:29 +00:00
|
|
|
* NOTIFY messages on a subscription which has already been terminated won't work.
|
|
|
|
*/
|
|
|
|
if (ast_sip_subscription_is_terminated(task_data->exten_state_sub->sip_sub)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* All access to the subscription must occur within a task executed within its serializer */
|
|
|
|
ast_sip_subscription_get_local_uri(task_data->exten_state_sub->sip_sub,
|
|
|
|
task_data->exten_state_data.local, sizeof(task_data->exten_state_data.local));
|
|
|
|
ast_sip_subscription_get_remote_uri(task_data->exten_state_sub->sip_sub,
|
|
|
|
task_data->exten_state_data.remote, sizeof(task_data->exten_state_data.remote));
|
|
|
|
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
/* 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(),
|
|
|
|
"exten_state", 1024, 1024);
|
2014-08-07 19:26:32 +00:00
|
|
|
if (!task_data->exten_state_data.pool) {
|
|
|
|
return -1;
|
|
|
|
}
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
|
2014-07-07 16:08:47 +00:00
|
|
|
task_data->exten_state_data.sub = task_data->exten_state_sub->sip_sub;
|
2016-05-05 14:14:00 +00:00
|
|
|
task_data->exten_state_data.datastores = ast_sip_subscription_get_datastores(task_data->exten_state_sub->sip_sub);
|
2014-07-07 16:08:47 +00:00
|
|
|
|
2014-09-18 16:09:25 +00:00
|
|
|
ast_sip_subscription_notify(task_data->exten_state_sub->sip_sub, &data,
|
2014-06-25 20:57:28 +00:00
|
|
|
task_data->terminate);
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
|
|
|
|
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(),
|
|
|
|
task_data->exten_state_data.pool);
|
2013-06-22 14:03:22 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Callback for exten/device state changes.
|
|
|
|
*
|
|
|
|
* Upon state change, send the appropriate notification to the subscriber.
|
|
|
|
*/
|
2016-04-06 22:57:20 +00:00
|
|
|
static int state_changed(const char *context, const char *exten,
|
|
|
|
struct ast_state_cb_info *info, void *data)
|
2013-06-22 14:03:22 +00:00
|
|
|
{
|
|
|
|
struct notify_task_data *task_data;
|
|
|
|
struct exten_state_subscription *exten_state_sub = data;
|
|
|
|
|
2022-08-03 14:55:47 +00:00
|
|
|
/* Terminated subscriptions are no longer associated with a valid tree.
|
|
|
|
* Do not queue notify_task.
|
|
|
|
*/
|
|
|
|
if (ast_sip_subscription_is_terminated(exten_state_sub->sip_sub)) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-06-22 14:03:22 +00:00
|
|
|
if (!(task_data = alloc_notify_task_data(exten, exten_state_sub, info))) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* safe to push this async since we copy the data from info and
|
|
|
|
add a ref for the device state info */
|
2015-05-06 18:24:29 +00:00
|
|
|
if (ast_sip_push_task(task_data->exten_state_sub->serializer, notify_task,
|
|
|
|
task_data)) {
|
2013-06-22 14:03:22 +00:00
|
|
|
ao2_cleanup(task_data);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void state_changed_destroy(int id, void *data)
|
|
|
|
{
|
|
|
|
struct exten_state_subscription *exten_state_sub = data;
|
|
|
|
ao2_cleanup(exten_state_sub);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct ast_datastore_info ds_info = { };
|
|
|
|
static const char ds_name[] = "exten state datastore";
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Add a datastore for exten exten_state_subscription.
|
|
|
|
*
|
|
|
|
* Adds the exten_state_subscription wrapper object to a datastore so it can be retrieved
|
|
|
|
* later based upon its association with the ast_sip_subscription.
|
|
|
|
*/
|
|
|
|
static int add_datastore(struct exten_state_subscription *exten_state_sub)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_datastore *, datastore,
|
|
|
|
ast_sip_subscription_alloc_datastore(&ds_info, ds_name), ao2_cleanup);
|
|
|
|
|
|
|
|
if (!datastore) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
datastore->data = exten_state_sub;
|
|
|
|
ast_sip_subscription_add_datastore(exten_state_sub->sip_sub, datastore);
|
|
|
|
ao2_ref(exten_state_sub, +1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Get the exten_state_subscription object associated with the given
|
|
|
|
* ast_sip_subscription in the datastore.
|
|
|
|
*/
|
|
|
|
static struct exten_state_subscription *get_exten_state_sub(
|
|
|
|
struct ast_sip_subscription *sub)
|
|
|
|
{
|
|
|
|
RAII_VAR(struct ast_datastore *, datastore,
|
|
|
|
ast_sip_subscription_get_datastore(sub, ds_name), ao2_cleanup);
|
|
|
|
|
|
|
|
return datastore ? datastore->data : NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void subscription_shutdown(struct ast_sip_subscription *sub)
|
|
|
|
{
|
|
|
|
struct exten_state_subscription *exten_state_sub = get_exten_state_sub(sub);
|
|
|
|
|
|
|
|
if (!exten_state_sub) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_extension_state_del(exten_state_sub->id, state_changed);
|
|
|
|
ast_sip_subscription_remove_datastore(exten_state_sub->sip_sub, ds_name);
|
|
|
|
/* remove data store reference */
|
|
|
|
ao2_cleanup(exten_state_sub);
|
|
|
|
}
|
|
|
|
|
2014-06-25 20:57:28 +00:00
|
|
|
static int new_subscribe(struct ast_sip_endpoint *endpoint,
|
|
|
|
const char *resource)
|
2013-06-22 14:03:22 +00:00
|
|
|
{
|
2016-07-06 14:29:27 +00:00
|
|
|
const char *context = S_OR(endpoint->subscription.context, endpoint->context);
|
|
|
|
|
|
|
|
if (!ast_exists_extension(NULL, context, resource, PRIORITY_HINT, NULL)) {
|
res_pjsip_pubsub: Correctly implement persisted subscriptions
This patch fixes 2 original issues and more that those 2 exposed.
* When we send a NOTIFY, and the client either doesn't respond or
responds with a non OK, pjproject only calls our
pubsub_on_evsub_state callback, no others. Since
pubsub_on_evsub_state (which does the sub_tree cleanup) does not
expect to be called back without the other callbacks being called
first, it just returns leaving the sub_tree orphaned. Now
pubsub_on_evsub_state checks the event for PJSIP_EVENT_TSX_STATE
which is what pjproject will set to tell us that it was the
transaction that timed out or failed and not the subscription
itself timing our or being terminated by the client. If is
TSX_STATE, pubsub_on_evsub_state now does the proper cleanup
regardless of the state of the subscription.
* When a client renews a subscription, we don't update the
persisted subscription with the new expires timestamp. This causes
subscription_persistence_recreate to prune the subscription if/when
asterisk restarts. Now, pubsub_on_rx_refresh calls
subscription_persistence_update to apply the new expires timestamp.
This exposed other issues however...
* When creating a dialog from rdata (which sub_persistence_recreate
does from the packet buffer) there must NOT be a tag on the To
header (which there will be when a client refreshes a
subscription). If there is one, pjsip_dlg_create_uas will fail.
To address this, subscription_persistence_update now accepts a flag
that indicates that the original packet buffer must not be updated.
New subscribes don't set the flag and renews do. This makes sure
that when the rdata is recreated on asterisk startup, it's done
from the original subscribe packet which won't have the tag on To.
* When creating a dialog from rdata, we were setting the dialog's
remote (SUBSCRIBE) cseq to be the same as the local (NOTIFY) cseq.
When the client tried to resubscribe after a restart with the
correct cseq, we'd reject the request with an Invalid CSeq error.
* The acts of creating a dialog and evsub by themselves when
recreating a subscription does NOT restart pjproject's subscription
timer. The result was that even if we did correctly recreate the
subscription, we never removed it if the client happened to go away
or send a non-OK response to a NOTIFY. However, there is no
pjproject function exposed to just set the timer on an evsub that
wasn't created by an incoming subscribe request. To address this,
we create our own timer using ast_sip_schedule_task. This timer is
used only for re-establishing subscriptions after a restart.
An earlier approach was to add support for setting pjproject's
timer (via a pjproject patch) and while that patch is still included
here, we don't use that call at the moment.
While addressing these issues, additional debugging was added and
some existing messages made more useful. A few formatting changes
were also made to 'pjsip show scheduled tasks' to make displaying
the subscription timers a little more friendly.
ASTERISK-26696
ASTERISK-26756
Change-Id: I8c605fc1e3923f466a74db087d5ab6f90abce68e
2017-02-07 19:17:12 +00:00
|
|
|
ast_log(LOG_NOTICE, "Endpoint '%s' state subscription failed: "
|
|
|
|
"Extension '%s' does not exist in context '%s' or has no associated hint\n",
|
|
|
|
ast_sorcery_object_get_id(endpoint), resource, context);
|
2014-06-25 20:57:28 +00:00
|
|
|
return 404;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 20:57:28 +00:00
|
|
|
return 200;
|
|
|
|
}
|
|
|
|
|
2022-02-01 15:59:02 +00:00
|
|
|
static int get_resource_display_name(struct ast_sip_endpoint *endpoint,
|
|
|
|
const char *resource, char *display_name, int display_name_size)
|
|
|
|
{
|
|
|
|
const char *context;
|
|
|
|
|
|
|
|
if (!endpoint || ast_strlen_zero(resource) || !display_name || display_name_size <= 0) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
context = S_OR(endpoint->subscription.context, endpoint->context);
|
|
|
|
|
|
|
|
if (!ast_get_hint(NULL, 0, display_name, display_name_size, NULL, context, resource)) {
|
|
|
|
ast_log(LOG_NOTICE, "Endpoint '%s': "
|
|
|
|
"Extension '%s' does not exist in context '%s' or has no associated hint\n",
|
|
|
|
ast_sorcery_object_get_id(endpoint), resource, context);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-08-07 19:26:32 +00:00
|
|
|
static int subscription_established(struct ast_sip_subscription *sip_sub)
|
2014-06-25 20:57:28 +00:00
|
|
|
{
|
|
|
|
struct ast_sip_endpoint *endpoint = ast_sip_subscription_get_endpoint(sip_sub);
|
|
|
|
const char *resource = ast_sip_subscription_get_resource_name(sip_sub);
|
|
|
|
struct exten_state_subscription *exten_state_sub;
|
|
|
|
|
|
|
|
if (!(exten_state_sub = exten_state_subscription_alloc(sip_sub, endpoint))) {
|
|
|
|
ao2_cleanup(endpoint);
|
|
|
|
return -1;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2016-07-06 14:29:27 +00:00
|
|
|
ast_copy_string(exten_state_sub->context,
|
|
|
|
S_OR(endpoint->subscription.context, endpoint->context),
|
|
|
|
sizeof(exten_state_sub->context));
|
2014-06-25 20:57:28 +00:00
|
|
|
ast_copy_string(exten_state_sub->exten, resource, sizeof(exten_state_sub->exten));
|
2013-06-22 14:03:22 +00:00
|
|
|
|
|
|
|
if ((exten_state_sub->id = ast_extension_state_add_destroy_extended(
|
|
|
|
exten_state_sub->context, exten_state_sub->exten,
|
|
|
|
state_changed, state_changed_destroy, exten_state_sub)) < 0) {
|
2013-07-11 16:23:41 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to subscribe endpoint '%s' to extension '%s@%s'\n",
|
|
|
|
ast_sorcery_object_get_id(endpoint), exten_state_sub->exten,
|
|
|
|
exten_state_sub->context);
|
2014-06-25 20:57:28 +00:00
|
|
|
ao2_cleanup(endpoint);
|
|
|
|
ao2_cleanup(exten_state_sub);
|
|
|
|
return -1;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 20:57:28 +00:00
|
|
|
/* Go ahead and cleanup the endpoint since we don't need it anymore */
|
|
|
|
ao2_cleanup(endpoint);
|
|
|
|
|
2013-06-22 14:03:22 +00:00
|
|
|
/* bump the ref since ast_extension_state_add holds a reference */
|
|
|
|
ao2_ref(exten_state_sub, +1);
|
|
|
|
|
|
|
|
if (add_datastore(exten_state_sub)) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to add to subscription datastore.\n");
|
2014-06-25 20:57:28 +00:00
|
|
|
ao2_cleanup(exten_state_sub);
|
|
|
|
return -1;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2014-06-25 20:57:28 +00:00
|
|
|
ao2_cleanup(exten_state_sub);
|
|
|
|
return 0;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-07 19:26:32 +00:00
|
|
|
static void exten_state_data_destructor(void *obj)
|
2013-06-22 14:03:22 +00:00
|
|
|
{
|
2014-08-07 19:26:32 +00:00
|
|
|
struct ast_sip_exten_state_data *exten_state_data = obj;
|
2013-06-22 14:03:22 +00:00
|
|
|
|
2014-08-07 19:26:32 +00:00
|
|
|
ao2_cleanup(exten_state_data->device_state_info);
|
|
|
|
ast_free(exten_state_data->presence_subtype);
|
|
|
|
ast_free(exten_state_data->presence_message);
|
|
|
|
if (exten_state_data->pool) {
|
|
|
|
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), exten_state_data->pool);
|
|
|
|
}
|
|
|
|
}
|
2013-06-22 14:03:22 +00:00
|
|
|
|
2014-08-07 19:26:32 +00:00
|
|
|
static struct ast_sip_exten_state_data *exten_state_data_alloc(struct ast_sip_subscription *sip_sub,
|
|
|
|
struct exten_state_subscription *exten_state_sub)
|
|
|
|
{
|
|
|
|
struct ast_sip_exten_state_data *exten_state_data;
|
|
|
|
char *subtype = NULL;
|
|
|
|
char *message = NULL;
|
2015-04-09 12:57:21 +00:00
|
|
|
int presence_state;
|
2013-06-22 14:03:22 +00:00
|
|
|
|
2014-08-07 19:26:32 +00:00
|
|
|
exten_state_data = ao2_alloc(sizeof(*exten_state_data), exten_state_data_destructor);
|
|
|
|
if (!exten_state_data) {
|
|
|
|
return NULL;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2014-08-07 19:26:32 +00:00
|
|
|
exten_state_data->exten = exten_state_sub->exten;
|
2015-04-09 12:57:21 +00:00
|
|
|
presence_state = ast_hint_presence_state(NULL, exten_state_sub->context, exten_state_sub->exten, &subtype, &message);
|
|
|
|
if (presence_state == -1 || presence_state == AST_PRESENCE_INVALID) {
|
2014-08-07 19:26:32 +00:00
|
|
|
ao2_cleanup(exten_state_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
2015-04-09 12:57:21 +00:00
|
|
|
exten_state_data->presence_state = presence_state;
|
2014-08-07 19:26:32 +00:00
|
|
|
exten_state_data->presence_subtype = subtype;
|
|
|
|
exten_state_data->presence_message = message;
|
|
|
|
exten_state_data->user_agent = exten_state_sub->user_agent;
|
|
|
|
ast_sip_subscription_get_local_uri(sip_sub, exten_state_data->local,
|
|
|
|
sizeof(exten_state_data->local));
|
|
|
|
ast_sip_subscription_get_remote_uri(sip_sub, exten_state_data->remote,
|
|
|
|
sizeof(exten_state_data->remote));
|
|
|
|
exten_state_data->sub = sip_sub;
|
2016-05-05 14:14:00 +00:00
|
|
|
exten_state_data->datastores = ast_sip_subscription_get_datastores(sip_sub);
|
2014-08-07 19:26:32 +00:00
|
|
|
|
|
|
|
exten_state_data->exten_state = ast_extension_state_extended(
|
|
|
|
NULL, exten_state_sub->context, exten_state_sub->exten,
|
|
|
|
&exten_state_data->device_state_info);
|
|
|
|
if (exten_state_data->exten_state < 0) {
|
|
|
|
ao2_cleanup(exten_state_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
exten_state_data->pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
|
|
|
|
"exten_state", 1024, 1024);
|
|
|
|
if (!exten_state_data->pool) {
|
|
|
|
ao2_cleanup(exten_state_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return exten_state_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *get_notify_data(struct ast_sip_subscription *sub)
|
|
|
|
{
|
|
|
|
struct exten_state_subscription *exten_state_sub;
|
|
|
|
|
|
|
|
exten_state_sub = get_exten_state_sub(sub);
|
|
|
|
if (!exten_state_sub) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return exten_state_data_alloc(sub, exten_state_sub);
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2013-11-23 17:26:57 +00:00
|
|
|
static void to_ami(struct ast_sip_subscription *sub,
|
|
|
|
struct ast_str **buf)
|
|
|
|
{
|
|
|
|
struct exten_state_subscription *exten_state_sub =
|
|
|
|
get_exten_state_sub(sub);
|
|
|
|
|
2014-10-30 21:14:01 +00:00
|
|
|
if (!exten_state_sub) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-11-23 17:26:57 +00:00
|
|
|
ast_str_append(buf, 0, "SubscriptionType: extension_state\r\n"
|
|
|
|
"Extension: %s\r\nExtensionStates: %s\r\n",
|
|
|
|
exten_state_sub->exten, ast_extension_state2str(
|
|
|
|
exten_state_sub->last_exten_state));
|
|
|
|
}
|
|
|
|
|
2016-04-27 22:19:53 +00:00
|
|
|
struct exten_state_pub_data {
|
|
|
|
/*! Publishers needing state update */
|
|
|
|
AST_VECTOR(name, struct exten_state_publisher *) pubs;
|
|
|
|
/*! Body generator state data */
|
|
|
|
struct ast_sip_exten_state_data exten_state_data;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void exten_state_pub_data_destroy(struct exten_state_pub_data *doomed)
|
|
|
|
{
|
|
|
|
if (!doomed) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_free((void *) doomed->exten_state_data.exten);
|
|
|
|
ast_free(doomed->exten_state_data.presence_subtype);
|
|
|
|
ast_free(doomed->exten_state_data.presence_message);
|
|
|
|
ao2_cleanup(doomed->exten_state_data.device_state_info);
|
|
|
|
|
|
|
|
AST_VECTOR_CALLBACK_VOID(&doomed->pubs, ao2_ref, -1);
|
|
|
|
AST_VECTOR_FREE(&doomed->pubs);
|
|
|
|
|
|
|
|
ast_free(doomed);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct exten_state_pub_data *exten_state_pub_data_alloc(const char *exten, struct ast_state_cb_info *info)
|
|
|
|
{
|
|
|
|
struct exten_state_pub_data *pub_data;
|
|
|
|
|
|
|
|
pub_data = ast_calloc(1, sizeof(*pub_data));
|
|
|
|
if (!pub_data) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (AST_VECTOR_INIT(&pub_data->pubs, ao2_container_count(publishers))) {
|
|
|
|
exten_state_pub_data_destroy(pub_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Save off currently known information for the body generators. */
|
|
|
|
pub_data->exten_state_data.exten = ast_strdup(exten);
|
|
|
|
pub_data->exten_state_data.exten_state = info->exten_state;
|
|
|
|
pub_data->exten_state_data.presence_state = info->presence_state;
|
|
|
|
pub_data->exten_state_data.presence_subtype = ast_strdup(info->presence_subtype);
|
|
|
|
pub_data->exten_state_data.presence_message = ast_strdup(info->presence_message);
|
|
|
|
pub_data->exten_state_data.device_state_info = ao2_bump(info->device_state_info);
|
|
|
|
if (!pub_data->exten_state_data.exten
|
|
|
|
|| !pub_data->exten_state_data.presence_subtype
|
|
|
|
|| !pub_data->exten_state_data.presence_message) {
|
|
|
|
exten_state_pub_data_destroy(pub_data);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return pub_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \internal
|
|
|
|
* \brief Create exten state PUBLISH messages under PJSIP thread.
|
|
|
|
* \since 14.0.0
|
|
|
|
*
|
|
|
|
* \return 0
|
|
|
|
*/
|
|
|
|
static int exten_state_publisher_cb(void *data)
|
|
|
|
{
|
|
|
|
struct exten_state_pub_data *pub_data = data;
|
|
|
|
struct exten_state_publisher *publisher;
|
|
|
|
size_t idx;
|
|
|
|
struct ast_str *body_text;
|
|
|
|
pj_pool_t *pool;
|
|
|
|
struct ast_sip_body_data gen_data = {
|
|
|
|
.body_type = AST_SIP_EXTEN_STATE_DATA,
|
|
|
|
.body_data = &pub_data->exten_state_data,
|
|
|
|
};
|
|
|
|
struct ast_sip_body body;
|
|
|
|
|
|
|
|
body_text = ast_str_create(64);
|
|
|
|
if (!body_text) {
|
|
|
|
exten_state_pub_data_destroy(pub_data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Need a PJSIP memory pool to generate the bodies. */
|
|
|
|
pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "pub_state_body",
|
|
|
|
1024, 1024);
|
|
|
|
if (!pool) {
|
|
|
|
ast_log(LOG_WARNING, "Exten state publishing unable to create memory pool\n");
|
|
|
|
exten_state_pub_data_destroy(pub_data);
|
|
|
|
ast_free(body_text);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
pub_data->exten_state_data.pool = pool;
|
|
|
|
|
|
|
|
for (idx = 0; idx < AST_VECTOR_SIZE(&pub_data->pubs); ++idx) {
|
|
|
|
const char *uri;
|
|
|
|
int res;
|
|
|
|
|
|
|
|
publisher = AST_VECTOR_GET(&pub_data->pubs, idx);
|
|
|
|
|
2016-05-10 16:28:04 +00:00
|
|
|
uri = ast_sip_publish_client_get_user_from_uri(publisher->client, pub_data->exten_state_data.exten,
|
|
|
|
pub_data->exten_state_data.local, sizeof(pub_data->exten_state_data.local));
|
2016-04-27 22:19:53 +00:00
|
|
|
if (ast_strlen_zero(uri)) {
|
|
|
|
ast_log(LOG_WARNING, "PUBLISH client '%s' has no from_uri or server_uri defined.\n",
|
|
|
|
publisher->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-05-10 16:28:04 +00:00
|
|
|
uri = ast_sip_publish_client_get_user_to_uri(publisher->client, pub_data->exten_state_data.exten,
|
|
|
|
pub_data->exten_state_data.remote, sizeof(pub_data->exten_state_data.remote));
|
2016-04-27 22:19:53 +00:00
|
|
|
if (ast_strlen_zero(uri)) {
|
|
|
|
ast_log(LOG_WARNING, "PUBLISH client '%s' has no to_uri or server_uri defined.\n",
|
|
|
|
publisher->name);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-05-05 14:14:00 +00:00
|
|
|
pub_data->exten_state_data.datastores = publisher->datastores;
|
|
|
|
|
2016-04-27 22:19:53 +00:00
|
|
|
res = ast_sip_pubsub_generate_body_content(publisher->body_type,
|
|
|
|
publisher->body_subtype, &gen_data, &body_text);
|
|
|
|
pj_pool_reset(pool);
|
|
|
|
if (res) {
|
|
|
|
ast_log(LOG_WARNING,
|
|
|
|
"PUBLISH client '%s' unable to generate %s/%s PUBLISH body.\n",
|
|
|
|
publisher->name, publisher->body_type, publisher->body_subtype);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
body.type = publisher->body_type;
|
|
|
|
body.subtype = publisher->body_subtype;
|
|
|
|
body.body_text = ast_str_buffer(body_text);
|
2016-05-10 16:28:04 +00:00
|
|
|
ast_sip_publish_client_user_send(publisher->client, pub_data->exten_state_data.exten, &body);
|
2016-04-27 22:19:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
|
|
|
|
|
|
|
|
ast_free(body_text);
|
|
|
|
exten_state_pub_data_destroy(pub_data);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
/*!
|
|
|
|
* \brief Global extension state callback function
|
|
|
|
*/
|
|
|
|
static int exten_state_publisher_state_cb(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
|
|
|
|
{
|
|
|
|
struct ao2_iterator publisher_iter;
|
|
|
|
struct exten_state_publisher *publisher;
|
2016-04-27 22:19:53 +00:00
|
|
|
struct exten_state_pub_data *pub_data = NULL;
|
|
|
|
|
|
|
|
ast_debug(5, "Exten state publisher: %s@%s Reason:%s State:%s Presence:%s Subtype:'%s' Message:'%s'\n",
|
|
|
|
exten, context,
|
|
|
|
info->reason == AST_HINT_UPDATE_DEVICE
|
|
|
|
? "Device"
|
|
|
|
: info->reason == AST_HINT_UPDATE_PRESENCE
|
|
|
|
? "Presence"
|
|
|
|
: "Unknown",
|
|
|
|
ast_extension_state2str(info->exten_state),
|
|
|
|
ast_presence_state2str(info->presence_state),
|
|
|
|
S_OR(info->presence_subtype, ""),
|
|
|
|
S_OR(info->presence_message, ""));
|
2016-04-14 12:03:24 +00:00
|
|
|
publisher_iter = ao2_iterator_init(publishers, 0);
|
|
|
|
for (; (publisher = ao2_iterator_next(&publisher_iter)); ao2_ref(publisher, -1)) {
|
|
|
|
if ((publisher->context_filter && regexec(&publisher->context_regex, context, 0, NULL, 0)) ||
|
|
|
|
(publisher->exten_filter && regexec(&publisher->exten_regex, exten, 0, NULL, 0))) {
|
|
|
|
continue;
|
|
|
|
}
|
2016-04-27 22:19:53 +00:00
|
|
|
|
|
|
|
if (!pub_data) {
|
|
|
|
pub_data = exten_state_pub_data_alloc(exten, info);
|
|
|
|
if (!pub_data) {
|
|
|
|
ao2_ref(publisher, -1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ao2_ref(publisher, +1);
|
2017-11-06 23:48:06 +00:00
|
|
|
if (AST_VECTOR_APPEND(&pub_data->pubs, publisher)) {
|
|
|
|
ao2_ref(publisher, -1);
|
|
|
|
} else {
|
|
|
|
ast_debug(5, "'%s' will publish exten state\n", publisher->name);
|
|
|
|
}
|
2016-04-14 12:03:24 +00:00
|
|
|
}
|
|
|
|
ao2_iterator_destroy(&publisher_iter);
|
|
|
|
|
2016-04-27 22:19:53 +00:00
|
|
|
if (pub_data
|
|
|
|
&& ast_sip_push_task(publish_exten_state_serializer, exten_state_publisher_cb,
|
|
|
|
pub_data)) {
|
|
|
|
exten_state_pub_data_destroy(pub_data);
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Hashing function for extension state publisher
|
|
|
|
*/
|
|
|
|
static int exten_state_publisher_hash(const void *obj, const int flags)
|
|
|
|
{
|
|
|
|
const struct exten_state_publisher *object;
|
|
|
|
const char *key;
|
|
|
|
|
|
|
|
switch (flags & OBJ_SEARCH_MASK) {
|
|
|
|
case OBJ_SEARCH_KEY:
|
|
|
|
key = obj;
|
|
|
|
break;
|
|
|
|
case OBJ_SEARCH_OBJECT:
|
|
|
|
object = obj;
|
|
|
|
key = object->name;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ast_assert(0);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return ast_str_hash(key);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Comparator function for extension state publisher
|
|
|
|
*/
|
|
|
|
static int exten_state_publisher_cmp(void *obj, void *arg, int flags)
|
|
|
|
{
|
|
|
|
const struct exten_state_publisher *object_left = obj;
|
|
|
|
const struct exten_state_publisher *object_right = arg;
|
|
|
|
const char *right_key = arg;
|
|
|
|
int cmp;
|
|
|
|
|
|
|
|
switch (flags & OBJ_SEARCH_MASK) {
|
|
|
|
case OBJ_SEARCH_OBJECT:
|
|
|
|
right_key = object_right->name;
|
|
|
|
/* Fall through */
|
|
|
|
case OBJ_SEARCH_KEY:
|
|
|
|
cmp = strcmp(object_left->name, right_key);
|
|
|
|
break;
|
|
|
|
case OBJ_SEARCH_PARTIAL_KEY:
|
|
|
|
/* Not supported by container. */
|
|
|
|
ast_assert(0);
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
cmp = 0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (cmp) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return CMP_MATCH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Destructor for extension state publisher
|
|
|
|
*/
|
|
|
|
static void exten_state_publisher_destroy(void *obj)
|
|
|
|
{
|
|
|
|
struct exten_state_publisher *publisher = obj;
|
|
|
|
|
|
|
|
if (publisher->context_filter) {
|
|
|
|
regfree(&publisher->context_regex);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (publisher->exten_filter) {
|
|
|
|
regfree(&publisher->exten_regex);
|
|
|
|
}
|
|
|
|
|
|
|
|
ao2_cleanup(publisher->client);
|
2016-05-05 14:14:00 +00:00
|
|
|
ao2_cleanup(publisher->datastores);
|
2016-04-14 12:03:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int build_regex(regex_t *regex, const char *text)
|
|
|
|
{
|
|
|
|
int res;
|
|
|
|
|
|
|
|
if ((res = regcomp(regex, text, REG_EXTENDED | REG_ICASE | REG_NOSUB))) {
|
|
|
|
size_t len = regerror(res, regex, NULL, 0);
|
|
|
|
char buf[len];
|
|
|
|
regerror(res, regex, buf, len);
|
|
|
|
ast_log(LOG_ERROR, "Could not compile regex '%s': %s\n", text, buf);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int publisher_start(struct ast_sip_outbound_publish *configuration, struct ast_sip_outbound_publish_client *client)
|
|
|
|
{
|
|
|
|
struct exten_state_publisher *publisher;
|
|
|
|
size_t name_size;
|
|
|
|
size_t body_type_size;
|
|
|
|
size_t body_subtype_size;
|
|
|
|
char *body_subtype;
|
|
|
|
const char *body_full;
|
|
|
|
const char *body_type;
|
|
|
|
const char *name;
|
|
|
|
const char *context;
|
|
|
|
const char *exten;
|
|
|
|
|
|
|
|
name = ast_sorcery_object_get_id(configuration);
|
|
|
|
|
|
|
|
body_full = ast_sorcery_object_get_extended(configuration, "body");
|
|
|
|
if (ast_strlen_zero(body_full)) {
|
|
|
|
ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Body not set\n",
|
|
|
|
name);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
body_subtype = ast_strdupa(body_full);
|
|
|
|
body_type = strsep(&body_subtype, "/");
|
|
|
|
if (ast_strlen_zero(body_type) || ast_strlen_zero(body_subtype)) {
|
|
|
|
ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Body '%s' missing type or subtype\n",
|
|
|
|
name, body_full);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-04-26 21:10:26 +00:00
|
|
|
if (!ast_sip_pubsub_is_body_generator_registered(body_type, body_subtype)) {
|
|
|
|
ast_log(LOG_ERROR, "Outbound extension state publisher '%s': '%s' body generator not registered\n",
|
|
|
|
name, body_full);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
name_size = strlen(name) + 1;
|
|
|
|
body_type_size = strlen(body_type) + 1;
|
|
|
|
body_subtype_size = strlen(body_subtype) + 1;
|
|
|
|
|
|
|
|
publisher = ao2_alloc_options(
|
|
|
|
sizeof(*publisher) + name_size + body_type_size + body_subtype_size,
|
|
|
|
exten_state_publisher_destroy, AO2_ALLOC_OPT_LOCK_NOLOCK);
|
|
|
|
if (!publisher) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ast_copy_string(publisher->name, name, name_size);
|
|
|
|
publisher->body_type = publisher->name + name_size;
|
|
|
|
ast_copy_string(publisher->body_type, body_type, body_type_size);
|
|
|
|
publisher->body_subtype = publisher->body_type + body_type_size;
|
|
|
|
ast_copy_string(publisher->body_subtype, body_subtype, body_subtype_size);
|
|
|
|
|
|
|
|
context = ast_sorcery_object_get_extended(configuration, "context");
|
|
|
|
if (!ast_strlen_zero(context)) {
|
|
|
|
if (build_regex(&publisher->context_regex, context)) {
|
|
|
|
ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Could not build context filter '%s'\n",
|
|
|
|
name, context);
|
|
|
|
ao2_ref(publisher, -1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
publisher->context_filter = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
exten = ast_sorcery_object_get_extended(configuration, "exten");
|
|
|
|
if (!ast_strlen_zero(exten)) {
|
|
|
|
if (build_regex(&publisher->exten_regex, exten)) {
|
|
|
|
ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Could not build exten filter '%s'\n",
|
|
|
|
name, exten);
|
|
|
|
ao2_ref(publisher, -1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
publisher->exten_filter = 1;
|
|
|
|
}
|
|
|
|
|
2016-05-05 14:14:00 +00:00
|
|
|
publisher->datastores = ast_datastores_alloc();
|
|
|
|
if (!publisher->datastores) {
|
|
|
|
ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Could not create datastores container\n",
|
|
|
|
name);
|
|
|
|
ao2_ref(publisher, -1);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
publisher->client = ao2_bump(client);
|
|
|
|
|
|
|
|
ao2_lock(publishers);
|
|
|
|
if (!ao2_container_count(publishers)) {
|
|
|
|
ast_extension_state_add(NULL, NULL, exten_state_publisher_state_cb, NULL);
|
|
|
|
}
|
|
|
|
ao2_link_flags(publishers, publisher, OBJ_NOLOCK);
|
|
|
|
ao2_unlock(publishers);
|
|
|
|
|
|
|
|
ao2_ref(publisher, -1);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int publisher_stop(struct ast_sip_outbound_publish_client *client)
|
|
|
|
{
|
|
|
|
ao2_find(publishers, ast_sorcery_object_get_id(client), OBJ_SEARCH_KEY | OBJ_UNLINK | OBJ_NODATA);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int unload_module(void)
|
|
|
|
{
|
2023-10-19 13:40:26 +00:00
|
|
|
/*
|
2022-10-16 20:35:29 +00:00
|
|
|
* pjsip_evsub_register_pkg is called by ast_sip_register_subscription_handler
|
|
|
|
* but there is no corresponding unregister function, so unloading
|
|
|
|
* a module does not remove the event package. If this module is ever
|
|
|
|
* loaded again, then pjproject will assert and cause a crash.
|
2023-10-19 13:40:26 +00:00
|
|
|
* For that reason, we must only be allowed to unload when
|
|
|
|
* asterisk is shutting down. If a pjsip_evsub_unregister_pkg
|
|
|
|
* API is added in the future then we should go back to unloading
|
|
|
|
* the module as intended.
|
2022-10-16 20:35:29 +00:00
|
|
|
*/
|
2023-10-19 13:40:26 +00:00
|
|
|
|
|
|
|
if (ast_shutdown_final()) {
|
|
|
|
ast_sip_unregister_event_publisher_handler(&dialog_publisher);
|
|
|
|
ast_sip_unregister_subscription_handler(&dialog_handler);
|
|
|
|
ast_sip_unregister_event_publisher_handler(&presence_publisher);
|
|
|
|
ast_sip_unregister_subscription_handler(&presence_handler);
|
|
|
|
|
|
|
|
ast_extension_state_del(0, exten_state_publisher_state_cb);
|
|
|
|
|
|
|
|
ast_taskprocessor_unreference(publish_exten_state_serializer);
|
|
|
|
publish_exten_state_serializer = NULL;
|
|
|
|
|
|
|
|
ao2_cleanup(publishers);
|
|
|
|
publishers = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
2016-04-14 12:03:24 +00:00
|
|
|
}
|
|
|
|
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
static int load_module(void)
|
2013-06-22 14:03:22 +00:00
|
|
|
{
|
2018-11-19 20:10:02 +00:00
|
|
|
publishers = ao2_container_alloc_hash(AO2_ALLOC_OPT_LOCK_MUTEX, 0,
|
|
|
|
PUBLISHER_BUCKETS, exten_state_publisher_hash, NULL, exten_state_publisher_cmp);
|
2016-04-14 12:03:24 +00:00
|
|
|
if (!publishers) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to create container to store extension state publishers\n");
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
}
|
2014-10-16 16:32:25 +00:00
|
|
|
|
2016-04-27 22:19:53 +00:00
|
|
|
publish_exten_state_serializer = ast_sip_create_serializer("pjsip/exten_state");
|
|
|
|
if (!publish_exten_state_serializer) {
|
|
|
|
unload_module();
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
}
|
|
|
|
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
if (ast_sip_register_subscription_handler(&presence_handler)) {
|
2013-06-22 14:03:22 +00:00
|
|
|
ast_log(LOG_WARNING, "Unable to register subscription handler %s\n",
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
presence_handler.event_name);
|
2016-04-14 12:03:24 +00:00
|
|
|
unload_module();
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ast_sip_register_event_publisher_handler(&presence_publisher)) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to register presence publisher %s\n",
|
|
|
|
presence_publisher.event_name);
|
|
|
|
unload_module();
|
Decouple subscription handling from NOTIFY/PUBLISH body generation.
When the PJSIP pubsub framework was created, subscription handlers were required
to state what event they handled along with what body types they knew how to
generate. While this serves well when implementing a base RFC, it has problems
when trying to extend the body to support non-standard or proprietary body
elements. The code also was NOTIFY-specific, meaning that when the time comes
that we start writing code to send out PUBLISH requests with MWI or presence
bodies, we would likely find ourselves duplicating code that had previously been
written.
This changeset introduces the concept of body generators and body supplements. A
body generator is responsible for allocating a native structure for a given body
type, providing the primary body content, converting the native structure to a
string, and deallocating resources. A body supplement takes the primary body
content (the native structure, not a string) generated by the body generator and
adds nonstandard elements to the body. With these elements living in their own
module, it becomes easy to extend our support for body types and to re-use
resources when sending a PUBLISH request.
Body generators and body supplements register themselves with the pubsub core,
similar to how subscription and publish handlers had done. Now, subscription
handlers do not need to know what type of body content they generate, but they
still need to inform the pubsub core about what the default body type for a
given event package is. The pubsub core keeps track of what body generators and
body supplements have been registered. When a SUBSCRIBE arrives, the pubsub core
will check that there is a subscription handler for the event in the SUBSCRIBE,
then it will check that there is a body generator that can provide the content
specified in the Accept header(s).
Because of the nature of body generators and supplements, it means
res_pjsip_exten_state and res_pjsip_mwi have been completely gutted. They no
longer worry about body types, instead calling
ast_sip_pubsub_generate_body_content() when they need to generate a NOTIFY body.
Review: https://reviewboard.asterisk.org/r/3150
........
Merged revisions 407016 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@407030 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2014-01-31 22:27:07 +00:00
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
2014-07-07 16:08:47 +00:00
|
|
|
|
|
|
|
if (ast_sip_register_subscription_handler(&dialog_handler)) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to register subscription handler %s\n",
|
|
|
|
dialog_handler.event_name);
|
2016-04-14 12:03:24 +00:00
|
|
|
unload_module();
|
2014-07-07 16:08:47 +00:00
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
}
|
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
if (ast_sip_register_event_publisher_handler(&dialog_publisher)) {
|
|
|
|
ast_log(LOG_WARNING, "Unable to register presence publisher %s\n",
|
|
|
|
dialog_publisher.event_name);
|
|
|
|
unload_module();
|
|
|
|
return AST_MODULE_LOAD_DECLINE;
|
|
|
|
}
|
2013-06-22 14:03:22 +00:00
|
|
|
|
2016-04-14 12:03:24 +00:00
|
|
|
return AST_MODULE_LOAD_SUCCESS;
|
2013-06-22 14:03:22 +00:00
|
|
|
}
|
|
|
|
|
2014-01-31 23:13:39 +00:00
|
|
|
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Extension State Notifications",
|
2015-05-06 00:49:04 +00:00
|
|
|
.support_level = AST_MODULE_SUPPORT_CORE,
|
|
|
|
.load = load_module,
|
|
|
|
.unload = unload_module,
|
2016-04-28 16:35:44 +00:00
|
|
|
.load_pri = AST_MODPRI_CHANNEL_DEPEND + 5,
|
2017-11-19 22:30:49 +00:00
|
|
|
.requires = "res_pjsip,res_pjsip_pubsub,res_pjsip_outbound_publish",
|
2013-06-22 14:03:22 +00:00
|
|
|
);
|