Asterisk - The Open Source Telephony Project GIT-master-2de1a68
|
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_ua.h>
#include "asterisk/cli.h"
#include "asterisk/config.h"
#include "asterisk/manager.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_session.h"
#include "asterisk/sorcery.h"
Go to the source code of this file.
Data Structures | |
struct | notify_cfg |
struct | notify_channel_data |
struct | notify_data |
struct | notify_option |
struct | notify_option_item |
struct | notify_uri_data |
Macros | |
#define | CONTENT_SIZE 512 |
#define | CONTENT_TYPE_SIZE 64 |
Typedefs | |
typedef struct notify_channel_data *(* | task_channel_data_create) (struct ast_sip_session *session, void *info) |
typedef struct notify_data *(* | task_data_create) (struct ast_sip_endpoint *, void *info) |
typedef struct notify_uri_data *(* | task_uri_data_create) (const char *uri, void *info) |
Enumerations | |
enum | notify_result { SUCCESS , INVALID_ENDPOINT , INVALID_CHANNEL , ALLOC_ERROR , TASK_PUSH_ERROR } |
enum | notify_type { NOTIFY_ENDPOINT , NOTIFY_URI , NOTIFY_CHANNEL } |
Functions | |
static void | __reg_module (void) |
static void | __unreg_module (void) |
AO2_GLOBAL_OBJ_STATIC (globals) | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
static void | build_ami_notify (pjsip_tx_data *tdata, void *info) |
static void | build_cli_notify (pjsip_tx_data *tdata, void *info) |
static void | build_notify (pjsip_tx_data *tdata, const char *name, const char *value, struct ast_str **content_type, struct ast_str **content) |
static void | build_notify_body (pjsip_tx_data *tdata, struct ast_str *content_type, struct ast_str *content) |
static char * | cli_complete_endpoint (const char *word) |
static char * | cli_complete_notify (const char *line, const char *word, int pos, int state, int using_uri) |
static char * | cli_notify (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
CONFIG_INFO_STANDARD (notify_cfg, globals, notify_cfg_alloc,.files=ACO_FILES(&module_conf)) | |
static int | load_module (void) |
static int | manager_notify (struct mansession *s, const struct message *m) |
static void | manager_notify_channel (struct mansession *s, const struct message *m, const char *channel) |
static void | manager_notify_endpoint (struct mansession *s, const struct message *m, const char *endpoint_name) |
static void | manager_notify_uri (struct mansession *s, const struct message *m, const char *uri) |
static void | manager_send_response (struct mansession *s, const struct message *m, enum notify_type type, enum notify_result res, struct ast_variable *vars, const char *endpoint_name) |
static int | multiple_headers_allowed (const char *name) |
static int | not_allowed (const char *name) |
static struct notify_channel_data * | notify_ami_channel_data_create (struct ast_sip_session *session, void *info) |
static void | notify_ami_channel_data_destroy (void *obj) |
static struct notify_data * | notify_ami_data_create (struct ast_sip_endpoint *endpoint, void *info) |
static void | notify_ami_data_destroy (void *obj) |
static struct notify_uri_data * | notify_ami_uri_data_create (const char *uri, void *info) |
static void | notify_ami_uri_data_destroy (void *obj) |
static void * | notify_cfg_alloc (void) |
static void | notify_cfg_destroy (void *obj) |
static int | notify_channel (void *obj) |
static struct notify_data * | notify_cli_data_create (struct ast_sip_endpoint *endpoint, void *info) |
static void | notify_cli_data_destroy (void *obj) |
static struct notify_uri_data * | notify_cli_uri_data_create (const char *uri, void *info) |
static void | notify_cli_uri_data_destroy (void *obj) |
static int | notify_contact (void *obj, void *arg, int flags) |
static int | notify_endpoint (void *obj) |
static void * | notify_option_alloc (const char *category) |
static int | notify_option_cmp (void *obj, void *arg, int flags) |
static void | notify_option_destroy (void *obj) |
static void * | notify_option_find (struct ao2_container *container, const char *category) |
static int | notify_option_handler (const struct aco_option *opt, struct ast_variable *var, void *obj) |
static int | notify_option_hash (const void *obj, int flags) |
static int | notify_uri (void *obj) |
static enum notify_result | push_notify (const char *endpoint_name, void *info, task_data_create data_create) |
static enum notify_result | push_notify_channel (const char *channel_name, void *info, task_channel_data_create data_create) |
static enum notify_result | push_notify_uri (const char *uri, void *info, task_uri_data_create data_create) |
static int | reload_module (void) |
static int | unload_module (void) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "CLI/AMI PJSIP NOTIFY 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_APP_DEPEND, .requires = "res_pjsip", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static struct ast_cli_entry | cli_options [] |
static struct aco_file | module_conf |
static const char | notify_config [] = "pjsip_notify.conf" |
static struct aco_type | notify_option |
static struct aco_type * | notify_options [] = ACO_TYPES(¬ify_option) |
#define CONTENT_SIZE 512 |
Definition at line 121 of file res_pjsip_notify.c.
#define CONTENT_TYPE_SIZE 64 |
Definition at line 120 of file res_pjsip_notify.c.
typedef struct notify_channel_data *(* task_channel_data_create) (struct ast_sip_session *session, void *info) |
Definition at line 756 of file res_pjsip_notify.c.
typedef struct notify_data *(* task_data_create) (struct ast_sip_endpoint *, void *info) |
Definition at line 756 of file res_pjsip_notify.c.
typedef struct notify_uri_data *(* task_uri_data_create) (const char *uri, void *info) |
Definition at line 756 of file res_pjsip_notify.c.
enum notify_result |
Enumerator | |
---|---|
SUCCESS | |
INVALID_ENDPOINT | |
INVALID_CHANNEL | |
ALLOC_ERROR | |
TASK_PUSH_ERROR |
Definition at line 787 of file res_pjsip_notify.c.
enum notify_type |
Enumerator | |
---|---|
NOTIFY_ENDPOINT | |
NOTIFY_URI | |
NOTIFY_CHANNEL |
Definition at line 1079 of file res_pjsip_notify.c.
|
static |
Definition at line 1295 of file res_pjsip_notify.c.
|
static |
Definition at line 1295 of file res_pjsip_notify.c.
AO2_GLOBAL_OBJ_STATIC | ( | globals | ) |
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1295 of file res_pjsip_notify.c.
|
static |
Definition at line 627 of file res_pjsip_notify.c.
References ast_free, ast_log, build_notify(), build_notify_body(), sip_to_pjsip::info(), LOG_NOTICE, ast_variable::name, ast_variable::next, NULL, RAII_VAR, and ast_variable::value.
Referenced by notify_ami_channel_data_create(), notify_ami_data_create(), and notify_ami_uri_data_create().
|
static |
Definition at line 603 of file res_pjsip_notify.c.
References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_free, build_notify(), build_notify_body(), sip_to_pjsip::info(), item, notify_option::items, aco_type::name, NULL, and RAII_VAR.
Referenced by notify_cli_data_create(), and notify_cli_uri_data_create().
|
static |
Definition at line 558 of file res_pjsip_notify.c.
References ast_log, ast_sip_add_header(), ast_str_append(), ast_str_create, ast_str_set(), ast_str_strlen(), CONTENT_SIZE, CONTENT_TYPE_SIZE, LOG_ERROR, LOG_WARNING, multiple_headers_allowed(), name, not_allowed(), NULL, and value.
Referenced by build_ami_notify(), and build_cli_notify().
|
static |
Definition at line 534 of file res_pjsip_notify.c.
References ast_sip_add_body(), ast_str_buffer(), ast_sip_body::body_text, ast_sip_body::subtype, and ast_sip_body::type.
Referenced by build_ami_notify(), and build_cli_notify().
|
static |
Definition at line 918 of file res_pjsip_notify.c.
References ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_cli_completion_add(), ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_prefix(), ast_strdup, endpoints, and NULL.
Referenced by cli_complete_notify().
|
static |
Definition at line 948 of file res_pjsip_notify.c.
References ao2_cleanup, ao2_global_obj_ref, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_strdup, ast_strlen_zero(), c, cli_complete_endpoint(), globals, notify_option::name, NULL, and RAII_VAR.
Referenced by cli_notify().
|
static |
Definition at line 1008 of file res_pjsip_notify.c.
References a, ALLOC_ERROR, ao2_cleanup, ao2_global_obj_ref, ast_cli(), cli_complete_notify(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, globals, INVALID_ENDPOINT, notify_cli_data_create(), notify_cli_uri_data_create(), notify_option_find(), NULL, push_notify(), push_notify_uri(), RAII_VAR, TASK_PUSH_ERROR, and ast_cli_entry::usage.
CONFIG_INFO_STANDARD | ( | notify_cfg | , |
globals | , | ||
notify_cfg_alloc | , | ||
. | files = ACO_FILES(&module_conf) |
||
) |
|
static |
Definition at line 1249 of file res_pjsip_notify.c.
References aco_info_destroy(), aco_info_init(), aco_option_register_custom, ACO_PREFIX, aco_process_config(), ARRAY_LEN, ast_cli_register_multiple, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, cli_options, EVENT_FLAG_SYSTEM, manager_notify(), notify_option_handler(), and notify_options.
|
static |
Definition at line 1208 of file res_pjsip_notify.c.
References ast_strlen_zero(), astman_get_header(), astman_send_error(), manager_notify_channel(), manager_notify_endpoint(), and manager_notify_uri().
Referenced by load_module().
|
static |
Definition at line 1192 of file res_pjsip_notify.c.
References astman_get_variables_order(), manager_send_response(), notify_ami_channel_data_create(), NOTIFY_CHANNEL, NULL, ORDER_NATURAL, and push_notify_channel().
Referenced by manager_notify().
|
static |
Definition at line 1124 of file res_pjsip_notify.c.
References ao2_cleanup, ao2_global_obj_ref, ast_strlen_zero(), astman_get_header(), astman_get_variables_order(), astman_send_error_va(), globals, manager_send_response(), notify_ami_data_create(), notify_cli_data_create(), NOTIFY_ENDPOINT, notify_option_find(), NULL, ORDER_NATURAL, push_notify(), and RAII_VAR.
Referenced by manager_notify().
|
static |
Definition at line 1162 of file res_pjsip_notify.c.
References ao2_cleanup, ao2_global_obj_ref, ast_strlen_zero(), astman_get_header(), astman_get_variables_order(), astman_send_error_va(), globals, manager_send_response(), notify_ami_uri_data_create(), notify_cli_uri_data_create(), notify_option_find(), NOTIFY_URI, NULL, ORDER_NATURAL, push_notify_uri(), and RAII_VAR.
Referenced by manager_notify().
|
static |
Definition at line 1085 of file res_pjsip_notify.c.
References ALLOC_ERROR, ast_assert, ast_variables_destroy(), astman_send_ack(), astman_send_error(), astman_send_error_va(), INVALID_CHANNEL, INVALID_ENDPOINT, NOTIFY_CHANNEL, NOTIFY_ENDPOINT, SUCCESS, TASK_PUSH_ERROR, and type.
Referenced by manager_notify_channel(), manager_notify_endpoint(), and manager_notify_uri().
|
static |
Definition at line 523 of file res_pjsip_notify.c.
References name.
Referenced by build_notify().
|
static |
Definition at line 496 of file res_pjsip_notify.c.
References ARRAY_LEN, and name.
Referenced by build_notify().
|
static |
Definition at line 470 of file res_pjsip_notify.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, build_ami_notify(), notify_channel_data::build_notify, sip_to_pjsip::info(), notify_channel_data::info, notify_ami_channel_data_destroy(), NULL, notify_channel_data::session, and session.
Referenced by manager_notify_channel().
|
static |
Definition at line 408 of file res_pjsip_notify.c.
References ao2_cleanup, ast_variables_destroy(), sip_to_pjsip::info(), notify_channel_data::info, and notify_channel_data::session.
Referenced by notify_ami_channel_data_create().
|
static |
Definition at line 423 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, build_ami_notify(), notify_data::build_notify, notify_data::endpoint, sip_to_pjsip::info(), notify_data::info, notify_ami_data_destroy(), and NULL.
Referenced by manager_notify_endpoint().
|
static |
Definition at line 382 of file res_pjsip_notify.c.
References ao2_cleanup, ast_variables_destroy(), notify_data::endpoint, sip_to_pjsip::info(), and notify_data::info.
Referenced by notify_ami_data_create().
|
static |
Definition at line 445 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, ast_strdup, build_ami_notify(), notify_uri_data::build_notify, sip_to_pjsip::info(), notify_uri_data::info, notify_ami_uri_data_destroy(), NULL, and notify_uri_data::uri.
Referenced by manager_notify_uri().
|
static |
Definition at line 395 of file res_pjsip_notify.c.
References ast_free, ast_variables_destroy(), sip_to_pjsip::info(), notify_uri_data::info, and notify_uri_data::uri.
Referenced by notify_ami_uri_data_create().
|
static |
Definition at line 226 of file res_pjsip_notify.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_hash, notify_cfg_destroy(), notify_option_cmp(), notify_option_hash(), notify_cfg::notify_options, and NULL.
|
static |
Definition at line 220 of file res_pjsip_notify.c.
References ao2_cleanup, and notify_cfg::notify_options.
Referenced by notify_cfg_alloc().
|
static |
Definition at line 756 of file res_pjsip_notify.c.
References ao2_cleanup, ast_channel_name(), ast_debug, ast_sip_add_header(), ast_sip_create_request(), ast_sip_send_request(), NULL, and RAII_VAR.
Referenced by build_calendar(), and push_notify_channel().
|
static |
Definition at line 330 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, build_cli_notify(), notify_data::build_notify, notify_data::endpoint, sip_to_pjsip::info(), notify_data::info, notify_cli_data_destroy(), and NULL.
Referenced by cli_notify(), and manager_notify_endpoint().
|
static |
Definition at line 284 of file res_pjsip_notify.c.
References ao2_cleanup, notify_data::endpoint, and notify_data::info.
Referenced by notify_cli_data_create().
|
static |
Definition at line 354 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, ast_strdup, build_cli_notify(), notify_uri_data::build_notify, sip_to_pjsip::info(), notify_uri_data::info, notify_cli_uri_data_destroy(), NULL, and notify_uri_data::uri.
Referenced by cli_notify(), and manager_notify_uri().
|
static |
Definition at line 312 of file res_pjsip_notify.c.
References ao2_cleanup, ast_free, notify_uri_data::info, and notify_uri_data::uri.
Referenced by notify_cli_uri_data_create().
|
static |
Definition at line 650 of file res_pjsip_notify.c.
References ast_log, ast_sip_add_header(), ast_sip_create_request(), ast_sip_send_request(), notify_data::build_notify, notify_data::endpoint, notify_data::info, LOG_ERROR, LOG_WARNING, NULL, and ast_sip_contact::uri.
Referenced by notify_endpoint().
|
static |
Definition at line 682 of file res_pjsip_notify.c.
References ao2_callback, ao2_cleanup, ast_log, ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_aor_contacts(), ast_strdupa, ast_strip(), ast_strlen_zero(), LOG_WARNING, notify_contact(), NULL, OBJ_NODATA, RAII_VAR, and strsep().
Referenced by push_notify().
|
static |
Definition at line 163 of file res_pjsip_notify.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_list, AO2_CONTAINER_ALLOC_OPT_DUPS_ALLOW, ast_copy_string(), notify_option::items, notify_option::name, notify_option_destroy(), and NULL.
|
static |
Definition at line 148 of file res_pjsip_notify.c.
References CMP_MATCH, notify_option::name, and OBJ_KEY.
Referenced by notify_cfg_alloc().
|
static |
Definition at line 157 of file res_pjsip_notify.c.
References ao2_cleanup, and notify_option::items.
Referenced by notify_option_alloc().
|
static |
Definition at line 186 of file res_pjsip_notify.c.
References ao2_find, container, and OBJ_KEY.
Referenced by cli_notify(), manager_notify_endpoint(), and manager_notify_uri().
|
static |
Definition at line 191 of file res_pjsip_notify.c.
References ao2_alloc, ao2_cleanup, ao2_link, ast_copy_string(), item, notify_option::items, aco_type::name, NULL, RAII_VAR, and var.
Referenced by load_module().
|
static |
Definition at line 142 of file res_pjsip_notify.c.
References ast_str_case_hash(), notify_option::name, and OBJ_KEY.
Referenced by notify_cfg_alloc().
|
static |
Definition at line 714 of file res_pjsip_notify.c.
References ao2_cleanup, ast_log, ast_sip_add_header(), ast_sip_create_request(), ast_sip_default_outbound_endpoint(), ast_sip_send_request(), ast_strlen_zero(), notify_data::endpoint, LOG_ERROR, LOG_WARNING, NULL, and RAII_VAR.
Referenced by push_notify_uri().
|
static |
Definition at line 808 of file res_pjsip_notify.c.
References ALLOC_ERROR, ao2_cleanup, ast_sip_get_sorcery(), ast_sip_push_task(), ast_sorcery_retrieve_by_id(), ast_sip_session::endpoint, notify_data::endpoint, sip_to_pjsip::info(), INVALID_ENDPOINT, notify_endpoint(), NULL, RAII_VAR, SUCCESS, and TASK_PUSH_ERROR.
Referenced by cli_notify(), and manager_notify_endpoint().
|
static |
Definition at line 856 of file res_pjsip_notify.c.
References ALLOC_ERROR, ao2_ref, ast_channel_get_by_name(), ast_channel_lock, ast_channel_tech(), ast_channel_tech_pvt(), ast_channel_unlock, ast_channel_unref, ast_debug, ast_log, ast_sip_push_task(), sip_to_pjsip::info(), INVALID_CHANNEL, LOG_WARNING, notify_channel(), ast_sip_channel_pvt::session, session, SUCCESS, TASK_PUSH_ERROR, and type.
Referenced by manager_notify_channel().
|
static |
Definition at line 835 of file res_pjsip_notify.c.
References ALLOC_ERROR, ao2_cleanup, ast_sip_push_task(), sip_to_pjsip::info(), notify_uri(), NULL, SUCCESS, TASK_PUSH_ERROR, and notify_uri_data::uri.
Referenced by cli_notify(), and manager_notify_uri().
|
static |
Definition at line 1269 of file res_pjsip_notify.c.
References aco_process_config(), ACO_PROCESS_ERROR, and AST_MODULE_LOAD_DECLINE.
|
static |
Definition at line 1278 of file res_pjsip_notify.c.
References aco_info_destroy(), ao2_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), ast_manager_unregister(), cli_options, and globals.
|
static |
Definition at line 1295 of file res_pjsip_notify.c.
|
static |
Definition at line 1295 of file res_pjsip_notify.c.
|
static |
Definition at line 1075 of file res_pjsip_notify.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 256 of file res_pjsip_notify.c.
|
static |
Definition at line 127 of file res_pjsip_notify.c.
|
static |
Definition at line 244 of file res_pjsip_notify.c.
|
static |
Definition at line 254 of file res_pjsip_notify.c.
Referenced by load_module().