Asterisk - The Open Source Telephony Project GIT-master-0644429
|
#include "asterisk.h"
#include <regex.h>
#include <pjsip.h>
#include <pjsip_simple.h>
#include <pjlib.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_outbound_publish.h"
#include "asterisk/res_pjsip_pubsub.h"
#include "asterisk/res_pjsip_body_generator_types.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/astobj2.h"
#include "asterisk/sorcery.h"
#include "asterisk/app.h"
#include "asterisk/taskprocessor.h"
Go to the source code of this file.
Data Structures | |
struct | exten_state_pub_data |
struct | exten_state_publisher |
An extension state publisher. More... | |
struct | exten_state_subscription |
A subscription for extension state. More... | |
struct | exten_state_pub_data::name |
struct | notify_task_data |
Macros | |
#define | BODY_SIZE 1024 |
#define | DEFAULT_DIALOG_BODY "application/dialog-info+xml" |
#define | DEFAULT_PRESENCE_BODY "application/pidf+xml" |
#define | EVENT_TYPE_SIZE 50 |
#define | INITIAL_LAST_EXTEN_STATE -3 |
#define | PUBLISHER_BUCKETS 31 |
The number of buckets to use for storing publishers. More... | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static int | add_datastore (struct exten_state_subscription *exten_state_sub) |
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) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static int | build_regex (regex_t *regex, const char *text) |
static struct ast_sip_exten_state_data * | exten_state_data_alloc (struct ast_sip_subscription *sip_sub, struct exten_state_subscription *exten_state_sub) |
static void | exten_state_data_destructor (void *obj) |
static struct exten_state_pub_data * | exten_state_pub_data_alloc (const char *exten, struct ast_state_cb_info *info) |
static void | exten_state_pub_data_destroy (struct exten_state_pub_data *doomed) |
static int | exten_state_publisher_cb (void *data) |
static int | exten_state_publisher_cmp (void *obj, void *arg, int flags) |
Comparator function for extension state publisher. More... | |
static void | exten_state_publisher_destroy (void *obj) |
Destructor for extension state publisher. More... | |
static int | exten_state_publisher_hash (const void *obj, const int flags) |
Hashing function for extension state publisher. More... | |
static int | exten_state_publisher_state_cb (const char *context, const char *exten, struct ast_state_cb_info *info, void *data) |
Global extension state callback function. More... | |
static struct exten_state_subscription * | exten_state_subscription_alloc (struct ast_sip_subscription *sip_sub, struct ast_sip_endpoint *endpoint) |
static void | exten_state_subscription_destructor (void *obj) |
static struct exten_state_subscription * | get_exten_state_sub (struct ast_sip_subscription *sub) |
static void * | get_notify_data (struct ast_sip_subscription *sub) |
static int | get_resource_display_name (struct ast_sip_endpoint *endpoint, const char *resource, char *display_name, int display_name_size) |
static char * | get_user_agent (const struct ast_sip_subscription *sip_sub) |
static int | load_module (void) |
static int | new_subscribe (struct ast_sip_endpoint *endpoint, const char *resource) |
static int | notify_task (void *obj) |
static void | notify_task_data_destructor (void *obj) |
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) |
static int | state_changed (const char *context, const char *exten, struct ast_state_cb_info *info, void *data) |
static void | state_changed_destroy (int id, void *data) |
static int | subscription_established (struct ast_sip_subscription *sub) |
static void | subscription_shutdown (struct ast_sip_subscription *sub) |
static void | to_ami (struct ast_sip_subscription *sub, struct ast_str **buf) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP Extension State Notifications" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND + 5, .requires = "res_pjsip,res_pjsip_pubsub,res_pjsip_outbound_publish", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
struct ast_sip_subscription_handler | dialog_handler |
struct ast_sip_notifier | dialog_notifier |
struct ast_sip_event_publisher_handler | dialog_publisher |
static struct ast_datastore_info | ds_info = { } |
static const char | ds_name [] = "exten state datastore" |
struct ast_sip_subscription_handler | presence_handler |
struct ast_sip_notifier | presence_notifier |
struct ast_sip_event_publisher_handler | presence_publisher |
static struct ast_taskprocessor * | publish_exten_state_serializer |
static struct ao2_container * | publishers |
Container of active outbound extension state publishers. More... | |
#define BODY_SIZE 1024 |
Definition at line 46 of file res_pjsip_exten_state.c.
#define DEFAULT_DIALOG_BODY "application/dialog-info+xml" |
Definition at line 114 of file res_pjsip_exten_state.c.
#define DEFAULT_PRESENCE_BODY "application/pidf+xml" |
Definition at line 113 of file res_pjsip_exten_state.c.
#define EVENT_TYPE_SIZE 50 |
Definition at line 47 of file res_pjsip_exten_state.c.
#define INITIAL_LAST_EXTEN_STATE -3 |
Definition at line 204 of file res_pjsip_exten_state.c.
#define PUBLISHER_BUCKETS 31 |
The number of buckets to use for storing publishers.
Definition at line 52 of file res_pjsip_exten_state.c.
|
static |
Definition at line 1059 of file res_pjsip_exten_state.c.
|
static |
Definition at line 1059 of file res_pjsip_exten_state.c.
|
static |
Definition at line 380 of file res_pjsip_exten_state.c.
References ao2_cleanup, ao2_ref, ast_sip_subscription_add_datastore(), ast_sip_subscription_alloc_datastore(), ds_info, ds_name, RAII_VAR, and exten_state_subscription::sip_sub.
Referenced by subscription_established().
|
static |
Definition at line 254 of file res_pjsip_exten_state.c.
References ao2_alloc, ao2_bump, ao2_ref, AST_EXTENSION_DEACTIVATED, AST_EXTENSION_REMOVED, ast_log, ast_sip_subscription_get_datastores(), ast_strdup, ast_verb, exten_state_subscription::exten, notify_task_data::exten_state_sub, sip_to_pjsip::info(), LOG_WARNING, notify_task_data_destructor(), NULL, exten_state_subscription::sip_sub, and exten_state_subscription::user_agent.
Referenced by state_changed().
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1059 of file res_pjsip_exten_state.c.
|
static |
Definition at line 854 of file res_pjsip_exten_state.c.
References ast_log, buf, len(), LOG_ERROR, NULL, regex(), and text.
Referenced by publisher_start().
|
static |
Definition at line 514 of file res_pjsip_exten_state.c.
References ao2_alloc, ao2_cleanup, ast_extension_state_extended(), ast_hint_presence_state(), AST_PRESENCE_INVALID, ast_sip_get_pjsip_endpoint(), ast_sip_subscription_get_datastores(), ast_sip_subscription_get_local_uri(), ast_sip_subscription_get_remote_uri(), exten_state_subscription::context, ast_sip_exten_state_data::datastores, ast_sip_exten_state_data::device_state_info, ast_sip_exten_state_data::exten, exten_state_subscription::exten, ast_sip_exten_state_data::exten_state, exten_state_data_destructor(), ast_sip_exten_state_data::local, NULL, ast_sip_exten_state_data::pool, ast_sip_exten_state_data::presence_message, ast_sip_exten_state_data::presence_state, ast_sip_exten_state_data::presence_subtype, ast_sip_exten_state_data::remote, ast_sip_exten_state_data::sub, ast_sip_exten_state_data::user_agent, and exten_state_subscription::user_agent.
Referenced by get_notify_data().
|
static |
Definition at line 502 of file res_pjsip_exten_state.c.
References ao2_cleanup, ast_free, ast_sip_get_pjsip_endpoint(), ast_sip_exten_state_data::device_state_info, ast_sip_exten_state_data::pool, ast_sip_exten_state_data::presence_message, and ast_sip_exten_state_data::presence_subtype.
Referenced by exten_state_data_alloc().
|
static |
Definition at line 614 of file res_pjsip_exten_state.c.
References ao2_bump, ao2_container_count(), ast_calloc, ast_strdup, AST_VECTOR_INIT, ast_sip_exten_state_data::device_state_info, ast_sip_exten_state_data::exten, ast_sip_exten_state_data::exten_state, exten_state_pub_data::exten_state_data, exten_state_pub_data_destroy(), sip_to_pjsip::info(), NULL, ast_sip_exten_state_data::presence_message, ast_sip_exten_state_data::presence_state, ast_sip_exten_state_data::presence_subtype, and exten_state_pub_data::pubs.
Referenced by exten_state_publisher_state_cb().
|
static |
Definition at line 597 of file res_pjsip_exten_state.c.
References ao2_cleanup, ao2_ref, ast_free, AST_VECTOR_CALLBACK_VOID, AST_VECTOR_FREE, ast_sip_exten_state_data::device_state_info, ast_sip_exten_state_data::exten, exten_state_pub_data::exten_state_data, ast_sip_exten_state_data::presence_message, ast_sip_exten_state_data::presence_subtype, and exten_state_pub_data::pubs.
Referenced by exten_state_pub_data_alloc(), exten_state_publisher_cb(), and exten_state_publisher_state_cb().
|
static |
Definition at line 651 of file res_pjsip_exten_state.c.
References ast_free, ast_log, AST_SIP_EXTEN_STATE_DATA, ast_sip_get_pjsip_endpoint(), ast_sip_publish_client_get_user_from_uri(), ast_sip_publish_client_get_user_to_uri(), ast_sip_publish_client_user_send(), ast_sip_pubsub_generate_body_content(), ast_str_buffer(), ast_str_create, ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, exten_state_publisher::body_subtype, ast_sip_body::body_text, ast_sip_body_data::body_type, exten_state_publisher::body_type, exten_state_publisher::client, ast_sip_exten_state_data::datastores, exten_state_publisher::datastores, ast_sip_exten_state_data::exten, exten_state_pub_data::exten_state_data, exten_state_pub_data_destroy(), ast_sip_exten_state_data::local, LOG_WARNING, exten_state_publisher::name, ast_sip_exten_state_data::pool, exten_state_pub_data::pubs, ast_sip_exten_state_data::remote, ast_sip_body::subtype, and ast_sip_body::type.
Referenced by exten_state_publisher_state_cb().
|
static |
Comparator function for extension state publisher.
Definition at line 807 of file res_pjsip_exten_state.c.
References ast_assert, CMP_MATCH, exten_state_publisher::name, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.
Referenced by load_module().
|
static |
Destructor for extension state publisher.
Definition at line 838 of file res_pjsip_exten_state.c.
References ao2_cleanup, exten_state_publisher::client, exten_state_publisher::context_filter, exten_state_publisher::context_regex, exten_state_publisher::datastores, exten_state_publisher::exten_filter, and exten_state_publisher::exten_regex.
Referenced by publisher_start().
|
static |
Hashing function for extension state publisher.
Definition at line 784 of file res_pjsip_exten_state.c.
References ast_assert, ast_str_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.
Referenced by load_module().
|
static |
Global extension state callback function.
Definition at line 731 of file res_pjsip_exten_state.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_debug, ast_extension_state2str(), AST_HINT_UPDATE_DEVICE, AST_HINT_UPDATE_PRESENCE, ast_presence_state2str(), ast_sip_push_task(), AST_VECTOR_APPEND, voicemailpwcheck::context, exten_state_publisher::context_filter, exten_state_publisher::context_regex, exten_state_publisher::exten_filter, exten_state_publisher::exten_regex, exten_state_pub_data_alloc(), exten_state_pub_data_destroy(), exten_state_publisher_cb(), sip_to_pjsip::info(), exten_state_publisher::name, NULL, publish_exten_state_serializer, exten_state_pub_data::pubs, and S_OR.
Referenced by publisher_start(), and unload_module().
|
static |
Definition at line 213 of file res_pjsip_exten_state.c.
References ao2_alloc, ao2_bump, AST_PRESENCE_NOT_SET, ast_sip_subscription_get_serializer(), exten_state_subscription_destructor(), get_user_agent(), INITIAL_LAST_EXTEN_STATE, exten_state_subscription::last_exten_state, exten_state_subscription::last_presence_state, NULL, exten_state_subscription::serializer, exten_state_subscription::sip_sub, and exten_state_subscription::user_agent.
Referenced by subscription_established().
|
static |
Definition at line 173 of file res_pjsip_exten_state.c.
References ast_free, ast_sip_subscription_destroy(), ast_taskprocessor_unreference(), and sub.
Referenced by exten_state_subscription_alloc().
|
static |
Definition at line 400 of file res_pjsip_exten_state.c.
References ao2_cleanup, ast_sip_subscription_get_datastore(), ds_name, NULL, RAII_VAR, and sub.
Referenced by get_notify_data(), subscription_shutdown(), and to_ami().
|
static |
Definition at line 562 of file res_pjsip_exten_state.c.
References exten_state_data_alloc(), get_exten_state_sub(), NULL, and sub.
|
static |
Definition at line 438 of file res_pjsip_exten_state.c.
References ast_get_hint(), ast_log, ast_sorcery_object_get_id(), ast_strlen_zero(), voicemailpwcheck::context, ast_sip_endpoint_subscription_configuration::context, ast_sip_endpoint::context, LOG_NOTICE, NULL, S_OR, and ast_sip_endpoint::subscription.
|
static |
Definition at line 182 of file res_pjsip_exten_state.c.
References ast_copy_pj_str(), ast_malloc, ast_sip_subscription_get_header(), ast_str_to_lower(), NULL, exten_state_subscription::sip_sub, and exten_state_subscription::user_agent.
Referenced by exten_state_subscription_alloc().
|
static |
Definition at line 1007 of file res_pjsip_exten_state.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_create_serializer(), ast_sip_register_event_publisher_handler(), ast_sip_register_subscription_handler(), dialog_handler, dialog_publisher, ast_sip_event_publisher_handler::event_name, ast_sip_subscription_handler::event_name, exten_state_publisher_cmp(), exten_state_publisher_hash(), LOG_WARNING, NULL, presence_handler, presence_publisher, publish_exten_state_serializer, PUBLISHER_BUCKETS, and unload_module().
|
static |
Definition at line 423 of file res_pjsip_exten_state.c.
References ast_exists_extension(), ast_log, ast_sorcery_object_get_id(), voicemailpwcheck::context, ast_sip_endpoint_subscription_configuration::context, ast_sip_endpoint::context, LOG_NOTICE, NULL, PRIORITY_HINT, S_OR, and ast_sip_endpoint::subscription.
|
static |
Definition at line 291 of file res_pjsip_exten_state.c.
References ao2_cleanup, AST_SIP_EXTEN_STATE_DATA, ast_sip_get_pjsip_endpoint(), ast_sip_subscription_get_datastores(), ast_sip_subscription_get_local_uri(), ast_sip_subscription_get_remote_uri(), ast_sip_subscription_is_terminated(), ast_sip_subscription_notify(), ast_sip_body_data::body_type, and RAII_VAR.
Referenced by state_changed().
|
static |
Definition at line 243 of file res_pjsip_exten_state.c.
References ao2_cleanup, ao2_ref, and ast_free.
Referenced by alloc_notify_task_data().
|
static |
Definition at line 869 of file res_pjsip_exten_state.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ao2_container_count(), ao2_link_flags, ao2_lock, ao2_ref, ao2_unlock, ast_copy_string(), ast_datastores_alloc(), ast_extension_state_add(), ast_log, ast_sip_pubsub_is_body_generator_registered(), ast_sorcery_object_get_extended(), ast_sorcery_object_get_id(), ast_strdupa, ast_strlen_zero(), exten_state_publisher::body_subtype, exten_state_publisher::body_type, build_regex(), exten_state_publisher::client, voicemailpwcheck::context, exten_state_publisher::context_filter, exten_state_publisher::context_regex, exten_state_publisher::datastores, exten_state_publisher::exten_filter, exten_state_publisher::exten_regex, exten_state_publisher_destroy(), exten_state_publisher_state_cb(), LOG_ERROR, exten_state_publisher::name, name, NULL, OBJ_NOLOCK, and strsep().
|
static |
Definition at line 968 of file res_pjsip_exten_state.c.
References ao2_find, ast_sorcery_object_get_id(), exten_state_publisher::client, OBJ_NODATA, OBJ_SEARCH_KEY, and OBJ_UNLINK.
|
static |
Definition at line 337 of file res_pjsip_exten_state.c.
References alloc_notify_task_data(), ao2_cleanup, ast_sip_push_task(), ast_sip_subscription_is_terminated(), exten_state_subscription::exten, sip_to_pjsip::info(), notify_task(), and exten_state_subscription::sip_sub.
Referenced by subscription_established(), and subscription_shutdown().
|
static |
Definition at line 364 of file res_pjsip_exten_state.c.
References ao2_cleanup.
Referenced by subscription_established().
|
static |
Definition at line 459 of file res_pjsip_exten_state.c.
References add_datastore(), ao2_cleanup, ao2_ref, ast_copy_string(), ast_extension_state_add_destroy_extended(), ast_log, ast_sip_subscription_get_endpoint(), ast_sip_subscription_get_resource_name(), ast_sorcery_object_get_id(), ast_sip_endpoint_subscription_configuration::context, ast_sip_endpoint::context, exten_state_subscription::context, exten_state_subscription::exten, exten_state_subscription_alloc(), exten_state_subscription::id, LOG_WARNING, S_OR, exten_state_subscription::sip_sub, state_changed(), state_changed_destroy(), and ast_sip_endpoint::subscription.
|
static |
Definition at line 409 of file res_pjsip_exten_state.c.
References ao2_cleanup, ast_extension_state_del(), ast_sip_subscription_remove_datastore(), ds_name, get_exten_state_sub(), exten_state_subscription::id, exten_state_subscription::sip_sub, state_changed(), and sub.
|
static |
Definition at line 574 of file res_pjsip_exten_state.c.
References ast_extension_state2str(), ast_str_append(), buf, exten_state_subscription::exten, get_exten_state_sub(), exten_state_subscription::last_exten_state, and sub.
Referenced by load_module(), stasis_message_can_be_ami(), stasis_message_to_ami(), and unload_module().
|
static |
Definition at line 974 of file res_pjsip_exten_state.c.
References ao2_cleanup, ast_extension_state_del(), ast_shutdown_final(), ast_sip_unregister_event_publisher_handler(), ast_sip_unregister_subscription_handler(), ast_taskprocessor_unreference(), dialog_handler, dialog_publisher, exten_state_publisher_state_cb(), NULL, presence_handler, presence_publisher, and publish_exten_state_serializer.
Referenced by load_module().
|
static |
Definition at line 1059 of file res_pjsip_exten_state.c.
|
static |
Definition at line 1059 of file res_pjsip_exten_state.c.
struct ast_sip_subscription_handler dialog_handler |
Definition at line 158 of file res_pjsip_exten_state.c.
Referenced by load_module(), and unload_module().
struct ast_sip_notifier dialog_notifier |
Definition at line 135 of file res_pjsip_exten_state.c.
struct ast_sip_event_publisher_handler dialog_publisher |
Definition at line 167 of file res_pjsip_exten_state.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 370 of file res_pjsip_exten_state.c.
Referenced by add_datastore().
|
static |
Definition at line 371 of file res_pjsip_exten_state.c.
Referenced by add_datastore(), get_exten_state_sub(), and subscription_shutdown().
struct ast_sip_subscription_handler presence_handler |
Definition at line 143 of file res_pjsip_exten_state.c.
Referenced by load_module(), and unload_module().
struct ast_sip_notifier presence_notifier |
Definition at line 127 of file res_pjsip_exten_state.c.
struct ast_sip_event_publisher_handler presence_publisher |
Definition at line 152 of file res_pjsip_exten_state.c.
Referenced by load_module(), and unload_module().
|
static |
Serializer for outbound extension state publishing.
Definition at line 60 of file res_pjsip_exten_state.c.
Referenced by exten_state_publisher_state_cb(), load_module(), and unload_module().
|
static |
Container of active outbound extension state publishers.
Definition at line 57 of file res_pjsip_exten_state.c.