Asterisk - The Open Source Telephony Project GIT-master-d856a3e
|
#include "asterisk.h"
#include <regex.h>
#include <pjsip.h>
#include <pjsip_simple.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_outbound_publish.h"
#include "asterisk/res_pjsip_pubsub.h"
#include "asterisk/module.h"
#include "asterisk/logger.h"
#include "asterisk/mwi.h"
Go to the source code of this file.
Data Structures | |
struct | asterisk_devicestate_publisher_state |
Structure which contains Asterisk device state publisher state information. More... | |
struct | asterisk_mwi_publisher_state |
Structure which contains Asterisk mailbox publisher state information. More... | |
struct | asterisk_publication_config |
Structure which contains Asterisk publication information. More... | |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | asterisk_devicestate_publisher_state_destroy (void *obj) |
Destroy callback for Asterisk devicestate publisher state information from datastore. More... | |
static void | asterisk_mwi_publisher_state_destroy (void *obj) |
Destroy callback for Asterisk mwi publisher state information from datastore. More... | |
static void * | asterisk_publication_config_alloc (const char *name) |
Allocator function for Asterisk publication configuration. More... | |
static void | asterisk_publication_config_destroy (void *obj) |
Destructor function for Asterisk publication configuration. More... | |
static int | asterisk_publication_devicestate (struct ast_sip_publication *pub, struct asterisk_publication_config *config, struct ast_eid *pubsub_eid, struct ast_json *json) |
static int | asterisk_publication_devicestate_refresh (struct ast_sip_publication *pub, struct asterisk_publication_config *config, struct ast_eid *pubsub_eid, struct ast_json *json) |
static int | asterisk_publication_devicestate_state_change (struct ast_sip_publication *pub, pjsip_msg_body *body, enum ast_sip_publish_state state) |
static int | asterisk_publication_mailboxstate (struct ast_sip_publication *pub, struct asterisk_publication_config *config, struct ast_eid *pubsub_eid, struct ast_json *json) |
static int | asterisk_publication_mwi_refresh (struct ast_sip_publication *pub, struct asterisk_publication_config *config, struct ast_eid *pubsub_eid, struct ast_json *json) |
static int | asterisk_publication_mwi_state_change (struct ast_sip_publication *pub, pjsip_msg_body *body, enum ast_sip_publish_state state) |
static int | asterisk_publication_new (struct ast_sip_endpoint *endpoint, const char *resource, const char *event_configuration) |
static void | asterisk_publication_send_refresh (void) |
Internal function to send refresh requests to all publications. More... | |
static void | asterisk_publisher_devstate_cb (void *data, struct stasis_subscription *sub, struct stasis_message *msg) |
Callback function for device state events. More... | |
static void | asterisk_publisher_mwistate_cb (void *data, struct stasis_subscription *sub, struct stasis_message *msg) |
Callback function for mailbox state events. More... | |
static int | asterisk_start_devicestate_publishing (struct ast_sip_outbound_publish *configuration, struct ast_sip_outbound_publish_client *client) |
static int | asterisk_start_mwi_publishing (struct ast_sip_outbound_publish *configuration, struct ast_sip_outbound_publish_client *client) |
static int | asterisk_stop_devicestate_publishing (struct ast_sip_outbound_publish_client *client) |
static int | asterisk_stop_mwi_publishing (struct ast_sip_outbound_publish_client *client) |
static int | build_regex (regex_t *regex, const char *text) |
static int | cached_devstate_cb (void *obj, void *arg, int flags) |
static int | cached_mwistate_cb (void *obj, void *arg, int flags) |
static int | load_module (void) |
static int | regex_filter_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | reload_module (void) |
static int | send_refresh_cb (void *obj, void *arg, int flags) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP Asterisk Event PUBLISH Support" , .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, .reload = reload_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND + 5, .requires = "res_pjsip,res_pjsip_outbound_publish,res_pjsip_pubsub", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
struct ast_sip_publish_handler | asterisk_devicestate_publication_handler |
struct ast_sip_event_publisher_handler | asterisk_devicestate_publisher_handler |
static const struct ast_datastore_info | asterisk_devicestate_publisher_state_datastore |
Datastore for attaching devicestate publisher state information. More... | |
struct ast_sip_publish_handler | asterisk_mwi_publication_handler |
struct ast_sip_event_publisher_handler | asterisk_mwi_publisher_handler |
static const struct ast_datastore_info | asterisk_mwi_publisher_state_datastore |
Datastore for attaching devicestate publisher state information. More... | |
|
static |
Definition at line 940 of file res_pjsip_publish_asterisk.c.
|
static |
Definition at line 940 of file res_pjsip_publish_asterisk.c.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 940 of file res_pjsip_publish_asterisk.c.
|
static |
Destroy callback for Asterisk devicestate publisher state information from datastore.
Definition at line 132 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, asterisk_devicestate_publisher_state::client, asterisk_devicestate_publisher_state::device_state_filter, and asterisk_devicestate_publisher_state::device_state_regex.
|
static |
Destroy callback for Asterisk mwi publisher state information from datastore.
Definition at line 150 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, asterisk_mwi_publisher_state::client, asterisk_mwi_publisher_state::mailbox_state_filter, and asterisk_mwi_publisher_state::mailbox_state_regex.
|
static |
Allocator function for Asterisk publication configuration.
Definition at line 825 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, asterisk_publication_config_destroy(), config, and NULL.
Referenced by load_module().
|
static |
Destructor function for Asterisk publication configuration.
Definition at line 817 of file res_pjsip_publish_asterisk.c.
References ast_string_field_free_memory, and config.
Referenced by asterisk_publication_config_alloc().
|
static |
Definition at line 490 of file res_pjsip_publish_asterisk.c.
References ast_debug, AST_DEVSTATE_CACHABLE, AST_DEVSTATE_NOT_CACHABLE, ast_devstate_val(), ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_publish_device_state_full(), ast_sorcery_object_get_id(), ast_strlen_zero(), config, and NULL.
Referenced by asterisk_publication_devicestate_state_change().
|
static |
Definition at line 557 of file res_pjsip_publish_asterisk.c.
References ao2_callback, ao2_ref, ast_device_state_cache(), ast_log, ast_sip_publish_client_get(), ast_sip_publish_client_get_datastore(), ast_sorcery_object_get_id(), ast_strlen_zero(), cached_devstate_cb(), config, LOG_ERROR, NULL, OBJ_NODATA, and stasis_cache_dump().
Referenced by asterisk_publication_devicestate_state_change().
|
static |
Definition at line 592 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, ast_debug, ast_json_load_buf(), ast_json_object_get(), ast_json_string_get(), ast_json_unref(), ast_sip_get_sorcery(), ast_sip_is_content_type(), ast_sip_publication_get_event_configuration(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_id(), ast_str_to_eid(), asterisk_publication_devicestate(), asterisk_publication_devicestate_refresh(), config, ast_eid::eid, NULL, RAII_VAR, and type.
|
static |
Definition at line 522 of file res_pjsip_publish_asterisk.c.
References ast_debug, ast_json_integer_get(), ast_json_object_get(), ast_json_string_get(), ast_publish_mwi_state_full(), ast_sorcery_object_get_id(), ast_strdupa, ast_strlen_zero(), config, voicemailpwcheck::mailbox, NULL, and strsep().
Referenced by asterisk_publication_mwi_state_change().
|
static |
Definition at line 648 of file res_pjsip_publish_asterisk.c.
References ao2_callback, ao2_ref, ast_log, ast_mwi_state_cache(), ast_sip_publish_client_get(), ast_sip_publish_client_get_datastore(), ast_sorcery_object_get_id(), ast_strlen_zero(), cached_mwistate_cb(), config, LOG_ERROR, NULL, OBJ_NODATA, and stasis_cache_dump().
Referenced by asterisk_publication_mwi_state_change().
|
static |
Definition at line 683 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, ast_debug, ast_json_load_buf(), ast_json_object_get(), ast_json_string_get(), ast_json_unref(), ast_sip_get_sorcery(), ast_sip_is_content_type(), ast_sip_publication_get_event_configuration(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_id(), ast_str_to_eid(), asterisk_publication_mailboxstate(), asterisk_publication_mwi_refresh(), config, ast_eid::eid, NULL, RAII_VAR, and type.
|
static |
Definition at line 477 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), config, and RAII_VAR.
|
static |
Internal function to send refresh requests to all publications.
Definition at line 764 of file res_pjsip_publish_asterisk.c.
References ao2_callback, ao2_ref, ast_eid_default, ast_eid_to_str(), ast_json_dump_string, ast_json_free(), ast_json_pack(), ast_json_unref(), AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_fields(), ast_sip_body::body_text, NULL, OBJ_NODATA, send_refresh_cb(), text, and ast_sip_body::type.
Referenced by load_module(), and reload_module().
|
static |
Callback function for device state events.
data | void pointer to ast_client structure |
sub,msg |
Definition at line 172 of file res_pjsip_publish_asterisk.c.
References ast_device_state_message_type(), ast_devstate_str(), ast_eid_cmp(), ast_eid_default, ast_eid_to_str(), ast_json_dump_string, ast_json_free(), ast_json_pack(), ast_json_unref(), ast_sip_publish_client_send(), ast_sip_body::body_text, ast_device_state_message::cachable, asterisk_devicestate_publisher_state::client, ast_datastore::data, ast_device_state_message::device, asterisk_devicestate_publisher_state::device_state_filter, asterisk_devicestate_publisher_state::device_state_regex, ast_device_state_message::eid, NULL, stasis_message_data(), stasis_message_type(), stasis_subscription_is_subscribed(), ast_device_state_message::state, sub, text, and ast_sip_body::type.
Referenced by asterisk_start_devicestate_publishing(), and cached_devstate_cb().
|
static |
Callback function for mailbox state events.
data | void pointer to ast_client structure |
sub,msg |
Definition at line 230 of file res_pjsip_publish_asterisk.c.
References ast_eid_cmp(), ast_eid_default, ast_eid_to_str(), ast_json_dump_string, ast_json_free(), ast_json_pack(), ast_json_unref(), ast_mwi_state_type(), ast_sip_publish_client_send(), ast_sip_body::body_text, asterisk_mwi_publisher_state::client, ast_datastore::data, ast_mwi_state::eid, asterisk_mwi_publisher_state::mailbox_state_filter, asterisk_mwi_publisher_state::mailbox_state_regex, ast_mwi_state::new_msgs, NULL, ast_mwi_state::old_msgs, stasis_message_data(), stasis_message_type(), stasis_subscription_is_subscribed(), sub, text, ast_sip_body::type, and ast_mwi_state::uniqueid.
Referenced by asterisk_start_mwi_publishing(), and cached_mwistate_cb().
|
static |
Definition at line 320 of file res_pjsip_publish_asterisk.c.
References ao2_bump, ao2_callback, ao2_cleanup, ao2_ref, ast_calloc, ast_device_state_cache(), ast_device_state_message_type(), ast_device_state_topic_all(), ast_sip_publish_client_add_datastore(), ast_sip_publish_client_alloc_datastore(), ast_sip_publish_client_remove_datastore(), ast_sorcery_object_get_extended(), ast_strlen_zero(), asterisk_devicestate_publisher_state_datastore, asterisk_publisher_devstate_cb(), build_regex(), cached_devstate_cb(), asterisk_devicestate_publisher_state::client, asterisk_devicestate_publisher_state::device_state_filter, asterisk_devicestate_publisher_state::device_state_regex, asterisk_devicestate_publisher_state::device_state_subscription, NULL, OBJ_NODATA, RAII_VAR, stasis_cache_dump(), stasis_subscribe, stasis_subscription_accept_message_type(), stasis_subscription_change_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), and value.
|
static |
Definition at line 399 of file res_pjsip_publish_asterisk.c.
References ao2_bump, ao2_callback, ao2_cleanup, ao2_ref, ast_calloc, ast_mwi_state_cache(), ast_mwi_state_type(), ast_mwi_topic_all(), ast_sip_publish_client_add_datastore(), ast_sip_publish_client_alloc_datastore(), ast_sip_publish_client_remove_datastore(), ast_sorcery_object_get_extended(), ast_strlen_zero(), asterisk_mwi_publisher_state_datastore, asterisk_publisher_mwistate_cb(), build_regex(), cached_mwistate_cb(), asterisk_mwi_publisher_state::client, asterisk_mwi_publisher_state::mailbox_state_filter, asterisk_mwi_publisher_state::mailbox_state_regex, asterisk_mwi_publisher_state::mailbox_state_subscription, NULL, OBJ_NODATA, RAII_VAR, stasis_cache_dump(), stasis_subscribe, stasis_subscription_accept_message_type(), stasis_subscription_change_type(), STASIS_SUBSCRIPTION_FILTER_SELECTIVE, stasis_subscription_set_filter(), and value.
|
static |
Definition at line 372 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, ao2_ref, ast_sip_publish_client_get_datastore(), ast_sip_publish_client_remove_datastore(), asterisk_devicestate_publisher_state::client, asterisk_devicestate_publisher_state::device_state_subscription, RAII_VAR, and stasis_unsubscribe_and_join().
|
static |
Definition at line 450 of file res_pjsip_publish_asterisk.c.
References ao2_cleanup, ao2_ref, ast_sip_publish_client_get_datastore(), ast_sip_publish_client_remove_datastore(), asterisk_mwi_publisher_state::client, asterisk_mwi_publisher_state::mailbox_state_subscription, RAII_VAR, and stasis_unsubscribe_and_join().
|
static |
Definition at line 305 of file res_pjsip_publish_asterisk.c.
References ast_log, buf, len(), LOG_ERROR, NULL, regex(), and text.
Referenced by asterisk_start_devicestate_publishing(), asterisk_start_mwi_publishing(), and regex_filter_handler().
|
static |
Definition at line 283 of file res_pjsip_publish_asterisk.c.
References asterisk_publisher_devstate_cb(), ast_datastore::data, and asterisk_devicestate_publisher_state::device_state_subscription.
Referenced by asterisk_publication_devicestate_refresh(), and asterisk_start_devicestate_publishing().
|
static |
Definition at line 294 of file res_pjsip_publish_asterisk.c.
References asterisk_publisher_mwistate_cb(), ast_datastore::data, and asterisk_mwi_publisher_state::mailbox_state_subscription.
Referenced by asterisk_publication_mwi_refresh(), and asterisk_start_mwi_publishing().
|
static |
Definition at line 860 of file res_pjsip_publish_asterisk.c.
References ast_eid_default, ast_eid_is_empty(), ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_get_sorcery(), ast_sip_register_event_publisher_handler(), ast_sip_register_publish_handler(), ast_sip_unregister_event_publisher_handler(), ast_sip_unregister_publish_handler(), ast_sorcery_apply_config, ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_register, ast_sorcery_reload_object(), asterisk_devicestate_publication_handler, asterisk_devicestate_publisher_handler, asterisk_mwi_publication_handler, asterisk_mwi_publisher_handler, asterisk_publication_config_alloc(), asterisk_publication_send_refresh(), asterisk_publication_config::device_state, asterisk_publication_config::devicestate_publish, ast_sip_event_publisher_handler::event_name, ast_sip_publish_handler::event_name, FLDSET, LOG_ERROR, LOG_WARNING, asterisk_publication_config::mailbox_state, asterisk_publication_config::mailboxstate_publish, NULL, OPT_BOOL_T, OPT_NOOP_T, OPT_STRINGFIELD_T, regex_filter_handler(), and STRFLDSET.
|
static |
Definition at line 838 of file res_pjsip_publish_asterisk.c.
References ast_strlen_zero(), build_regex(), config, and var.
Referenced by load_module().
|
static |
Definition at line 916 of file res_pjsip_publish_asterisk.c.
References ast_sip_get_sorcery(), ast_sorcery_reload_object(), and asterisk_publication_send_refresh().
|
static |
Definition at line 739 of file res_pjsip_publish_asterisk.c.
References ao2_ref, ast_sip_publish_client_get(), ast_sip_publish_client_send(), ast_strlen_zero(), and config.
Referenced by asterisk_publication_send_refresh().
|
static |
Definition at line 923 of file res_pjsip_publish_asterisk.c.
References ast_sip_get_sorcery(), ast_sip_unregister_event_publisher_handler(), ast_sip_unregister_publish_handler(), ast_sorcery_object_unregister(), asterisk_devicestate_publication_handler, asterisk_devicestate_publisher_handler, asterisk_mwi_publication_handler, and asterisk_mwi_publisher_handler.
|
static |
Definition at line 940 of file res_pjsip_publish_asterisk.c.
|
static |
Definition at line 940 of file res_pjsip_publish_asterisk.c.
struct ast_sip_publish_handler asterisk_devicestate_publication_handler |
Definition at line 804 of file res_pjsip_publish_asterisk.c.
Referenced by load_module(), and unload_module().
struct ast_sip_event_publisher_handler asterisk_devicestate_publisher_handler |
Definition at line 393 of file res_pjsip_publish_asterisk.c.
Referenced by load_module(), and unload_module().
|
static |
Datastore for attaching devicestate publisher state information.
Definition at line 144 of file res_pjsip_publish_asterisk.c.
Referenced by asterisk_start_devicestate_publishing().
struct ast_sip_publish_handler asterisk_mwi_publication_handler |
Definition at line 810 of file res_pjsip_publish_asterisk.c.
Referenced by load_module(), and unload_module().
struct ast_sip_event_publisher_handler asterisk_mwi_publisher_handler |
Definition at line 471 of file res_pjsip_publish_asterisk.c.
Referenced by load_module(), and unload_module().
|
static |
Datastore for attaching devicestate publisher state information.
Definition at line 162 of file res_pjsip_publish_asterisk.c.
Referenced by asterisk_start_mwi_publishing().