Asterisk - The Open Source Telephony Project
18.5.0
|
#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 | 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 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 = "30ef0c93b36035ec78c9cfd712d36d9b" , .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 201 of file res_pjsip_exten_state.c.
Referenced by exten_state_subscription_alloc().
#define PUBLISHER_BUCKETS 31 |
The number of buckets to use for storing publishers.
Definition at line 52 of file res_pjsip_exten_state.c.
Referenced by load_module().
|
static |
Definition at line 1012 of file res_pjsip_exten_state.c.
|
static |
Definition at line 1012 of file res_pjsip_exten_state.c.
|
static |
Definition at line 369 of file res_pjsip_exten_state.c.
References ao2_cleanup, ao2_ref, ast_sip_subscription_add_datastore(), ast_sip_subscription_alloc_datastore(), ds_name, RAII_VAR, and exten_state_subscription::sip_sub.
Referenced by subscription_established().
|
static |
Definition at line 251 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, ast_sip_exten_state_data::datastores, ast_sip_exten_state_data::device_state_info, ast_state_cb_info::device_state_info, ast_sip_exten_state_data::exten, exten_state_subscription::exten, ast_sip_exten_state_data::exten_state, ast_state_cb_info::exten_state, notify_task_data::exten_state_data, notify_task_data::exten_state_sub, exten_state_subscription::last_exten_state, exten_state_subscription::last_presence_state, LOG_WARNING, notify_task_data_destructor(), NULL, ast_sip_exten_state_data::presence_message, ast_state_cb_info::presence_message, ast_sip_exten_state_data::presence_state, ast_state_cb_info::presence_state, ast_sip_exten_state_data::presence_subtype, ast_state_cb_info::presence_subtype, exten_state_subscription::sip_sub, ast_sip_exten_state_data::sub, notify_task_data::terminate, ast_sip_exten_state_data::user_agent, and exten_state_subscription::user_agent.
Referenced by state_changed().
struct ast_module* AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1012 of file res_pjsip_exten_state.c.
|
static |
Definition at line 822 of file res_pjsip_exten_state.c.
References ast_log, buf, len(), LOG_ERROR, and NULL.
Referenced by publisher_start().
|
static |
Definition at line 482 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, exten_state_subscription::sip_sub, 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 470 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 582 of file res_pjsip_exten_state.c.
References ao2_bump, ao2_container_count(), ast_calloc, ast_strdup, AST_VECTOR_INIT, ast_state_cb_info::device_state_info, ast_state_cb_info::exten_state, exten_state_pub_data_destroy(), NULL, ast_state_cb_info::presence_message, ast_state_cb_info::presence_state, and ast_state_cb_info::presence_subtype.
Referenced by exten_state_publisher_state_cb().
|
static |
Definition at line 565 of file res_pjsip_exten_state.c.
References ao2_cleanup, ao2_ref, ast_free, AST_VECTOR_CALLBACK_VOID, and AST_VECTOR_FREE.
Referenced by exten_state_pub_data_alloc(), exten_state_publisher_cb(), and exten_state_publisher_state_cb().
|
static |
Definition at line 619 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, exten_state_publisher::body_type, ast_sip_body_data::body_type, exten_state_publisher::client, exten_state_publisher::datastores, exten_state_pub_data_destroy(), LOG_WARNING, exten_state_publisher::name, pool, 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 775 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 806 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 752 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 699 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, exten_state_publisher::context_filter, exten_state_publisher::context_regex, exten_state_publisher::exten_filter, exten_state_publisher::exten_regex, ast_state_cb_info::exten_state, exten_state_pub_data_alloc(), exten_state_pub_data_destroy(), exten_state_publisher_cb(), exten_state_publisher::name, NULL, ast_state_cb_info::presence_message, ast_state_cb_info::presence_state, ast_state_cb_info::presence_subtype, ast_state_cb_info::reason, and S_OR.
Referenced by publisher_start(), and unload_module().
|
static |
Definition at line 210 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 170 of file res_pjsip_exten_state.c.
References ast_free, ast_sip_subscription_destroy(), ast_taskprocessor_unreference(), exten_state_subscription::serializer, exten_state_subscription::sip_sub, sub, and exten_state_subscription::user_agent.
Referenced by exten_state_subscription_alloc().
|
static |
Definition at line 389 of file res_pjsip_exten_state.c.
References ao2_cleanup, ast_sip_subscription_get_datastore(), ds_name, NULL, and RAII_VAR.
Referenced by get_notify_data(), subscription_shutdown(), and to_ami().
|
static |
Definition at line 530 of file res_pjsip_exten_state.c.
References exten_state_data_alloc(), get_exten_state_sub(), and NULL.
|
static |
Definition at line 179 of file res_pjsip_exten_state.c.
References ast_copy_pj_str(), ast_malloc, ast_sip_subscription_get_header(), ast_str_to_lower(), NULL, and exten_state_subscription::user_agent.
Referenced by exten_state_subscription_alloc().
|
static |
Definition at line 960 of file res_pjsip_exten_state.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_log, AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, ast_sip_create_serializer(), ast_sip_register_event_publisher_handler(), ast_sip_register_subscription_handler(), ASTERISK_GPL_KEY, ast_sip_event_publisher_handler::event_name, ast_sip_subscription_handler::event_name, exten_state_publisher_cmp(), exten_state_publisher_hash(), LOG_WARNING, NULL, PUBLISHER_BUCKETS, and unload_module().
|
static |
Definition at line 412 of file res_pjsip_exten_state.c.
References ast_exists_extension(), ast_log, ast_sorcery_object_get_id(), exten_state_subscription::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 288 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 240 of file res_pjsip_exten_state.c.
References ao2_cleanup, ao2_ref, ast_free, ast_sip_exten_state_data::device_state_info, notify_task_data::exten_state_data, notify_task_data::exten_state_sub, ast_sip_exten_state_data::presence_message, ast_sip_exten_state_data::presence_subtype, and ast_sip_exten_state_data::user_agent.
Referenced by alloc_notify_task_data().
|
static |
Definition at line 837 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, exten_state_subscription::context, exten_state_publisher::context_filter, exten_state_publisher::context_regex, exten_state_publisher::datastores, exten_state_subscription::exten, exten_state_publisher::exten_filter, exten_state_publisher::exten_regex, exten_state_publisher_destroy(), exten_state_publisher_state_cb(), LOG_ERROR, name, exten_state_publisher::name, NULL, OBJ_NOLOCK, and strsep().
|
static |
Definition at line 936 of file res_pjsip_exten_state.c.
References ao2_find, ast_sorcery_object_get_id(), OBJ_NODATA, OBJ_SEARCH_KEY, and OBJ_UNLINK.
|
static |
Definition at line 333 of file res_pjsip_exten_state.c.
References alloc_notify_task_data(), ao2_cleanup, ast_sip_push_task(), notify_task_data::exten_state_sub, notify_task(), and exten_state_subscription::serializer.
Referenced by subscription_established(), and subscription_shutdown().
|
static |
Definition at line 353 of file res_pjsip_exten_state.c.
References ao2_cleanup.
Referenced by subscription_established().
|
static |
Definition at line 427 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(), exten_state_subscription::context, ast_sip_endpoint_subscription_configuration::context, ast_sip_endpoint::context, exten_state_subscription::exten, exten_state_subscription_alloc(), exten_state_subscription::id, LOG_WARNING, S_OR, state_changed(), state_changed_destroy(), and ast_sip_endpoint::subscription.
|
static |
Definition at line 398 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, and state_changed().
|
static |
Definition at line 542 of file res_pjsip_exten_state.c.
References ast_extension_state2str(), ast_str_append(), exten_state_subscription::exten, get_exten_state_sub(), and exten_state_subscription::last_exten_state.
Referenced by agi_async_end_to_ami(), aoc_e_to_ami(), ast_rtp_publish_rtcp_message(), contactstatus_to_json(), dahdichannel_to_ami(), declined_handler(), load_module(), peerstatus_to_json(), queue_agent_ringnoanswer_to_ami(), queue_caller_abandon_to_ami(), queue_member_ringinuse_to_ami(), security_event_to_ami(), stasis_message_can_be_ami(), stasis_message_to_ami(), test_suite_event_to_ami(), unhold_to_json(), and unload_module().
|
static |
Definition at line 942 of file res_pjsip_exten_state.c.
References ao2_cleanup, ast_extension_state_del(), ast_sip_unregister_event_publisher_handler(), ast_sip_unregister_subscription_handler(), ast_taskprocessor_unreference(), exten_state_publisher_state_cb(), and NULL.
Referenced by load_module().
|
static |
Definition at line 1012 of file res_pjsip_exten_state.c.
|
static |
Definition at line 1012 of file res_pjsip_exten_state.c.
struct ast_sip_subscription_handler dialog_handler |
Definition at line 155 of file res_pjsip_exten_state.c.
struct ast_sip_notifier dialog_notifier |
Definition at line 133 of file res_pjsip_exten_state.c.
struct ast_sip_event_publisher_handler dialog_publisher |
Definition at line 164 of file res_pjsip_exten_state.c.
|
static |
Definition at line 359 of file res_pjsip_exten_state.c.
|
static |
Definition at line 360 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 140 of file res_pjsip_exten_state.c.
struct ast_sip_notifier presence_notifier |
Definition at line 126 of file res_pjsip_exten_state.c.
struct ast_sip_event_publisher_handler presence_publisher |
Definition at line 149 of file res_pjsip_exten_state.c.
|
static |
Serializer for outbound extension state publishing.
Definition at line 60 of file res_pjsip_exten_state.c.
|
static |
Container of active outbound extension state publishers.
Definition at line 57 of file res_pjsip_exten_state.c.
Referenced by AST_TEST_DEFINE(), and explicit_publish_cb().