Asterisk - The Open Source Telephony Project GIT-master-f36a736
|
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_simple.h>
#include "asterisk/res_pjproject.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_outbound_publish.h"
#include "asterisk/module.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/threadpool.h"
#include "asterisk/datastore.h"
#include "res_pjsip/include/res_pjsip_private.h"
Go to the source code of this file.
Data Structures | |
struct | ast_sip_outbound_publish |
Outbound publish information. More... | |
struct | ast_sip_outbound_publish_client |
Outbound publish client state information (persists for lifetime of a publish) More... | |
struct | ast_sip_outbound_publish_state |
Outbound publish state information (persists for lifetime of a publish) More... | |
struct | publisher_handlers |
struct | sip_outbound_publish_message |
Queued outbound publish message. More... | |
struct | sip_outbound_publisher |
Macros | |
#define | ADD_TO_NEW_STATES(__obj) |
#define | DATASTORE_BUCKETS 53 |
#define | DEFAULT_PUBLISHER_BUCKETS 119 |
#define | DEFAULT_STATE_BUCKETS 31 |
Default number of client state container buckets. More... | |
#define | DESTROY_CLIENT() |
#define | MAX_UNLOAD_TIMEOUT_TIME 35 /* Seconds */ |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static | AO2_GLOBAL_OBJ_STATIC (current_states) |
AO2_STRING_FIELD_CMP_FN (sip_outbound_publisher, user) | |
AO2_STRING_FIELD_HASH_FN (sip_outbound_publisher, user) | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
int | ast_sip_publish_client_add_datastore (struct ast_sip_outbound_publish_client *client, struct ast_datastore *datastore) |
Add a datastore to a SIP event publisher. More... | |
struct ast_datastore * | ast_sip_publish_client_alloc_datastore (const struct ast_datastore_info *info, const char *uid) |
Alternative for ast_datastore_alloc() More... | |
struct ast_sip_outbound_publish_client * | ast_sip_publish_client_get (const char *name) |
Find a publish client using its name. More... | |
struct ast_datastore * | ast_sip_publish_client_get_datastore (struct ast_sip_outbound_publish_client *client, const char *name) |
Retrieve an event publisher datastore. More... | |
const char * | ast_sip_publish_client_get_from_uri (struct ast_sip_outbound_publish_client *client) |
Get the From URI the client will use. More... | |
const char * | ast_sip_publish_client_get_to_uri (struct ast_sip_outbound_publish_client *client) |
Get the To URI the client will use. More... | |
const char * | ast_sip_publish_client_get_user_from_uri (struct ast_sip_outbound_publish_client *client, const char *user, char *uri, size_t size) |
Get the From URI the client will use for a specific user. More... | |
const char * | ast_sip_publish_client_get_user_to_uri (struct ast_sip_outbound_publish_client *client, const char *user, char *uri, size_t size) |
Get the To URI the client will use for a specific user. More... | |
void | ast_sip_publish_client_remove (struct ast_sip_outbound_publish_client *client, const char *user) |
Remove the user from the client (stopping it from publishing) More... | |
void | ast_sip_publish_client_remove_datastore (struct ast_sip_outbound_publish_client *client, const char *name) |
Remove a publication datastore from an event publisher. More... | |
int | ast_sip_publish_client_send (struct ast_sip_outbound_publish_client *client, const struct ast_sip_body *body) |
Send an outgoing PUBLISH message using a client. More... | |
int | ast_sip_publish_client_user_send (struct ast_sip_outbound_publish_client *client, const char *user, const struct ast_sip_body *body) |
Send an outgoing PUBLISH message based on the user. More... | |
int | ast_sip_register_event_publisher_handler (struct ast_sip_event_publisher_handler *handler) |
Register an event publisher handler. More... | |
void | ast_sip_unregister_event_publisher_handler (struct ast_sip_event_publisher_handler *handler) |
Unregister a publish handler. More... | |
static int | can_reuse_publish (struct ast_sip_outbound_publish *existing, struct ast_sip_outbound_publish *applied) |
static int | cancel_and_unpublish (void *obj, void *arg, int flags) |
Helper function which cancels and un-publishes a no longer used client. More... | |
static void | cancel_publish_refresh (struct sip_outbound_publisher *publisher) |
Helper function which cancels the refresh timer on a publisher. More... | |
static int | cancel_refresh_timer_task (void *data) |
Task for cancelling a refresh timer. More... | |
static int | current_state_reusable (struct ast_sip_outbound_publish *publish, struct ast_sip_outbound_publish_state *current_state) |
static int | datastore_cmp (void *obj, void *arg, int flags) |
static int | datastore_hash (const void *obj, int flags) |
static int | explicit_publish_destroy (void *data) |
static struct ast_sip_event_publisher_handler * | find_publisher_handler_for_event_name (const char *event_name) |
static struct ao2_container * | get_publishes_and_update_state (void) |
static int | load_module (void) |
static int | outbound_auth_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | outbound_publish_state_cmp (void *obj, void *arg, int flags) |
comparator function for client objects More... | |
static int | outbound_publish_state_hash (const void *obj, const int flags) |
hashing function for state objects More... | |
static int | publisher_client_send (void *obj, void *arg, void *data, int flags) |
static int | reload_module (void) |
static void | schedule_publish_refresh (struct sip_outbound_publisher *publisher, int expiration) |
Helper function which sets up the timer to send publication. More... | |
static int | send_unpublish_task (void *data) |
Task for sending an unpublish. More... | |
static void | set_transport (struct sip_outbound_publisher *publisher, pjsip_tx_data *tdata) |
static void * | sip_outbound_publish_alloc (const char *name) |
Allocator function for publish information. More... | |
static int | sip_outbound_publish_apply (const struct ast_sorcery *sorcery, void *obj) |
Apply function which finds or allocates a state structure. More... | |
static void | sip_outbound_publish_callback (struct pjsip_publishc_cbparam *param) |
Callback function for publish client responses. More... | |
static struct sip_outbound_publisher * | sip_outbound_publish_client_add_publisher (struct ast_sip_outbound_publish_client *client, const char *user) |
static void | sip_outbound_publish_client_destroy (void *obj) |
Destructor function for publish client. More... | |
static struct sip_outbound_publisher * | sip_outbound_publish_client_get_publisher (struct ast_sip_outbound_publish_client *client, const char *user) |
static void | sip_outbound_publish_datastore_destroy (void *obj) |
static void | sip_outbound_publish_destroy (void *obj) |
Destructor function for publish information. More... | |
static struct ast_sip_outbound_publish_state * | sip_outbound_publish_state_alloc (struct ast_sip_outbound_publish *publish) |
Allocator function for publish client. More... | |
static void | sip_outbound_publish_state_destroy (void *obj) |
Destructor function for publish state. More... | |
static void | sip_outbound_publish_synchronize (struct ast_sip_event_publisher_handler *removed) |
Helper function which starts or stops publish clients when applicable. More... | |
static void | sip_outbound_publish_timer_cb (pj_timer_heap_t *timer_heap, struct pj_timer_entry *entry) |
Publish client timer callback function. More... | |
static struct sip_outbound_publisher * | sip_outbound_publisher_alloc (struct ast_sip_outbound_publish_client *client, const char *user) |
static void | sip_outbound_publisher_destroy (void *obj) |
Destructor function for publish client. More... | |
static int | sip_outbound_publisher_init (void *data) |
Helper function that allocates a pjsip publish client and configures it. More... | |
static int | sip_outbound_publisher_reinit (void *obj, void *arg, int flags) |
static int | sip_outbound_publisher_reinit_all (void *data) |
static int | sip_outbound_publisher_set_uri (pj_pool_t *pool, const char *uri, const char *user, pj_str_t *res_uri) |
static int | sip_outbound_publisher_set_uris (pj_pool_t *pool, struct sip_outbound_publisher *publisher, pj_str_t *server_uri, pj_str_t *to_uri, pj_str_t *from_uri) |
static struct ast_sip_outbound_publish_state * | sip_publish_state_get (const char *id) |
static int | sip_publisher_service_queue (void *data) |
static void | stop_publishing (struct ast_sip_outbound_publish_client *client, struct ast_sip_event_publisher_handler *handler) |
static void | sub_add_handler (struct ast_sip_event_publisher_handler *handler) |
static int | unload_module (void) |
static int | validate_publish_config (struct ast_sip_outbound_publish *publish) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "PJSIP Outbound 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, .requires = "res_pjproject,res_pjsip", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static ast_rwlock_t | load_lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } |
Used for locking while loading/reloading. More... | |
static struct ao2_container * | new_states |
Used on [re]loads to hold new state data. More... | |
static int | pjsip_max_url_size = PJSIP_MAX_URL_SIZE |
struct publisher_handlers | publisher_handlers = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static struct ast_serializer_shutdown_group * | shutdown_group |
#define ADD_TO_NEW_STATES | ( | __obj | ) |
#define DATASTORE_BUCKETS 53 |
Definition at line 1363 of file res_pjsip_outbound_publish.c.
#define DEFAULT_PUBLISHER_BUCKETS 119 |
Definition at line 257 of file res_pjsip_outbound_publish.c.
#define DEFAULT_STATE_BUCKETS 31 |
Default number of client state container buckets.
Definition at line 268 of file res_pjsip_outbound_publish.c.
#define DESTROY_CLIENT | ( | ) |
#define MAX_UNLOAD_TIMEOUT_TIME 35 /* Seconds */ |
Time needs to be long enough for a transaction to timeout if nothing replies.
Definition at line 262 of file res_pjsip_outbound_publish.c.
|
static |
Definition at line 1707 of file res_pjsip_outbound_publish.c.
|
static |
Definition at line 1707 of file res_pjsip_outbound_publish.c.
|
static |
AO2_STRING_FIELD_CMP_FN | ( | sip_outbound_publisher | , |
user | |||
) |
AO2_STRING_FIELD_HASH_FN | ( | sip_outbound_publisher | , |
user | |||
) |
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1707 of file res_pjsip_outbound_publish.c.
int ast_sip_publish_client_add_datastore | ( | struct ast_sip_outbound_publish_client * | client, |
struct ast_datastore * | datastore | ||
) |
Add a datastore to a SIP event publisher.
Note that SIP uses reference counted datastores. The datastore passed into this function must have been allocated using ao2_alloc() or there will be serious problems.
client | The publication client to add the datastore to |
datastore | The datastore to be added to the subscription |
0 | Success |
-1 | Failure |
Definition at line 724 of file res_pjsip_outbound_publish.c.
References ao2_link, ast_assert, ast_strlen_zero(), ast_sip_outbound_publish_client::datastores, ast_datastore::info, NULL, and ast_datastore::uid.
Referenced by asterisk_start_devicestate_publishing(), and asterisk_start_mwi_publishing().
struct ast_datastore * ast_sip_publish_client_alloc_datastore | ( | const struct ast_datastore_info * | info, |
const char * | uid | ||
) |
Alternative for ast_datastore_alloc()
There are two major differences between this and ast_datastore_alloc() 1) This allocates a refcounted object 2) This will fill in a uid if one is not provided
DO NOT call ast_datastore_free() on a datastore allocated in this way since that function will attempt to free the datastore rather than play nicely with its refcount.
info | Callbacks for datastore |
uid | Identifier for datastore |
NULL | Failed to allocate datastore |
non-NULL | Newly allocated datastore |
Definition at line 694 of file res_pjsip_outbound_publish.c.
References ao2_alloc, ao2_cleanup, ao2_ref, ast_strdup, ast_strlen_zero(), ast_uuid_generate_str(), AST_UUID_STR_LEN, sip_to_pjsip::info(), NULL, RAII_VAR, sip_outbound_publish_datastore_destroy(), and ast_datastore::uid.
Referenced by asterisk_start_devicestate_publishing(), and asterisk_start_mwi_publishing().
struct ast_sip_outbound_publish_client * ast_sip_publish_client_get | ( | const char * | name | ) |
Find a publish client using its name.
name | The name of the publish client |
NULL | failure |
non-NULL | success |
Definition at line 528 of file res_pjsip_outbound_publish.c.
References ao2_ref, name, NULL, and sip_publish_state_get().
Referenced by asterisk_publication_devicestate_refresh(), asterisk_publication_mwi_refresh(), and send_refresh_cb().
struct ast_datastore * ast_sip_publish_client_get_datastore | ( | struct ast_sip_outbound_publish_client * | client, |
const char * | name | ||
) |
Retrieve an event publisher datastore.
The datastore retrieved will have its reference count incremented. When the caller is done with the datastore, the reference counted needs to be decremented using ao2_ref().
client | The publication client from which to retrieve the datastore |
name | The name of the datastore to retrieve |
NULL | Failed to find the specified datastore |
non-NULL | The specified datastore |
Definition at line 737 of file res_pjsip_outbound_publish.c.
References ao2_find, ast_sip_outbound_publish_client::datastores, name, and OBJ_SEARCH_KEY.
Referenced by asterisk_publication_devicestate_refresh(), asterisk_publication_mwi_refresh(), asterisk_stop_devicestate_publishing(), and asterisk_stop_mwi_publishing().
const char * ast_sip_publish_client_get_from_uri | ( | struct ast_sip_outbound_publish_client * | client | ) |
Get the From URI the client will use.
client | The publication client to get the From URI |
From-uri | on success |
Empty-string | on failure |
Definition at line 541 of file res_pjsip_outbound_publish.c.
References publish, ast_sip_outbound_publish_client::publish, and S_OR.
const char * ast_sip_publish_client_get_to_uri | ( | struct ast_sip_outbound_publish_client * | client | ) |
Get the To URI the client will use.
client | The publication client to get the To URI |
From-uri | on success |
Empty-string | on failure |
Definition at line 591 of file res_pjsip_outbound_publish.c.
References publish, ast_sip_outbound_publish_client::publish, and S_OR.
const char * ast_sip_publish_client_get_user_from_uri | ( | struct ast_sip_outbound_publish_client * | client, |
const char * | user, | ||
char * | uri, | ||
size_t | size | ||
) |
Get the From URI the client will use for a specific user.
client | The publication client to get the From URI of a user |
user | The user to retrieve the From URI for |
uri | A buffer to place the URI into |
size | The size of the buffer |
From-uri | on success |
Empty-string | on failure |
Definition at line 575 of file res_pjsip_outbound_publish.c.
References ao2_ref, ast_copy_string(), sip_outbound_publisher::client, sip_outbound_publisher::from_uri, NULL, and sip_outbound_publish_client_get_publisher().
Referenced by exten_state_publisher_cb().
const char * ast_sip_publish_client_get_user_to_uri | ( | struct ast_sip_outbound_publish_client * | client, |
const char * | user, | ||
char * | uri, | ||
size_t | size | ||
) |
Get the To URI the client will use for a specific user.
client | The publication client to get the To URI of a user |
user | The user to retrieve the To URI for |
uri | A buffer to place the URI into |
size | The size of the buffer |
To-uri | on success |
Empty-string | on failure |
Definition at line 598 of file res_pjsip_outbound_publish.c.
References ao2_ref, ast_copy_string(), sip_outbound_publisher::client, NULL, sip_outbound_publish_client_get_publisher(), and sip_outbound_publisher::to_uri.
Referenced by exten_state_publisher_cb().
void ast_sip_publish_client_remove | ( | struct ast_sip_outbound_publish_client * | client, |
const char * | user | ||
) |
Remove the user from the client (stopping it from publishing)
client | The publication client |
user | The user to remove |
Definition at line 1125 of file res_pjsip_outbound_publish.c.
References ao2_find, sip_outbound_publisher::client, load_lock, lock, OBJ_NODATA, OBJ_SEARCH_KEY, OBJ_UNLINK, and SCOPED_WRLOCK.
void ast_sip_publish_client_remove_datastore | ( | struct ast_sip_outbound_publish_client * | client, |
const char * | name | ||
) |
Remove a publication datastore from an event publisher.
This operation may cause the datastore's free() callback to be called if the reference count reaches zero.
client | The publication client to remove the datastore from |
name | The name of the datastore to remove |
Definition at line 743 of file res_pjsip_outbound_publish.c.
References ao2_find, ast_sip_outbound_publish_client::datastores, name, OBJ_NODATA, OBJ_SEARCH_KEY, and OBJ_UNLINK.
Referenced by asterisk_start_devicestate_publishing(), asterisk_start_mwi_publishing(), asterisk_stop_devicestate_publishing(), and asterisk_stop_mwi_publishing().
int ast_sip_publish_client_send | ( | struct ast_sip_outbound_publish_client * | client, |
const struct ast_sip_body * | body | ||
) |
Send an outgoing PUBLISH message using a client.
client | The publication client to send from |
body | An optional body to add to the PUBLISH |
-1 | failure |
0 | success |
Definition at line 842 of file res_pjsip_outbound_publish.c.
References ao2_callback_data, sip_outbound_publish_message::body, lock, OBJ_NODATA, publisher_client_send(), ast_sip_outbound_publish_client::publishers, and SCOPED_AO2LOCK.
Referenced by asterisk_publisher_devstate_cb(), asterisk_publisher_mwistate_cb(), and send_refresh_cb().
int ast_sip_publish_client_user_send | ( | struct ast_sip_outbound_publish_client * | client, |
const char * | user, | ||
const struct ast_sip_body * | body | ||
) |
Send an outgoing PUBLISH message based on the user.
client | The publication client to send from |
user | The user to send to |
body | An optional body to add to the PUBLISH |
-1 | failure |
0 | success |
Definition at line 1109 of file res_pjsip_outbound_publish.c.
References ao2_ref, sip_outbound_publisher::client, publisher_client_send(), and sip_outbound_publish_client_get_publisher().
Referenced by exten_state_publisher_cb().
int ast_sip_register_event_publisher_handler | ( | struct ast_sip_event_publisher_handler * | handler | ) |
Register an event publisher handler.
0 | Handler was registered successfully |
non-zero | Handler was not registered successfully |
Definition at line 614 of file res_pjsip_outbound_publish.c.
References ast_log, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), find_publisher_handler_for_event_name(), handler(), lock, LOG_ERROR, NULL, SCOPED_LOCK, sip_outbound_publish_synchronize(), and sub_add_handler().
Referenced by load_module().
void ast_sip_unregister_event_publisher_handler | ( | struct ast_sip_event_publisher_handler * | handler | ) |
Unregister a publish handler.
Definition at line 641 of file res_pjsip_outbound_publish.c.
References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, handler(), lock, ast_sip_event_publisher_handler::next, SCOPED_LOCK, and sip_outbound_publish_synchronize().
Referenced by load_module(), and unload_module().
|
static |
Definition at line 1239 of file res_pjsip_outbound_publish.c.
References AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sip_outbound_publish::event, ast_sip_outbound_publish::from_uri, ast_sip_outbound_publish::outbound_auths, ast_sip_outbound_publish::outbound_proxy, ast_sip_outbound_publish::server_uri, and ast_sip_outbound_publish::to_uri.
Referenced by current_state_reusable().
|
static |
Helper function which cancels and un-publishes a no longer used client.
Definition at line 1152 of file res_pjsip_outbound_publish.c.
References ao2_bump, ao2_ref, ast_log, ast_sip_push_task(), ast_sorcery_object_get_id(), cancel_refresh_timer_task(), sip_outbound_publisher::destroy, explicit_publish_destroy(), lock, LOG_WARNING, sip_outbound_publisher::owner, ast_sip_outbound_publish_client::publish, SCOPED_AO2LOCK, send_unpublish_task(), sip_outbound_publisher::sending, sip_outbound_publisher::serializer, and ast_sip_outbound_publish_client::started.
Referenced by sip_outbound_publish_state_destroy(), and sip_outbound_publish_synchronize().
|
static |
Helper function which cancels the refresh timer on a publisher.
Definition at line 363 of file res_pjsip_outbound_publish.c.
References ao2_ref, ast_sip_get_pjsip_endpoint(), and sip_outbound_publisher::timer.
Referenced by cancel_refresh_timer_task(), and schedule_publish_refresh().
|
static |
Task for cancelling a refresh timer.
Definition at line 417 of file res_pjsip_outbound_publish.c.
References ao2_ref, and cancel_publish_refresh().
Referenced by cancel_and_unpublish(), and sip_outbound_publish_client_add_publisher().
|
static |
Definition at line 1492 of file res_pjsip_outbound_publish.c.
References ao2_cleanup, ao2_ref, ast_log, ast_sip_push_task_wait_servant(), ast_sorcery_object_get_id(), can_reuse_publish(), ast_sip_outbound_publish_state::client, LOG_ERROR, ast_sip_outbound_publish::multi_user, NULL, publish, ast_sip_outbound_publish_client::publish, ast_sip_outbound_publish_client::publishers, and sip_outbound_publisher_reinit_all().
Referenced by sip_outbound_publish_apply().
|
static |
Definition at line 1387 of file res_pjsip_outbound_publish.c.
References CMP_MATCH, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, OBJ_SEARCH_PARTIAL_KEY, and ast_datastore::uid.
Referenced by sip_outbound_publish_state_alloc().
|
static |
Definition at line 1365 of file res_pjsip_outbound_publish.c.
References ast_assert, ast_str_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and ast_datastore::uid.
Referenced by sip_outbound_publish_state_alloc().
|
static |
Definition at line 1132 of file res_pjsip_outbound_publish.c.
References ao2_ref, and sip_outbound_publisher::client.
Referenced by cancel_and_unpublish().
|
static |
Definition at line 350 of file res_pjsip_outbound_publish.c.
References AST_RWLIST_TRAVERSE, ast_sip_event_publisher_handler::event_name, and ast_sip_event_publisher_handler::next.
Referenced by ast_sip_register_event_publisher_handler(), sip_outbound_publish_synchronize(), and stop_publishing().
|
static |
Definition at line 323 of file res_pjsip_outbound_publish.c.
References ao2_cleanup, ao2_global_obj_replace_unref, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_fields(), container, load_lock, lock, new_states, NULL, and SCOPED_WRLOCK.
Referenced by sip_outbound_publish_synchronize().
|
static |
Definition at line 1647 of file res_pjsip_outbound_publish.c.
References ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_pjproject_get_buildopt(), AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_serializer_shutdown_group_alloc(), ast_sip_get_pjsip_endpoint(), ast_sip_get_sorcery(), 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(), ast_sip_outbound_publish::expiration, FLDSET, ast_sip_outbound_publish::from_uri, LOG_ERROR, ast_sip_outbound_publish::max_auth_attempts, ast_sip_outbound_publish::multi_user, NULL, OPT_BOOL_T, OPT_NOOP_T, OPT_STRINGFIELD_T, OPT_UINT_T, outbound_auth_handler(), ast_sip_outbound_publish::outbound_proxy, pjsip_max_url_size, server_uri, shutdown_group, sip_outbound_publish_alloc(), sip_outbound_publish_apply(), sip_outbound_publish_synchronize(), STRFLDSET, ast_sip_outbound_publish::to_uri, ast_sip_outbound_publish::transport, and unload_module().
|
static |
Definition at line 1614 of file res_pjsip_outbound_publish.c.
References ast_sip_auth_vector_init(), publish, and var.
Referenced by load_module().
|
static |
comparator function for client objects
Definition at line 295 of file res_pjsip_outbound_publish.c.
References ast_assert, CMP_MATCH, ast_sip_outbound_publish_state::id, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.
Referenced by sip_outbound_publish_apply().
|
static |
hashing function for state objects
Definition at line 274 of file res_pjsip_outbound_publish.c.
References ast_assert, ast_str_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.
Referenced by sip_outbound_publish_apply().
|
static |
Definition at line 796 of file res_pjsip_outbound_publish.c.
References ao2_bump, ao2_ref, ast_calloc, AST_LIST_INSERT_TAIL, ast_sip_push_task(), sip_outbound_publish_message::body, ast_sip_body::body_text, sip_outbound_publisher::client, lock, sip_outbound_publisher::queue, SCOPED_AO2LOCK, sip_outbound_publisher::serializer, sip_publisher_service_queue(), ast_sip_body::subtype, and ast_sip_body::type.
Referenced by ast_sip_publish_client_send(), ast_sip_publish_client_user_send(), and sip_outbound_publish_timer_cb().
|
static |
Definition at line 1690 of file res_pjsip_outbound_publish.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_sip_get_sorcery(), ast_sorcery_reload_object(), NULL, and sip_outbound_publish_synchronize().
|
static |
Helper function which sets up the timer to send publication.
Definition at line 373 of file res_pjsip_outbound_publish.c.
References ao2_bump, ao2_ref, ast_log, ast_sip_get_pjsip_endpoint(), cancel_publish_refresh(), ast_sip_outbound_publish::expiration, LOG_WARNING, sip_outbound_publisher::owner, publish, ast_sip_outbound_publish_client::publish, and sip_outbound_publisher::timer.
Referenced by sip_outbound_publish_callback().
|
static |
Task for sending an unpublish.
Definition at line 440 of file res_pjsip_outbound_publish.c.
References ao2_ref, sip_outbound_publisher::client, and set_transport().
Referenced by cancel_and_unpublish(), and sip_outbound_publish_callback().
|
static |
Definition at line 427 of file res_pjsip_outbound_publish.c.
References ast_sip_set_tpselector_from_transport_name(), ast_sip_tpselector_unref(), ast_strlen_zero(), sip_outbound_publisher::owner, ast_sip_outbound_publish_client::publish, and ast_sip_outbound_publish::transport.
Referenced by send_unpublish_task(), sip_outbound_publish_callback(), and sip_publisher_service_queue().
|
static |
Allocator function for publish information.
Definition at line 667 of file res_pjsip_outbound_publish.c.
References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, NULL, publish, and sip_outbound_publish_destroy().
Referenced by load_module().
|
static |
Apply function which finds or allocates a state structure.
Definition at line 1545 of file res_pjsip_outbound_publish.c.
References ADD_TO_NEW_STATES, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_hash, ao2_ref, ast_log, ast_sorcery_object_get_id(), ast_sip_outbound_publish_state::client, current_state_reusable(), DEFAULT_STATE_BUCKETS, LOG_ERROR, ast_sip_outbound_publish::multi_user, new_states, NULL, outbound_publish_state_cmp(), outbound_publish_state_hash(), sip_outbound_publish_client_add_publisher(), sip_outbound_publish_state_alloc(), sip_publish_state_get(), and validate_publish_config().
Referenced by load_module().
|
static |
Callback function for publish client responses.
Definition at line 1260 of file res_pjsip_outbound_publish.c.
References ao2_bump, ao2_cleanup, ao2_ref, ast_free, AST_LIST_EMPTY, AST_LIST_REMOVE_HEAD, ast_log, ast_sip_create_request_with_auth(), ast_sip_push_task(), ast_sorcery_object_get_id(), DESTROY_CLIENT, end, lock, LOG_ERROR, LOG_NOTICE, LOG_WARNING, NULL, publish, RAII_VAR, schedule_publish_refresh(), SCOPED_AO2LOCK, send_unpublish_task(), set_transport(), sip_outbound_publisher_init(), and sip_publisher_service_queue().
Referenced by sip_outbound_publisher_init().
|
static |
Definition at line 1085 of file res_pjsip_outbound_publish.c.
References ao2_link, ao2_ref, ast_sip_push_task(), cancel_refresh_timer_task(), sip_outbound_publisher::client, NULL, sip_outbound_publisher::serializer, and sip_outbound_publisher_alloc().
Referenced by sip_outbound_publish_apply(), and sip_outbound_publish_client_get_publisher().
|
static |
Destructor function for publish client.
Definition at line 1188 of file res_pjsip_outbound_publish.c.
References ao2_cleanup, ast_sip_outbound_publish_client::datastores, and ast_sip_outbound_publish_client::publish.
Referenced by sip_outbound_publish_state_alloc().
|
static |
Definition at line 551 of file res_pjsip_outbound_publish.c.
References ao2_find, ast_rwlock_unlock, ast_rwlock_wrlock, sip_outbound_publisher::client, load_lock, NULL, OBJ_SEARCH_KEY, and sip_outbound_publish_client_add_publisher().
Referenced by ast_sip_publish_client_get_user_from_uri(), ast_sip_publish_client_get_user_to_uri(), and ast_sip_publish_client_user_send().
|
static |
Definition at line 680 of file res_pjsip_outbound_publish.c.
References ast_free, ast_datastore::data, ast_datastore_info::destroy, ast_datastore::info, NULL, and ast_datastore::uid.
Referenced by ast_sip_publish_client_alloc_datastore().
|
static |
Destructor function for publish information.
Definition at line 657 of file res_pjsip_outbound_publish.c.
References ast_sip_auth_vector_destroy(), ast_string_field_free_memory, and publish.
Referenced by sip_outbound_publish_alloc().
|
static |
Allocator function for publish client.
Definition at line 1423 of file res_pjsip_outbound_publish.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_bump, ao2_container_alloc_hash, ao2_ref, ast_sorcery_object_get_id(), DATASTORE_BUCKETS, datastore_cmp(), datastore_hash(), NULL, publish, sip_outbound_publish_client_destroy(), sip_outbound_publish_state_destroy(), and state.
Referenced by sip_outbound_publish_apply().
|
static |
Destructor function for publish state.
Definition at line 1204 of file res_pjsip_outbound_publish.c.
References ao2_callback, ao2_cleanup, cancel_and_unpublish(), NULL, OBJ_NODATA, OBJ_UNLINK, and stop_publishing().
Referenced by sip_outbound_publish_state_alloc().
|
static |
Helper function which starts or stops publish clients when applicable.
Definition at line 470 of file res_pjsip_outbound_publish.c.
References ao2_bump, ao2_callback, ao2_cleanup, ao2_global_obj_ref, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_debug, ast_log, ast_sorcery_object_get_id(), cancel_and_unpublish(), ast_sip_event_publisher_handler::event_name, find_publisher_handler_for_event_name(), get_publishes_and_update_state(), handler(), LOG_ERROR, NULL, OBJ_NODATA, publish, RAII_VAR, state, and stop_publishing().
Referenced by ast_sip_register_event_publisher_handler(), ast_sip_unregister_event_publisher_handler(), load_module(), and reload_module().
|
static |
Publish client timer callback function.
Definition at line 401 of file res_pjsip_outbound_publish.c.
References ao2_lock, ao2_ref, ao2_unlock, AST_LIST_EMPTY, NULL, publisher_client_send(), and sip_outbound_publisher::queue.
Referenced by sip_outbound_publisher_alloc().
|
static |
Definition at line 1033 of file res_pjsip_outbound_publish.c.
References ao2_alloc, ao2_bump, ao2_ref, ast_log, ast_sip_create_serializer_group(), ast_sip_push_task_wait_servant(), ast_sorcery_object_get_id(), ast_taskprocessor_build_name(), AST_TASKPROCESSOR_MAX_NAME, sip_outbound_publisher::client, LOG_ERROR, NULL, sip_outbound_publisher::owner, sip_outbound_publisher::serializer, shutdown_group, sip_outbound_publish_timer_cb(), sip_outbound_publisher_destroy(), sip_outbound_publisher_init(), sip_outbound_publisher::timer, and sip_outbound_publisher::user.
Referenced by sip_outbound_publish_client_add_publisher().
|
static |
Destructor function for publish client.
Definition at line 1015 of file res_pjsip_outbound_publish.c.
References ao2_cleanup, ast_free, AST_LIST_REMOVE_HEAD, ast_taskprocessor_unreference(), sip_outbound_publisher::from_uri, sip_outbound_publisher::owner, sip_outbound_publisher::queue, sip_outbound_publisher::serializer, and sip_outbound_publisher::to_uri.
Referenced by sip_outbound_publisher_alloc().
|
static |
Helper function that allocates a pjsip publish client and configures it.
Definition at line 935 of file res_pjsip_outbound_publish.c.
References ao2_bump, ao2_cleanup, ao2_ref, ast_log, ast_sip_get_pjsip_endpoint(), ast_sorcery_object_get_id(), ast_strlen_zero(), sip_outbound_publisher::client, sip_outbound_publisher::from_uri, LOG_ERROR, NULL, sip_outbound_publisher::owner, pjsip_max_url_size, publish, ast_sip_outbound_publish_client::publish, RAII_VAR, server_uri, sip_outbound_publish_callback(), sip_outbound_publisher_set_uris(), and sip_outbound_publisher::to_uri.
Referenced by sip_outbound_publish_callback(), sip_outbound_publisher_alloc(), and sip_outbound_publisher_reinit().
|
static |
Definition at line 1003 of file res_pjsip_outbound_publish.c.
References sip_outbound_publisher_init().
Referenced by sip_outbound_publisher_reinit_all().
|
static |
Definition at line 1008 of file res_pjsip_outbound_publish.c.
References ao2_callback, NULL, OBJ_NODATA, and sip_outbound_publisher_reinit().
Referenced by current_state_reusable().
|
static |
Definition at line 853 of file res_pjsip_outbound_publish.c.
References ast_strlen_zero(), pjsip_max_url_size, and tmp().
Referenced by sip_outbound_publisher_set_uris().
|
static |
Definition at line 889 of file res_pjsip_outbound_publish.c.
References ast_log, ast_sorcery_object_get_id(), ast_strdup, ast_strlen_zero(), ast_sip_outbound_publish::from_uri, sip_outbound_publisher::from_uri, LOG_ERROR, sip_outbound_publisher::owner, publish, ast_sip_outbound_publish_client::publish, server_uri, sip_outbound_publisher_set_uri(), ast_sip_outbound_publish::to_uri, sip_outbound_publisher::to_uri, and sip_outbound_publisher::user.
Referenced by sip_outbound_publisher_init().
|
static |
Definition at line 514 of file res_pjsip_outbound_publish.c.
References ao2_find, ao2_global_obj_ref, ao2_ref, NULL, and OBJ_SEARCH_KEY.
Referenced by ast_sip_publish_client_get(), and sip_outbound_publish_apply().
|
static |
Definition at line 749 of file res_pjsip_outbound_publish.c.
References ao2_bump, ao2_cleanup, ao2_ref, ast_free, AST_LIST_FIRST, AST_LIST_REMOVE_HEAD, ast_sip_add_body(), ast_sip_push_task(), ast_strlen_zero(), ast_datastore::data, lock, RAII_VAR, SCOPED_AO2LOCK, service, set_transport(), sip_publisher_service_queue(), and status.
Referenced by publisher_client_send(), sip_outbound_publish_callback(), and sip_publisher_service_queue().
|
static |
Definition at line 455 of file res_pjsip_outbound_publish.c.
References sip_outbound_publisher::client, find_publisher_handler_for_event_name(), and handler().
Referenced by sip_outbound_publish_state_destroy(), and sip_outbound_publish_synchronize().
|
static |
Definition at line 345 of file res_pjsip_outbound_publish.c.
References AST_RWLIST_INSERT_TAIL, and handler().
Referenced by ast_sip_register_event_publisher_handler().
|
static |
Definition at line 1622 of file res_pjsip_outbound_publish.c.
References ao2_cleanup, ao2_global_obj_release, ast_debug, ast_log, ast_serializer_shutdown_group_join(), ast_sip_get_sorcery(), ast_sorcery_object_unregister(), LOG_WARNING, MAX_UNLOAD_TIMEOUT_TIME, NULL, and shutdown_group.
Referenced by load_module().
|
static |
Definition at line 1461 of file res_pjsip_outbound_publish.c.
References ast_log, ast_sip_validate_uri_length(), ast_sorcery_object_get_id(), ast_strlen_zero(), LOG_ERROR, and publish.
Referenced by sip_outbound_publish_apply().
|
static |
Definition at line 1707 of file res_pjsip_outbound_publish.c.
|
static |
Definition at line 1707 of file res_pjsip_outbound_publish.c.
|
static |
Used for locking while loading/reloading.
Mutli-user configurations make it so publishers can be dynamically added and removed. Publishers should not be added or removed during a [re]load since it could cause the current_clients container to be out of sync. Thus the reason for this lock.
Definition at line 255 of file res_pjsip_outbound_publish.c.
Referenced by ast_sip_publish_client_remove(), get_publishes_and_update_state(), and sip_outbound_publish_client_get_publisher().
|
static |
Used on [re]loads to hold new state data.
Definition at line 271 of file res_pjsip_outbound_publish.c.
Referenced by get_publishes_and_update_state(), load_module(), and sip_outbound_publish_apply().
|
static |
Definition at line 124 of file res_pjsip_outbound_publish.c.
Referenced by load_module(), sip_outbound_publisher_init(), and sip_outbound_publisher_set_uri().
struct publisher_handlers publisher_handlers = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
|
static |
Shutdown group to monitor sip_outbound_registration_client_state serializers.
Definition at line 265 of file res_pjsip_outbound_publish.c.
Referenced by load_module(), sip_outbound_publisher_alloc(), and unload_module().