Asterisk - The Open Source Telephony Project GIT-master-3dae2cf
|
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_simple.h>
#include <pjsip/sip_transaction.h>
#include <pj/timer.h>
#include <pjlib.h>
#include <pjmedia/errno.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/strings.h"
#include "pjsip/sip_parser.h"
#include "res_pjsip/include/res_pjsip_private.h"
#include "asterisk/linkedlists.h"
#include "asterisk/logger.h"
#include "asterisk/lock.h"
#include "asterisk/utils.h"
#include "asterisk/astobj2.h"
#include "asterisk/module.h"
#include "asterisk/serializer.h"
#include "asterisk/threadpool.h"
#include "asterisk/taskprocessor.h"
#include "asterisk/uuid.h"
#include "asterisk/sorcery.h"
#include "asterisk/file.h"
#include "asterisk/causes.h"
#include "asterisk/cli.h"
#include "asterisk/callerid.h"
#include "asterisk/res_pjsip_cli.h"
#include "asterisk/test.h"
#include "asterisk/res_pjsip_presence_xml.h"
#include "asterisk/res_pjproject.h"
#include "asterisk/utf8.h"
#include "asterisk/acl.h"
Go to the source code of this file.
Data Structures | |
struct | endpoint_formatters |
struct | endpoint_identifier_list |
struct | endpoint_identifiers |
struct | response_code_map |
struct | send_request_data |
Structure to hold information about an outbound request. More... | |
struct | send_request_wrapper |
struct | supplements |
struct | sync_task_data |
Macros | |
#define | DEBUG_BUF_SIZE 256 |
#define | ENDPOINT_IDENTIFIER_FORMAT "%-20.20s\n" |
#define | MOD_DATA_CONTACT "contact" |
#define | SERIALIZER_POOL_SIZE 8 |
#define | SIP_SERVANT_ID 0x5E2F1D |
#define | TIMEOUT_TIMER2 5 |
#define | TIMER_INACTIVE 0 |
Typedefs | |
typedef pj_status_t(* | create_dlg_uac) (pjsip_user_agent *ua, pjsip_rx_data *rdata, const pj_str_t *contact, pjsip_dialog **p_dlg) |
Functions | |
static void | __init_pj_thread_storage (void) |
static void | __init_servant_id_storage (void) |
static void | __reg_module (void) |
static void | __unreg_module (void) |
static pjsip_msg_body * | ast_body_to_pjsip_body (pj_pool_t *pool, const struct ast_sip_body *body) |
void | ast_copy_pj_str (char *dest, const pj_str_t *src, size_t size) |
Copy a pj_str_t into a standard character buffer. More... | |
int | ast_copy_pj_str2 (char **dest, const pj_str_t *src) |
Create and copy a pj_str_t into a standard character buffer. More... | |
struct ast_module * | AST_MODULE_SELF_SYM (void) |
int | ast_sip_add_body (pjsip_tx_data *tdata, const struct ast_sip_body *body) |
Add a body to an outbound SIP message. More... | |
int | ast_sip_add_body_multipart (pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies) |
Add a multipart body to an outbound SIP message. More... | |
void | ast_sip_add_date_header (pjsip_tx_data *tdata) |
Adds a Date header to the tdata, formatted like: Date: Wed, 01 Jan 2021 14:53:01 GMT. More... | |
int | ast_sip_add_header (pjsip_tx_data *tdata, const char *name, const char *value) |
Add a header to an outbound SIP message. More... | |
pjsip_generic_string_hdr * | ast_sip_add_header2 (pjsip_tx_data *tdata, const char *name, const char *value) |
Add a header to an outbound SIP message, returning a pointer to the header. More... | |
void | ast_sip_add_usereqphone (const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri) |
Add 'user=phone' parameter to URI if enabled and user is a phone number. More... | |
int | ast_sip_append_body (pjsip_tx_data *tdata, const char *body_text) |
Append body data to a SIP message. More... | |
int | ast_sip_are_media_types_equal (pjsip_media_type *a, pjsip_media_type *b) |
Compare pjsip media types. More... | |
const char * | ast_sip_call_codec_pref_to_str (struct ast_flags pref) |
Convert the call codec preference flags to a string. More... | |
int | ast_sip_call_codec_str_to_pref (struct ast_flags *pref, const char *pref_str, int is_outgoing) |
Convert a call codec preference string to preference flags. More... | |
enum ast_sip_check_auth_result | ast_sip_check_authentication (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata) |
Method to determine authentication status of an incoming request. More... | |
pjsip_dialog * | ast_sip_create_dialog_uac (const struct ast_sip_endpoint *endpoint, const char *uri, const char *request_user) |
General purpose method for creating a UAC dialog with an endpoint. More... | |
pjsip_dialog * | ast_sip_create_dialog_uas (const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status) |
General purpose method for creating a UAS dialog with an endpoint. More... | |
pjsip_dialog * | ast_sip_create_dialog_uas_locked (const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status) |
General purpose method for creating a UAS dialog with an endpoint. More... | |
int | ast_sip_create_rdata (pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port) |
General purpose method for creating an rdata structure using specific information. More... | |
int | ast_sip_create_rdata_with_contact (pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port, const char *contact) |
General purpose method for creating an rdata structure using specific information. More... | |
int | ast_sip_create_request (const char *method, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *contact, pjsip_tx_data **tdata) |
General purpose method for creating a SIP request. More... | |
int | ast_sip_create_request_with_auth (const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, pjsip_tx_data *old_request, pjsip_tx_data **new_request) |
Create a response to an authentication challenge. More... | |
int | ast_sip_create_response (const pjsip_rx_data *rdata, int st_code, struct ast_sip_contact *contact, pjsip_tx_data **tdata) |
General purpose method for creating a SIP response. More... | |
struct ast_taskprocessor * | ast_sip_create_serializer (const char *name) |
Create a new serializer for SIP tasks. More... | |
struct ast_taskprocessor * | ast_sip_create_serializer_group (const char *name, struct ast_serializer_shutdown_group *shutdown_group) |
Create a new serializer for SIP tasks. More... | |
void * | ast_sip_dict_get (void *ht, const char *key) |
Retrieves the value associated with the given key. More... | |
void * | ast_sip_dict_set (pj_pool_t *pool, void *ht, const char *key, void *val) |
Set the value for the given key. More... | |
int | ast_sip_dlg_set_transport (const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg, pjsip_tpselector *selector) |
Set the transport on a dialog. More... | |
int | ast_sip_dtmf_to_str (const enum ast_sip_dtmf_mode dtmf, char *buf, size_t buf_len) |
Convert the DTMF mode enum value into a string. More... | |
int | ast_sip_failover_request (pjsip_tx_data *tdata) |
Set a request to use the next value in the list of resolved addresses. More... | |
struct ast_sip_transport_state * | ast_sip_find_transport_state_in_use (struct ast_sip_request_transport_details *details) |
Returns the transport state currently in use based on request transport details. More... | |
int | ast_sip_format_endpoint_ami (struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami, int *count) |
Formats the endpoint and sends over AMI. More... | |
pjsip_sip_uri * | ast_sip_get_contact_sip_uri (pjsip_tx_data *tdata) |
Return the SIP URI of the Contact header. More... | |
struct ast_sip_endpoint * | ast_sip_get_endpoint (const char *to, int get_default_outbound, char **uri) |
Retrieves an endpoint and URI from the "to" string. More... | |
int | ast_sip_get_host_ip (int af, pj_sockaddr *addr) |
Retrieve the local host address in IP form. More... | |
const char * | ast_sip_get_host_ip_string (int af) |
Retrieve the local host address in string form. More... | |
pjsip_endpoint * | ast_sip_get_pjsip_endpoint (void) |
Get a pointer to the PJSIP endpoint. More... | |
int | ast_sip_get_transport_name (const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, char *buf, size_t buf_len) |
Get the transport name from an endpoint or request uri. More... | |
const int | ast_sip_hangup_sip2cause (int cause) |
Convert SIP hangup causes to Asterisk hangup causes. More... | |
struct ast_sip_endpoint * | ast_sip_identify_endpoint (pjsip_rx_data *rdata) |
Determine the endpoint that has sent a SIP message. More... | |
int | ast_sip_is_allowed_uri (pjsip_uri *uri) |
Check whether a pjsip_uri is allowed or not. More... | |
int | ast_sip_is_content_type (pjsip_media_type *content_type, char *type, char *subtype) |
Checks if the given content type matches type/subtype. More... | |
int | ast_sip_is_media_type_in (pjsip_media_type *a,...) |
Check if a media type is in a list of others. More... | |
int | ast_sip_is_uri_sip_sips (pjsip_uri *uri) |
Check whether a pjsip_uri is SIP/SIPS or not. More... | |
void | ast_sip_modify_id_header (pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const struct ast_party_id *id) |
Set name and number information on an identity header. More... | |
const pj_str_t * | ast_sip_pjsip_uri_get_hostname (pjsip_uri *uri) |
Get the host portion of the pjsip_uri. More... | |
struct pjsip_param * | ast_sip_pjsip_uri_get_other_param (pjsip_uri *uri, const pj_str_t *param_str) |
Find an 'other' SIP/SIPS URI parameter by name. More... | |
const pj_str_t * | ast_sip_pjsip_uri_get_username (pjsip_uri *uri) |
Get the user portion of the pjsip_uri. More... | |
int | ast_sip_push_task (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Pushes a task to SIP servants. More... | |
int | ast_sip_push_task_synchronous (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Push a task to SIP servants and wait for it to complete. More... | |
static int | ast_sip_push_task_wait (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
int | ast_sip_push_task_wait_serializer (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Push a task to the serializer and wait for it to complete. More... | |
int | ast_sip_push_task_wait_servant (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data) |
Push a task to SIP servants and wait for it to complete. More... | |
char * | ast_sip_rdata_get_header_value (pjsip_rx_data *rdata, const pj_str_t str) |
Get a specific header value from rdata. More... | |
int | ast_sip_register_authenticator (struct ast_sip_authenticator *auth) |
Register a SIP authenticator. More... | |
void | ast_sip_register_endpoint_formatter (struct ast_sip_endpoint_formatter *obj) |
Register an endpoint formatter. More... | |
int | ast_sip_register_endpoint_identifier (struct ast_sip_endpoint_identifier *identifier) |
Register a SIP endpoint identifier. More... | |
int | ast_sip_register_endpoint_identifier_with_name (struct ast_sip_endpoint_identifier *identifier, const char *name) |
Register a SIP endpoint identifier with a name. More... | |
int | ast_sip_register_outbound_authenticator (struct ast_sip_outbound_authenticator *auth) |
Register an outbound SIP authenticator. More... | |
int | ast_sip_register_service (pjsip_module *module) |
Register a SIP service in Asterisk. More... | |
void | ast_sip_register_supplement (struct ast_sip_supplement *supplement) |
Register a supplement to SIP out of dialog processing. More... | |
int | ast_sip_requires_authentication (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata) |
Determine if an incoming request requires authentication. More... | |
int | ast_sip_rewrite_uri_to_local (pjsip_sip_uri *uri, pjsip_tx_data *tdata) |
Replace domain and port of SIP URI to point to (external) signaling address of this Asterisk instance. More... | |
int | ast_sip_send_out_of_dialog_request (pjsip_tx_data *tdata, struct ast_sip_endpoint *endpoint, int timeout, void *token, void(*callback)(void *token, pjsip_event *e)) |
General purpose method for sending an Out-Of-Dialog SIP request. More... | |
int | ast_sip_send_request (pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e)) |
General purpose method for sending a SIP request. More... | |
int | ast_sip_send_response (pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint) |
Send a response to an out of dialog request. More... | |
int | ast_sip_send_stateful_response (pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint) |
Send a stateful response to an out of dialog request. More... | |
int | ast_sip_set_id_connected_line (struct pjsip_rx_data *rdata, struct ast_party_id *id) |
Set the ID for a connected line update. More... | |
int | ast_sip_set_id_from_invite (struct pjsip_rx_data *rdata, struct ast_party_id *id, struct ast_party_id *default_id, int trust_inbound) |
Set the ID from an INVITE. More... | |
int | ast_sip_set_outbound_proxy (pjsip_tx_data *tdata, const char *proxy) |
Set the outbound proxy for an outbound SIP message. More... | |
int | ast_sip_set_request_transport_details (struct ast_sip_request_transport_details *details, pjsip_tx_data *tdata, int use_ipv6) |
Sets request transport details based on tdata. More... | |
int | ast_sip_set_tpselector_from_ep_or_uri (const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, pjsip_tpselector *selector) |
Sets pjsip_tpselector from an endpoint or uri. More... | |
int | ast_sip_set_tpselector_from_transport (const struct ast_sip_transport *transport, pjsip_tpselector *selector) |
Sets pjsip_tpselector from ast_sip_transport. More... | |
int | ast_sip_set_tpselector_from_transport_name (const char *transport_name, pjsip_tpselector *selector) |
Sets pjsip_tpselector from ast_sip_transport. More... | |
int | ast_sip_str2rc (const char *name) |
Convert name to SIP response code. More... | |
int | ast_sip_str_to_dtmf (const char *dtmf_mode) |
Convert the DTMF mode name into an enum. More... | |
int | ast_sip_thread_is_servant (void) |
Determine if the current thread is a SIP servant thread. More... | |
struct ast_threadpool * | ast_sip_threadpool (void) |
Retrieve the SIP threadpool object. More... | |
long | ast_sip_threadpool_queue_size (void) |
Return the size of the SIP threadpool's task queue. More... | |
void | ast_sip_tpselector_unref (pjsip_tpselector *selector) |
Unreference a pjsip_tpselector. More... | |
void | ast_sip_unregister_authenticator (struct ast_sip_authenticator *auth) |
Unregister a SIP authenticator. More... | |
void | ast_sip_unregister_endpoint_formatter (struct ast_sip_endpoint_formatter *obj) |
Unregister an endpoint formatter. More... | |
void | ast_sip_unregister_endpoint_identifier (struct ast_sip_endpoint_identifier *identifier) |
Unregister a SIP endpoint identifier. More... | |
void | ast_sip_unregister_outbound_authenticator (struct ast_sip_outbound_authenticator *auth) |
Unregister an outbound SIP authenticator. More... | |
void | ast_sip_unregister_service (pjsip_module *module) |
void | ast_sip_unregister_supplement (struct ast_sip_supplement *supplement) |
Unregister a an supplement to SIP out of dialog processing. More... | |
int | ast_sip_update_from (pjsip_tx_data *tdata, char *from) |
Overwrite fields in the outbound 'From' header. More... | |
int | ast_sip_update_to_uri (pjsip_tx_data *tdata, const char *to) |
Replace the To URI in the tdata with the supplied one. More... | |
int | ast_sip_will_uri_survive_restart (pjsip_sip_uri *uri, struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata) |
static int | check_request_status (struct send_request_data *req_data, pjsip_event *e) |
static void | clean_contact_from_tdata (pjsip_tx_data *tdata) |
static char * | cli_dump_endpt (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | cli_show_endpoint_identifiers (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static char * | cli_show_settings (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
static pjsip_dialog * | create_dialog_uas (const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status, create_dlg_uac create_fun) |
static int | create_in_dialog_request (const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata) |
static int | create_out_of_dialog_request (const pjsip_method *method, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *provided_contact, pjsip_tx_data **tdata) |
static int | do_cli_dump_endpt (void *v_a) |
static pj_bool_t | does_method_match (const pj_str_t *message_method, const char *supplement_method) |
static pj_status_t | endpt_send_request (struct ast_sip_endpoint *endpoint, pjsip_tx_data *tdata, pj_int32_t timeout, void *token, pjsip_endpt_send_callback cb) |
static void | endpt_send_request_cb (void *token, pjsip_event *e) |
static int | find_transport_state_in_use (void *obj, void *arg, int flags) |
Callback function for finding the transport the request is going out on. More... | |
static pjsip_fromto_hdr * | get_id_header (pjsip_rx_data *rdata, const pj_str_t *header_name) |
static const pjsip_method * | get_pjsip_method (const char *method) |
static struct ast_sip_endpoint * | handle_atsign (const char *to, char *destination, char **uri, char *slash, char *atsign, char *scheme, int get_default_outbound) |
static struct ast_sip_endpoint * | handle_single_token (const char *to, char *destination, int get_default_outbound, char **uri) |
static struct ast_sip_endpoint * | handle_slash (const char *to, char *destination, char **uri, char *slash, char *atsign, char *scheme) |
static int | insert_user_in_contact_uri (const char *to, const char *endpoint_name, const char *aors, const char *user, char **uri) |
Find a contact and insert a "user@" into its URI. More... | |
static int | load_module (void) |
static int | load_pjsip (void) |
static void * | monitor_thread_exec (void *endpt) |
void | never_called_res_pjsip (void) |
static void | pool_destroy_callback (void *arg) |
static int | register_service (void *data) |
static int | reload_configuration_task (void *obj) |
static int | reload_module (void) |
static void | remove_request_headers (pjsip_endpoint *endpt) |
static int | send_in_dialog_request (pjsip_tx_data *tdata, struct pjsip_dialog *dlg) |
static void | send_request_cb (void *token, pjsip_event *e) |
static struct send_request_data * | send_request_data_alloc (struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e)) |
static void | send_request_data_destroy (void *obj) |
static void | send_request_timer_callback (pj_timer_heap_t *theap, pj_timer_entry *entry) |
static void | send_request_wrapper_destructor (void *obj) |
static int | set_id_from_from (struct pjsip_rx_data *rdata, struct ast_party_id *id) |
static void | set_id_from_hdr (pjsip_fromto_hdr *hdr, struct ast_party_id *id) |
static int | set_id_from_pai (pjsip_rx_data *rdata, struct ast_party_id *id) |
static int | set_id_from_rpid (pjsip_rx_data *rdata, struct ast_party_id *id) |
static int | sip_dialog_create_from (pj_pool_t *pool, pj_str_t *from, const char *user, const char *domain, const pj_str_t *target, pjsip_tpselector *selector) |
static void | sip_thread_start (void) |
static void | stop_monitor_thread (void) |
static pj_bool_t | supplement_on_rx_request (pjsip_rx_data *rdata) |
static void | supplement_outgoing_response (pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint) |
static int | sync_task (void *data) |
static int | uas_use_sips_contact (pjsip_rx_data *rdata) |
Determine if a SIPS Contact header is required. More... | |
static int | unload_module (void) |
static int | unload_pjsip (void *data) |
static int | unregister_service (void *data) |
Variables | |
static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_GLOBAL_SYMBOLS | AST_MODFLAG_LOAD_ORDER , .description = "Basic SIP resource" , .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, .unload = unload_module, .reload = reload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND - 5, .requires = "dnsmgr,res_pjproject,res_sorcery_config,res_sorcery_memory,res_sorcery_astdb", .optional_modules = "res_geolocation,res_statsd", } |
static const struct ast_module_info * | ast_module_info = &__mod_info |
static pjsip_endpoint * | ast_pjsip_endpoint |
pj_caching_pool | caching_pool |
static struct ast_cli_entry | cli_commands [] |
struct endpoint_formatters | endpoint_formatters = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static struct endpoint_identifiers | endpoint_identifiers = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
static pj_sockaddr | host_ip_ipv4 |
static char | host_ip_ipv4_string [PJ_INET6_ADDRSTRLEN] |
static pj_sockaddr | host_ip_ipv6 |
static char | host_ip_ipv6_string [PJ_INET6_ADDRSTRLEN] |
static const pjsip_method | info_method = {PJSIP_OTHER_METHOD, {"INFO", 4} } |
pj_pool_t * | memory_pool |
static const pjsip_method | message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} } |
struct { | |
const char * method | |
const pjsip_method * pmethod | |
} | methods [] |
static int | monitor_continue |
pj_thread_t * | monitor_thread |
static struct ast_threadstorage | pj_thread_storage = { .once = PTHREAD_ONCE_INIT , .key_init = __init_pj_thread_storage , .custom_init = NULL , } |
pjsip_media_type | pjsip_media_type_application_cpim_xpidf_xml |
pjsip_media_type | pjsip_media_type_application_json |
pjsip_media_type | pjsip_media_type_application_media_control_xml |
pjsip_media_type | pjsip_media_type_application_pidf_xml |
pjsip_media_type | pjsip_media_type_application_rlmi_xml |
pjsip_media_type | pjsip_media_type_application_sdp |
pjsip_media_type | pjsip_media_type_application_simple_message_summary |
pjsip_media_type | pjsip_media_type_application_xpidf_xml |
pjsip_media_type | pjsip_media_type_multipart_alternative |
pjsip_media_type | pjsip_media_type_multipart_mixed |
pjsip_media_type | pjsip_media_type_multipart_related |
pjsip_media_type | pjsip_media_type_text_plain |
static const struct response_code_map | rc_map [] |
static const pjsip_method | refer_method = {PJSIP_OTHER_METHOD, {"REFER", 5} } |
static struct ast_sip_authenticator * | registered_authenticator |
static struct ast_sip_outbound_authenticator * | registered_outbound_authenticator |
static struct ast_threadstorage | servant_id_storage = { .once = PTHREAD_ONCE_INIT , .key_init = __init_servant_id_storage , .custom_init = NULL , } |
static struct ast_serializer_pool * | sip_serializer_pool |
static struct ast_threadpool * | sip_threadpool |
static pjsip_module | supplement_module |
struct supplements | supplements = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , } |
#define DEBUG_BUF_SIZE 256 |
#define ENDPOINT_IDENTIFIER_FORMAT "%-20.20s\n" |
#define MOD_DATA_CONTACT "contact" |
Definition at line 66 of file res_pjsip.c.
#define SERIALIZER_POOL_SIZE 8 |
Number of serializers in pool if one not supplied.
Definition at line 69 of file res_pjsip.c.
#define SIP_SERVANT_ID 0x5E2F1D |
Definition at line 2283 of file res_pjsip.c.
#define TIMEOUT_TIMER2 5 |
Definition at line 1513 of file res_pjsip.c.
#define TIMER_INACTIVE 0 |
Definition at line 1512 of file res_pjsip.c.
typedef pj_status_t(* create_dlg_uac) (pjsip_user_agent *ua, pjsip_rx_data *rdata, const pj_str_t *contact, pjsip_dialog **p_dlg) |
Definition at line 1115 of file res_pjsip.c.
|
static |
Definition at line 2281 of file res_pjsip.c.
|
static |
Definition at line 2282 of file res_pjsip.c.
|
static |
Definition at line 4097 of file res_pjsip.c.
|
static |
Definition at line 4097 of file res_pjsip.c.
|
static |
Definition at line 2039 of file res_pjsip.c.
References ast_sip_body::body_text, ast_sip_body::subtype, type, and ast_sip_body::type.
Referenced by ast_sip_add_body(), and ast_sip_add_body_multipart().
void ast_copy_pj_str | ( | char * | dest, |
const pj_str_t * | src, | ||
size_t | size | ||
) |
Copy a pj_str_t into a standard character buffer.
pj_str_t is not NULL-terminated. Any place that expects a NULL- terminated string needs to have the pj_str_t copied into a separate buffer.
This method copies the pj_str_t contents into the destination buffer and NULL-terminates the buffer.
dest | The destination buffer |
src | The pj_str_t to copy |
size | The size of the destination buffer. |
Definition at line 2201 of file res_pjsip.c.
References MIN.
Referenced by apply_dtls_attrib(), apply_negotiated_sdp_stream(), assign_uuid(), ast_sip_get_transport_name(), ast_sip_header_to_security_mechanism(), ast_sip_report_auth_challenge_sent(), ast_sip_report_auth_failed_challenge_response(), chan_pjsip_get_uniqueid(), change_outgoing_sdp_stream_media_address(), channel_read_pjsip(), cli_complete_subscription_common(), cli_list_subscriptions_detail(), cli_show_subscriptions_detail(), determine_sip_publish_type(), dialog_info_generate_body_content(), endpoint_lookup(), evaluate_like(), extract_contact_addr(), find_aor2(), find_aor_name(), find_challenge(), get_auth_header(), get_codecs(), get_dest_tn(), get_destination(), get_endpoint_details(), get_from_header(), get_mid_bundle_group(), get_user_agent(), handle_incoming_request(), handle_incoming_sdp(), handle_negotiated_sdp_session_media(), handle_registration_response(), headers_to_vars(), incoming_in_dialog_request(), log_failed_request(), negotiate_incoming_sdp_stream(), options_on_rx_request(), parse_uri_cb(), process_extmap_attributes(), process_ice_attributes(), process_ice_auth_attrb(), process_ssrc_attributes(), publish_request_initial(), pubsub_on_rx_publish_request(), pubsub_on_rx_subscribe_request(), refer_blind_callback(), refer_incoming_blind_request(), refer_incoming_refer_request(), rfc3326_use_reason_header(), rfc3329_incoming_response(), rx_data_to_ast_msg(), save_response_fields_to_transport(), sdp_requires_deferral(), security_event_populate(), session_inv_on_redirected(), session_outgoing_nat_hook(), set_id_from_hdr(), set_id_from_oli(), set_mid_and_bundle_group(), set_redirecting_value(), set_remote_mslabel_and_stream_group(), set_sipdomain_variable(), sip_subscription_to_ami(), sub_persistence_recreate(), subscription_get_generator_from_rdata(), subscription_get_handler_from_rdata(), subscription_persistence_create(), subscription_persistence_update(), and transfer_refer().
int ast_copy_pj_str2 | ( | char ** | dest, |
const pj_str_t * | src | ||
) |
Create and copy a pj_str_t into a standard character buffer.
pj_str_t is not NULL-terminated. Any place that expects a NULL- terminated string needs to have the pj_str_t copied into a separate buffer.
Copies the pj_str_t contents into a newly allocated buffer pointed to by dest. NULL-terminates the buffer.
[out] | dest | The destination buffer |
src | The pj_str_t to copy |
Definition at line 2208 of file res_pjsip.c.
References ast_asprintf, and NULL.
struct ast_module * AST_MODULE_SELF_SYM | ( | void | ) |
Definition at line 4097 of file res_pjsip.c.
int ast_sip_add_body | ( | pjsip_tx_data * | tdata, |
const struct ast_sip_body * | body | ||
) |
Add a body to an outbound SIP message.
If this is called multiple times, the latest body will replace the current body.
tdata | The message to add the body to |
body | The message body to add |
0 | Success |
-1 | Failure |
Definition at line 2052 of file res_pjsip.c.
References ast_body_to_pjsip_body().
Referenced by aoc_bye_outgoing_request(), aoc_bye_outgoing_response(), aoc_send_as_xml(), build_notify_body(), msg_send(), send_unsolicited_mwi_notify_to_contact(), sendtext(), sip_publisher_service_queue(), transmit_info_dtmf(), and transmit_info_with_vidupdate().
int ast_sip_add_body_multipart | ( | pjsip_tx_data * | tdata, |
const struct ast_sip_body * | bodies[], | ||
int | num_bodies | ||
) |
Add a multipart body to an outbound SIP message.
This will treat each part of the input vector as part of a multipart body and add each part to the SIP message.
tdata | The message to add the body to |
bodies | The message bodies to add |
num_bodies | The parts of the body to add |
0 | Success |
-1 | Failure |
Definition at line 2059 of file res_pjsip.c.
References ast_body_to_pjsip_body(), and NULL.
void ast_sip_add_date_header | ( | pjsip_tx_data * | tdata | ) |
Adds a Date header to the tdata, formatted like: Date: Wed, 01 Jan 2021 14:53:01 GMT.
Definition at line 90 of file res_pjsip.c.
References ast_sip_add_header(), and NULL.
Referenced by add_date_header().
int ast_sip_add_header | ( | pjsip_tx_data * | tdata, |
const char * | name, | ||
const char * | value | ||
) |
Add a header to an outbound SIP message.
tdata | The message to add the header to |
name | The header name |
value | The header value |
0 | Success |
-1 | Failure |
Definition at line 2008 of file res_pjsip.c.
Referenced by add_header_from_channel_var(), add_headers_to_message(), ast_sip_add_date_header(), ast_sip_add_security_headers(), ast_sip_message_apply_transport(), build_notify(), handle_outgoing_request(), notify_channel(), notify_contact(), notify_uri(), options_incoming_request(), rfc3326_add_reason_header(), send_options_response(), sip_publication_respond(), transfer_refer(), and vars_to_headers().
pjsip_generic_string_hdr * ast_sip_add_header2 | ( | pjsip_tx_data * | tdata, |
const char * | name, | ||
const char * | value | ||
) |
Add a header to an outbound SIP message, returning a pointer to the header.
tdata | The message to add the header to |
name | The header name |
value | The header value |
Definition at line 2023 of file res_pjsip.c.
Referenced by handle_outgoing_request().
void ast_sip_add_usereqphone | ( | const struct ast_sip_endpoint * | endpoint, |
pj_pool_t * | pool, | ||
pjsip_uri * | uri | ||
) |
Add 'user=phone' parameter to URI if enabled and user is a phone number.
endpoint | The endpoint to use for configuration |
pool | The memory pool to allocate the parameter from |
uri | The URI to check for user and to add parameter to |
Definition at line 930 of file res_pjsip.c.
References AST_DIGIT_ANY, and ast_sip_endpoint::usereqphone.
Referenced by ast_sip_create_dialog_uac(), create_out_of_dialog_request(), and set_from_header().
int ast_sip_append_body | ( | pjsip_tx_data * | tdata, |
const char * | body_text | ||
) |
Append body data to a SIP message.
This acts mostly the same as ast_sip_add_body, except that rather than replacing a body if it currently exists, it appends data to an existing body.
tdata | The message to append the body to |
body_text | The string to append to the end of the current body |
0 | Success |
-1 | Failure |
Definition at line 2075 of file res_pjsip.c.
References ast_str_alloca, ast_str_buffer(), and ast_str_set().
int ast_sip_are_media_types_equal | ( | pjsip_media_type * | a, |
pjsip_media_type * | b | ||
) |
Compare pjsip media types.
a | the first media type |
b | the second media type |
1 | Media types are equal |
0 | Media types are not equal |
Definition at line 2219 of file res_pjsip.c.
Referenced by find_pidf(), and video_info_incoming_request().
const char * ast_sip_call_codec_pref_to_str | ( | struct ast_flags | pref | ) |
Convert the call codec preference flags to a string.
pref | the call codec preference setting |
Definition at line 2554 of file res_pjsip.c.
References ast_sip_call_codec_pref_test, and value.
Referenced by incoming_call_offer_pref_to_str(), log_caps(), and outgoing_call_offer_pref_to_str().
int ast_sip_call_codec_str_to_pref | ( | struct ast_flags * | pref, |
const char * | pref_str, | ||
int | is_outgoing | ||
) |
Convert a call codec preference string to preference flags.
pref | A pointer to an ast_flags structure to receive the preference flags |
pref_str | The call codec preference setting string |
is_outgoing | Is for outgoing calls? |
0 | The string was parsed successfully |
-1 | The string option was invalid |
Definition at line 2577 of file res_pjsip.c.
References ast_set_flag, AST_SIP_CALL_CODEC_PREF_ALL, AST_SIP_CALL_CODEC_PREF_FIRST, AST_SIP_CALL_CODEC_PREF_INTERSECT, AST_SIP_CALL_CODEC_PREF_LOCAL, AST_SIP_CALL_CODEC_PREF_REMOTE, AST_SIP_CALL_CODEC_PREF_UNION, and ast_flags::flags.
Referenced by call_offer_pref_handler(), and test_create_joint().
enum ast_sip_check_auth_result ast_sip_check_authentication | ( | struct ast_sip_endpoint * | endpoint, |
pjsip_rx_data * | rdata, | ||
pjsip_tx_data * | tdata | ||
) |
Method to determine authentication status of an incoming request.
This will call into a registered authenticator. The registered authenticator will do what is necessary to determine whether the incoming request passes authentication. A tentative response is passed into this function so that if, say, a digest authentication challenge should be sent in the ensuing response, it can be added to the response.
endpoint | The endpoint from the request was sent |
rdata | The request to potentially authenticate |
tdata | Tentative response to the request |
Definition at line 179 of file res_pjsip.c.
References ast_log, AST_SIP_AUTHENTICATION_SUCCESS, ast_sip_authenticator::check_authentication, LOG_WARNING, and registered_authenticator.
Referenced by authenticate().
pjsip_dialog * ast_sip_create_dialog_uac | ( | const struct ast_sip_endpoint * | endpoint, |
const char * | aor_name, | ||
const char * | request_user | ||
) |
General purpose method for creating a UAC dialog with an endpoint.
endpoint | A pointer to the endpoint |
aor_name | Optional name of the AOR to target, may even be an explicit SIP URI |
request_user | Optional user to place into the target URI |
non-NULL | success |
NULL | failure |
Definition at line 964 of file res_pjsip.c.
References ast_begins_with(), ast_log, ast_sip_add_usereqphone(), ast_sip_dlg_set_transport(), ast_sip_tpselector_unref(), ast_sorcery_object_get_id(), ast_strlen_zero(), ast_sip_endpoint::contact_user, ast_sip_endpoint::fromdomain, ast_sip_endpoint::fromuser, ast_sip_endpoint::info, LOG_ERROR, NULL, ast_sip_endpoint::outbound_proxy, sip_dialog_create_from(), and tmp().
Referenced by ast_sip_create_subscription(), ast_sip_session_create_outgoing(), and refer_send().
pjsip_dialog * ast_sip_create_dialog_uas | ( | const struct ast_sip_endpoint * | endpoint, |
pjsip_rx_data * | rdata, | ||
pj_status_t * | status | ||
) |
General purpose method for creating a UAS dialog with an endpoint.
endpoint | A pointer to the endpoint | |
rdata | The request that is starting the dialog | |
[out] | status | On failure, the reason for failure in creating the dialog |
Definition at line 1176 of file res_pjsip.c.
References create_dialog_uas(), and status.
pjsip_dialog * ast_sip_create_dialog_uas_locked | ( | const struct ast_sip_endpoint * | endpoint, |
pjsip_rx_data * | rdata, | ||
pj_status_t * | status | ||
) |
General purpose method for creating a UAS dialog with an endpoint.
This function creates and returns a locked, and referenced counted pjsip dialog object. The caller is thus responsible for freeing the allocated memory, decrementing the reference, and releasing the lock when done with the returned object.
The dialog is returned locked and with a reference in order to ensure that the dialog object, and any of its associated objects (e.g. transaction) are not untimely destroyed. For instance, that could happen when a transport error occurs.
As long as the caller maintains a reference to the dialog there should be no worry that it might unknowingly be destroyed. However, once the caller unlocks the dialog there is a danger that some of the dialog's internal objects could be lost and/or compromised. For example, when the aforementioned transport error occurs the dialog's associated transaction gets destroyed (see pjsip_dlg_on_tsx_state in sip_dialog.c, and mod_inv_on_tsx_state in sip_inv.c).
In this case and before using the dialog again the caller should re-lock the dialog, check to make sure the dialog is still established, and the transaction still exists and has not been destroyed.
endpoint | A pointer to the endpoint | |
rdata | The request that is starting the dialog | |
[out] | status | On failure, the reason for failure in creating the dialog |
A | locked, and reference counted pjsip_dialog object. |
NULL | on failure |
Definition at line 1192 of file res_pjsip.c.
References create_dialog_uas(), and status.
Referenced by create_subscription_tree(), and pre_session_setup().
int ast_sip_create_rdata | ( | pjsip_rx_data * | rdata, |
char * | packet, | ||
const char * | src_name, | ||
int | src_port, | ||
char * | transport_type, | ||
const char * | local_name, | ||
int | local_port | ||
) |
General purpose method for creating an rdata structure using specific information.
[out] | rdata | The rdata structure that will be populated |
packet | A SIP message | |
src_name | The source IP address of the message | |
src_port | The source port of the message | |
transport_type | The type of transport the message was received on | |
local_name | The local IP address the message was received on | |
local_port | The local port the message was received on |
0 | success |
-1 | failure |
Definition at line 1266 of file res_pjsip.c.
References ast_sip_create_rdata_with_contact(), and NULL.
int ast_sip_create_rdata_with_contact | ( | pjsip_rx_data * | rdata, |
char * | packet, | ||
const char * | src_name, | ||
int | src_port, | ||
char * | transport_type, | ||
const char * | local_name, | ||
int | local_port, | ||
const char * | contact_uri | ||
) |
General purpose method for creating an rdata structure using specific information.
[out] | rdata | The rdata structure that will be populated |
packet | A SIP message | |
src_name | The source IP address of the message | |
src_port | The source port of the message | |
transport_type | The type of transport the message was received on | |
local_name | The local IP address the message was received on | |
local_port | The local port the message was received on | |
contact_uri | The contact URI of the message |
0 | success |
-1 | failure |
Definition at line 1214 of file res_pjsip.c.
References ast_copy_string(), ast_log, ast_strlen_zero(), LOG_WARNING, NULL, and tmp().
Referenced by ast_sip_create_rdata(), and subscription_persistence_recreate().
int ast_sip_create_request | ( | const char * | method, |
struct pjsip_dialog * | dlg, | ||
struct ast_sip_endpoint * | endpoint, | ||
const char * | uri, | ||
struct ast_sip_contact * | contact, | ||
pjsip_tx_data ** | tdata | ||
) |
General purpose method for creating a SIP request.
Its typical use would be to create one-off requests such as an out of dialog SIP MESSAGE.
The request can either be in- or out-of-dialog. If in-dialog, the dlg parameter MUST be present. If out-of-dialog the endpoint parameter MUST be present. If both are present, then we will assume that the message is to be sent in-dialog.
The uri parameter can be specified if the request should be sent to an explicit URI rather than one configured on the endpoint.
method | The method of the SIP request to send | |
dlg | Optional. If specified, the dialog on which to request the message. | |
endpoint | Optional. If specified, the request will be created out-of-dialog to the endpoint. | |
uri | Optional. If specified, the request will be sent to this URI rather than one configured for the endpoint. | |
contact | The contact with which this request is associated for out-of-dialog requests. | |
[out] | tdata | The newly-created request |
The provided contact is attached to tdata with its reference bumped, but will not survive for the entire lifetime of tdata since the contact is cleaned up when all supplements have completed execution.
0 | Success |
-1 | Failure |
Definition at line 1435 of file res_pjsip.c.
References ast_assert, ast_log, create_in_dialog_request(), create_out_of_dialog_request(), get_pjsip_method(), LOG_WARNING, method, NULL, and pmethod.
Referenced by aoc_send_as_xml(), msg_send(), notify_channel(), notify_contact(), notify_uri(), send_unsolicited_mwi_notify_to_contact(), sendtext(), sip_options_qualify_contact(), transmit_info_dtmf(), and transmit_info_with_vidupdate().
int ast_sip_create_request_with_auth | ( | const struct ast_sip_auth_vector * | auths, |
pjsip_rx_data * | challenge, | ||
pjsip_tx_data * | tdata, | ||
pjsip_tx_data ** | new_request | ||
) |
Create a response to an authentication challenge.
This will call into an outbound authenticator's create_request_with_auth callback to create a new request with authentication credentials. See the create_request_with_auth callback in the ast_sip_outbound_authenticator structure for details about the parameters and return values.
Definition at line 214 of file res_pjsip.c.
References ast_log, challenge(), ast_sip_outbound_authenticator::create_request_with_auth, LOG_WARNING, and registered_outbound_authenticator.
Referenced by check_request_status(), handle_registration_response(), outbound_invite_auth(), refer_client_on_evsub_state(), session_inv_on_tsx_state_changed(), and sip_outbound_publish_callback().
int ast_sip_create_response | ( | const pjsip_rx_data * | rdata, |
int | st_code, | ||
struct ast_sip_contact * | contact, | ||
pjsip_tx_data ** | p_tdata | ||
) |
General purpose method for creating a SIP response.
Its typical use would be to create responses for out of dialog requests.
rdata | The rdata from the incoming request. | |
st_code | The response code to transmit. | |
contact | The contact with which this request is associated. | |
[out] | p_tdata | The newly-created response |
The provided contact is attached to tdata with its reference bumped, but will not survive for the entire lifetime of tdata since the contact is cleaned up when all supplements have completed execution.
0 | Success |
-1 | Failure |
Definition at line 2468 of file res_pjsip.c.
References ao2_bump, ast_sip_get_pjsip_endpoint(), ast_sip_mod_data_set, MOD_DATA_CONTACT, NULL, and supplement_module.
Referenced by send_options_response(), and send_response().
void * ast_sip_dict_get | ( | void * | ht, |
const char * | key | ||
) |
Retrieves the value associated with the given key.
ht | the hash table/dictionary to search |
key | the key to find |
the | value associated with the key, NULL otherwise. |
Definition at line 2327 of file res_pjsip.c.
References NULL.
void * ast_sip_dict_set | ( | pj_pool_t * | pool, |
void * | ht, | ||
const char * | key, | ||
void * | val | ||
) |
Set the value for the given key.
Note - if the hash table does not exist one is created first, the key/value pair is set, and the hash table returned.
pool | the pool to allocate memory in |
ht | the hash table/dictionary in which to store the key/value pair |
key | the key to associate a value with |
val | the value to associate with a key |
the | given, or newly created, hash table. |
Definition at line 2338 of file res_pjsip.c.
int ast_sip_dlg_set_transport | ( | const struct ast_sip_endpoint * | endpoint, |
pjsip_dialog * | dlg, | ||
pjsip_tpselector * | selector | ||
) |
Set the transport on a dialog.
endpoint | |
dlg | |
selector | (optional) |
Definition at line 727 of file res_pjsip.c.
References ast_sip_set_tpselector_from_ep_or_uri(), and ast_sip_tpselector_unref().
Referenced by ast_sip_create_dialog_uac().
int ast_sip_dtmf_to_str | ( | const enum ast_sip_dtmf_mode | dtmf, |
char * | buf, | ||
size_t | buf_len | ||
) |
Convert the DTMF mode enum value into a string.
dtmf | the dtmf mode |
buf | Buffer to receive dtmf mode string |
buf_len | Buffer length |
0 | Success |
-1 | Failure |
Definition at line 2504 of file res_pjsip.c.
References ast_copy_string(), AST_SIP_DTMF_AUTO, AST_SIP_DTMF_AUTO_INFO, AST_SIP_DTMF_INBAND, AST_SIP_DTMF_INFO, AST_SIP_DTMF_NONE, AST_SIP_DTMF_RFC_4733, and buf.
Referenced by dtmf_to_str(), and pjsip_acf_dtmf_mode_read().
int ast_sip_failover_request | ( | pjsip_tx_data * | tdata | ) |
Set a request to use the next value in the list of resolved addresses.
tdata | the tx data from the original request |
0 | No more addresses to try |
1 | The request was successfully re-intialized |
Definition at line 1816 of file res_pjsip.c.
References NULL, and send_request_wrapper::tdata.
Referenced by check_request_status(), and handle_registration_response().
struct ast_sip_transport_state * ast_sip_find_transport_state_in_use | ( | struct ast_sip_request_transport_details * | details | ) |
Returns the transport state currently in use based on request transport details.
details |
transport_state |
Definition at line 595 of file res_pjsip.c.
References ao2_callback, ao2_cleanup, ast_sip_get_transport_states(), find_transport_state_in_use(), NULL, RAII_VAR, and transport_states.
Referenced by ast_sip_rewrite_uri_to_local(), and process_nat().
int ast_sip_format_endpoint_ami | ( | struct ast_sip_endpoint * | endpoint, |
struct ast_sip_ami * | ami, | ||
int * | count | ||
) |
Formats the endpoint and sends over AMI.
endpoint | the endpoint to format and send |
ami | AMI variable container |
count | the number of formatters operated on |
0 | Success, otherwise non-zero on error |
Definition at line 501 of file res_pjsip.c.
References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sip_endpoint_formatter::format_ami, lock, and SCOPED_LOCK.
Referenced by ami_show_endpoint().
pjsip_sip_uri * ast_sip_get_contact_sip_uri | ( | pjsip_tx_data * | tdata | ) |
Return the SIP URI of the Contact header.
tdata |
Pointer | to SIP URI of Contact |
NULL | if Contact header not found or not a SIP(S) URI |
Definition at line 564 of file res_pjsip.c.
References NULL.
Referenced by ast_sip_rewrite_uri_to_local(), ast_sip_set_request_transport_details(), and process_nat().
struct ast_sip_endpoint * ast_sip_get_endpoint | ( | const char * | to, |
int | get_default_outbound, | ||
char ** | uri | ||
) |
Retrieves an endpoint and URI from the "to" string.
This URI is used as the Request URI.
Expects the given 'to' to be in one of the following formats: Why we allow so many is a mystery.
Basic:
endpoint : We'll get URI from the default aor/contact endpoint/aor : We'll get the URI from the specific aor/contact endpoint@domain : We toss the domain part and just use the endpoint
These all use the endpoint and specified URI:
endpoint/<sip[s]:host> endpoint/<sip[s]:user@host> endpoint/"Bob" <sip[s]:host> endpoint/"Bob" <sip[s]:user@host> endpoint/sip[s]:host endpoint/sip[s]:user@host endpoint/host endpoint/user@host
These all use the default endpoint and specified URI:
<sip[s]:host> <sip[s]:user@host> "Bob" <sip[s]:host> "Bob" <sip[s]:user@host> sip[s]:host sip[s]:user@host
These use the default endpoint and specified host:
host user@host
This form is similar to a dialstring:
PJSIP/user@endpoint
In this case, the user will be added to the endpoint contact's URI. If the contact URI already has a user, it will be replaced.
The ones that have the sip[s] scheme are the easiest to parse. The rest all have some issue.
endpoint vs host : We have to test for endpoint first endpoint/aor vs endpoint/host : We have to test for aor first What if there's an aor with the same name as the host? endpoint@domain vs user@host : We have to test for endpoint first. What if there's an endpoint with the same name as the user?
to | 'To' field with possible endpoint |
get_default_outbound | If nonzero, try to retrieve the default outbound endpoint if no endpoint was found. Otherwise, return NULL if no endpoint was found. |
uri | Pointer to a char* which will be set to the URI. Always must be ast_free'd by the caller - even if the return value is NULL! |
Definition at line 3249 of file res_pjsip.c.
References ao2_cleanup, ast_debug, ast_malloc, ast_sip_default_outbound_endpoint(), ast_strdup, ast_strdupa, handle_atsign(), handle_single_token(), handle_slash(), NULL, and S_OR.
Referenced by msg_send(), and refer_send().
int ast_sip_get_host_ip | ( | int | af, |
pj_sockaddr * | addr | ||
) |
Retrieve the local host address in IP form.
af | The address family to retrieve |
addr | A place to store the local host address |
0 | success |
-1 | failure |
Definition at line 2480 of file res_pjsip.c.
References ast_strlen_zero(), host_ip_ipv4, host_ip_ipv4_string, host_ip_ipv6, and host_ip_ipv6_string.
const char * ast_sip_get_host_ip_string | ( | int | af | ) |
Retrieve the local host address in string form.
af | The address family to retrieve |
non-NULL | success |
NULL | failure |
Definition at line 2493 of file res_pjsip.c.
References host_ip_ipv4_string, host_ip_ipv6_string, and NULL.
Referenced by create_local_sdp(), create_outgoing_sdp_stream(), and multihomed_rewrite_sdp().
pjsip_endpoint * ast_sip_get_pjsip_endpoint | ( | void | ) |
Get a pointer to the PJSIP endpoint.
This is useful when modules have specific information they need to register with the PJSIP core.
NULL | endpoint has not been created yet. |
non-NULL | PJSIP endpoint. |
Definition at line 520 of file res_pjsip.c.
References ast_pjsip_endpoint.
Referenced by acl_on_rx_msg(), aoc_release_pool(), aoc_send_as_xml(), ast_res_pjsip_cleanup_options_handling(), ast_res_pjsip_init_options_handling(), ast_sip_create_response(), ast_sip_destroy_transport_events(), ast_sip_initialize_transport_events(), ast_sip_pubsub_register_body_generator(), ast_sip_send_response(), ast_sip_send_stateful_response(), ast_sip_session_defer_termination(), ast_sip_session_resume_reinvite(), authenticate(), cancel_publish_refresh(), cancel_registration(), channel_read_pjsip(), create_out_of_dialog_request(), digest_create_request_with_auth(), distribute(), distributor(), do_cli_dump_endpt(), endpoint_lookup(), endpt_send_request(), endpt_send_request_cb(), exten_state_data_alloc(), exten_state_data_destructor(), exten_state_publisher_cb(), filter_on_tx_message(), find_registrar_aor(), insert_user_in_contact_uri(), keepalive_transport_send_keepalive(), load_module(), logging_on_rx_msg(), logging_on_tx_msg(), notify_task(), on_rx_process_uris(), options_incoming_request(), parse_uri_cb(), pool_destroy_callback(), pre_session_setup(), publish_request_initial(), pubsub_on_rx_mwi_notify_request(), pubsub_on_rx_publish_request(), pubsub_on_rx_subscribe_request(), register_aor(), registrar_on_rx_request(), reschedule_reinvite(), schedule_publish_refresh(), schedule_registration(), send_options_response(), session_reinvite_on_rx_request(), sip_dialog_create_contact(), sip_dialog_create_from(), sip_outbound_publisher_init(), sip_outbound_registration_regc_alloc(), sip_publication_respond(), sip_session_defer_termination_stop_timer(), subscription_persistence_load(), system_create_resolver_and_set_nameservers(), t38_change_state(), transport_apply(), and transport_create().
int ast_sip_get_transport_name | ( | const struct ast_sip_endpoint * | endpoint, |
pjsip_sip_uri * | sip_uri, | ||
char * | buf, | ||
size_t | buf_len | ||
) |
Get the transport name from an endpoint or request uri.
endpoint | |
sip_uri | |
buf | Buffer to receive transport name |
buf_len | Buffer length |
0 | Success |
-1 | Failure |
Definition at line 698 of file res_pjsip.c.
References ast_alloca, ast_copy_pj_str(), ast_copy_string(), AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN, ast_sockaddr_parse(), ast_strlen_zero(), buf, NULL, PARSE_PORT_FORBID, and ast_sip_endpoint::transport.
Referenced by ast_sip_set_tpselector_from_ep_or_uri().
const int ast_sip_hangup_sip2cause | ( | int | cause | ) |
Convert SIP hangup causes to Asterisk hangup causes.
cause | SIP cause |
matched | cause code from causes.h |
Definition at line 3531 of file res_pjsip.c.
References AST_CAUSE_BEARERCAPABILITY_NOTAVAIL, AST_CAUSE_BUSY, AST_CAUSE_CALL_REJECTED, AST_CAUSE_CONGESTION, AST_CAUSE_DESTINATION_OUT_OF_ORDER, AST_CAUSE_FACILITY_REJECTED, AST_CAUSE_FAILURE, AST_CAUSE_INTERWORKING, AST_CAUSE_INVALID_NUMBER_FORMAT, AST_CAUSE_NO_ANSWER, AST_CAUSE_NO_ROUTE_DESTINATION, AST_CAUSE_NO_USER_RESPONSE, AST_CAUSE_NORMAL, AST_CAUSE_NORMAL_TEMPORARY_FAILURE, AST_CAUSE_NUMBER_CHANGED, AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE, AST_CAUSE_UNALLOCATED, and AST_CAUSE_USER_BUSY.
Referenced by chan_pjsip_incoming_response_update_cause(), chan_pjsip_session_end(), and rfc3326_use_reason_header().
struct ast_sip_endpoint * ast_sip_identify_endpoint | ( | pjsip_rx_data * | rdata | ) |
Determine the endpoint that has sent a SIP message.
This will call into each of the registered endpoint identifiers' identify_endpoint() callbacks until one returns a non-NULL endpoint. This will return an ao2 object. Its reference count will need to be decremented when completed using the endpoint.
rdata | The inbound SIP message to use when identifying the endpoint. |
NULL | No matching endpoint |
non-NULL | The matching endpoint |
Definition at line 330 of file res_pjsip.c.
References ast_assert, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, endpoint_identifier_list::identifier, ast_sip_endpoint_identifier::identify_endpoint, lock, NULL, and SCOPED_LOCK.
Referenced by endpoint_lookup().
int ast_sip_is_allowed_uri | ( | pjsip_uri * | uri | ) |
Check whether a pjsip_uri is allowed or not.
uri | The pjsip_uri to check |
1 | if allowed |
0 | if not allowed |
Definition at line 3472 of file res_pjsip.c.
References ast_sip_is_uri_sip_sips().
Referenced by endpoint_lookup(), get_destination(), on_rx_process_uris(), options_on_rx_request(), rx_data_to_ast_msg(), and set_redirecting_reason_by_cause().
int ast_sip_is_content_type | ( | pjsip_media_type * | content_type, |
char * | type, | ||
char * | subtype | ||
) |
Checks if the given content type matches type/subtype.
Compares the pjsip_media_type with the passed type and subtype and returns the result of that comparison. The media type parameters are ignored.
content_type | The pjsip_media_type structure to compare |
type | The media type to compare |
subtype | The media subtype to compare |
0 | No match |
-1 | Match |
Definition at line 2248 of file res_pjsip.c.
References compare(), and type.
Referenced by asterisk_publication_devicestate_state_change(), asterisk_publication_mwi_state_change(), check_content_type(), and pubsub_on_rx_notify_request().
int ast_sip_is_media_type_in | ( | pjsip_media_type * | a, |
... | |||
) |
Check if a media type is in a list of others.
a | pjsip_media_type to search for |
... | one or more pointers to pjsip_media_types the last of which must be "SENTINEL" |
1 | Media types are equal |
0 | Media types are not equal |
Definition at line 2228 of file res_pjsip.c.
References a, ast_assert, b, NULL, and SENTINEL.
Referenced by check_content_disposition().
int ast_sip_is_uri_sip_sips | ( | pjsip_uri * | uri | ) |
Check whether a pjsip_uri is SIP/SIPS or not.
uri | The pjsip_uri to check |
1 | if true |
0 | if false |
Definition at line 3467 of file res_pjsip.c.
Referenced by ast_sip_is_allowed_uri(), ast_sip_pjsip_uri_get_hostname(), ast_sip_pjsip_uri_get_other_param(), ast_sip_pjsip_uri_get_username(), filter_on_tx_message(), get_endpoint_details(), get_from_header(), publish_request_initial(), pubsub_on_rx_subscribe_request(), and sanitize_tdata().
void ast_sip_modify_id_header | ( | pj_pool_t * | pool, |
pjsip_fromto_hdr * | id_hdr, | ||
const struct ast_party_id * | id | ||
) |
Set name and number information on an identity header.
pool | Memory pool to use for string duplication |
id_hdr | A From, P-Asserted-Identity, or Remote-Party-ID header to modify |
id | The identity information to apply to the header |
Definition at line 2850 of file res_pjsip.c.
References ast_alloca, ast_escape_quoted(), ast_strlen_zero(), id, and NULL.
Referenced by add_pai_header(), add_rpid_header(), and set_from_header().
const pj_str_t * ast_sip_pjsip_uri_get_hostname | ( | pjsip_uri * | uri | ) |
Get the host portion of the pjsip_uri.
uri | The pjsip_uri to get the host from |
Definition at line 3496 of file res_pjsip.c.
References AST_PJ_STR_EMPTY, and ast_sip_is_uri_sip_sips().
Referenced by dialog_info_generate_body_content(), find_aor2(), get_endpoint_details(), get_from_header(), and set_sipdomain_variable().
struct pjsip_param * ast_sip_pjsip_uri_get_other_param | ( | pjsip_uri * | uri, |
const pj_str_t * | param_str | ||
) |
Find an 'other' SIP/SIPS URI parameter by name.
A convenience function to find a named parameter from a SIP/SIPS URI. This function will not find the following standard SIP/SIPS URI parameters which are stored separately by PJSIP:
user
method
transport
ttl
lr
maddr
uri | The pjsip_uri to get the parameter from |
param_str | The name of the parameter to find |
Definition at line 3511 of file res_pjsip.c.
References ast_sip_is_uri_sip_sips(), and NULL.
Referenced by get_uri_option_line(), and set_redirecting_reason_by_cause().
const pj_str_t * ast_sip_pjsip_uri_get_username | ( | pjsip_uri * | uri | ) |
Get the user portion of the pjsip_uri.
uri | The pjsip_uri to get the user from |
Definition at line 3477 of file res_pjsip.c.
References AST_PJ_STR_EMPTY, and ast_sip_is_uri_sip_sips().
Referenced by add_diversion_header(), endpoint_lookup(), find_aor2(), get_destination(), get_from_header(), options_on_rx_request(), publish_request_initial(), pubsub_on_rx_subscribe_request(), rx_data_to_ast_msg(), set_id_from_hdr(), and sub_persistence_recreate().
|
static |
Definition at line 2137 of file res_pjsip.c.
References ast_cond_destroy, ast_cond_init, ast_cond_wait, ast_mutex_destroy, ast_mutex_init, ast_mutex_lock, ast_mutex_unlock, ast_sip_push_task(), sync_task_data::complete, sync_task_data::cond, sync_task_data::fail, sync_task_data::lock, NULL, sync_task(), sync_task_data::task, and sync_task_data::task_data.
Referenced by ast_sip_push_task_wait_serializer(), and ast_sip_push_task_wait_servant().
char * ast_sip_rdata_get_header_value | ( | pjsip_rx_data * | rdata, |
const pj_str_t | str | ||
) |
Get a specific header value from rdata.
rdata | The rdata |
str | The header to find |
NULL | on failure |
The | header value on success |
Definition at line 345 of file res_pjsip.c.
Referenced by stir_shaken_incoming_request().
int ast_sip_register_authenticator | ( | struct ast_sip_authenticator * | auth | ) |
Register a SIP authenticator.
An authenticator has three main purposes: 1) Determining if authentication should be performed on an incoming request 2) Gathering credentials necessary for issuing an authentication challenge 3) Authenticating a request that has credentials
Asterisk provides a default authenticator, but it may be replaced by a custom one if desired.
auth | The authenticator to register |
0 | Success |
-1 | Failure |
Definition at line 140 of file res_pjsip.c.
References ast_debug, ast_log, LOG_WARNING, and registered_authenticator.
Referenced by load_module().
void ast_sip_register_endpoint_formatter | ( | struct ast_sip_endpoint_formatter * | obj | ) |
Register an endpoint formatter.
obj | the formatter to register |
Definition at line 481 of file res_pjsip.c.
References AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, lock, ast_cli_entry::next, and SCOPED_LOCK.
Referenced by ast_res_pjsip_init_options_handling(), ast_sip_initialize_sorcery_auth(), ast_sip_initialize_sorcery_location(), ast_sip_initialize_sorcery_transport(), and load_module().
int ast_sip_register_endpoint_identifier | ( | struct ast_sip_endpoint_identifier * | identifier | ) |
Register a SIP endpoint identifier.
An endpoint identifier's purpose is to determine which endpoint a given SIP message has come from.
Multiple endpoint identifiers may be registered so that if an endpoint cannot be identified by one identifier, it may be identified by another.
Asterisk provides two endpoint identifiers. One identifies endpoints based on the user part of the From header URI. The other identifies endpoints based on the source IP address.
If the order in which endpoint identifiers is run is important to you, then be sure to load individual endpoint identifier modules in the order you wish for them to be run in modules.conf
identifier | The SIP endpoint identifier to register |
0 | Success |
-1 | Failure |
Definition at line 310 of file res_pjsip.c.
References ast_sip_register_endpoint_identifier_with_name(), endpoint_identifier_list::identifier, and NULL.
Referenced by load_module().
int ast_sip_register_endpoint_identifier_with_name | ( | struct ast_sip_endpoint_identifier * | identifier, |
const char * | name | ||
) |
Register a SIP endpoint identifier with a name.
An endpoint identifier's purpose is to determine which endpoint a given SIP message has come from.
Multiple endpoint identifiers may be registered so that if an endpoint cannot be identified by one identifier, it may be identified by another.
identifier | The SIP endpoint identifier to register |
name | The name of the endpoint identifier |
0 | Success |
-1 | Failure |
Definition at line 233 of file res_pjsip.c.
References ast_calloc, ast_debug, ast_free, ast_log, AST_RWLIST_EMPTY, AST_RWLIST_INSERT_AFTER, AST_RWLIST_INSERT_BEFORE_CURRENT, AST_RWLIST_INSERT_HEAD, AST_RWLIST_INSERT_TAIL, AST_RWLIST_NEXT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_sip_get_endpoint_identifier_order(), ast_strlen_zero(), current, endpoint_identifier_list::identifier, lock, LOG_ERROR, name, endpoint_identifier_list::name, endpoint_identifier_list::priority, and SCOPED_LOCK.
Referenced by ast_sip_register_endpoint_identifier(), and load_module().
int ast_sip_register_outbound_authenticator | ( | struct ast_sip_outbound_authenticator * | outbound_auth | ) |
Register an outbound SIP authenticator.
An outbound authenticator is responsible for creating responses to authentication challenges by remote endpoints.
outbound_auth | The authenticator to register |
0 | Success |
-1 | Failure |
Definition at line 191 of file res_pjsip.c.
References ast_debug, ast_log, LOG_WARNING, and registered_outbound_authenticator.
Referenced by load_module().
int ast_sip_register_service | ( | pjsip_module * | module | ) |
Register a SIP service in Asterisk.
This is more-or-less a wrapper around pjsip_endpt_register_module(). Registering a service makes it so that PJSIP will call into the service at appropriate times. For more information about PJSIP module callbacks, see the PJSIP documentation. Asterisk modules that call this function will likely do so at module load time.
module | The module that is to be registered with PJSIP |
0 | Success |
-1 | Failure |
Definition at line 117 of file res_pjsip.c.
References ast_sip_push_task_wait_servant(), NULL, and register_service().
Referenced by ast_res_pjsip_init_message_filter(), ast_sip_initialize_distributor(), ast_sip_initialize_global_headers(), ast_sip_initialize_transport_management(), and load_module().
void ast_sip_register_supplement | ( | struct ast_sip_supplement * | supplement | ) |
Register a supplement to SIP out of dialog processing.
This allows for someone to insert themselves in the processing of out of dialog SIP requests and responses. This, for example could allow for a module to set channel data based on headers in an incoming message. Similarly, a module could reject an incoming request if desired.
supplement | The supplement to register |
Definition at line 1456 of file res_pjsip.c.
References AST_RWLIST_INSERT_BEFORE_CURRENT, AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, lock, ast_sip_supplement::next, ast_sip_supplement::priority, and SCOPED_LOCK.
Referenced by ast_res_pjsip_init_message_filter(), and load_module().
int ast_sip_requires_authentication | ( | struct ast_sip_endpoint * | endpoint, |
pjsip_rx_data * | rdata | ||
) |
Determine if an incoming request requires authentication.
This calls into the registered authenticator's requires_authentication callback in order to determine if the request requires authentication.
If there is no registered authenticator, then authentication will be assumed not to be required.
endpoint | The endpoint from which the request originates |
rdata | The incoming SIP request |
non-zero | The request requires authentication |
0 | The request does not require authentication |
Definition at line 163 of file res_pjsip.c.
References ast_sip_endpoint::allow_unauthenticated_options, ast_debug, ast_log, LOG_WARNING, registered_authenticator, and ast_sip_authenticator::requires_authentication.
Referenced by authenticate().
int ast_sip_rewrite_uri_to_local | ( | pjsip_sip_uri * | uri, |
pjsip_tx_data * | tdata | ||
) |
Replace domain and port of SIP URI to point to (external) signaling address of this Asterisk instance.
uri | |
tdata |
0 | success |
-1 | failure |
Definition at line 605 of file res_pjsip.c.
References ao2_cleanup, ast_sip_find_transport_state_in_use(), ast_sip_get_contact_sip_uri(), ast_sip_get_sorcery(), ast_sip_set_request_transport_details(), ast_sip_transport_is_local, ast_sockaddr_isnull(), ast_sockaddr_parse(), ast_sockaddr_set_port, ast_sockaddr_stringify_host(), ast_sorcery_retrieve_by_id(), NULL, PARSE_PORT_FORBID, RAII_VAR, and ast_sip_transport_state::transport.
Referenced by refer_on_tx_request().
int ast_sip_send_out_of_dialog_request | ( | pjsip_tx_data * | tdata, |
struct ast_sip_endpoint * | endpoint, | ||
int | timeout, | ||
void * | token, | ||
void(*)(void *token, pjsip_event *e) | callback | ||
) |
General purpose method for sending an Out-Of-Dialog SIP request.
This is a companion function for ast_sip_create_request. The request created there can be passed to this function, though any request may be passed in.
This will automatically set up handling outbound authentication challenges if they arrive.
tdata | The request to send |
endpoint | Optional. If specified, the out-of-dialog request is sent to the endpoint. |
timeout | If non-zero, after the timeout the transaction will be terminated and the callback will be called with the PJSIP_EVENT_TIMER type. |
token | Data to be passed to the callback upon receipt of out-of-dialog response. |
callback | Callback to be called upon receipt of out-of-dialog response. |
0 | Success |
-1 | Failure (out-of-dialog callback will not be called.) |
Definition at line 1938 of file res_pjsip.c.
References ao2_cleanup, AST_LIST_TRAVERSE, AST_RWLIST_RDLOCK, AST_RWLIST_UNLOCK, ast_sip_message_apply_transport(), ast_sip_mod_data_get, ast_sip_mod_data_set, does_method_match(), ast_sip_contact::endpoint, endpt_send_request(), ast_sip_supplement::method, MOD_DATA_CONTACT, NULL, ast_sip_supplement::outgoing_request, send_request_cb(), send_request_data_alloc(), supplement_module, and ast_sip_endpoint::transport.
Referenced by ast_sip_send_request(), and sip_options_qualify_contact().
int ast_sip_send_request | ( | pjsip_tx_data * | tdata, |
struct pjsip_dialog * | dlg, | ||
struct ast_sip_endpoint * | endpoint, | ||
void * | token, | ||
void(*)(void *token, pjsip_event *e) | callback | ||
) |
General purpose method for sending a SIP request.
This is a companion function for ast_sip_create_request. The request created there can be passed to this function, though any request may be passed in.
This will automatically set up handling outbound authentication challenges if they arrive.
tdata | The request to send |
dlg | Optional. The dialog in which the request is sent. Otherwise it is out-of-dialog. |
endpoint | Optional. If specified, the out-of-dialog request is sent to the endpoint. |
token | Data to be passed to the callback upon receipt of out-of-dialog response. |
callback | Callback to be called upon receipt of out-of-dialog response. |
0 | Success |
-1 | Failure (out-of-dialog callback will not be called.) |
Definition at line 1979 of file res_pjsip.c.
References ast_assert, ast_sip_send_out_of_dialog_request(), ast_sip_contact::endpoint, and send_in_dialog_request().
Referenced by msg_send(), notify_channel(), notify_contact(), notify_uri(), refer_client_on_evsub_state(), send_unsolicited_mwi_notify_to_contact(), and sendtext().
int ast_sip_send_response | ( | pjsip_response_addr * | res_addr, |
pjsip_tx_data * | tdata, | ||
struct ast_sip_endpoint * | sip_endpoint | ||
) |
Send a response to an out of dialog request.
Use this function sparingly, since this does not create a transaction within PJSIP. This means that if the request is retransmitted, it is your responsibility to detect this and not process the same request twice, and to send the same response for each retransmission.
res_addr | The response address for this response |
tdata | The response to send |
sip_endpoint | The ast_sip_endpoint associated with this response |
0 | Success |
-1 | Failure |
Definition at line 2396 of file res_pjsip.c.
References ast_sip_get_pjsip_endpoint(), NULL, status, and supplement_outgoing_response().
int ast_sip_send_stateful_response | ( | pjsip_rx_data * | rdata, |
pjsip_tx_data * | tdata, | ||
struct ast_sip_endpoint * | sip_endpoint | ||
) |
Send a stateful response to an out of dialog request.
This creates a transaction within PJSIP, meaning that if the request that we are responding to is retransmitted, we will not attempt to re-handle the request.
rdata | The request that is being responded to |
tdata | The response to send |
sip_endpoint | The ast_sip_endpoint associated with this response |
0 | Success |
-1 | Failure |
Definition at line 2424 of file res_pjsip.c.
References ast_sip_get_pjsip_endpoint(), clean_contact_from_tdata(), NULL, pool_destroy_callback(), and supplement_outgoing_response().
Referenced by register_aor(), send_options_response(), and send_response().
int ast_sip_set_id_connected_line | ( | struct pjsip_rx_data * | rdata, |
struct ast_party_id * | id | ||
) |
Set the ID for a connected line update.
-1 | on failure, 0 on success |
Definition at line 2822 of file res_pjsip.c.
References set_id_from_pai(), and set_id_from_rpid().
Referenced by update_incoming_connected_line().
int ast_sip_set_id_from_invite | ( | struct pjsip_rx_data * | rdata, |
struct ast_party_id * | id, | ||
struct ast_party_id * | default_id, | ||
int | trust_inbound | ||
) |
Set the ID from an INVITE.
rdata | |
id | ID structure to fill |
default_id | Default ID structure with data to use (for non-trusted endpoints) |
trust_inbound | Whether or not the endpoint is trusted (controls whether PAI or RPID can be used) |
-1 | on failure, 0 on success |
Definition at line 2827 of file res_pjsip.c.
References ast_free, ast_party_id_copy(), ast_strdup, id, ast_party_id::number, set_id_from_from(), set_id_from_pai(), set_id_from_rpid(), ast_party_id::tag, and ast_party_number::valid.
Referenced by caller_id_incoming_request(), and fetch_callerid_num().
int ast_sip_set_outbound_proxy | ( | pjsip_tx_data * | tdata, |
const char * | proxy | ||
) |
Set the outbound proxy for an outbound SIP message.
tdata | The message to set the outbound proxy on |
proxy | SIP uri of the proxy |
0 | Success |
-1 | Failure |
Definition at line 1992 of file res_pjsip.c.
Referenced by create_out_of_dialog_request(), path_outgoing_request(), and sip_options_qualify_contact().
int ast_sip_set_request_transport_details | ( | struct ast_sip_request_transport_details * | details, |
pjsip_tx_data * | tdata, | ||
int | use_ipv6 | ||
) |
Sets request transport details based on tdata.
details | pre-allocated request transport details to set |
tdata | |
use_ipv6 | if non-zero, ipv6 transports will be considered |
0 | success |
-1 | failure |
Definition at line 648 of file res_pjsip.c.
References ast_sip_get_contact_sip_uri(), AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, ast_sip_request_transport_details::factory, if(), ast_sip_request_transport_details::local_address, ast_sip_request_transport_details::local_port, NULL, ast_sip_request_transport_details::transport, and ast_sip_request_transport_details::type.
Referenced by ast_sip_rewrite_uri_to_local(), and process_nat().
int ast_sip_set_tpselector_from_ep_or_uri | ( | const struct ast_sip_endpoint * | endpoint, |
pjsip_sip_uri * | sip_uri, | ||
pjsip_tpselector * | selector | ||
) |
Sets pjsip_tpselector from an endpoint or uri.
endpoint | If endpoint->transport is set, it's used |
sip_uri | If sip_uri contains a x-ast-txp parameter, it's used |
selector | The selector to be populated |
0 | success |
-1 | failure |
Definition at line 911 of file res_pjsip.c.
References ast_sip_get_transport_name(), and ast_sip_set_tpselector_from_transport_name().
Referenced by ast_sip_dlg_set_transport(), create_dialog_uas(), and create_out_of_dialog_request().
int ast_sip_set_tpselector_from_transport | ( | const struct ast_sip_transport * | transport, |
pjsip_tpselector * | selector | ||
) |
Sets pjsip_tpselector from ast_sip_transport.
transport | The transport to be used |
selector | The selector to be populated |
0 | success |
-1 | failure |
Definition at line 843 of file res_pjsip.c.
References ao2_lock, ao2_ref, ao2_unlock, ast_log, ast_sip_get_transport_state(), ast_sorcery_object_get_id(), AST_TRANSPORT_WS, AST_TRANSPORT_WSS, ast_sip_transport_state::factory, ast_sip_transport_state::flow, LOG_ERROR, LOG_WARNING, and ast_sip_transport_state::transport.
Referenced by ast_sip_set_tpselector_from_transport_name().
int ast_sip_set_tpselector_from_transport_name | ( | const char * | transport_name, |
pjsip_tpselector * | selector | ||
) |
Sets pjsip_tpselector from ast_sip_transport.
transport_name | The name of the transport to be used |
selector | The selector to be populated |
0 | success |
-1 | failure |
Definition at line 893 of file res_pjsip.c.
References ao2_cleanup, ast_log, ast_sip_get_sorcery(), ast_sip_set_tpselector_from_transport(), ast_sorcery_retrieve_by_id(), ast_strlen_zero(), LOG_ERROR, NULL, RAII_VAR, and ast_sip_transport_state::transport.
Referenced by ast_sip_set_tpselector_from_ep_or_uri(), registration_client_send(), set_transport(), and sip_outbound_registration_regc_alloc().
int ast_sip_str2rc | ( | const char * | name | ) |
Convert name to SIP response code.
name | SIP response code name matching one of the enum names defined in "enum pjsip_status_code" defined in sip_msg.h. May be specified with or without the PJSIP_SC_ prefix. |
SIP | response code |
-1 | if matching code not found |
Definition at line 3714 of file res_pjsip.c.
References ARRAY_LEN, ast_strlen_zero(), response_code_map::code, response_code_map::long_name, name, rc_map, and response_code_map::short_name.
Referenced by response_code_validator().
int ast_sip_str_to_dtmf | ( | const char * | dtmf_mode | ) |
Convert the DTMF mode name into an enum.
dtmf_mode | dtmf mode as a string |
>= | 0 The enum value |
-1 | Failure |
Definition at line 2533 of file res_pjsip.c.
References AST_SIP_DTMF_AUTO, AST_SIP_DTMF_AUTO_INFO, AST_SIP_DTMF_INBAND, AST_SIP_DTMF_INFO, AST_SIP_DTMF_NONE, AST_SIP_DTMF_RFC_4733, and result.
Referenced by dtmf_handler(), and pjsip_acf_dtmf_mode_write().
struct ast_threadpool * ast_sip_threadpool | ( | void | ) |
Retrieve the SIP threadpool object.
Definition at line 3462 of file res_pjsip.c.
References sip_threadpool.
Referenced by load_module().
long ast_sip_threadpool_queue_size | ( | void | ) |
Return the size of the SIP threadpool's task queue.
Definition at line 3457 of file res_pjsip.c.
References ast_threadpool_queue_size(), and sip_threadpool.
void ast_sip_tpselector_unref | ( | pjsip_tpselector * | selector | ) |
Unreference a pjsip_tpselector.
selector | The selector to be unreffed |
Definition at line 923 of file res_pjsip.c.
Referenced by ast_sip_create_dialog_uac(), ast_sip_dlg_set_transport(), create_dialog_uas(), create_out_of_dialog_request(), registration_client_send(), set_transport(), and sip_outbound_registration_regc_alloc().
void ast_sip_unregister_authenticator | ( | struct ast_sip_authenticator * | auth | ) |
Unregister a SIP authenticator.
When there is no authenticator registered, requests cannot be challenged or authenticated.
auth | The authenticator to unregister |
Definition at line 152 of file res_pjsip.c.
References ast_debug, ast_log, LOG_WARNING, NULL, and registered_authenticator.
Referenced by unload_module().
void ast_sip_unregister_endpoint_formatter | ( | struct ast_sip_endpoint_formatter * | obj | ) |
Unregister an endpoint formatter.
obj | the formatter to unregister |
Definition at line 487 of file res_pjsip.c.
References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, lock, and SCOPED_LOCK.
Referenced by ast_res_pjsip_cleanup_options_handling(), ast_sip_destroy_sorcery_auth(), ast_sip_destroy_sorcery_location(), ast_sip_destroy_sorcery_transport(), and unload_module().
void ast_sip_unregister_endpoint_identifier | ( | struct ast_sip_endpoint_identifier * | identifier | ) |
Unregister a SIP endpoint identifier.
This stops an endpoint identifier from being used.
identifier | The SIP endoint identifier to unregister |
Definition at line 315 of file res_pjsip.c.
References ast_debug, ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, endpoint_identifier_list::identifier, lock, and SCOPED_LOCK.
Referenced by unload_module().
void ast_sip_unregister_outbound_authenticator | ( | struct ast_sip_outbound_authenticator * | auth | ) |
Unregister an outbound SIP authenticator.
When there is no outbound authenticator registered, authentication challenges will be handled as any other final response would be.
auth | The authenticator to unregister |
Definition at line 203 of file res_pjsip.c.
References ast_debug, ast_log, LOG_WARNING, NULL, and registered_outbound_authenticator.
Referenced by unload_module().
void ast_sip_unregister_service | ( | pjsip_module * | module | ) |
This is the opposite of ast_sip_register_service(). Unregistering a service means that PJSIP will no longer call into the module any more. This will likely occur when an Asterisk module is unloaded.
module | The PJSIP module to unregister |
Definition at line 133 of file res_pjsip.c.
References ast_sip_push_task_wait_servant(), NULL, and unregister_service().
Referenced by ast_res_pjsip_cleanup_message_filter(), ast_sip_destroy_distributor(), ast_sip_destroy_global_headers(), ast_sip_destroy_transport_management(), load_module(), unload_module(), and unload_pjsip().
void ast_sip_unregister_supplement | ( | struct ast_sip_supplement * | supplement | ) |
Unregister a an supplement to SIP out of dialog processing.
supplement | The supplement to unregister |
Definition at line 1476 of file res_pjsip.c.
References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, lock, ast_sip_supplement::next, and SCOPED_LOCK.
Referenced by ast_res_pjsip_cleanup_message_filter(), and unload_module().
int ast_sip_update_from | ( | pjsip_tx_data * | tdata, |
char * | from | ||
) |
Overwrite fields in the outbound 'From' header.
The outbound 'From' header is created/added in ast_sip_create_request with default data. If available that data may be info specified in the 'from_user' and 'from_domain' options found on the endpoint. That information will be overwritten with data in the given 'from' parameter.
tdata | the outbound message data structure |
from | info to copy into the header. Can be either a SIP URI, or in the format user[@domain] |
0 | success, -1: failure |
Definition at line 3383 of file res_pjsip.c.
References ast_log, ast_strlen_zero(), and LOG_WARNING.
Referenced by msg_send(), and refer_send().
int ast_sip_update_to_uri | ( | pjsip_tx_data * | tdata, |
const char * | to | ||
) |
Replace the To URI in the tdata with the supplied one.
tdata | the outbound message data structure |
to | URI to replace the To URI with. Must be a valid SIP URI. |
0 | success, -1: failure |
Definition at line 3323 of file res_pjsip.c.
References ast_alloca, ast_debug, ast_log, buf, DEBUG_ATLEAST, DEBUG_BUF_SIZE, if(), LOG_WARNING, and NULL.
Referenced by msg_send(), and refer_send().
int ast_sip_will_uri_survive_restart | ( | pjsip_sip_uri * | uri, |
struct ast_sip_endpoint * | endpoint, | ||
pjsip_rx_data * | rdata | ||
) |
Definition at line 525 of file res_pjsip.c.
References ast_sip_endpoint::nat, result, and ast_sip_endpoint_nat_configuration::rewrite_contact.
Referenced by subscription_persistence_update().
|
static |
Definition at line 1839 of file res_pjsip.c.
References ao2_bump, ao2_ref, ast_sip_create_request_with_auth(), ast_sip_failover_request(), send_request_data::challenge_count, send_request_data::endpoint, endpt_send_request(), MAX_RX_CHALLENGES, ast_sip_endpoint::outbound_auths, and send_request_cb().
Referenced by send_request_cb().
|
static |
Definition at line 2415 of file res_pjsip.c.
References ao2_cleanup, ast_sip_mod_data_get, ast_sip_mod_data_set, MOD_DATA_CONTACT, NULL, and supplement_module.
Referenced by ast_sip_send_stateful_response().
|
static |
Definition at line 371 of file res_pjsip.c.
References a, ast_sip_push_task_wait_servant(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, do_cli_dump_endpt(), NULL, and ast_cli_entry::usage.
|
static |
Definition at line 411 of file res_pjsip.c.
References a, ast_cli(), AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, ENDPOINT_IDENTIFIER_FORMAT, lock, endpoint_identifier_list::name, NULL, SCOPED_LOCK, and ast_cli_entry::usage.
|
static |
Definition at line 442 of file res_pjsip.c.
References a, ast_cli(), ast_free, ast_str_buffer(), ast_str_create, CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SUCCESS, ast_cli_entry::command, voicemailpwcheck::context, NULL, sip_cli_print_global(), sip_cli_print_system(), and ast_cli_entry::usage.
|
static |
Definition at line 1118 of file res_pjsip.c.
References ast_assert, ast_log, ast_sip_set_tpselector_from_ep_or_uri(), ast_sip_tpselector_unref(), ast_sorcery_object_get_id(), ast_strlen_zero(), ast_sip_endpoint::contact_user, LOG_ERROR, NULL, S_OR, status, ast_sip_transport_state::transport, type, and uas_use_sips_contact().
Referenced by ast_sip_create_dialog_uas(), and ast_sip_create_dialog_uas_locked().
|
static |
Definition at line 1307 of file res_pjsip.c.
References ast_log, LOG_WARNING, and method.
Referenced by ast_sip_create_request().
|
static |
Definition at line 1325 of file res_pjsip.c.
References ao2_bump, ao2_cleanup, ast_sip_endpoint::aors, ast_log, ast_sip_add_usereqphone(), ast_sip_get_pjsip_endpoint(), ast_sip_location_retrieve_contact_from_aor_list(), ast_sip_mod_data_set, ast_sip_set_outbound_proxy(), ast_sip_set_tpselector_from_ep_or_uri(), ast_sip_tpselector_unref(), ast_sorcery_object_get_id(), ast_strlen_zero(), ast_sip_endpoint::contact_user, ast_sip_endpoint::fromdomain, ast_sip_endpoint::fromuser, LOG_ERROR, LOG_WARNING, method, MOD_DATA_CONTACT, NULL, ast_sip_endpoint::outbound_proxy, RAII_VAR, sip_dialog_create_from(), and supplement_module.
Referenced by ast_sip_create_request().
|
static |
Definition at line 360 of file res_pjsip.c.
References a, ast_pjproject_log_intercept_begin(), ast_pjproject_log_intercept_end(), and ast_sip_get_pjsip_endpoint().
Referenced by cli_dump_endpt().
|
static |
Definition at line 1499 of file res_pjsip.c.
References ast_strlen_zero(), message_method, and method.
Referenced by ast_sip_send_out_of_dialog_request(), send_request_cb(), supplement_on_rx_request(), and supplement_outgoing_response().
|
static |
Definition at line 1696 of file res_pjsip.c.
References ao2_alloc, ao2_lock, ao2_ref, ao2_t_ref, ao2_unlock, ast_debug, ast_log, ast_sip_get_pjsip_endpoint(), ast_sorcery_object_get_id(), send_request_wrapper::callback, send_request_wrapper::cb_called, endpt_send_request_cb(), LOG_ERROR, NULL, send_request_wrapper::send_cb_called, send_request_timer_callback(), send_request_wrapper_destructor(), send_request_wrapper::tdata, send_request_wrapper::timeout, send_request_wrapper::timeout_timer, TIMEOUT_TIMER2, TIMER_INACTIVE, and send_request_wrapper::token.
Referenced by ast_sip_send_out_of_dialog_request(), and check_request_status().
|
static |
Definition at line 1573 of file res_pjsip.c.
References ao2_lock, ao2_ref, ao2_unlock, ast_debug, ast_sip_get_pjsip_endpoint(), send_request_wrapper::callback, send_request_wrapper::cb_called, send_request_wrapper::send_cb_called, send_request_wrapper::timeout_timer, TIMEOUT_TIMER2, TIMER_INACTIVE, and send_request_wrapper::token.
Referenced by endpt_send_request().
|
static |
Callback function for finding the transport the request is going out on.
Definition at line 576 of file res_pjsip.c.
References CMP_MATCH, CMP_STOP, ast_sip_transport_state::factory, ast_sip_request_transport_details::factory, ast_sip_request_transport_details::local_address, ast_sip_request_transport_details::local_port, ast_sip_transport_state::transport, ast_sip_request_transport_details::transport, ast_sip_transport_state::type, and ast_sip_request_transport_details::type.
Referenced by ast_sip_find_transport_state_in_use().
|
static |
Definition at line 2673 of file res_pjsip.c.
References NULL.
Referenced by set_id_from_pai(), and set_id_from_rpid().
|
static |
Definition at line 1296 of file res_pjsip.c.
References ARRAY_LEN, method, methods, and NULL.
Referenced by ast_sip_create_request().
|
static |
Definition at line 3191 of file res_pjsip.c.
References ao2_cleanup, ast_sip_endpoint::aors, ast_debug, ast_log, ast_malloc, ast_sip_default_outbound_endpoint(), ast_sip_get_sorcery(), ast_sip_location_retrieve_contact_from_aor_list(), AST_SIP_USER_OPTIONS_TRUNCATE_CHECK, ast_sorcery_retrieve_by_id(), ast_strdup, ast_sip_contact::endpoint, ast_sip_contact::endpoint_name, LOG_WARNING, NULL, and ast_sip_contact::uri.
Referenced by ast_sip_get_endpoint().
|
static |
Definition at line 2955 of file res_pjsip.c.
References ao2_cleanup, ast_sip_endpoint::aors, ast_debug, ast_log, ast_malloc, ast_sip_default_outbound_endpoint(), ast_sip_get_sorcery(), ast_sip_location_retrieve_contact_from_aor_list(), ast_sorcery_retrieve_by_id(), ast_strdup, LOG_WARNING, NULL, and RAII_VAR.
Referenced by ast_sip_get_endpoint().
|
static |
Definition at line 3034 of file res_pjsip.c.
References ao2_cleanup, ast_sip_endpoint::aors, ast_begins_with(), ast_debug, ast_log, ast_malloc, ast_sip_get_sorcery(), ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_first_aor_contact(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_id(), ast_strdup, insert_user_in_contact_uri(), LOG_WARNING, NULL, and ast_sip_contact::uri.
Referenced by ast_sip_get_endpoint().
|
static |
Find a contact and insert a "user@" into its URI.
to | Original destination (for error messages only) |
endpoint_name | Endpoint name (for error messages only) |
aors | Command separated list of AORs |
user | The user to insert in the contact URI |
uri | Pointer to buffer in which to return the URI. Must be freed by caller. |
Definition at line 2890 of file res_pjsip.c.
References ao2_cleanup, ast_debug, ast_log, ast_malloc, ast_sip_get_pjsip_endpoint(), ast_sip_location_retrieve_contact_from_aor_list(), ast_sip_contact::endpoint_name, LOG_WARNING, NULL, out, RAII_VAR, and ast_sip_contact::uri.
Referenced by handle_slash().
|
static |
Definition at line 3922 of file res_pjsip.c.
References ARRAY_LEN, ast_cli_register_multiple, ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_res_pjsip_init_message_filter(), ast_res_pjsip_init_options_handling(), ast_res_pjsip_initialize_configuration(), ast_res_pjsip_preinit_options_handling(), ast_serializer_pool_create(), ast_serializer_pool_destroy(), ast_sip_destroy_scheduler(), ast_sip_initialize_distributor(), ast_sip_initialize_dns(), ast_sip_initialize_global_headers(), ast_sip_initialize_resolver(), ast_sip_initialize_scheduler(), ast_sip_initialize_system(), ast_sip_initialize_transport_events(), ast_sip_initialize_transport_management(), ast_sip_location_prune_boot_contacts(), ast_sip_register_service(), AST_TEST_REGISTER, ast_threadpool_create(), ast_threadpool_shutdown(), cli_commands, error(), load_pjsip(), LOG_ERROR, LOG_WARNING, NULL, options, pjsip_media_type_application_cpim_xpidf_xml, pjsip_media_type_application_json, pjsip_media_type_application_media_control_xml, pjsip_media_type_application_pidf_xml, pjsip_media_type_application_rlmi_xml, pjsip_media_type_application_sdp, pjsip_media_type_application_simple_message_summary, pjsip_media_type_application_xpidf_xml, pjsip_media_type_multipart_alternative, pjsip_media_type_multipart_mixed, pjsip_media_type_multipart_related, pjsip_media_type_text_plain, SERIALIZER_POOL_SIZE, sip_get_threadpool_options(), sip_serializer_pool, sip_thread_start(), sip_threadpool, supplement_module, and unload_pjsip().
|
static |
Definition at line 3842 of file res_pjsip.c.
References ast_log, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_pjproject_caching_pool_init(), ast_pjsip_endpoint, ast_verb, caching_pool, error(), host_ip_ipv4, host_ip_ipv4_string, host_ip_ipv6, host_ip_ipv6_string, LOG_ERROR, memory_pool, monitor_continue, monitor_thread, monitor_thread_exec(), NULL, remove_request_headers(), and status.
Referenced by load_module().
|
static |
Definition at line 2266 of file res_pjsip.c.
References ast_pjsip_endpoint, monitor_continue, and NULL.
Referenced by load_pjsip().
void never_called_res_pjsip | ( | void | ) |
Definition at line 3903 of file res_pjsip.c.
References NULL.
|
static |
Definition at line 2409 of file res_pjsip.c.
References ast_sip_get_pjsip_endpoint().
Referenced by ast_sip_send_stateful_response().
|
static |
Definition at line 102 of file res_pjsip.c.
References ast_debug, ast_log, ast_pjsip_endpoint, and LOG_ERROR.
Referenced by ast_sip_register_service().
|
static |
Definition at line 3790 of file res_pjsip.c.
References ast_res_pjsip_init_options_handling(), ast_res_pjsip_reload_configuration(), and ast_sip_initialize_dns().
Referenced by reload_module().
|
static |
Definition at line 4058 of file