Asterisk - The Open Source Telephony Project GIT-master-b023714
|
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_ua.h>
#include "asterisk/app.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) | |
static int | app_notify (struct ast_channel *chan, const char *data) |
Application entry point to send a SIP notify to an endpoint. | |
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 (struct ast_cli_args *a) |
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 struct ast_variable * | headers_to_variables (const char *headers) |
Convert headers string such as "Event=hold&Event=answer&..." into ast variable list. | |
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_channel_data * | notify_cli_channel_data_create (struct ast_sip_session *session, void *info) |
static void | notify_cli_channel_data_destroy (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 = ASTERISK_GPL_KEY , .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 128 of file res_pjsip_notify.c.
#define CONTENT_TYPE_SIZE 64 |
Definition at line 127 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 794 of file res_pjsip_notify.c.
typedef struct notify_data *(* task_data_create) (struct ast_sip_endpoint *, void *info) |
Definition at line 794 of file res_pjsip_notify.c.
typedef struct notify_uri_data *(* task_uri_data_create) (const char *uri, void *info) |
Definition at line 794 of file res_pjsip_notify.c.
enum notify_result |
Enumerator | |
---|---|
SUCCESS | |
INVALID_ENDPOINT | |
INVALID_CHANNEL | |
ALLOC_ERROR | |
TASK_PUSH_ERROR |
Definition at line 825 of file res_pjsip_notify.c.
enum notify_type |
Enumerator | |
---|---|
NOTIFY_ENDPOINT | |
NOTIFY_URI | |
NOTIFY_CHANNEL |
Definition at line 1135 of file res_pjsip_notify.c.
|
static |
Definition at line 1444 of file res_pjsip_notify.c.
|
static |
Definition at line 1444 of file res_pjsip_notify.c.
AO2_GLOBAL_OBJ_STATIC | ( | globals | ) |
|
static |
Application entry point to send a SIP notify to an endpoint.
Definition at line 1335 of file res_pjsip_notify.c.
References ALLOC_ERROR, ao2_cleanup, ao2_global_obj_ref, args, AST_APP_ARG, ast_channel_name(), AST_DECLARE_APP_ARGS, ast_log, AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), ast_variables_destroy(), globals, headers_to_variables(), INVALID_CHANNEL, INVALID_ENDPOINT, LOG_WARNING, notify_ami_channel_data_create(), notify_ami_uri_data_create(), notify_cli_channel_data_create(), notify_cli_uri_data_create(), notify_option_find(), NULL, push_notify_channel(), push_notify_uri(), RAII_VAR, SUCCESS, and TASK_PUSH_ERROR.
Referenced by load_module().
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 1444 of file res_pjsip_notify.c.
|
static |
Definition at line 665 of file res_pjsip_notify.c.
References ast_free, ast_log, build_notify(), build_notify_body(), 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 641 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(), item, notify_option::items, aco_type::name, NULL, and RAII_VAR.
Referenced by notify_cli_channel_data_create(), notify_cli_data_create(), and notify_cli_uri_data_create().
|
static |
Definition at line 596 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 572 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 956 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 986 of file res_pjsip_notify.c.
References a, ao2_cleanup, ao2_global_obj_ref, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ast_complete_channels(), 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 1056 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_CHANNEL, INVALID_ENDPOINT, notify_cli_channel_data_create(), notify_cli_data_create(), notify_cli_uri_data_create(), notify_option_find(), NULL, push_notify(), push_notify_channel(), push_notify_uri(), RAII_VAR, result, TASK_PUSH_ERROR, and ast_cli_entry::usage.
CONFIG_INFO_STANDARD | ( | notify_cfg | , |
globals | , | ||
notify_cfg_alloc | , | ||
. | files = ACO_FILES(&module_conf) |
||
) |
|
static |
Convert headers string such as "Event=hold&Event=answer&..." into ast variable list.
Definition at line 1307 of file res_pjsip_notify.c.
References ast_strlen_zero(), ast_variable_new, name, NULL, strsep(), value, and var.
Referenced by app_notify().
|
static |
Definition at line 1396 of file res_pjsip_notify.c.
References aco_info_destroy(), aco_info_init(), aco_option_register_custom, ACO_PREFIX, aco_process_config(), app_notify(), ARRAY_LEN, ast_cli_register_multiple, ast_manager_register_xml, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_register_application_xml, cli_options, EVENT_FLAG_SYSTEM, manager_notify(), notify_option_handler(), and notify_options.
|
static |
Definition at line 1264 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 1248 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 1180 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 1218 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 1141 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 561 of file res_pjsip_notify.c.
References name.
Referenced by build_notify().
|
static |
Definition at line 534 of file res_pjsip_notify.c.
References ARRAY_LEN, and name.
Referenced by build_notify().
|
static |
Definition at line 508 of file res_pjsip_notify.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, build_ami_notify(), notify_channel_data::build_notify, notify_channel_data::info, notify_ami_channel_data_destroy(), NULL, notify_channel_data::session, and session.
Referenced by app_notify(), and manager_notify_channel().
|
static |
Definition at line 446 of file res_pjsip_notify.c.
References ao2_cleanup, ast_variables_destroy(), notify_channel_data::info, and notify_channel_data::session.
Referenced by notify_ami_channel_data_create().
|
static |
Definition at line 461 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, build_ami_notify(), notify_data::build_notify, notify_data::endpoint, notify_data::info, notify_ami_data_destroy(), and NULL.
Referenced by manager_notify_endpoint().
|
static |
Definition at line 420 of file res_pjsip_notify.c.
References ao2_cleanup, ast_variables_destroy(), notify_data::endpoint, and notify_data::info.
Referenced by notify_ami_data_create().
|
static |
Definition at line 483 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, ast_strdup, build_ami_notify(), notify_uri_data::build_notify, notify_uri_data::info, notify_ami_uri_data_destroy(), NULL, and notify_uri_data::uri.
Referenced by app_notify(), and manager_notify_uri().
|
static |
Definition at line 433 of file res_pjsip_notify.c.
References ast_free, ast_variables_destroy(), notify_uri_data::info, and notify_uri_data::uri.
Referenced by notify_ami_uri_data_create().
|
static |
Definition at line 233 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 227 of file res_pjsip_notify.c.
References ao2_cleanup, and notify_cfg::notify_options.
Referenced by notify_cfg_alloc().
|
static |
Definition at line 794 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 397 of file res_pjsip_notify.c.
References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_ref, build_cli_notify(), notify_channel_data::build_notify, notify_channel_data::info, notify_cli_channel_data_destroy(), NULL, notify_channel_data::session, and session.
Referenced by app_notify(), and cli_notify().
|
static |
Definition at line 327 of file res_pjsip_notify.c.
References ao2_cleanup, notify_channel_data::info, and notify_channel_data::session.
Referenced by notify_cli_channel_data_create().
|
static |
Definition at line 345 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, build_cli_notify(), notify_data::build_notify, notify_data::endpoint, notify_data::info, notify_cli_data_destroy(), and NULL.
Referenced by cli_notify(), and manager_notify_endpoint().
|
static |
Definition at line 291 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 369 of file res_pjsip_notify.c.
References ao2_alloc, ao2_ref, ast_strdup, build_cli_notify(), notify_uri_data::build_notify, notify_uri_data::info, notify_cli_uri_data_destroy(), NULL, and notify_uri_data::uri.
Referenced by app_notify(), cli_notify(), and manager_notify_uri().
|
static |
Definition at line 319 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 688 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 720 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 170 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 155 of file res_pjsip_notify.c.
References CMP_MATCH, notify_option::name, and OBJ_KEY.
Referenced by notify_cfg_alloc().
|
static |
Definition at line 164 of file res_pjsip_notify.c.
References ao2_cleanup, and notify_option::items.
Referenced by notify_option_alloc().
|
static |
Definition at line 193 of file res_pjsip_notify.c.
References ao2_find, container, and OBJ_KEY.
Referenced by app_notify(), cli_notify(), manager_notify_endpoint(), and manager_notify_uri().
|
static |
Definition at line 198 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 149 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 752 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 846 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, notify_data::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 894 of file res_pjsip_notify.c.
References ALLOC_ERROR, ao2_ref, ast_channel_get_by_name(), ast_channel_lock, ast_channel_tech_pvt(), ast_channel_unlock, ast_channel_unref, ast_debug, ast_log, ast_sip_push_task(), INVALID_CHANNEL, LOG_WARNING, notify_channel(), ast_sip_channel_pvt::session, session, SUCCESS, TASK_PUSH_ERROR, and type.
Referenced by app_notify(), cli_notify(), and manager_notify_channel().
|
static |
Definition at line 873 of file res_pjsip_notify.c.
References ALLOC_ERROR, ao2_cleanup, ast_sip_push_task(), notify_uri_data::info, notify_uri(), NULL, SUCCESS, TASK_PUSH_ERROR, and notify_uri_data::uri.
Referenced by app_notify(), cli_notify(), and manager_notify_uri().
|
static |
Definition at line 1417 of file res_pjsip_notify.c.
References aco_process_config(), ACO_PROCESS_ERROR, and AST_MODULE_LOAD_DECLINE.
|
static |
Definition at line 1426 of file res_pjsip_notify.c.
References aco_info_destroy(), ao2_global_obj_release, ARRAY_LEN, ast_cli_unregister_multiple(), ast_manager_unregister(), ast_unregister_application(), cli_options, and globals.
|
static |
Definition at line 1444 of file res_pjsip_notify.c.
|
static |
Definition at line 1444 of file res_pjsip_notify.c.
|
static |
Definition at line 1131 of file res_pjsip_notify.c.
Referenced by load_module(), and unload_module().
|
static |
Definition at line 263 of file res_pjsip_notify.c.
|
static |
Definition at line 134 of file res_pjsip_notify.c.
|
static |
Definition at line 251 of file res_pjsip_notify.c.
|
static |
Definition at line 261 of file res_pjsip_notify.c.
Referenced by load_module().