Asterisk - The Open Source Telephony Project GIT-master-f36a736
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
res_pjsip.h File Reference
#include <pjsip.h>
#include <pjsip_simple.h>
#include <pjsip/sip_transaction.h>
#include <pj/timer.h>
#include <pjlib.h>
#include "asterisk/stringfields.h"
#include "asterisk/netsock2.h"
#include "asterisk/linkedlists.h"
#include "asterisk/channel.h"
#include "asterisk/sorcery.h"
#include "asterisk/dnsmgr.h"
#include "asterisk/endpoints.h"
#include "asterisk/udptl.h"
#include "asterisk/rtp_engine.h"
#include "asterisk/vector.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/stream.h"
Include dependency graph for res_pjsip.h:

Go to the source code of this file.

Data Structures

struct  ast_sip_ami
 AMI variable container. More...
 
struct  ast_sip_aor
 A SIP address of record. More...
 
struct  ast_sip_auth
 
struct  ast_sip_auth_objects_vector
 
struct  ast_sip_auth_vector
 
struct  ast_sip_authenticator
 An interchangeable way of handling digest authentication for SIP. More...
 
struct  ast_sip_body
 SIP body description. More...
 
struct  ast_sip_contact
 Contact associated with an address of record. More...
 
struct  ast_sip_contact_status
 A contact's status. More...
 
struct  ast_sip_contact_wrapper
 A wrapper for contact that adds the aor_id and a consistent contact id. Used by ast_sip_for_each_contact. More...
 
struct  ast_sip_direct_media_configuration
 Direct media options for SIP endpoints. More...
 
struct  ast_sip_domain_alias
 
struct  ast_sip_endpoint
 An entity with which Asterisk communicates. More...
 
struct  ast_sip_endpoint_extensions
 Endpoint configuration for SIP extensions. More...
 
struct  ast_sip_endpoint_formatter
 An entity responsible formatting endpoint information. More...
 
struct  ast_sip_endpoint_id_configuration
 Party identification options for endpoints. More...
 
struct  ast_sip_endpoint_identifier
 An entity responsible for identifying the source of a SIP message. More...
 
struct  ast_sip_endpoint_info_configuration
 Endpoint configuration options for INFO packages. More...
 
struct  ast_sip_endpoint_media_configuration
 Media configuration for SIP endpoints. More...
 
struct  ast_sip_endpoint_nat_configuration
 NAT configuration options for endpoints. More...
 
struct  ast_sip_endpoint_pickup_configuration
 Call pickup configuration options for endpoints. More...
 
struct  ast_sip_endpoint_subscription_configuration
 Endpoint subscription configuration. More...
 
struct  ast_sip_identify_by_vector
 
struct  ast_sip_info_recording_configuration
 Configuration for one-touch INFO recording. More...
 
struct  ast_sip_media_rtp_configuration
 RTP configuration for SIP endpoints. More...
 
struct  ast_sip_mwi_configuration
 Endpoint configuration for unsolicited MWI. More...
 
struct  ast_sip_nat_hook
 Structure for SIP nat hook information. More...
 
struct  ast_sip_outbound_authenticator
 an interchangeable way of responding to authentication challenges More...
 
struct  ast_sip_request_transport_details
 Structure which contains information about a transport. More...
 
struct  ast_sip_security_mechanism
 Structure representing a security mechanism as defined in RFC 3329. More...
 
struct  ast_sip_security_mechanism_vector
 
struct  ast_sip_service_route_vector
 
struct  ast_sip_supplement
 A supplement to SIP message processing. More...
 
struct  ast_sip_t38_configuration
 
struct  ast_sip_timer_options
 Session timers options. More...
 
struct  ast_sip_tpmgr_state_callback
 
struct  ast_sip_transport
 Transport to bind to. More...
 
struct  ast_sip_transport_state
 Structure for SIP transport information. More...
 

Macros

#define AST_SIP_AUTH_MAX_REALM_LENGTH   255 /* From the auth/realm realtime column size */
 
#define ast_sip_call_codec_pref_test(__param, __codec_pref)   (!!(ast_test_flag( &__param, AST_SIP_CALL_CODEC_PREF_ ## __codec_pref )))
 Returns true if the preference is set in the parameter. More...
 
#define ast_sip_cleanup_auth_objects_vector(auth_objects)   AST_VECTOR_RESET(auth_objects, ao2_cleanup)
 Clean up retrieved auth objects in vector. More...
 
#define AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR(_transport, _dest)    pj_sockaddr_print(&_transport->key.rem_addr, _dest, sizeof(_dest), 1);
 Fill a buffer with a pjsip transport's remote ip address and port. More...
 
#define ast_sip_mod_data_get(mod_data, id, key)    ast_sip_dict_get(mod_data[id], key)
 Using the dictionary stored in mod_data array at a given id, retrieve the value associated with the given key. More...
 
#define ast_sip_mod_data_set(pool, mod_data, id, key, val)    mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)
 Utilizing a mod_data array for a given id, set the value associated with the given key. More...
 
#define ast_sip_transport_is_local(transport_state, addr)    (transport_state->localnet && ast_apply_ha(transport_state->localnet, addr) != AST_SENSE_ALLOW)
 
#define ast_sip_transport_is_nonlocal(transport_state, addr)    (!transport_state->localnet || ast_apply_ha(transport_state->localnet, addr) == AST_SENSE_ALLOW)
 
#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str)
 Truncate the URI user field options string if enabled. More...
 
#define AST_SIP_X_AST_TXP   "x-ast-txp"
 
#define AST_SIP_X_AST_TXP_LEN   9
 
#define COLON_PORT_STRLEN   6
 
#define IP6ADDR_COLON_PORT_BUFLEN   (PJ_INET6_ADDRSTRLEN + COLON_PORT_STRLEN)
 
#define MAX_RX_CHALLENGES   10
 
#define PJSIP_EXPIRES_NOT_SPECIFIED   ((pj_uint32_t)-1)
 
#define PJSIP_MINVERSION(m, n, p)   (((m << 24) | (n << 16) | (p << 8)) >= PJ_VERSION_NUM)
 
#define PJSTR_PRINTF_SPEC   "%.*s"
 
#define PJSTR_PRINTF_VAR(_v)   ((int)(_v).slen), ((_v).ptr)
 
#define SIP_SORCERY_AUTH_TYPE   "auth"
 
#define SIP_SORCERY_DOMAIN_ALIAS_TYPE   "domain_alias"
 
#define SIP_TLS_MAX_CIPHERS   64
 Maximum number of ciphers supported for a TLS transport. More...
 

Typedefs

typedef int(* ast_sip_dialog_outbound_auth_cb) (pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data)
 Callback called when an outbound request with authentication credentials is to be sent in dialog. More...
 
typedef int(* ast_sip_task) (void *user_data)
 
typedef int(* ast_transport_monitor_data_matcher) (void *a, void *b)
 Transport shutdown monitor data matcher. More...
 
typedef void(* ast_transport_monitor_shutdown_cb) (void *data)
 Transport shutdown monitor callback. More...
 

Enumerations

enum  ast_sip_100rel_mode { AST_SIP_100REL_UNSUPPORTED = 0 , AST_SIP_100REL_SUPPORTED , AST_SIP_100REL_PEER_SUPPORTED , AST_SIP_100REL_REQUIRED }
 100rel modes for SIP endpoints More...
 
enum  ast_sip_auth_type { AST_SIP_AUTH_TYPE_USER_PASS , AST_SIP_AUTH_TYPE_MD5 , AST_SIP_AUTH_TYPE_GOOGLE_OAUTH , AST_SIP_AUTH_TYPE_ARTIFICIAL }
 Methods of storing SIP digest authentication credentials. More...
 
enum  ast_sip_call_codec_pref {
  AST_SIP_CALL_CODEC_PREF_INTERSECT = 1 << 0 , AST_SIP_CALL_CODEC_PREF_UNION = 1 << 1 , AST_SIP_CALL_CODEC_PREF_ALL = 1 << 2 , AST_SIP_CALL_CODEC_PREF_FIRST = 1 << 3 ,
  AST_SIP_CALL_CODEC_PREF_LOCAL = 1 << 4 , AST_SIP_CALL_CODEC_PREF_REMOTE = 1 << 5
}
 Incoming/Outgoing call offer/answer joint codec preference. More...
 
enum  ast_sip_check_auth_result { AST_SIP_AUTHENTICATION_CHALLENGE , AST_SIP_AUTHENTICATION_SUCCESS , AST_SIP_AUTHENTICATION_FAILED , AST_SIP_AUTHENTICATION_ERROR }
 Possible returns from ast_sip_check_authentication. More...
 
enum  ast_sip_contact_filter { AST_SIP_CONTACT_FILTER_DEFAULT = 0 , AST_SIP_CONTACT_FILTER_REACHABLE = (1 << 0) }
 Contact retrieval filtering flags. More...
 
enum  ast_sip_contact_status_type {
  UNAVAILABLE , AVAILABLE , UNKNOWN , CREATED ,
  REMOVED
}
 Status type for a contact. More...
 
enum  ast_sip_direct_media_glare_mitigation { AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE , AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_OUTGOING , AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING }
 
enum  ast_sip_dtmf_mode {
  AST_SIP_DTMF_NONE , AST_SIP_DTMF_RFC_4733 , AST_SIP_DTMF_INBAND , AST_SIP_DTMF_INFO ,
  AST_SIP_DTMF_AUTO , AST_SIP_DTMF_AUTO_INFO
}
 DTMF modes for SIP endpoints. More...
 
enum  ast_sip_endpoint_identifier_type {
  AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME = (1 << 0) , AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME = (1 << 1) , AST_SIP_ENDPOINT_IDENTIFY_BY_IP = (1 << 2) , AST_SIP_ENDPOINT_IDENTIFY_BY_HEADER = (1 << 3) ,
  AST_SIP_ENDPOINT_IDENTIFY_BY_REQUEST_URI = (1 << 4)
}
 Different methods by which incoming requests can be matched to endpoints. More...
 
enum  ast_sip_scheduler_task_flags {
  AST_SIP_SCHED_TASK_DEFAULTS = (0 << 0) , AST_SIP_SCHED_TASK_FIXED = (0 << 0) , AST_SIP_SCHED_TASK_VARIABLE = (1 << 0) , AST_SIP_SCHED_TASK_ONESHOT = (1 << 6) ,
  AST_SIP_SCHED_TASK_DATA_NOT_AO2 = (0 << 1) , AST_SIP_SCHED_TASK_DATA_AO2 = (1 << 1) , AST_SIP_SCHED_TASK_DATA_NO_CLEANUP = (0 << 3) , AST_SIP_SCHED_TASK_DATA_FREE = ( 1 << 3 ) ,
  AST_SIP_SCHED_TASK_PERIODIC = (0 << 4) , AST_SIP_SCHED_TASK_DELAY = (1 << 4) , AST_SIP_SCHED_TASK_TRACK = (1 << 5)
}
 Task flags for the res_pjsip scheduler. More...
 
enum  ast_sip_security_mechanism_type { AST_SIP_SECURITY_MECH_NONE = 0 , AST_SIP_SECURITY_MECH_MSRP_TLS , AST_SIP_SECURITY_MECH_SDES_SRTP , AST_SIP_SECURITY_MECH_DTLS_SRTP }
 The security mechanism type. More...
 
enum  ast_sip_security_negotiation { AST_SIP_SECURITY_NEG_NONE = 0 , AST_SIP_SECURITY_NEG_MEDIASEC }
 The kind of security negotiation. More...
 
enum  ast_sip_session_media_encryption { AST_SIP_MEDIA_TRANSPORT_INVALID = 0 , AST_SIP_MEDIA_ENCRYPT_NONE , AST_SIP_MEDIA_ENCRYPT_SDES , AST_SIP_MEDIA_ENCRYPT_DTLS }
 
enum  ast_sip_session_redirect { AST_SIP_REDIRECT_USER = 0 , AST_SIP_REDIRECT_URI_CORE , AST_SIP_REDIRECT_URI_PJSIP }
 
enum  ast_sip_session_refresh_method { AST_SIP_SESSION_REFRESH_METHOD_INVITE , AST_SIP_SESSION_REFRESH_METHOD_UPDATE }
 
enum  ast_sip_supplement_priority { AST_SIP_SUPPLEMENT_PRIORITY_FIRST = 0 , AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL = 1000000 , AST_SIP_SUPPLEMENT_PRIORITY_LAST = INT_MAX }
 
enum  ast_transport_monitor_reg { AST_TRANSPORT_MONITOR_REG_SUCCESS , AST_TRANSPORT_MONITOR_REG_REPLACED , AST_TRANSPORT_MONITOR_REG_NOT_FOUND , AST_TRANSPORT_MONITOR_REG_FAILED }
 

Functions

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_sip_endpointast_pjsip_rdata_get_endpoint (pjsip_rx_data *rdata)
 Get the looked-up endpoint on an out-of dialog request or response. More...
 
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_global_request_header (const char *name, const char *value, int replace)
 
int ast_sip_add_global_response_header (const char *name, const char *value, int replace)
 
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...
 
int ast_sip_add_security_headers (struct ast_sip_security_mechanism_vector *security_mechanisms, const char *header_name, int add_qval, pjsip_tx_data *tdata)
 Add security headers to transmission data. 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_auth_type_to_str (enum ast_sip_auth_type type)
 Converts the given auth type to a string. More...
 
void ast_sip_auth_vector_destroy (struct ast_sip_auth_vector *vector)
 Free contents of an auth vector. More...
 
int ast_sip_auth_vector_init (struct ast_sip_auth_vector *vector, const char *auth_names)
 Initialize an auth vector with the configured values. More...
 
int ast_sip_auths_to_str (const struct ast_sip_auth_vector *auths, char **buf)
 Converts an auths array to a string of comma separated values. 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...
 
void ast_sip_cleanup_auths (struct ast_sip_auth *auths[], size_t num_auths)
 Clean up retrieved auth structures from memory. More...
 
int ast_sip_contact_to_str (void *object, void *arg, int flags)
 Handler used to convert a contact to a string. More...
 
struct ast_strast_sip_create_ami_event (const char *event, struct ast_sip_ami *ami)
 Creates a string to store AMI event data in. More...
 
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. 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_uri)
 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 *tdata, 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 **p_tdata)
 General purpose method for creating a SIP response. More...
 
struct ast_taskprocessorast_sip_create_serializer (const char *name)
 Create a new serializer for SIP tasks. More...
 
struct ast_taskprocessorast_sip_create_serializer_group (const char *name, struct ast_serializer_shutdown_group *shutdown_group)
 Create a new serializer for SIP tasks. More...
 
struct ast_sip_endpointast_sip_default_outbound_endpoint (void)
 Retrieve the default outbound endpoint. More...
 
struct ast_sip_endpointast_sip_dialog_get_endpoint (pjsip_dialog *dlg)
 Get the endpoint associated with this dialog. More...
 
void ast_sip_dialog_set_endpoint (pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint)
 Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup. More...
 
void ast_sip_dialog_set_serializer (pjsip_dialog *dlg, struct ast_taskprocessor *serializer)
 Set a serializer on a SIP dialog so requests and responses are automatically serialized. More...
 
int ast_sip_dialog_setup_outbound_authentication (pjsip_dialog *dlg, const struct ast_sip_endpoint *endpoint, ast_sip_dialog_outbound_auth_cb cb, void *user_data)
 Set up outbound authentication on a SIP dialog. 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...
 
void * ast_sip_endpoint_alloc (const char *name)
 Allocate a new SIP endpoint. 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_stateast_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_for_each_aor (const char *aors, ao2_callback_fn on_aor, void *arg)
 For every aor in the comma separated aors string call the given 'on_aor' handler. More...
 
int ast_sip_for_each_auth (const struct ast_sip_auth_vector *array, ao2_callback_fn on_auth, void *arg)
 For every auth in the array call the given 'on_auth' handler. More...
 
int ast_sip_for_each_channel (const struct ast_sip_endpoint *endpoint, ao2_callback_fn on_channel_snapshot, void *arg)
 For every channel snapshot on an endpoint all the given 'on_channel_snapshot' handler. More...
 
int ast_sip_for_each_channel_snapshot (const struct ast_endpoint_snapshot *endpoint_snapshot, ao2_callback_fn on_channel_snapshot, void *arg)
 For every channel snapshot on an endpoint snapshot call the given 'on_channel_snapshot' handler. More...
 
int ast_sip_for_each_contact (const struct ast_sip_aor *aor, ao2_callback_fn on_contact, void *arg)
 For every contact on an AOR call the given 'on_contact' handler. More...
 
int ast_sip_format_auths_ami (const struct ast_sip_auth_vector *auths, struct ast_sip_ami *ami)
 Format auth details for AMI. More...
 
int ast_sip_format_contact_ami (void *obj, void *arg, int flags)
 Formats the contact and sends over AMI. 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...
 
unsigned int ast_sip_get_all_codecs_on_empty_reinvite (void)
 Retrieve the system setting 'all_codecs_on_empty_reinvite'. More...
 
unsigned int ast_sip_get_allow_sending_180_after_183 (void)
 Retrieve the global setting 'allow_sending_180_after_183'. More...
 
struct ast_sip_authast_sip_get_artificial_auth (void)
 Retrieves a reference to the artificial auth. More...
 
struct ast_sip_endpointast_sip_get_artificial_endpoint (void)
 Retrieves a reference to the artificial endpoint. More...
 
unsigned int ast_sip_get_contact_expiration_check_interval (void)
 Retrieve the system contact expiration check interval setting. More...
 
const char * ast_sip_get_contact_short_status_label (const enum ast_sip_contact_status_type status)
 
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_contact_statusast_sip_get_contact_status (const struct ast_sip_contact *contact)
 Retrieve the current status for a contact. More...
 
const char * ast_sip_get_contact_status_label (const enum ast_sip_contact_status_type status)
 translate ast_sip_contact_status_type to character string. More...
 
char * ast_sip_get_debug (void)
 Retrieve the system debug setting (yes|no|host). More...
 
void ast_sip_get_default_from_user (char *from_user, size_t size)
 Retrieve the global default from user. More...
 
void ast_sip_get_default_realm (char *realm, size_t size)
 Retrieve the global default realm. More...
 
char * ast_sip_get_default_voicemail_extension (void)
 Retrieve the default voicemail extension. More...
 
const char * ast_sip_get_device_state (const struct ast_sip_endpoint *endpoint)
 Retrieve the device state for an endpoint. More...
 
unsigned int ast_sip_get_disable_multi_domain (void)
 Retrieve the system setting 'disable multi domain'. More...
 
struct ast_taskprocessorast_sip_get_distributor_serializer (pjsip_rx_data *rdata)
 Determine the distributor serializer for the SIP message. More...
 
struct ast_sip_endpointast_sip_get_endpoint (const char *to, int get_default_outbound, char **uri)
 Retrieves an endpoint and URI from the "to" string. More...
 
char * ast_sip_get_endpoint_identifier_order (void)
 Retrieve the global endpoint_identifier_order setting. More...
 
struct ast_endpoint_snapshotast_sip_get_endpoint_snapshot (const struct ast_sip_endpoint *endpoint)
 Retrieve the endpoint snapshot for an endpoint. More...
 
struct ao2_containerast_sip_get_endpoints (void)
 Retrieve any endpoints available to sorcery. 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...
 
unsigned int ast_sip_get_ignore_uri_user_options (void)
 Retrieve the global setting 'ignore_uri_user_options'. More...
 
unsigned int ast_sip_get_keep_alive_interval (void)
 Retrieve the system keep alive interval setting. More...
 
unsigned int ast_sip_get_max_initial_qualify_time (void)
 Retrieve the system max initial qualify time. More...
 
unsigned int ast_sip_get_mwi_disable_initial_unsolicited (void)
 Retrieve the global setting 'disable sending unsolicited mwi on startup'. More...
 
unsigned int ast_sip_get_mwi_tps_queue_high (void)
 Retrieve the global MWI taskprocessor high water alert trigger level. More...
 
int ast_sip_get_mwi_tps_queue_low (void)
 Retrieve the global MWI taskprocessor low water clear alert level. More...
 
unsigned int ast_sip_get_norefersub (void)
 Retrieve the global setting 'norefersub'. More...
 
pjsip_endpoint * ast_sip_get_pjsip_endpoint (void)
 Get a pointer to the PJSIP endpoint. More...
 
char * ast_sip_get_regcontext (void)
 Retrieve the global regcontext setting. More...
 
unsigned int ast_sip_get_send_contact_status_on_update_registration (void)
 Retrieve the global setting 'send_contact_status_on_update_registration'. More...
 
struct ast_sorceryast_sip_get_sorcery (void)
 Get a pointer to the SIP sorcery structure. 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...
 
struct ast_sip_transport_stateast_sip_get_transport_state (const char *transport_id)
 Retrieve transport state. More...
 
struct ao2_containerast_sip_get_transport_states (void)
 Retrieves all transport states. More...
 
void ast_sip_get_unidentified_request_thresholds (unsigned int *count, unsigned int *period, unsigned int *prune_interval)
 Retrieve the unidentified request security event thresholds. More...
 
unsigned int ast_sip_get_use_callerid_contact (void)
 Retrieve the global setting 'use_callerid_contact'. More...
 
const int ast_sip_hangup_sip2cause (int cause)
 Convert SIP hangup causes to Asterisk hangup causes. More...
 
void ast_sip_header_to_security_mechanism (const pjsip_generic_string_hdr *hdr, struct ast_sip_security_mechanism_vector *security_mechanisms)
 Append to security mechanism vector from SIP header. More...
 
struct ast_sip_endpointast_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,...) attribute_sentinel
 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...
 
int ast_sip_location_add_contact (struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, struct ast_sip_endpoint *endpoint)
 Add a new contact to an AOR. More...
 
int ast_sip_location_add_contact_nolock (struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, struct ast_sip_endpoint *endpoint)
 Add a new contact to an AOR without locking the AOR. More...
 
struct ast_sip_contactast_sip_location_create_contact (struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, int prune_on_boot, struct ast_sip_endpoint *endpoint)
 Create a new contact for an AOR without locking the AOR. More...
 
int ast_sip_location_delete_contact (struct ast_sip_contact *contact)
 Delete a contact. More...
 
void ast_sip_location_prune_boot_contacts (void)
 Prune the prune_on_boot contacts. More...
 
struct ast_sip_aorast_sip_location_retrieve_aor (const char *aor_name)
 Retrieve a named AOR. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts (const struct ast_sip_aor *aor)
 Retrieve all contacts currently available for an AOR. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts_filtered (const struct ast_sip_aor *aor, unsigned int flags)
 Retrieve all contacts currently available for an AOR and filter based on flags. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts_nolock (const struct ast_sip_aor *aor)
 Retrieve all contacts currently available for an AOR without locking the AOR. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts_nolock_filtered (const struct ast_sip_aor *aor, unsigned int flags)
 Retrieve all contacts currently available for an AOR without locking the AOR and filter based on flags. More...
 
struct ast_sip_contactast_sip_location_retrieve_contact (const char *contact_name)
 Retrieve a named contact. More...
 
void ast_sip_location_retrieve_contact_and_aor_from_list (const char *aor_list, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
 Retrieve the first bound contact AND the AOR chosen from a list of AORs. More...
 
void ast_sip_location_retrieve_contact_and_aor_from_list_filtered (const char *aor_list, unsigned int flags, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
 Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags. More...
 
struct ast_sip_contactast_sip_location_retrieve_contact_from_aor_list (const char *aor_list)
 Retrieve the first bound contact from a list of AORs. More...
 
struct ao2_containerast_sip_location_retrieve_contacts_from_aor_list (const char *aor_list)
 Retrieve all contacts from a list of AORs. More...
 
struct ast_sip_contactast_sip_location_retrieve_first_aor_contact (const struct ast_sip_aor *aor)
 Retrieve the first bound contact for an AOR. More...
 
struct ast_sip_contactast_sip_location_retrieve_first_aor_contact_filtered (const struct ast_sip_aor *aor, unsigned int flags)
 Retrieve the first bound contact for an AOR and filter based on flags. More...
 
int ast_sip_location_update_contact (struct ast_sip_contact *contact)
 Update a contact. More...
 
void ast_sip_message_apply_transport (const char *transport_name, pjsip_tx_data *tdata)
 Apply the configuration for a transport to an outgoing message. 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...
 
void ast_sip_persistent_endpoint_publish_contact_state (const char *endpoint_name, const struct ast_sip_contact_status *contact_status)
 Publish the change of state for a contact. More...
 
int ast_sip_persistent_endpoint_update_state (const char *endpoint_name, enum ast_endpoint_state state)
 Change state of a persistent endpoint. 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...
 
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 *outbound_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...
 
void ast_sip_remove_headers_by_name_and_value (pjsip_msg *msg, const pj_str_t *hdr_name, const char *value)
 Removes all headers of a specific name and value from a pjsip_msg. More...
 
void ast_sip_report_auth_challenge_sent (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
 Send a security event notification for when an authentication challenge is sent. More...
 
void ast_sip_report_auth_failed_challenge_response (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Send a security event notification for when a challenge response has failed. More...
 
void ast_sip_report_auth_success (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Send a security event notification for when authentication succeeds. More...
 
void ast_sip_report_failed_acl (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *name)
 Send a security event notification for when an ACL check fails. More...
 
void ast_sip_report_invalid_endpoint (const char *name, pjsip_rx_data *rdata)
 Send a security event notification for when an invalid endpoint is requested. More...
 
void ast_sip_report_mem_limit (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Send a security event notification for when a memory limit is hit. More...
 
void ast_sip_report_req_no_support (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *req_type)
 Send a security event notification for when a request is not supported. 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_retrieve_auths (const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out)
 Retrieve relevant SIP auth structures from sorcery. More...
 
int ast_sip_retrieve_auths_vector (const struct ast_sip_auth_vector *auth_ids, struct ast_sip_auth_objects_vector *auth_objects)
 Retrieve relevant SIP auth structures from sorcery as a vector. 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_sched_is_task_running (struct ast_sip_sched_task *schtd)
 Checks if the task is currently running. More...
 
int ast_sip_sched_is_task_running_by_name (const char *name)
 Checks if the task is currently running. More...
 
int ast_sip_sched_task_cancel (struct ast_sip_sched_task *schtd)
 Cancels the next invocation of a task. More...
 
int ast_sip_sched_task_cancel_by_name (const char *name)
 Cancels the next invocation of a task by name. More...
 
int ast_sip_sched_task_get_name (struct ast_sip_sched_task *schtd, char *name, size_t maxlen)
 Gets the task name. More...
 
int ast_sip_sched_task_get_next_run (struct ast_sip_sched_task *schtd)
 Gets the number of milliseconds until the next invocation. More...
 
int ast_sip_sched_task_get_next_run_by_name (const char *name)
 Gets the number of milliseconds until the next invocation. More...
 
int ast_sip_sched_task_get_times (struct ast_sip_sched_task *schtd, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end)
 Gets the last start and end times of the task. More...
 
int ast_sip_sched_task_get_times2 (struct ast_sip_sched_task *schtd, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end, int *interval, int *time_left, struct timeval *next_start)
 Gets the queued, last start, last_end, time left, interval, next run. More...
 
int ast_sip_sched_task_get_times_by_name (const char *name, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end)
 Gets the last start and end times of the task by name. More...
 
int ast_sip_sched_task_get_times_by_name2 (const char *name, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end, int *interval, int *time_left, struct timeval *next_start)
 Gets the queued, last start, last_end, time left, interval, next run by task name. More...
 
struct ast_sip_sched_taskast_sip_schedule_task (struct ast_taskprocessor *serializer, int interval, ast_sip_task sip_task, const char *name, void *task_data, enum ast_sip_scheduler_task_flags flags)
 Schedule a task to run in the res_pjsip thread pool. More...
 
int ast_sip_security_mechanism_vector_init (struct ast_sip_security_mechanism_vector *security_mechanism, const char *value)
 Initialize security mechanism vector from string of security mechanisms. More...
 
int ast_sip_security_mechanisms_to_str (const struct ast_sip_security_mechanism_vector *security_mechanisms, int add_qvalue, char **buf)
 Writes the security mechanisms of an endpoint into a buffer as a string and returns the buffer. More...
 
void ast_sip_security_mechanisms_vector_copy (struct ast_sip_security_mechanism_vector *dst, const struct ast_sip_security_mechanism_vector *src)
 Duplicate a security mechanism. More...
 
void ast_sip_security_mechanisms_vector_destroy (struct ast_sip_security_mechanism_vector *security_mechanisms)
 Free contents of a security mechanism vector. 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...
 
struct ast_sip_service_route_vectorast_sip_service_route_vector_alloc (void)
 Allocate a vector of service routes. More...
 
void ast_sip_service_route_vector_destroy (struct ast_sip_service_route_vector *service_routes)
 Destroy a vector of service routes. 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_security_negotiation (enum ast_sip_security_negotiation *security_negotiation, const char *val)
 Set the security negotiation based on a given string. 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_sorcery_object_to_ami (const void *obj, struct ast_str **buf)
 Converts a sorcery object to a string of object properties. 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_str_to_security_mechanism (struct ast_sip_security_mechanism **security_mechanism, const char *value)
 Allocate a security mechanism from a string. More...
 
int ast_sip_thread_is_servant (void)
 Determine if the current thread is a SIP servant thread. More...
 
struct ast_threadpoolast_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...
 
enum ast_transport_monitor_reg ast_sip_transport_monitor_register (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data)
 Register a reliable transport shutdown monitor callback. More...
 
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_key (const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *ao2_data)
 Register a reliable transport shutdown monitor callback. More...
 
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches)
 Register a reliable transport shutdown monitor callback replacing any duplicate. More...
 
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace_key (const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches)
 Register a reliable transport shutdown monitor callback replacing any duplicate. More...
 
void ast_sip_transport_monitor_unregister (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
 Unregister a reliable transport shutdown monitor. More...
 
void ast_sip_transport_monitor_unregister_all (ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
 Unregister a transport shutdown monitor from all reliable transports. More...
 
void ast_sip_transport_monitor_unregister_key (const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
 Unregister a reliable transport shutdown monitor. More...
 
void ast_sip_transport_state_register (struct ast_sip_tpmgr_state_callback *element)
 Register a transport state notification callback element. More...
 
int ast_sip_transport_state_set_preferred_identity (const char *transport_name, const char *identity)
 Sets the P-Preferred-Identity on a child transport. More...
 
int ast_sip_transport_state_set_service_routes (const char *transport_name, struct ast_sip_service_route_vector *service_routes)
 Sets the service routes on a child transport. More...
 
int ast_sip_transport_state_set_transport (const char *transport_name, pjsip_transport *transport)
 Sets the PJSIP transport on a child transport. More...
 
void ast_sip_transport_state_unregister (struct ast_sip_tpmgr_state_callback *element)
 Unregister a transport state notification callback element. 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...
 

Variables

static const pj_str_t AST_PJ_STR_EMPTY = { "", 0 }
 
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
 

Macro Definition Documentation

◆ AST_SIP_AUTH_MAX_REALM_LENGTH

#define AST_SIP_AUTH_MAX_REALM_LENGTH   255 /* From the auth/realm realtime column size */

Definition at line 74 of file res_pjsip.h.

◆ ast_sip_call_codec_pref_test

#define ast_sip_call_codec_pref_test (   __param,
  __codec_pref 
)    (!!(ast_test_flag( &__param, AST_SIP_CALL_CODEC_PREF_ ## __codec_pref )))

Returns true if the preference is set in the parameter.

Since
18.0.0
Parameters
__paramA ast_flags struct with one or more of enum ast_sip_call_codec_pref set
__codec_prefThe last component of one of the enum values
Return values
1if the enum value is set
0if not

Definition at line 694 of file res_pjsip.h.

◆ ast_sip_cleanup_auth_objects_vector

#define ast_sip_cleanup_auth_objects_vector (   auth_objects)    AST_VECTOR_RESET(auth_objects, ao2_cleanup)

Clean up retrieved auth objects in vector.

Call this function once you have completed operating on auths retrieved from ast_sip_retrieve_auths_vector. All auth objects will have their reference counts decremented and the vector size will be reset to 0. You must still call AST_VECTOR_FREE() on the vector itself.

Parameters
auth_objectsA vector of auth structures to clean up

Definition at line 2847 of file res_pjsip.h.

◆ AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR

#define AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR (   _transport,
  _dest 
)     pj_sockaddr_print(&_transport->key.rem_addr, _dest, sizeof(_dest), 1);

Fill a buffer with a pjsip transport's remote ip address and port.

Parameters
_transportThe pjsip_transport to use
_destThe destination buffer of at least IP6ADDR_COLON_PORT_BUFLEN bytes

Definition at line 90 of file res_pjsip.h.

◆ ast_sip_mod_data_get

#define ast_sip_mod_data_get (   mod_data,
  id,
  key 
)     ast_sip_dict_get(mod_data[id], key)

Using the dictionary stored in mod_data array at a given id, retrieve the value associated with the given key.

Parameters
mod_dataa module data array
idthe mod_data array index
keythe key to find
Return values
thevalue associated with the key, NULL otherwise.

Definition at line 2947 of file res_pjsip.h.

◆ ast_sip_mod_data_set

#define ast_sip_mod_data_set (   pool,
  mod_data,
  id,
  key,
  val 
)     mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)

Utilizing a mod_data array for a given id, set the value associated with the given key.

For a given structure's mod_data array set the element indexed by id to be a dictionary containing the key/val pair.

Parameters
poola memory allocation pool
mod_dataa module data array
idthe mod_data array index
keythe key to find
valthe value to associate with a key

Definition at line 2979 of file res_pjsip.h.

◆ ast_sip_transport_is_local

#define ast_sip_transport_is_local (   transport_state,
  addr 
)     (transport_state->localnet && ast_apply_ha(transport_state->localnet, addr) != AST_SENSE_ALLOW)

Definition at line 212 of file res_pjsip.h.

◆ ast_sip_transport_is_nonlocal

#define ast_sip_transport_is_nonlocal (   transport_state,
  addr 
)     (!transport_state->localnet || ast_apply_ha(transport_state->localnet, addr) == AST_SENSE_ALLOW)

Definition at line 209 of file res_pjsip.h.

◆ AST_SIP_USER_OPTIONS_TRUNCATE_CHECK

#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK (   str)

Truncate the URI user field options string if enabled.

Since
13.12.0
Parameters
strURI user field string to truncate if enabled

We need to be able to handle URI's looking like "sip:1235557890;phone-context=national@x.x.x.x;user=phone"

Where the URI user field is: "1235557890;phone-context=national"

When truncated the string will become: "1235557890"

Definition at line 3350 of file res_pjsip.h.

◆ AST_SIP_X_AST_TXP

#define AST_SIP_X_AST_TXP   "x-ast-txp"

URI parameter for symmetric transport

Definition at line 1077 of file res_pjsip.h.

◆ AST_SIP_X_AST_TXP_LEN

#define AST_SIP_X_AST_TXP_LEN   9

Definition at line 1078 of file res_pjsip.h.

◆ COLON_PORT_STRLEN

#define COLON_PORT_STRLEN   6

Definition at line 77 of file res_pjsip.h.

◆ IP6ADDR_COLON_PORT_BUFLEN

#define IP6ADDR_COLON_PORT_BUFLEN   (PJ_INET6_ADDRSTRLEN + COLON_PORT_STRLEN)

Definition at line 82 of file res_pjsip.h.

◆ MAX_RX_CHALLENGES

#define MAX_RX_CHALLENGES   10

Maximum number of challenges before assuming that we are in a loop

Definition at line 107 of file res_pjsip.h.

◆ PJSIP_EXPIRES_NOT_SPECIFIED

#define PJSIP_EXPIRES_NOT_SPECIFIED   ((pj_uint32_t)-1)

Definition at line 68 of file res_pjsip.h.

◆ PJSIP_MINVERSION

#define PJSIP_MINVERSION (   m,
  n,
 
)    (((m << 24) | (n << 16) | (p << 8)) >= PJ_VERSION_NUM)

Definition at line 59 of file res_pjsip.h.

◆ PJSTR_PRINTF_SPEC

#define PJSTR_PRINTF_SPEC   "%.*s"

Definition at line 71 of file res_pjsip.h.

◆ PJSTR_PRINTF_VAR

#define PJSTR_PRINTF_VAR (   _v)    ((int)(_v).slen), ((_v).ptr)

Definition at line 72 of file res_pjsip.h.

◆ SIP_SORCERY_AUTH_TYPE

#define SIP_SORCERY_AUTH_TYPE   "auth"

Definition at line 574 of file res_pjsip.h.

◆ SIP_SORCERY_DOMAIN_ALIAS_TYPE

#define SIP_SORCERY_DOMAIN_ALIAS_TYPE   "domain_alias"

Definition at line 309 of file res_pjsip.h.

◆ SIP_TLS_MAX_CIPHERS

#define SIP_TLS_MAX_CIPHERS   64

Maximum number of ciphers supported for a TLS transport.

Definition at line 104 of file res_pjsip.h.

Typedef Documentation

◆ ast_sip_dialog_outbound_auth_cb

typedef int(* ast_sip_dialog_outbound_auth_cb) (pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data)

Callback called when an outbound request with authentication credentials is to be sent in dialog.

This callback will have the created request on it. The callback's purpose is to do any extra housekeeping that needs to be done as well as to send the request out.

This callback is only necessary if working with a PJSIP API that sits between the application and the dialog layer.

Parameters
dlgThe dialog to which the request belongs
tdataThe created request to be sent out
user_dataData supplied with the callback
Return values
0Success
-1Failure

Definition at line 1764 of file res_pjsip.h.

◆ ast_transport_monitor_data_matcher

typedef int(* ast_transport_monitor_data_matcher) (void *a, void *b)

Transport shutdown monitor data matcher.

Since
13.20.0
Parameters
aUser data to compare.
bUser data to compare.
Return values
1The data objects match
0The data objects don't match

Definition at line 3932 of file res_pjsip.h.

◆ ast_transport_monitor_shutdown_cb

typedef void(* ast_transport_monitor_shutdown_cb) (void *data)

Transport shutdown monitor callback.

Since
13.18.0
Parameters
dataUser data to know what to do when transport shuts down.
Note
The callback does not need to care that data is an ao2 object.

Definition at line 3920 of file res_pjsip.h.

Enumeration Type Documentation

◆ ast_sip_100rel_mode

100rel modes for SIP endpoints

Enumerator
AST_SIP_100REL_UNSUPPORTED 

Do not support 100rel. (no)

AST_SIP_100REL_SUPPORTED 

As UAC, indicate 100rel support in Supported header. (yes)

AST_SIP_100REL_PEER_SUPPORTED 

As UAS, send 1xx responses reliably, if the UAC indicated its support. Otherwise same as AST_SIP_100REL_SUPPORTED. (peer_supported)

AST_SIP_100REL_REQUIRED 

Require the use of 100rel. (required)

Definition at line 526 of file res_pjsip.h.

526 {
527 /*! Do not support 100rel. (no) */
529 /*! As UAC, indicate 100rel support in Supported header. (yes) */
531 /*! As UAS, send 1xx responses reliably, if the UAC indicated its support. Otherwise same as AST_SIP_100REL_SUPPORTED. (peer_supported) */
533 /*! Require the use of 100rel. (required) */
535};
@ AST_SIP_100REL_PEER_SUPPORTED
Definition: res_pjsip.h:532
@ AST_SIP_100REL_UNSUPPORTED
Definition: res_pjsip.h:528
@ AST_SIP_100REL_SUPPORTED
Definition: res_pjsip.h:530
@ AST_SIP_100REL_REQUIRED
Definition: res_pjsip.h:534

◆ ast_sip_auth_type

Methods of storing SIP digest authentication credentials.

Note that both methods result in MD5 digest authentication being used. The two methods simply alter how Asterisk determines the credentials for a SIP authentication

Enumerator
AST_SIP_AUTH_TYPE_USER_PASS 

Credentials stored as a username and password combination

AST_SIP_AUTH_TYPE_MD5 

Credentials stored as an MD5 sum

AST_SIP_AUTH_TYPE_GOOGLE_OAUTH 

Google Oauth

AST_SIP_AUTH_TYPE_ARTIFICIAL 

Credentials not stored this is a fake auth

Definition at line 563 of file res_pjsip.h.

563 {
564 /*! Credentials stored as a username and password combination */
566 /*! Credentials stored as an MD5 sum */
568 /*! Google Oauth */
570 /*! Credentials not stored this is a fake auth */
572};
@ AST_SIP_AUTH_TYPE_GOOGLE_OAUTH
Definition: res_pjsip.h:569
@ AST_SIP_AUTH_TYPE_ARTIFICIAL
Definition: res_pjsip.h:571
@ AST_SIP_AUTH_TYPE_MD5
Definition: res_pjsip.h:567
@ AST_SIP_AUTH_TYPE_USER_PASS
Definition: res_pjsip.h:565

◆ ast_sip_call_codec_pref

Incoming/Outgoing call offer/answer joint codec preference.

The default is INTERSECT ALL LOCAL.

Enumerator
AST_SIP_CALL_CODEC_PREF_INTERSECT 

Two bits for merge

Intersection of local and remote

AST_SIP_CALL_CODEC_PREF_UNION 

Union of local and remote

AST_SIP_CALL_CODEC_PREF_ALL 

Two bits for filter

No filter

AST_SIP_CALL_CODEC_PREF_FIRST 

Only the first

AST_SIP_CALL_CODEC_PREF_LOCAL 

Two bits for preference and sort

Prefer, and order by local values

AST_SIP_CALL_CODEC_PREF_REMOTE 

Prefer, and order by remote values

Definition at line 665 of file res_pjsip.h.

665 {
666 /*! Two bits for merge */
667 /*! Intersection of local and remote */
669 /*! Union of local and remote */
671
672 /*! Two bits for filter */
673 /*! No filter */
675 /*! Only the first */
677
678 /*! Two bits for preference and sort */
679 /*! Prefer, and order by local values */
681 /*! Prefer, and order by remote values */
683};
@ AST_SIP_CALL_CODEC_PREF_ALL
Definition: res_pjsip.h:674
@ AST_SIP_CALL_CODEC_PREF_LOCAL
Definition: res_pjsip.h:680
@ AST_SIP_CALL_CODEC_PREF_REMOTE
Definition: res_pjsip.h:682
@ AST_SIP_CALL_CODEC_PREF_UNION
Definition: res_pjsip.h:670
@ AST_SIP_CALL_CODEC_PREF_FIRST
Definition: res_pjsip.h:676
@ AST_SIP_CALL_CODEC_PREF_INTERSECT
Definition: res_pjsip.h:668

◆ ast_sip_check_auth_result

Possible returns from ast_sip_check_authentication.

Enumerator
AST_SIP_AUTHENTICATION_CHALLENGE 

Authentication needs to be challenged

AST_SIP_AUTHENTICATION_SUCCESS 

Authentication succeeded

AST_SIP_AUTHENTICATION_FAILED 

Authentication failed

AST_SIP_AUTHENTICATION_ERROR 

Authentication encountered some internal error

Definition at line 1228 of file res_pjsip.h.

1228 {
1229 /*! Authentication needs to be challenged */
1231 /*! Authentication succeeded */
1233 /*! Authentication failed */
1235 /*! Authentication encountered some internal error */
1237};
@ AST_SIP_AUTHENTICATION_CHALLENGE
Definition: res_pjsip.h:1230
@ AST_SIP_AUTHENTICATION_ERROR
Definition: res_pjsip.h:1236
@ AST_SIP_AUTHENTICATION_SUCCESS
Definition: res_pjsip.h:1232
@ AST_SIP_AUTHENTICATION_FAILED
Definition: res_pjsip.h:1234

◆ ast_sip_contact_filter

Contact retrieval filtering flags.

Enumerator
AST_SIP_CONTACT_FILTER_DEFAULT 

Default filter flags.

AST_SIP_CONTACT_FILTER_REACHABLE 

Return only reachable or unknown contacts.

Definition at line 1300 of file res_pjsip.h.

1300 {
1301 /*! \brief Default filter flags */
1303
1304 /*! \brief Return only reachable or unknown contacts */
1306};
@ AST_SIP_CONTACT_FILTER_REACHABLE
Return only reachable or unknown contacts.
Definition: res_pjsip.h:1305
@ AST_SIP_CONTACT_FILTER_DEFAULT
Default filter flags.
Definition: res_pjsip.h:1302

◆ ast_sip_contact_status_type

Status type for a contact.

Enumerator
UNAVAILABLE 

Frequency > 0, but no response from remote uri

AVAILABLE 

Frequency > 0, and got response from remote uri

UNKNOWN 

Default last status, and when a contact status object is not found

CREATED 

Frequency == 0, has a contact, but don't know status (non-qualified)

REMOVED 

Definition at line 431 of file res_pjsip.h.

431 {
432 /*! Frequency > 0, but no response from remote uri */
434 /*! Frequency > 0, and got response from remote uri */
435 AVAILABLE,
436 /*! Default last status, and when a contact status object is not found */
437 UNKNOWN,
438 /*! Frequency == 0, has a contact, but don't know status (non-qualified) */
439 CREATED,
440 REMOVED,
441};
@ AVAILABLE
Definition: res_pjsip.h:435
@ UNAVAILABLE
Definition: res_pjsip.h:433
@ REMOVED
Definition: res_pjsip.h:440
@ UNKNOWN
Definition: res_pjsip.h:437
@ CREATED
Definition: res_pjsip.h:439

◆ ast_sip_direct_media_glare_mitigation

Enumerator
AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE 

Take no special action to mitigate reinvite glare

AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_OUTGOING 

Do not send an initial direct media session refresh on outgoing call legs Subsequent session refreshes will be sent no matter the session direction

AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING 

Do not send an initial direct media session refresh on incoming call legs Subsequent session refreshes will be sent no matter the session direction

Definition at line 627 of file res_pjsip.h.

627 {
628 /*! Take no special action to mitigate reinvite glare */
630 /*! Do not send an initial direct media session refresh on outgoing call legs
631 * Subsequent session refreshes will be sent no matter the session direction
632 */
634 /*! Do not send an initial direct media session refresh on incoming call legs
635 * Subsequent session refreshes will be sent no matter the session direction
636 */
638};
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE
Definition: res_pjsip.h:629
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING
Definition: res_pjsip.h:637
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_OUTGOING
Definition: res_pjsip.h:633

◆ ast_sip_dtmf_mode

DTMF modes for SIP endpoints.

Enumerator
AST_SIP_DTMF_NONE 

No DTMF to be used

AST_SIP_DTMF_RFC_4733 

Use RFC 4733 events for DTMF

AST_SIP_DTMF_INBAND 

Use DTMF in the audio stream

AST_SIP_DTMF_INFO 

Use SIP INFO DTMF (blech)

AST_SIP_DTMF_AUTO 

Use SIP 4733 if supported by the other side or INBAND if not

AST_SIP_DTMF_AUTO_INFO 

Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not

Definition at line 540 of file res_pjsip.h.

540 {
541 /*! No DTMF to be used */
543 /* XXX Should this be 2833 instead? */
544 /*! Use RFC 4733 events for DTMF */
546 /*! Use DTMF in the audio stream */
548 /*! Use SIP INFO DTMF (blech) */
550 /*! Use SIP 4733 if supported by the other side or INBAND if not */
552 /*! Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not */
554};
@ AST_SIP_DTMF_NONE
Definition: res_pjsip.h:542
@ AST_SIP_DTMF_AUTO_INFO
Definition: res_pjsip.h:553
@ AST_SIP_DTMF_AUTO
Definition: res_pjsip.h:551
@ AST_SIP_DTMF_INBAND
Definition: res_pjsip.h:547
@ AST_SIP_DTMF_INFO
Definition: res_pjsip.h:549
@ AST_SIP_DTMF_RFC_4733
Definition: res_pjsip.h:545

◆ ast_sip_endpoint_identifier_type

Different methods by which incoming requests can be matched to endpoints.

Enumerator
AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME 

Identify based on user name in From header

AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME 

Identify based on user name in Auth header first, then From header

AST_SIP_ENDPOINT_IDENTIFY_BY_IP 

Identify based on source IP address

AST_SIP_ENDPOINT_IDENTIFY_BY_HEADER 

Identify based on arbitrary headers

AST_SIP_ENDPOINT_IDENTIFY_BY_REQUEST_URI 

Identify based on request uri

Definition at line 606 of file res_pjsip.h.

606 {
607 /*! Identify based on user name in From header */
609 /*! Identify based on user name in Auth header first, then From header */
611 /*! Identify based on source IP address */
613 /*! Identify based on arbitrary headers */
615 /*! Identify based on request uri */
617};
@ AST_SIP_ENDPOINT_IDENTIFY_BY_HEADER
Definition: res_pjsip.h:614
@ AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME
Definition: res_pjsip.h:608
@ AST_SIP_ENDPOINT_IDENTIFY_BY_REQUEST_URI
Definition: res_pjsip.h:616
@ AST_SIP_ENDPOINT_IDENTIFY_BY_IP
Definition: res_pjsip.h:612
@ AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME
Definition: res_pjsip.h:610

◆ ast_sip_security_mechanism_type

The security mechanism type.

Enumerator
AST_SIP_SECURITY_MECH_NONE 
AST_SIP_SECURITY_MECH_MSRP_TLS 
AST_SIP_SECURITY_MECH_SDES_SRTP 
AST_SIP_SECURITY_MECH_DTLS_SRTP 

Definition at line 361 of file res_pjsip.h.

361 {
363 /* Use msrp-tls as security mechanism */
365 /* Use sdes-srtp as security mechanism */
367 /* Use dtls-srtp as security mechanism */
369 /* Add RFC 3329 (sec-agree) mechanisms like tle, digest, ipsec-ike in the future */
370};
@ AST_SIP_SECURITY_MECH_DTLS_SRTP
Definition: res_pjsip.h:368
@ AST_SIP_SECURITY_MECH_SDES_SRTP
Definition: res_pjsip.h:366
@ AST_SIP_SECURITY_MECH_MSRP_TLS
Definition: res_pjsip.h:364
@ AST_SIP_SECURITY_MECH_NONE
Definition: res_pjsip.h:362

◆ ast_sip_security_negotiation

The kind of security negotiation.

Enumerator
AST_SIP_SECURITY_NEG_NONE 

No security mechanism negotiation

AST_SIP_SECURITY_NEG_MEDIASEC 

Use mediasec security mechanism negotiation

Definition at line 350 of file res_pjsip.h.

350 {
351 /*! No security mechanism negotiation */
353 /*! Use mediasec security mechanism negotiation */
355 /* Add RFC 3329 (sec-agree) mechanism negotiation in the future */
356};
@ AST_SIP_SECURITY_NEG_MEDIASEC
Definition: res_pjsip.h:354
@ AST_SIP_SECURITY_NEG_NONE
Definition: res_pjsip.h:352

◆ ast_sip_session_media_encryption

Enumerator
AST_SIP_MEDIA_TRANSPORT_INVALID 

Invalid media encryption configuration

AST_SIP_MEDIA_ENCRYPT_NONE 

Do not allow any encryption of session media

AST_SIP_MEDIA_ENCRYPT_SDES 

Offer SDES-encrypted session media

AST_SIP_MEDIA_ENCRYPT_DTLS 

Offer encrypted session media with datagram TLS key exchange

Definition at line 640 of file res_pjsip.h.

640 {
641 /*! Invalid media encryption configuration */
643 /*! Do not allow any encryption of session media */
645 /*! Offer SDES-encrypted session media */
647 /*! Offer encrypted session media with datagram TLS key exchange */
649};
@ AST_SIP_MEDIA_ENCRYPT_SDES
Definition: res_pjsip.h:646
@ AST_SIP_MEDIA_TRANSPORT_INVALID
Definition: res_pjsip.h:642
@ AST_SIP_MEDIA_ENCRYPT_NONE
Definition: res_pjsip.h:644
@ AST_SIP_MEDIA_ENCRYPT_DTLS
Definition: res_pjsip.h:648

◆ ast_sip_session_redirect

Enumerator
AST_SIP_REDIRECT_USER 

User portion of the target URI should be used as the target in the dialplan

AST_SIP_REDIRECT_URI_CORE 

Target URI should be used as the target in the dialplan

AST_SIP_REDIRECT_URI_PJSIP 

Target URI should be used as the target within chan_pjsip itself

Definition at line 651 of file res_pjsip.h.

651 {
652 /*! User portion of the target URI should be used as the target in the dialplan */
654 /*! Target URI should be used as the target in the dialplan */
656 /*! Target URI should be used as the target within chan_pjsip itself */
658};
@ AST_SIP_REDIRECT_URI_CORE
Definition: res_pjsip.h:655
@ AST_SIP_REDIRECT_URI_PJSIP
Definition: res_pjsip.h:657
@ AST_SIP_REDIRECT_USER
Definition: res_pjsip.h:653

◆ ast_sip_session_refresh_method

Enumerator
AST_SIP_SESSION_REFRESH_METHOD_INVITE 

Use reinvite to negotiate direct media

AST_SIP_SESSION_REFRESH_METHOD_UPDATE 

Use UPDATE to negotiate direct media

Definition at line 620 of file res_pjsip.h.

620 {
621 /*! Use reinvite to negotiate direct media */
623 /*! Use UPDATE to negotiate direct media */
625};
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
Definition: res_pjsip.h:624
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
Definition: res_pjsip.h:622

◆ ast_sip_supplement_priority

Enumerator
AST_SIP_SUPPLEMENT_PRIORITY_FIRST 

Top priority. Supplements with this priority are those that need to run before any others

AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL 

Channel creation priority. chan_pjsip creates a channel at this priority. If your supplement depends on being run before or after channel creation, then set your priority to be lower or higher than this value.

AST_SIP_SUPPLEMENT_PRIORITY_LAST 

Lowest priority. Supplements with this priority should be run after all other supplements

Definition at line 3178 of file res_pjsip.h.

3178 {
3179 /*! Top priority. Supplements with this priority are those that need to run before any others */
3181 /*! Channel creation priority.
3182 * chan_pjsip creates a channel at this priority. If your supplement depends on being run before
3183 * or after channel creation, then set your priority to be lower or higher than this value.
3184 */
3186 /*! Lowest priority. Supplements with this priority should be run after all other supplements */
3188};
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
Definition: res_pjsip.h:3185
@ AST_SIP_SUPPLEMENT_PRIORITY_FIRST
Definition: res_pjsip.h:3180
@ AST_SIP_SUPPLEMENT_PRIORITY_LAST
Definition: res_pjsip.h:3187

◆ ast_transport_monitor_reg

Enumerator
AST_TRANSPORT_MONITOR_REG_SUCCESS 

Successfully registered the transport monitor.

AST_TRANSPORT_MONITOR_REG_REPLACED 

Replaced the already existing transport monitor with new one.

AST_TRANSPORT_MONITOR_REG_NOT_FOUND 

Transport not found to monitor.

Note
Transport is either already shutdown or is not reliable.
AST_TRANSPORT_MONITOR_REG_FAILED 

Error while registering transport monitor.

Definition at line 3934 of file res_pjsip.h.

3934 {
3935 /*! \brief Successfully registered the transport monitor */
3937 /*! \brief Replaced the already existing transport monitor with new one. */
3939 /*!
3940 * \brief Transport not found to monitor.
3941 * \note Transport is either already shutdown or is not reliable.
3942 */
3944 /*! \brief Error while registering transport monitor. */
3946};
@ AST_TRANSPORT_MONITOR_REG_NOT_FOUND
Transport not found to monitor.
Definition: res_pjsip.h:3943
@ AST_TRANSPORT_MONITOR_REG_REPLACED
Replaced the already existing transport monitor with new one.
Definition: res_pjsip.h:3938
@ AST_TRANSPORT_MONITOR_REG_FAILED
Error while registering transport monitor.
Definition: res_pjsip.h:3945
@ AST_TRANSPORT_MONITOR_REG_SUCCESS
Successfully registered the transport monitor.
Definition: res_pjsip.h:3936

Function Documentation

◆ ast_copy_pj_str()

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.

Parameters
destThe destination buffer
srcThe pj_str_t to copy
sizeThe size of the destination buffer.

Definition at line 2201 of file res_pjsip.c.

2202{
2203 size_t chars_to_copy = MIN(size - 1, pj_strlen(src));
2204 memcpy(dest, pj_strbuf(src), chars_to_copy);
2205 dest[chars_to_copy] = '\0';
2206}
#define MIN(a, b)
Definition: utils.h:231

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().

◆ ast_copy_pj_str2()

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.

Note
Caller is responsible for freeing the allocated memory.
Parameters
[out]destThe destination buffer
srcThe pj_str_t to copy
Returns
Number of characters copied or negative value on error

Definition at line 2208 of file res_pjsip.c.

2209{
2210 int res = ast_asprintf(dest, "%.*s", (int)pj_strlen(src), pj_strbuf(src));
2211
2212 if (res < 0) {
2213 *dest = NULL;
2214 }
2215
2216 return res;
2217}
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267
#define NULL
Definition: resample.c:96

References ast_asprintf, and NULL.

◆ ast_pjsip_rdata_get_endpoint()

struct ast_sip_endpoint * ast_pjsip_rdata_get_endpoint ( pjsip_rx_data *  rdata)

Get the looked-up endpoint on an out-of dialog request or response.

The function may ONLY be called on out-of-dialog requests or responses. For in-dialog requests and responses, it is required that the user of the dialog has the looked-up endpoint stored locally.

This function should never return NULL if the message is out-of-dialog. It will always return NULL if the message is in-dialog.

This function will increase the reference count of the returned endpoint by one. Release your reference using the ao2_ref function when finished.

Parameters
rdataOut-of-dialog request or response
Returns
The looked up endpoint

Definition at line 966 of file pjsip_distributor.c.

967{
968 struct ast_sip_endpoint *endpoint = rdata->endpt_info.mod_data[endpoint_mod.id];
969 if (endpoint) {
970 ao2_ref(endpoint, +1);
971 }
972 return endpoint;
973}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
static pjsip_module endpoint_mod
An entity with which Asterisk communicates.
Definition: res_pjsip.h:958

References ao2_ref, and endpoint_mod.

Referenced by authenticate(), handle_new_invite_request(), nat_on_rx_message(), options_on_rx_request(), pubsub_on_rx_mwi_notify_request(), pubsub_on_rx_publish_request(), pubsub_on_rx_refresh(), pubsub_on_rx_subscribe_request(), registrar_on_rx_request(), rx_data_to_ast_msg(), send_options_response(), send_response(), and supplement_on_rx_request().

◆ ast_sip_add_body()

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.

Parameters
tdataThe message to add the body to
bodyThe message body to add
Return values
0Success
-1Failure

Definition at line 2052 of file res_pjsip.c.

2053{
2054 pjsip_msg_body *pjsip_body = ast_body_to_pjsip_body(tdata->pool, body);
2055 tdata->msg->body = pjsip_body;
2056 return 0;
2057}
static pjsip_msg_body * ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
Definition: res_pjsip.c:2039

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().

◆ ast_sip_add_body_multipart()

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.

Parameters
tdataThe message to add the body to
bodiesThe message bodies to add
num_bodiesThe parts of the body to add
Return values
0Success
-1Failure

Definition at line 2059 of file res_pjsip.c.

2060{
2061 int i;
2062 /* NULL for type and subtype automatically creates "multipart/mixed" */
2063 pjsip_msg_body *body = pjsip_multipart_create(tdata->pool, NULL, NULL);
2064
2065 for (i = 0; i < num_bodies; ++i) {
2066 pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
2067 part->body = ast_body_to_pjsip_body(tdata->pool, bodies[i]);
2068 pjsip_multipart_add_part(tdata->pool, body, part);
2069 }
2070
2071 tdata->msg->body = body;
2072 return 0;
2073}

References ast_body_to_pjsip_body(), and NULL.

◆ ast_sip_add_date_header()

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.

Since
16.19.0
Note
There is no checking done to see if the header already exists before adding it. It's up to the caller of this function to determine if that needs to be done or not.

Definition at line 90 of file res_pjsip.c.

91{
92 char date[256];
93 struct tm tm;
94 time_t t = time(NULL);
95
96 gmtime_r(&t, &tm);
97 strftime(date, sizeof(date), "%a, %d %b %Y %T GMT", &tm);
98
99 ast_sip_add_header(tdata, "Date", date);
100}
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
Definition: res_pjsip.c:2008

References ast_sip_add_header(), and NULL.

Referenced by add_date_header().

◆ ast_sip_add_global_request_header()

int ast_sip_add_global_request_header ( const char *  name,
const char *  value,
int  replace 
)

Definition at line 153 of file pjsip_global_headers.c.

154{
156}
static const char name[]
Definition: format_mp3.c:68
static int replace(struct ast_channel *chan, const char *cmd, char *data, struct ast_str **buf, ssize_t len)
Definition: func_strings.c:888
static int add_header(struct header_list *headers, const char *name, const char *value, int replace)
static struct header_list request_headers
int value
Definition: syslog.c:37

References add_header(), name, replace(), request_headers, and value.

Referenced by global_apply().

◆ ast_sip_add_global_response_header()

int ast_sip_add_global_response_header ( const char *  name,
const char *  value,
int  replace 
)

Definition at line 158 of file pjsip_global_headers.c.

159{
161}
static struct header_list response_headers

References add_header(), name, replace(), response_headers, and value.

Referenced by global_apply().

◆ ast_sip_add_header()

int ast_sip_add_header ( pjsip_tx_data *  tdata,
const char *  name,
const char *  value 
)

Add a header to an outbound SIP message.

Parameters
tdataThe message to add the header to
nameThe header name
valueThe header value
Return values
0Success
-1Failure

Definition at line 2008 of file res_pjsip.c.

2009{
2010 pj_str_t hdr_name;
2011 pj_str_t hdr_value;
2012 pjsip_generic_string_hdr *hdr;
2013
2014 pj_cstr(&hdr_name, name);
2015 pj_cstr(&hdr_value, value);
2016
2017 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2018
2019 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2020 return 0;
2021}

References name, and value.

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().

◆ ast_sip_add_header2()

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.

Parameters
tdataThe message to add the header to
nameThe header name
valueThe header value
Returns
The pjsip_generic_string_hdr * added.

Definition at line 2023 of file res_pjsip.c.

2025{
2026 pj_str_t hdr_name;
2027 pj_str_t hdr_value;
2028 pjsip_generic_string_hdr *hdr;
2029
2030 pj_cstr(&hdr_name, name);
2031 pj_cstr(&hdr_value, value);
2032
2033 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2034
2035 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2036 return hdr;
2037}

References name, and value.

Referenced by handle_outgoing_request().

◆ ast_sip_add_security_headers()

int ast_sip_add_security_headers ( struct ast_sip_security_mechanism_vector security_mechanisms,
const char *  header_name,
int  add_qval,
pjsip_tx_data *  tdata 
)

Add security headers to transmission data.

Parameters
security_mechanismsVector of security mechanisms.
header_nameThe header name under which to add the security mechanisms. One of Security-Client, Security-Server, Security-Verify.
add_qvalIf zero, don't add the q-value to the header.
tdataThe transmission data.
Return values
0Success
non-zeroFailure

Definition at line 290 of file security_agreements.c.

291 {
292 struct ast_sip_security_mechanism *mech;
293 char *buf;
294 int mech_cnt;
295 int i;
296 int add_qvalue = 1;
297 static const pj_str_t proxy_require = { "Proxy-Require", 13 };
298 static const pj_str_t require = { "Require", 7 };
299
300 if (!security_mechanisms || !tdata) {
301 return EINVAL;
302 }
303
304 if (!strcmp(header_name, "Security-Client")) {
305 add_qvalue = 0;
306 } else if (strcmp(header_name, "Security-Server") &&
307 strcmp(header_name, "Security-Verify")) {
308 return EINVAL;
309 }
310 /* If we're adding Security-Client headers, don't add q-value
311 * even if the function caller requested it. */
312 add_qvalue = add_qvalue && add_qval;
313
314 mech_cnt = AST_VECTOR_SIZE(security_mechanisms);
315 for (i = 0; i < mech_cnt; ++i) {
316 mech = AST_VECTOR_GET(security_mechanisms, i);
317 if (security_mechanism_to_str(mech, add_qvalue, &buf)) {
318 continue;
319 }
320 ast_sip_add_header(tdata, header_name, buf);
321 ast_free(buf);
322 }
323
324 if (pjsip_msg_find_hdr_by_name(tdata->msg, &require, NULL) == NULL) {
325 ast_sip_add_header(tdata, "Require", "mediasec");
326 }
327 if (pjsip_msg_find_hdr_by_name(tdata->msg, &proxy_require, NULL) == NULL) {
328 ast_sip_add_header(tdata, "Proxy-Require", "mediasec");
329 }
330 return 0;
331}
#define ast_free(a)
Definition: astmm.h:180
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
Definition: res_pjsip.c:2008
static int security_mechanism_to_str(const struct ast_sip_security_mechanism *security_mechanism, int add_qvalue, char **buf)
Structure representing a security mechanism as defined in RFC 3329.
Definition: res_pjsip.h:375
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680

References ast_free, ast_sip_add_header(), AST_VECTOR_GET, AST_VECTOR_SIZE, buf, NULL, and security_mechanism_to_str().

Referenced by add_outgoing_request_headers(), and add_security_headers().

◆ ast_sip_add_usereqphone()

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.

Parameters
endpointThe endpoint to use for configuration
poolThe memory pool to allocate the parameter from
uriThe URI to check for user and to add parameter to

Definition at line 930 of file res_pjsip.c.

931{
932 pjsip_sip_uri *sip_uri;
933 int i = 0;
934 static const pj_str_t STR_PHONE = { "phone", 5 };
935
936 if (!endpoint || !endpoint->usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
937 return;
938 }
939
940 sip_uri = pjsip_uri_get_uri(uri);
941
942 if (!pj_strlen(&sip_uri->user)) {
943 return;
944 }
945
946 if (pj_strbuf(&sip_uri->user)[0] == '+') {
947 i = 1;
948 }
949
950 /* Test URI user against allowed characters in AST_DIGIT_ANY */
951 for (; i < pj_strlen(&sip_uri->user); i++) {
952 if (!strchr(AST_DIGIT_ANY, pj_strbuf(&sip_uri->user)[i])) {
953 break;
954 }
955 }
956
957 if (i < pj_strlen(&sip_uri->user)) {
958 return;
959 }
960
961 sip_uri->user_param = STR_PHONE;
962}
#define AST_DIGIT_ANY
Definition: file.h:48
unsigned int usereqphone
Definition: res_pjsip.h:1027

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().

◆ ast_sip_append_body()

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.

Parameters
tdataThe message to append the body to
body_textThe string to append to the end of the current body
Return values
0Success
-1Failure

Definition at line 2075 of file res_pjsip.c.

2076{
2077 size_t combined_size = strlen(body_text) + tdata->msg->body->len;
2078 struct ast_str *body_buffer = ast_str_alloca(combined_size);
2079
2080 ast_str_set(&body_buffer, 0, "%.*s%s", (int) tdata->msg->body->len, (char *) tdata->msg->body->data, body_text);
2081
2082 tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
2083 pj_memcpy(tdata->msg->body->data, ast_str_buffer(body_buffer), combined_size);
2084 tdata->msg->body->len = combined_size;
2085
2086 return 0;
2087}
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
#define ast_str_alloca(init_len)
Definition: strings.h:848
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1113
Support for dynamic strings.
Definition: strings.h:623

References ast_str_alloca, ast_str_buffer(), and ast_str_set().

◆ ast_sip_are_media_types_equal()

int ast_sip_are_media_types_equal ( pjsip_media_type *  a,
pjsip_media_type *  b 
)

Compare pjsip media types.

Parameters
athe first media type
bthe second media type
Return values
1Media types are equal
0Media types are not equal

Definition at line 2219 of file res_pjsip.c.

2220{
2221 int rc = 0;
2222 if (a != NULL && b != NULL) {
2223 rc = pjsip_media_type_cmp(a, b, 0) ? 0 : 1;
2224 }
2225 return rc;
2226}
static struct test_val b
static struct test_val a

References a, b, and NULL.

Referenced by find_pidf(), and video_info_incoming_request().

◆ ast_sip_auth_type_to_str()

const char * ast_sip_auth_type_to_str ( enum ast_sip_auth_type  type)

Converts the given auth type to a string.

Parameters
typethe auth type to convert
Return values
astring representative of the auth type

Definition at line 80 of file config_auth.c.

81{
83 auth_types_map[type] : "";
84}
static const char type[]
Definition: chan_ooh323.c:109
static const char * auth_types_map[]
Definition: config_auth.c:74
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
Definition: utils.h:687

References ARRAY_IN_BOUNDS, auth_types_map, and type.

Referenced by auth_type_to_str().

◆ ast_sip_auth_vector_destroy()

void ast_sip_auth_vector_destroy ( struct ast_sip_auth_vector vector)

Free contents of an auth vector.

Parameters
vectorVector whose contents are to be freed

Definition at line 306 of file pjsip_configuration.c.

307{
308 int i;
309 size_t size;
310
311 if (!auths) {
312 return;
313 }
314
315 size = AST_VECTOR_SIZE(auths);
316
317 for (i = 0; i < size; ++i) {
318 const char *name = AST_VECTOR_REMOVE_UNORDERED(auths, 0);
319 ast_free((char *) name);
320 }
321 AST_VECTOR_FREE(auths);
322}
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
#define AST_VECTOR_REMOVE_UNORDERED(vec, idx)
Remove an element from an unordered vector by index.
Definition: vector.h:438

References ast_free, AST_VECTOR_FREE, AST_VECTOR_REMOVE_UNORDERED, AST_VECTOR_SIZE, and name.

Referenced by ast_sip_auth_vector_init(), endpoint_destructor(), handle_client_state_destruction(), sip_outbound_publish_destroy(), sip_outbound_registration_destroy(), and sip_outbound_registration_perform().

◆ ast_sip_auth_vector_init()

int ast_sip_auth_vector_init ( struct ast_sip_auth_vector vector,
const char *  auth_names 
)

Initialize an auth vector with the configured values.

Parameters
vectorVector to initialize
auth_namesComma-separated list of names to set in the array
Return values
0Success
non-zeroFailure

Definition at line 324 of file pjsip_configuration.c.

325{
326 char *auth_names = ast_strdupa(value);
327 char *val;
328
329 ast_assert(auths != NULL);
330
331 if (AST_VECTOR_SIZE(auths)) {
333 }
334 if (AST_VECTOR_INIT(auths, 1)) {
335 return -1;
336 }
337
338 while ((val = ast_strip(strsep(&auth_names, ",")))) {
339 if (ast_strlen_zero(val)) {
340 continue;
341 }
342
343 val = ast_strdup(val);
344 if (!val) {
345 goto failure;
346 }
347 if (AST_VECTOR_APPEND(auths, val)) {
348 ast_free(val);
349
350 goto failure;
351 }
352 }
353 return 0;
354
355failure:
357 return -1;
358}
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:241
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
char * strsep(char **str, const char *delims)
void ast_sip_auth_vector_destroy(struct ast_sip_auth_vector *auths)
Free contents of an auth vector.
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
Definition: strings.h:223
Definition: ast_expr2.c:325
#define ast_assert(a)
Definition: utils.h:739
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256

References ast_assert, ast_free, ast_sip_auth_vector_destroy(), ast_strdup, ast_strdupa, ast_strip(), ast_strlen_zero(), AST_VECTOR_APPEND, AST_VECTOR_INIT, AST_VECTOR_SIZE, NULL, strsep(), and value.

Referenced by inbound_auth_handler(), and outbound_auth_handler().

◆ ast_sip_auths_to_str()

int ast_sip_auths_to_str ( const struct ast_sip_auth_vector auths,
char **  buf 
)

Converts an auths array to a string of comma separated values.

Parameters
authsan auth array
bufthe string buffer to write the object data
Return values
0Success, non-zero on failure

Definition at line 374 of file pjsip_configuration.c.

375{
376 if (!auths || !AST_VECTOR_SIZE(auths)) {
377 return 0;
378 }
379
380 if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
381 return -1;
382 }
383
384 /* I feel like accessing the vector's elem array directly is cheating...*/
386 return 0;
387}
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
Definition: sorcery.h:110
void ast_join_delim(char *s, size_t len, const char *const w[], unsigned int size, char delim)
Join an array of strings into a single string.
Definition: utils.c:2378
const char ** elems
Definition: res_pjsip.h:601

References ast_calloc, ast_join_delim(), AST_VECTOR_SIZE, buf, ast_sip_auth_vector::elems, and MAX_OBJECT_FIELD.

Referenced by format_str_append_auth(), inbound_auths_to_str(), and outbound_auths_to_str().

◆ ast_sip_call_codec_pref_to_str()

const char * ast_sip_call_codec_pref_to_str ( struct ast_flags  pref)

Convert the call codec preference flags to a string.

Since
18.0.0
Parameters
prefthe call codec preference setting
Returns
a constant string with either the setting value or 'unknown'
Note
Don't try to free the string!

Definition at line 2554 of file res_pjsip.c.

2555{
2556 const char *value;
2557
2558 if (ast_sip_call_codec_pref_test(pref, LOCAL) && ast_sip_call_codec_pref_test(pref, INTERSECT) && ast_sip_call_codec_pref_test(pref, ALL)) {
2559 value = "local";
2560 } else if (ast_sip_call_codec_pref_test(pref, LOCAL) && ast_sip_call_codec_pref_test(pref, UNION) && ast_sip_call_codec_pref_test(pref, ALL)) {
2561 value = "local_merge";
2562 } else if (ast_sip_call_codec_pref_test(pref, LOCAL) && ast_sip_call_codec_pref_test(pref, INTERSECT) && ast_sip_call_codec_pref_test(pref, FIRST)) {
2563 value = "local_first";
2564 } else if (ast_sip_call_codec_pref_test(pref, REMOTE) && ast_sip_call_codec_pref_test(pref, INTERSECT) && ast_sip_call_codec_pref_test(pref, ALL)) {
2565 value = "remote";
2566 } else if (ast_sip_call_codec_pref_test(pref, REMOTE) && ast_sip_call_codec_pref_test(pref, UNION) && ast_sip_call_codec_pref_test(pref, ALL)) {
2567 value = "remote_merge";
2568 } else if (ast_sip_call_codec_pref_test(pref, REMOTE) && ast_sip_call_codec_pref_test(pref, UNION) && ast_sip_call_codec_pref_test(pref, FIRST)) {
2569 value = "remote_first";
2570 } else {
2571 value = "unknown";
2572 }
2573
2574 return value;
2575}
#define ast_sip_call_codec_pref_test(__param, __codec_pref)
Returns true if the preference is set in the parameter.
Definition: res_pjsip.h:694

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().

◆ ast_sip_call_codec_str_to_pref()

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.

Since
18.0.0
Parameters
prefA pointer to an ast_flags structure to receive the preference flags
pref_strThe call codec preference setting string
is_outgoingIs for outgoing calls?
Return values
0The string was parsed successfully
-1The string option was invalid

Definition at line 2577 of file res_pjsip.c.

2578{
2579 pref->flags = 0;
2580
2581 if (strcmp(pref_str, "local") == 0) {
2583 } else if (is_outgoing && strcmp(pref_str, "local_merge") == 0) {
2585 } else if (strcmp(pref_str, "local_first") == 0) {
2587 } else if (strcmp(pref_str, "remote") == 0) {
2589 } else if (is_outgoing && strcmp(pref_str, "remote_merge") == 0) {
2591 } else if (strcmp(pref_str, "remote_first") == 0) {
2593 } else {
2594 return -1;
2595 }
2596
2597 return 0;
2598}
unsigned int flags
Definition: utils.h:200
#define ast_set_flag(p, flag)
Definition: utils.h:70

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().

◆ ast_sip_check_authentication()

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.

Parameters
endpointThe endpoint from the request was sent
rdataThe request to potentially authenticate
tdataTentative response to the request
Returns
The result of checking authentication.

Definition at line 179 of file res_pjsip.c.

181{
183 ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is successful\n");
185 }
186 return registered_authenticator->check_authentication(endpoint, rdata, tdata);
187}
#define ast_log
Definition: astobj2.c:42
#define LOG_WARNING
static struct ast_sip_authenticator * registered_authenticator
Definition: res_pjsip.c:138
enum ast_sip_check_auth_result(* check_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
Check that an incoming request passes authentication.
Definition: res_pjsip.h:1261

References ast_log, AST_SIP_AUTHENTICATION_SUCCESS, ast_sip_authenticator::check_authentication, LOG_WARNING, and registered_authenticator.

Referenced by authenticate().

◆ ast_sip_cleanup_auths()

void ast_sip_cleanup_auths ( struct ast_sip_auth auths[],
size_t  num_auths 
)

Clean up retrieved auth structures from memory.

Call this function once you have completed operating on auths retrieved from ast_sip_retrieve_auths

Parameters
authsAn array of auth object pointers to clean up
num_authsThe number of auths in the array

Definition at line 2542 of file pjsip_configuration.c.

2543{
2544 int i;
2545 for (i = 0; i < num_auths; ++i) {
2546 ao2_cleanup(auths[i]);
2547 }
2548}
#define ao2_cleanup(obj)
Definition: astobj2.h:1934

References ao2_cleanup.

Referenced by digest_check_auth(), and set_outbound_initial_authentication_credentials().

◆ ast_sip_contact_to_str()

int ast_sip_contact_to_str ( void *  object,
void *  arg,
int  flags 
)

Handler used to convert a contact to a string.

Parameters
objectthe ast_sip_aor_contact_pair containing a list of contacts to iterate and the contact
arguser data passed to handler
flags
Return values
0Success, non-zero on failure

Definition at line 770 of file location.c.

771{
772 struct ast_sip_contact_wrapper *wrapper = object;
773 struct ast_str **buf = arg;
774
775 ast_str_append(buf, 0, "%s,", wrapper->contact_id);
776
777 return 0;
778}
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1139
A wrapper for contact that adds the aor_id and a consistent contact id. Used by ast_sip_for_each_cont...
Definition: res_pjsip.h:514

References ast_str_append(), buf, and ast_sip_contact_wrapper::contact_id.

Referenced by contacts_to_str(), sip_contact_to_str(), and sip_endpoints_aors_ami().

◆ ast_sip_create_ami_event()

struct ast_str * ast_sip_create_ami_event ( const char *  event,
struct ast_sip_ami ami 
)

Creates a string to store AMI event data in.

Parameters
eventthe event to set
amiAMI session and message container
Return values
aninitialized ast_str or NULL on error.

Definition at line 1724 of file pjsip_configuration.c.

1725{
1727
1728 if (!(buf)) {
1729 astman_send_error_va(ami->s, ami->m, "Unable create event "
1730 "for %s\n", event);
1731 return NULL;
1732 }
1733
1734 ast_str_set(&buf, 0, "Event: %s\r\n", event);
1735 if (!ast_strlen_zero(ami->action_id)) {
1736 ast_str_append(&buf, 0, "ActionID: %s\r\n", ami->action_id);
1737 }
1738 return buf;
1739}
void astman_send_error_va(struct mansession *s, const struct message *m, const char *fmt,...)
Send error in manager transaction (with va_args support)
Definition: manager.c:1974
#define AMI_DEFAULT_STR_SIZE
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:659
const char * action_id
Definition: res_pjsip.h:3052
struct mansession * s
Definition: res_pjsip.h:3048
const struct message * m
Definition: res_pjsip.h:3050
Definition: astman.c:222

References ast_sip_ami::action_id, AMI_DEFAULT_STR_SIZE, ast_str_append(), ast_str_create, ast_str_set(), ast_strlen_zero(), astman_send_error_va(), buf, ast_sip_ami::m, NULL, and ast_sip_ami::s.

Referenced by ami_outbound_registration_task(), ami_registrations_aor(), ami_subscription_detail(), ast_sip_format_contact_ami(), format_ami_aor_handler(), format_ami_aorlist_handler(), format_ami_auth_handler(), format_ami_authlist_handler(), format_ami_contactlist_handler(), format_ami_endpoint(), format_ami_endpoint_transport(), format_ami_endpoints(), format_ami_resource_lists(), and send_identify_ami_event().

◆ ast_sip_create_dialog_uac()

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.

Parameters
endpointA pointer to the endpoint
aor_nameOptional name of the AOR to target, may even be an explicit SIP URI
request_userOptional user to place into the target URI
Return values
non-NULLsuccess
NULLfailure

Definition at line 964 of file res_pjsip.c.

966{
967 char enclosed_uri[PJSIP_MAX_URL_SIZE];
968 pj_str_t local_uri = { "sip:temp@temp", 13 }, remote_uri, target_uri;
969 pj_status_t res;
970 pjsip_dialog *dlg = NULL;
971 const char *outbound_proxy = endpoint->outbound_proxy;
972 pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
973 static const pj_str_t HCONTACT = { "Contact", 7 };
974
975 if (!ast_begins_with(uri, "<")) {
976 snprintf(enclosed_uri, sizeof(enclosed_uri), "<%s>", uri);
977 } else {
978 snprintf(enclosed_uri, sizeof(enclosed_uri), "%s", uri);
979 }
980 pj_cstr(&remote_uri, enclosed_uri);
981
982 pj_cstr(&target_uri, uri);
983
984 res = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, &target_uri, &dlg);
985 if (res == PJ_SUCCESS && !(PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target))) {
986 /* dlg->target is a pjsip_other_uri, but it's assumed to be a
987 * pjsip_sip_uri below. Fail fast. */
988 res = PJSIP_EINVALIDURI;
989 pjsip_dlg_terminate(dlg);
990 }
991 if (res != PJ_SUCCESS) {
992 if (res == PJSIP_EINVALIDURI) {
994 "Endpoint '%s': Could not create dialog to invalid URI '%s'. Is endpoint registered and reachable?\n",
995 ast_sorcery_object_get_id(endpoint), uri);
996 }
997 return NULL;
998 }
999
1000 /* We have to temporarily bump up the sess_count here so the dialog is not prematurely destroyed */
1001 dlg->sess_count++;
1002
1003 ast_sip_dlg_set_transport(endpoint, dlg, &selector);
1004
1005 if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, endpoint->fromdomain, &remote_uri, &selector)) {
1006 dlg->sess_count--;
1007 pjsip_dlg_terminate(dlg);
1008 ast_sip_tpselector_unref(&selector);
1009 return NULL;
1010 }
1011
1012 ast_sip_tpselector_unref(&selector);
1013
1014 /* Update the dialog with the new local URI, we do it afterwards so we can use the dialog pool for construction */
1015 pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
1016 dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
1017 if (!dlg->local.info->uri) {
1019 "Could not parse URI '%s' for endpoint '%s'\n",
1020 dlg->local.info_str.ptr, ast_sorcery_object_get_id(endpoint));
1021 dlg->sess_count--;
1022 pjsip_dlg_terminate(dlg);
1023 return NULL;
1024 }
1025
1026 dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL);
1027
1028 if (!ast_strlen_zero(endpoint->contact_user)) {
1029 pjsip_sip_uri *sip_uri;
1030
1031 sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
1032 pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);
1033 }
1034
1035 /* If a request user has been specified and we are permitted to change it, do so */
1036 if (!ast_strlen_zero(request_user)) {
1037 pjsip_sip_uri *sip_uri;
1038
1039 if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
1040 sip_uri = pjsip_uri_get_uri(dlg->target);
1041 pj_strdup2(dlg->pool, &sip_uri->user, request_user);
1042 }
1043 if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
1044 sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
1045 pj_strdup2(dlg->pool, &sip_uri->user, request_user);
1046 }
1047 }
1048
1049 /* Add the user=phone parameter if applicable */
1050 ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->target);
1051 ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->remote.info->uri);
1052 ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->local.info->uri);
1053
1054 if (!ast_strlen_zero(outbound_proxy)) {
1055 pjsip_route_hdr route_set, *route;
1056 static const pj_str_t ROUTE_HNAME = { "Route", 5 };
1057 pj_str_t tmp;
1058
1059 pj_list_init(&route_set);
1060
1061 pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
1062 if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
1063 ast_log(LOG_ERROR, "Could not create dialog to endpoint '%s' as outbound proxy URI '%s' is not valid\n",
1064 ast_sorcery_object_get_id(endpoint), outbound_proxy);
1065 dlg->sess_count--;
1066 pjsip_dlg_terminate(dlg);
1067 return NULL;
1068 }
1069 pj_list_insert_nodes_before(&route_set, route);
1070
1071 pjsip_dlg_set_route_set(dlg, &route_set);
1072 }
1073
1074 dlg->sess_count--;
1075
1076 return dlg;
1077}
static int tmp()
Definition: bt_open.c:389
#define LOG_ERROR
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.
Definition: res_pjsip.c:930
int ast_sip_dlg_set_transport(const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg, pjsip_tpselector *selector)
Set the transport on a dialog.
Definition: res_pjsip.c:727
void ast_sip_tpselector_unref(pjsip_tpselector *selector)
Unreference a pjsip_tpselector.
Definition: res_pjsip.c:923
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)
Definition: res_pjsip.c:749
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2317
static int force_inline attribute_pure ast_begins_with(const char *str, const char *prefix)
Checks whether a string begins with another.
Definition: strings.h:97
char * contact_user
Definition: res_pjsip.h:1037
const ast_string_field outbound_proxy
Definition: res_pjsip.h:987
const ast_string_field fromdomain
Definition: res_pjsip.h:987
const ast_string_field fromuser
Definition: res_pjsip.h:987

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().

◆ ast_sip_create_dialog_uas()

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.

Deprecated:
This function is unsafe (due to the returned object not being locked nor having its reference incremented) and should no longer be used. Instead use ast_sip_create_dialog_uas_locked so a properly locked and referenced object is returned.
Parameters
endpointA pointer to the endpoint
rdataThe request that is starting the dialog
[out]statusOn failure, the reason for failure in creating the dialog

Definition at line 1176 of file res_pjsip.c.

1177{
1178#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
1179 pjsip_dialog *dlg;
1180
1181 dlg = create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas_and_inc_lock);
1182 if (dlg) {
1183 pjsip_dlg_dec_lock(dlg);
1184 }
1185
1186 return dlg;
1187#else
1188 return create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas);
1189#endif
1190}
jack_status_t status
Definition: app_jack.c:146
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)
Definition: res_pjsip.c:1118

References create_dialog_uas(), and status.

◆ ast_sip_create_dialog_uas_locked()

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.

Note
The safest way to unlock the object, and decrement its reference is by calling pjsip_dlg_dec_lock. Alternatively, pjsip_dlg_dec_session can be used to decrement the reference only.

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.

Parameters
endpointA pointer to the endpoint
rdataThe request that is starting the dialog
[out]statusOn failure, the reason for failure in creating the dialog
Return values
Alocked, and reference counted pjsip_dialog object.
NULLon failure

Definition at line 1192 of file res_pjsip.c.

1194{
1195#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
1196 return create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas_and_inc_lock);
1197#else
1198 /*
1199 * This is put here in order to be compatible with older versions of pjproject.
1200 * Best we can do in this case is immediately lock after getting the dialog.
1201 * However, that does leave a "gap" between creating and locking.
1202 */
1203 pjsip_dialog *dlg;
1204
1205 dlg = create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas);
1206 if (dlg) {
1207 pjsip_dlg_inc_lock(dlg);
1208 }
1209
1210 return dlg;
1211#endif
1212 }

References create_dialog_uas(), and status.

Referenced by create_subscription_tree(), and pre_session_setup().

◆ ast_sip_create_rdata()

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.

Parameters
[out]rdataThe rdata structure that will be populated
packetA SIP message
src_nameThe source IP address of the message
src_portThe source port of the message
transport_typeThe type of transport the message was received on
local_nameThe local IP address the message was received on
local_portThe local port the message was received on
Return values
0success
-1failure

Definition at line 1266 of file res_pjsip.c.

1268{
1269 return ast_sip_create_rdata_with_contact(rdata, packet, src_name, src_port, transport_type,
1270 local_name, local_port, NULL);
1271}
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.
Definition: res_pjsip.c:1214

References ast_sip_create_rdata_with_contact(), and NULL.

◆ ast_sip_create_rdata_with_contact()

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.

Since
13.15.0
Parameters
[out]rdataThe rdata structure that will be populated
packetA SIP message
src_nameThe source IP address of the message
src_portThe source port of the message
transport_typeThe type of transport the message was received on
local_nameThe local IP address the message was received on
local_portThe local port the message was received on
contact_uriThe contact URI of the message
Return values
0success
-1failure

Definition at line 1214 of file res_pjsip.c.

1216{
1217 pj_str_t tmp;
1218
1219 /*
1220 * Initialize the error list in case there is a parse error
1221 * in the given packet.
1222 */
1223 pj_list_init(&rdata->msg_info.parse_err);
1224
1225 rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
1226 if (!rdata->tp_info.transport) {
1227 return -1;
1228 }
1229
1230 ast_copy_string(rdata->pkt_info.packet, packet, sizeof(rdata->pkt_info.packet));
1231 ast_copy_string(rdata->pkt_info.src_name, src_name, sizeof(rdata->pkt_info.src_name));
1232 rdata->pkt_info.src_port = src_port;
1233 pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
1234 pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
1235
1236 pjsip_parse_rdata(packet, strlen(packet), rdata);
1237 if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
1238 return -1;
1239 }
1240
1241 if (!ast_strlen_zero(contact)) {
1242 pjsip_contact_hdr *contact_hdr;
1243
1244 contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
1245 if (contact_hdr) {
1246 contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (char *)contact,
1247 strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
1248 if (!contact_hdr->uri) {
1249 ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact);
1250 return -1;
1251 }
1252 }
1253 }
1254
1255 pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
1256 rdata->msg_info.via->rport_param = -1;
1257
1258 rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
1259 rdata->tp_info.transport->type_name = transport_type;
1260 pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
1261 rdata->tp_info.transport->local_name.port = local_port;
1262
1263 return 0;
1264}
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ast_copy_string(), ast_log, ast_strlen_zero(), LOG_WARNING, NULL, and tmp().

Referenced by ast_sip_create_rdata(), and subscription_persistence_recreate().

◆ ast_sip_create_request()

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.

Parameters
methodThe method of the SIP request to send
dlgOptional. If specified, the dialog on which to request the message.
endpointOptional. If specified, the request will be created out-of-dialog to the endpoint.
uriOptional. If specified, the request will be sent to this URI rather than one configured for the endpoint.
contactThe contact with which this request is associated for out-of-dialog requests.
[out]tdataThe 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.

Return values
0Success
-1Failure

Definition at line 1435 of file res_pjsip.c.

1438{
1439 const pjsip_method *pmethod = get_pjsip_method(method);
1440
1441 if (!pmethod) {
1442 ast_log(LOG_WARNING, "Unknown method '%s'. Cannot send request\n", method);
1443 return -1;
1444 }
1445
1446 if (dlg) {
1447 return create_in_dialog_request(pmethod, dlg, tdata);
1448 } else {
1449 ast_assert(endpoint != NULL);
1450 return create_out_of_dialog_request(pmethod, endpoint, uri, contact, tdata);
1451 }
1452}
static int create_in_dialog_request(const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata)
Definition: res_pjsip.c:1307
static const pjsip_method * get_pjsip_method(const char *method)
Definition: res_pjsip.c:1296
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)
Definition: res_pjsip.c:1325
const char * method
Definition: res_pjsip.c:1279
const pjsip_method * pmethod
Definition: res_pjsip.c:1280

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().

◆ ast_sip_create_request_with_auth()

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.

216{
218 ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
219 return -1;
220 }
221 return registered_outbound_authenticator->create_request_with_auth(auths, challenge, old_request, new_request);
222}
static struct ast_sip_outbound_authenticator * registered_outbound_authenticator
Definition: res_pjsip.c:189
static void challenge(const char *realm, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale)
astobj2 callback for adding digest challenges to responses
int(* create_request_with_auth)(const struct ast_sip_auth_vector *auths, struct pjsip_rx_data *challenge, struct pjsip_tx_data *old_request, struct pjsip_tx_data **new_request)
Create a new request with authentication credentials.
Definition: res_pjsip.h:1282

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().

◆ ast_sip_create_response()

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.

Parameters
rdataThe rdata from the incoming request.
st_codeThe response code to transmit.
contactThe contact with which this request is associated.
[out]p_tdataThe 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.

Return values
0Success
-1Failure

Definition at line 2468 of file res_pjsip.c.

2470{
2471 int res = pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, st_code, NULL, tdata);
2472
2473 if (!res) {
2474 ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
2475 }
2476
2477 return res;
2478}
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
#define MOD_DATA_CONTACT
Definition: res_pjsip.c:66
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:520
static pjsip_module supplement_module
Definition: res_pjsip.c:1318
#define ast_sip_mod_data_set(pool, mod_data, id, key, val)
Utilizing a mod_data array for a given id, set the value associated with the given key.
Definition: res_pjsip.h:2979

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().

◆ ast_sip_default_outbound_endpoint()

struct ast_sip_endpoint * ast_sip_default_outbound_endpoint ( void  )

Retrieve the default outbound endpoint.

Return values
Thedefault outbound endpoint, NULL if not found.

Definition at line 2518 of file pjsip_configuration.c.

2519{
2522 sip_sorcery, "endpoint", name);
2523}
char * ast_sip_global_default_outbound_endpoint(void)
static struct ast_sorcery * sip_sorcery
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References ast_free, ast_sip_global_default_outbound_endpoint(), ast_sorcery_retrieve_by_id(), ast_strlen_zero(), name, NULL, RAII_VAR, and sip_sorcery.

Referenced by ast_sip_get_endpoint(), handle_atsign(), handle_single_token(), and notify_uri().

◆ ast_sip_dialog_setup_outbound_authentication()

int ast_sip_dialog_setup_outbound_authentication ( pjsip_dialog *  dlg,
const struct ast_sip_endpoint endpoint,
ast_sip_dialog_outbound_auth_cb  cb,
void *  user_data 
)

Set up outbound authentication on a SIP dialog.

This sets up the infrastructure so that all requests associated with a created dialog can be re-sent with authentication credentials if the original request is challenged.

Parameters
dlgThe dialog on which requests will be authenticated
endpointThe endpoint whom this dialog pertains to
cbCallback to call to send requests with authentication
user_dataData to be provided to the callback when it is called
Return values
0Success
-1Failure

◆ ast_sip_dict_get()

void * ast_sip_dict_get ( void *  ht,
const char *  key 
)

Retrieves the value associated with the given key.

Parameters
htthe hash table/dictionary to search
keythe key to find
Return values
thevalue associated with the key, NULL otherwise.

Definition at line 2327 of file res_pjsip.c.

2328{
2329 unsigned int hval = 0;
2330
2331 if (!ht) {
2332 return NULL;
2333 }
2334
2335 return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
2336}

References NULL.

◆ ast_sip_dict_set()

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.

Parameters
poolthe pool to allocate memory in
htthe hash table/dictionary in which to store the key/value pair
keythe key to associate a value with
valthe value to associate with a key
Return values
thegiven, or newly created, hash table.

Definition at line 2338 of file res_pjsip.c.

2340{
2341 if (!ht) {
2342 ht = pj_hash_create(pool, 11);
2343 }
2344
2345 pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0, val);
2346
2347 return ht;
2348}

◆ ast_sip_dlg_set_transport()

int ast_sip_dlg_set_transport ( const struct ast_sip_endpoint endpoint,
pjsip_dialog *  dlg,
pjsip_tpselector *  selector 
)

Set the transport on a dialog.

Since
13.15.0
Parameters
endpoint
dlg
selector(optional)
Note
This API calls ast_sip_get_transport_name(endpoint, dlg->target) and if the result is non-NULL, calls pjsip_dlg_set_transport. If 'selector' is non-NULL, it is updated with the selector used.
It is the responsibility of the caller to unref the passed in selector if one is provided.

Definition at line 727 of file res_pjsip.c.

729{
730 pjsip_sip_uri *uri;
731 pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
732
733 uri = pjsip_uri_get_uri(dlg->target);
734 if (!selector) {
735 selector = &sel;
736 }
737
738 ast_sip_set_tpselector_from_ep_or_uri(endpoint, uri, selector);
739
740 pjsip_dlg_set_transport(dlg, selector);
741
742 if (selector == &sel) {
744 }
745
746 return 0;
747}
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.
Definition: res_pjsip.c:911

References ast_sip_set_tpselector_from_ep_or_uri(), and ast_sip_tpselector_unref().

Referenced by ast_sip_create_dialog_uac().

◆ ast_sip_dtmf_to_str()

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.

Since
13.18.0
Parameters
dtmfthe dtmf mode
bufBuffer to receive dtmf mode string
buf_lenBuffer length
Return values
0Success
-1Failure

Definition at line 2504 of file res_pjsip.c.

2506{
2507 switch (dtmf) {
2508 case AST_SIP_DTMF_NONE:
2509 ast_copy_string(buf, "none", buf_len);
2510 break;
2512 ast_copy_string(buf, "rfc4733", buf_len);
2513 break;
2515 ast_copy_string(buf, "inband", buf_len);
2516 break;
2517 case AST_SIP_DTMF_INFO:
2518 ast_copy_string(buf, "info", buf_len);
2519 break;
2520 case AST_SIP_DTMF_AUTO:
2521 ast_copy_string(buf, "auto", buf_len);
2522 break;
2524 ast_copy_string(buf, "auto_info", buf_len);
2525 break;
2526 default:
2527 buf[0] = '\0';
2528 return -1;
2529 }
2530 return 0;
2531}

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().

◆ ast_sip_endpoint_alloc()

void * ast_sip_endpoint_alloc ( const char *  name)

Allocate a new SIP endpoint.

This will return an endpoint with its refcount increased by one. This reference can be released using ao2_ref().

Parameters
nameThe name of the endpoint.
Return values
NULLEndpoint allocation failed
non-NULLThe newly allocated endpoint

Definition at line 2457 of file pjsip_configuration.c.

2458{
2459 struct ast_sip_endpoint *endpoint = ast_sorcery_generic_alloc(sizeof(*endpoint), endpoint_destructor);
2460 if (!endpoint) {
2461 return NULL;
2462 }
2463 if (ast_string_field_init(endpoint, 128)) {
2464 ao2_cleanup(endpoint);
2465 return NULL;
2466 }
2467
2468 if (ast_string_field_init_extended(endpoint, geoloc_incoming_call_profile) ||
2469 ast_string_field_init_extended(endpoint, geoloc_outgoing_call_profile)) {
2470 ao2_cleanup(endpoint);
2471 return NULL;
2472 }
2473 if (ast_string_field_init_extended(endpoint, overlap_context)) {
2474 ao2_cleanup(endpoint);
2475 return NULL;
2476 }
2477 if (ast_string_field_init_extended(endpoint, tenantid)) {
2478 ao2_cleanup(endpoint);
2479 return NULL;
2480 }
2481
2483 ao2_cleanup(endpoint);
2484 return NULL;
2485 }
2487 ao2_cleanup(endpoint);
2488 return NULL;
2489 }
2490 if (init_info_configuration(&endpoint->info)) {
2491 ao2_cleanup(endpoint);
2492 return NULL;
2493 }
2494 if (init_media_configuration(&endpoint->media)) {
2495 ao2_cleanup(endpoint);
2496 return NULL;
2497 }
2498
2499 ast_party_id_init(&endpoint->id.self);
2500 endpoint->id.self.tag = ast_strdup("");
2501
2502 if (AST_VECTOR_INIT(&endpoint->ident_method_order, 1)) {
2503 return NULL;
2504 }
2505
2506 return endpoint;
2507}
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1776
@ AST_FORMAT_CAP_FLAG_DEFAULT
Definition: format_cap.h:38
#define ast_format_cap_alloc(flags)
Allocate a new ast_format_cap structure.
Definition: format_cap.h:49
static int init_info_configuration(struct ast_sip_endpoint_info_configuration *info)
static int init_media_configuration(struct ast_sip_endpoint_media_configuration *media)
static int init_subscription_configuration(struct ast_sip_endpoint_subscription_configuration *subscription)
static void endpoint_destructor(void *obj)
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359
#define ast_string_field_init_extended(x, field)
Initialize an extended string field.
Definition: stringfields.h:401
char * tag
User-set "tag".
Definition: channel.h:356
struct ast_party_id self
Definition: res_pjsip.h:767
struct ast_format_cap * codecs
Definition: res_pjsip.h:916
struct ast_sip_endpoint_id_configuration id
Definition: res_pjsip.h:997
struct ast_sip_identify_by_vector ident_method_order
Definition: res_pjsip.h:1011
struct ast_sip_endpoint_media_configuration media
Definition: res_pjsip.h:991
struct ast_sip_endpoint_subscription_configuration subscription
Definition: res_pjsip.h:993
struct ast_sip_endpoint_info_configuration info
Definition: res_pjsip.h:999

References ao2_cleanup, ast_format_cap_alloc, AST_FORMAT_CAP_FLAG_DEFAULT, ast_party_id_init(), ast_sorcery_generic_alloc(), ast_strdup, ast_string_field_init, ast_string_field_init_extended, AST_VECTOR_INIT, ast_sip_endpoint_media_configuration::codecs, endpoint_destructor(), ast_sip_endpoint::id, ast_sip_endpoint::ident_method_order, ast_sip_endpoint::info, init_info_configuration(), init_media_configuration(), init_subscription_configuration(), ast_sip_endpoint::media, NULL, ast_sip_endpoint_id_configuration::self, ast_sip_endpoint::subscription, and ast_party_id::tag.

Referenced by ast_res_pjsip_initialize_configuration().

◆ ast_sip_failover_request()

int ast_sip_failover_request ( pjsip_tx_data *  tdata)

Set a request to use the next value in the list of resolved addresses.

Parameters
tdatathe tx data from the original request
Return values
0No more addresses to try
1The request was successfully re-intialized

Definition at line 1816 of file res_pjsip.c.

1817{
1818 pjsip_via_hdr *via;
1819
1820 if (!tdata || !tdata->dest_info.addr.count
1821 || (tdata->dest_info.cur_addr == tdata->dest_info.addr.count - 1)) {
1822 /* No more addresses to try */
1823 return 0;
1824 }
1825
1826 /* Try next address */
1827 ++tdata->dest_info.cur_addr;
1828
1829 via = (pjsip_via_hdr*)pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
1830 via->branch_param.slen = 0;
1831
1832 pjsip_tx_data_invalidate_msg(tdata);
1833
1834 return 1;
1835}

References NULL, and send_request_wrapper::tdata.

Referenced by check_request_status(), and handle_registration_response().

◆ ast_sip_find_transport_state_in_use()

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.

Parameters
details
Return values
transport_state
Note
ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object

Definition at line 595 of file res_pjsip.c.

595 {
597
599 return NULL;
600 }
601
603}
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
static struct ao2_container * transport_states
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.
Definition: res_pjsip.c:576
struct ao2_container * ast_sip_get_transport_states(void)
Retrieves all transport states.
Generic container type.

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().

◆ ast_sip_for_each_aor()

int ast_sip_for_each_aor ( const char *  aors,
ao2_callback_fn  on_aor,
void *  arg 
)

For every aor in the comma separated aors string call the given 'on_aor' handler.

Parameters
aorsa comma separated list of aors
on_aorcallback for each aor
arguser data passed to handler
Return values
0Success, non-zero on failure

Definition at line 687 of file location.c.

688{
689 char *copy;
690 char *name;
691 int res;
692
693 if (!on_aor || ast_strlen_zero(aors)) {
694 return 0;
695 }
696
697 copy = ast_strdupa(aors);
698 while ((name = ast_strip(strsep(&copy, ",")))) {
699 struct ast_sip_aor *aor;
700
702 if (aor) {
703 res = on_aor(aor, arg, 0);
704 ao2_ref(aor, -1);
705 if (res) {
706 return -1;
707 }
708 }
709 }
710 return 0;
711}
static int copy(char *infile, char *outfile)
Utility function to copy a file.
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition: location.c:147
A SIP address of record.
Definition: res_pjsip.h:475

References ao2_ref, ast_sip_location_retrieve_aor(), ast_strdupa, ast_strip(), ast_strlen_zero(), copy(), name, and strsep().

Referenced by ami_registrations_endpoint(), ast_sip_location_retrieve_contacts_from_aor_list(), cli_aor_iterate(), format_ami_contact_status(), format_ami_endpoint_aor(), format_ami_endpoints(), mwi_new_subscribe(), and mwi_subscribe_all().

◆ ast_sip_for_each_auth()

int ast_sip_for_each_auth ( const struct ast_sip_auth_vector array,
ao2_callback_fn  on_auth,
void *  arg 
)

For every auth in the array call the given 'on_auth' handler.

Parameters
arrayan array of auths
on_authcallback for each auth
arguser data passed to handler
Return values
0Success, non-zero on failure

Definition at line 135 of file config_auth.c.

137{
138 int i;
139
140 if (!vector || !AST_VECTOR_SIZE(vector)) {
141 return 0;
142 }
143
144 for (i = 0; i < AST_VECTOR_SIZE(vector); ++i) {
145 /* AST_VECTOR_GET is safe to use since the vector is immutable */
148 AST_VECTOR_GET(vector,i)), ao2_cleanup);
149
150 if (!auth) {
151 continue;
152 }
153
154 if (on_auth(auth, arg, 0)) {
155 return -1;
156 }
157 }
158
159 return 0;
160}
#define SIP_SORCERY_AUTH_TYPE
Definition: res_pjsip.h:574
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.

References ao2_cleanup, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), AST_VECTOR_GET, AST_VECTOR_SIZE, RAII_VAR, and SIP_SORCERY_AUTH_TYPE.

Referenced by ast_sip_format_auths_ami(), and cli_iterator().

◆ ast_sip_for_each_channel()

int ast_sip_for_each_channel ( const struct ast_sip_endpoint endpoint,
ao2_callback_fn  on_channel_snapshot,
void *  arg 
)

For every channel snapshot on an endpoint all the given 'on_channel_snapshot' handler.

Parameters
endpointendpoint
on_channel_snapshotcallback for each channel snapshot
arguser data passed to handler
Return values
0Success, non-zero on failure

Definition at line 1690 of file pjsip_configuration.c.

1693{
1694 RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup);
1695 return ast_sip_for_each_channel_snapshot(endpoint_snapshot, on_channel_snapshot, arg);
1696}
int ast_sip_for_each_channel_snapshot(const struct ast_endpoint_snapshot *endpoint_snapshot, ao2_callback_fn on_channel_snapshot, void *arg)
For every channel snapshot on an endpoint snapshot call the given 'on_channel_snapshot' handler.
struct ast_endpoint_snapshot * ast_sip_get_endpoint_snapshot(const struct ast_sip_endpoint *endpoint)
Retrieve the endpoint snapshot for an endpoint.
A snapshot of an endpoint's state.

References ao2_cleanup, ast_sip_for_each_channel_snapshot(), ast_sip_get_endpoint_snapshot(), and RAII_VAR.

Referenced by cli_channel_iterate(), and cli_channelstats_iterate().

◆ ast_sip_for_each_channel_snapshot()

int ast_sip_for_each_channel_snapshot ( const struct ast_endpoint_snapshot endpoint_snapshot,
ao2_callback_fn  on_channel_snapshot,
void *  arg 
)

For every channel snapshot on an endpoint snapshot call the given 'on_channel_snapshot' handler.

Parameters
endpoint_snapshotsnapshot of an endpoint
on_channel_snapshotcallback for each channel snapshot
arguser data passed to handler
Return values
0Success, non-zero on failure

Definition at line 1663 of file pjsip_configuration.c.

1666{
1667 int num, num_channels = endpoint_snapshot->num_channels;
1668
1669 if (!on_channel_snapshot || !num_channels) {
1670 return 0;
1671 }
1672
1673 for (num = 0; num < num_channels; ++num) {
1674 RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
1675 int res;
1676
1677 snapshot = ast_channel_snapshot_get_latest(endpoint_snapshot->channel_ids[num]);
1678 if (!snapshot) {
1679 continue;
1680 }
1681
1682 res = on_channel_snapshot(snapshot, arg, 0);
1683 if (res) {
1684 return -1;
1685 }
1686 }
1687 return 0;
1688}
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object,...
Structure representing a snapshot of channel state.

References ao2_cleanup, ast_channel_snapshot_get_latest(), ast_endpoint_snapshot::channel_ids, NULL, ast_endpoint_snapshot::num_channels, and RAII_VAR.

Referenced by active_channels_to_str(), and ast_sip_for_each_channel().

◆ ast_sip_for_each_contact()

int ast_sip_for_each_contact ( const struct ast_sip_aor aor,
ao2_callback_fn  on_contact,
void *  arg 
)

For every contact on an AOR call the given 'on_contact' handler.

Parameters
aorthe aor containing a list of contacts to iterate
on_contactcallback on each contact on an AOR. The object received by the callback will be a ast_sip_contact_wrapper structure.
arguser data passed to handler
Return values
0Success, non-zero on failure

Definition at line 722 of file location.c.

724{
725 struct ao2_container *contacts;
726 struct ao2_iterator i;
727 int res = 0;
728 void *object = NULL;
729
730 if (!on_contact ||
731 !(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
732 return 0;
733 }
734
735 i = ao2_iterator_init(contacts, 0);
736 while ((object = ao2_iterator_next(&i))) {
737 RAII_VAR(struct ast_sip_contact *, contact, object, ao2_cleanup);
739 const char *aor_id = ast_sorcery_object_get_id(aor);
740
741 wrapper = ao2_alloc_options(sizeof(struct ast_sip_contact_wrapper),
743 if (!wrapper) {
744 res = -1;
745 break;
746 }
747 wrapper->contact_id = ast_malloc(strlen(aor_id) + strlen(contact->uri) + 2);
748 if (!wrapper->contact_id) {
749 res = -1;
750 break;
751 }
752 sprintf(wrapper->contact_id, "%s/%s", aor_id, contact->uri);
753 wrapper->aor_id = ast_strdup(aor_id);
754 if (!wrapper->aor_id) {
755 res = -1;
756 break;
757 }
758 wrapper->contact = contact;
759 ao2_bump(wrapper->contact);
760
761 if ((res = on_contact(wrapper, arg, 0))) {
762 break;
763 }
764 }
766 ao2_ref(contacts, -1);
767 return res;
768}
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:191
#define ao2_iterator_next(iter)
Definition: astobj2.h:1911
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition: astobj2.h:367
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:404
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static void contact_wrapper_destroy(void *obj)
Definition: location.c:713
struct ao2_container * ast_sip_location_retrieve_aor_contacts(const struct ast_sip_aor *aor)
Retrieve all contacts currently available for an AOR.
Definition: location.c:247
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821
Contact associated with an address of record.
Definition: res_pjsip.h:389

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_alloc_options, ao2_bump, ao2_cleanup, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_malloc, ast_sip_location_retrieve_aor_contacts(), ast_sorcery_object_get_id(), ast_strdup, contact_wrapper_destroy(), NULL, and RAII_VAR.

Referenced by ami_registrations_aor(), cli_aor_gather_contacts(), cli_contact_iterate(), contacts_to_str(), contacts_to_var_list(), format_contact_status_for_aor(), and sip_endpoints_aors_ami().

◆ ast_sip_format_auths_ami()

int ast_sip_format_auths_ami ( const struct ast_sip_auth_vector auths,
struct ast_sip_ami ami 
)

Format auth details for AMI.

Parameters
authsan auth array
amiami variable container
Return values
0Success, non-zero on failure

Definition at line 195 of file config_auth.c.

197{
199}
static int format_ami_auth_handler(void *obj, void *arg, int flags)
Definition: config_auth.c:168
int ast_sip_for_each_auth(const struct ast_sip_auth_vector *vector, ao2_callback_fn on_auth, void *arg)
For every auth in the array call the given 'on_auth' handler.
Definition: config_auth.c:135

References ast_sip_for_each_auth(), and format_ami_auth_handler().

Referenced by ami_outbound_registration_task(), and format_ami_endpoint_auth().

◆ ast_sip_format_contact_ami()

int ast_sip_format_contact_ami ( void *  obj,
void *  arg,
int  flags 
)

Formats the contact and sends over AMI.

Parameters
obja pointer an ast_sip_contact_wrapper structure
arga pointer to an ast_sip_ami structure
flagsignored
Return values
0Success, otherwise non-zero on error

Definition at line 2719 of file pjsip_options.c.

2720{
2721 struct ast_sip_contact_wrapper *wrapper = obj;
2722 struct ast_sip_contact *contact = wrapper->contact;
2723 struct ast_sip_ami *ami = arg;
2725 struct ast_str *buf;
2726 const struct ast_sip_endpoint *endpoint = ami->arg;
2727 char secs[AST_TIME_T_LEN];
2728
2729 buf = ast_sip_create_ami_event("ContactStatusDetail", ami);
2730 if (!buf) {
2731 return -1;
2732 }
2733
2735
2736 ast_str_append(&buf, 0, "AOR: %s\r\n", wrapper->aor_id);
2737 ast_str_append(&buf, 0, "URI: %s\r\n", contact->uri);
2738 ast_str_append(&buf, 0, "UserAgent: %s\r\n", contact->user_agent);
2739 ast_time_t_to_string(contact->expiration_time.tv_sec, secs, sizeof(secs));
2740 ast_str_append(&buf, 0, "RegExpire: %s\r\n", secs);
2741 if (!ast_strlen_zero(contact->via_addr)) {
2742 ast_str_append(&buf, 0, "ViaAddress: %s", contact->via_addr);
2743 if (contact->via_port) {
2744 ast_str_append(&buf, 0, ":%d", contact->via_port);
2745 }
2746 ast_str_append(&buf, 0, "\r\n");
2747 }
2748 if (!ast_strlen_zero(contact->call_id)) {
2749 ast_str_append(&buf, 0, "CallID: %s\r\n", contact->call_id);
2750 }
2751 ast_str_append(&buf, 0, "Status: %s\r\n",
2753 if (!status || status->status != AVAILABLE) {
2754 ast_str_append(&buf, 0, "RoundtripUsec: N/A\r\n");
2755 } else {
2756 ast_str_append(&buf, 0, "RoundtripUsec: %" PRId64 "\r\n", status->rtt);
2757 }
2758 ast_str_append(&buf, 0, "EndpointName: %s\r\n",
2759 endpoint ? ast_sorcery_object_get_id(endpoint) : S_OR(contact->endpoint_name, ""));
2760
2761 ast_str_append(&buf, 0, "ID: %s\r\n", ast_sorcery_object_get_id(contact));
2762 ast_str_append(&buf, 0, "AuthenticateQualify: %d\r\n", contact->authenticate_qualify);
2763 ast_str_append(&buf, 0, "OutboundProxy: %s\r\n", contact->outbound_proxy);
2764 ast_str_append(&buf, 0, "Path: %s\r\n", contact->path);
2765 ast_str_append(&buf, 0, "QualifyFrequency: %u\r\n", contact->qualify_frequency);
2766 ast_str_append(&buf, 0, "QualifyTimeout: %.3f\r\n", contact->qualify_timeout);
2767
2768 astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
2769 ami->count++;
2770
2771 ast_free(buf);
2773 return 0;
2774}
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:1890
struct ast_sip_contact_status * ast_sip_get_contact_status(const struct ast_sip_contact *contact)
Retrieve the current status for a contact.
const char * ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
translate ast_sip_contact_status_type to character string.
struct ast_str * ast_sip_create_ami_event(const char *event, struct ast_sip_ami *ami)
Creates a string to store AMI event data in.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80
AMI variable container.
Definition: res_pjsip.h:3046
void * arg
Definition: res_pjsip.h:3054
A contact's status.
Definition: res_pjsip.h:448
struct ast_sip_contact * contact
Definition: res_pjsip.h:520
const ast_string_field uri
Definition: res_pjsip.h:411
double qualify_timeout
Definition: res_pjsip.h:419
const ast_string_field via_addr
Definition: res_pjsip.h:411
const ast_string_field call_id
Definition: res_pjsip.h:411
const ast_string_field outbound_proxy
Definition: res_pjsip.h:411
struct timeval expiration_time
Definition: res_pjsip.h:413
const ast_string_field path
Definition: res_pjsip.h:411
const ast_string_field endpoint_name
Definition: res_pjsip.h:411
int authenticate_qualify
Definition: res_pjsip.h:417
const ast_string_field user_agent
Definition: res_pjsip.h:411
unsigned int qualify_frequency
Definition: res_pjsip.h:415
int ast_time_t_to_string(time_t time, char *buf, size_t length)
Converts to a string representation of a time_t as decimal seconds since the epoch....
Definition: time.c:152
#define AST_TIME_T_LEN
Definition: time.h:45

References ao2_cleanup, ast_sip_contact_wrapper::aor_id, ast_sip_ami::arg, ast_free, ast_sip_create_ami_event(), ast_sip_get_contact_status(), ast_sip_get_contact_status_label(), ast_sorcery_object_get_id(), ast_str_append(), ast_str_buffer(), ast_strlen_zero(), AST_TIME_T_LEN, ast_time_t_to_string(), astman_append(), ast_sip_contact::authenticate_qualify, AVAILABLE, buf, ast_sip_contact::call_id, ast_sip_contact_wrapper::contact, ast_sip_ami::count, ast_sip_contact::endpoint_name, ast_sip_contact::expiration_time, ast_sip_contact::outbound_proxy, ast_sip_contact::path, ast_sip_contact::qualify_frequency, ast_sip_contact::qualify_timeout, ast_sip_ami::s, S_OR, status, UNKNOWN, ast_sip_contact::uri, ast_sip_contact::user_agent, ast_sip_contact::via_addr, and ast_sip_contact::via_port.

Referenced by ami_show_registration_contact_statuses(), and format_contact_status_for_aor().

◆ ast_sip_format_endpoint_ami()

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.

Parameters
endpointthe endpoint to format and send
amiAMI variable container
countthe number of formatters operated on
Return values
0Success, otherwise non-zero on error

Definition at line 501 of file res_pjsip.c.

503{
504 int res = 0;
507 *count = 0;
509 if (i->format_ami && ((res = i->format_ami(endpoint, ami)) < 0)) {
510 return res;
511 }
512
513 if (!res) {
514 (*count)++;
515 }
516 }
517 return 0;
518}
ast_mutex_t lock
Definition: app_sla.c:331
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:494
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:583
An entity responsible formatting endpoint information.
Definition: res_pjsip.h:3072
int(* format_ami)(const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami)
Callback used to format endpoint information over AMI.
Definition: res_pjsip.h:3076

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().

◆ ast_sip_get_all_codecs_on_empty_reinvite()

unsigned int ast_sip_get_all_codecs_on_empty_reinvite ( void  )

Retrieve the system setting 'all_codecs_on_empty_reinvite'.

Return values
nonzero if we should return all codecs on empty re-INVITE

Definition at line 543 of file config_global.c.

544{
545 unsigned int all_codecs_on_empty_reinvite;
546 struct global_config *cfg;
547
548 cfg = get_global_cfg();
549 if (!cfg) {
551 }
552
554 ao2_ref(cfg, -1);
556}
static struct global_config * get_global_cfg(void)
#define DEFAULT_ALL_CODECS_ON_EMPTY_REINVITE
Definition: config_global.c:57
unsigned int all_codecs_on_empty_reinvite

References global_config::all_codecs_on_empty_reinvite, ao2_ref, DEFAULT_ALL_CODECS_ON_EMPTY_REINVITE, and get_global_cfg().

Referenced by session_inv_on_create_offer().

◆ ast_sip_get_allow_sending_180_after_183()

unsigned int ast_sip_get_allow_sending_180_after_183 ( void  )

Retrieve the global setting 'allow_sending_180_after_183'.

Return values
nonzero if disable.

Definition at line 453 of file config_global.c.

454{
455 unsigned int allow_sending_180_after_183;
456 struct global_config *cfg;
457
458 cfg = get_global_cfg();
459 if (!cfg) {
461 }
462
464 ao2_ref(cfg, -1);
466}
#define DEFAULT_ALLOW_SENDING_180_AFTER_183
Definition: config_global.c:51
unsigned int allow_sending_180_after_183
Definition: config_global.c:98

References global_config::allow_sending_180_after_183, ao2_ref, DEFAULT_ALLOW_SENDING_180_AFTER_183, and get_global_cfg().

Referenced by chan_pjsip_indicate().

◆ ast_sip_get_artificial_auth()

struct ast_sip_auth * ast_sip_get_artificial_auth ( void  )

Retrieves a reference to the artificial auth.

Return values
Theartificial auth

Definition at line 628 of file pjsip_distributor.c.

629{
630 return ao2_global_obj_ref(artificial_auth);
631}
#define ao2_global_obj_ref(holder)
Get a reference to the object stored in the global holder.
Definition: astobj2.h:918

References ao2_global_obj_ref.

Referenced by digest_check_auth(), and global_loaded().

◆ ast_sip_get_artificial_endpoint()

struct ast_sip_endpoint * ast_sip_get_artificial_endpoint ( void  )

Retrieves a reference to the artificial endpoint.

Return values
Theartificial endpoint

Definition at line 651 of file pjsip_distributor.c.

652{
654 return artificial_endpoint;
655}
static struct ast_sip_endpoint * artificial_endpoint

References ao2_ref, and artificial_endpoint.

Referenced by digest_check_auth(), digest_requires_authentication(), endpoint_lookup(), and get_account_id().

◆ ast_sip_get_contact_expiration_check_interval()

unsigned int ast_sip_get_contact_expiration_check_interval ( void  )

Retrieve the system contact expiration check interval setting.

Return values
thecontact expiration check interval.

Definition at line 315 of file config_global.c.

316{
317 unsigned int interval;
318 struct global_config *cfg;
319
320 cfg = get_global_cfg();
321 if (!cfg) {
323 }
324
325 interval = cfg->contact_expiration_check_interval;
326 ao2_ref(cfg, -1);
327 return interval;
328}
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL
Definition: config_global.c:42
unsigned int contact_expiration_check_interval
Definition: config_global.c:94

References ao2_ref, global_config::contact_expiration_check_interval, DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL, and get_global_cfg().

Referenced by expiration_global_loaded().

◆ ast_sip_get_contact_short_status_label()

const char * ast_sip_get_contact_short_status_label ( const enum ast_sip_contact_status_type  status)

Definition at line 339 of file pjsip_options.c.

340{
342 return short_status_map[status];
343}
static const char * short_status_map[]
#define ARRAY_LEN(a)
Definition: utils.h:666

References ARRAY_LEN, ast_assert, short_status_map, and status.

Referenced by cli_contact_print_body().

◆ ast_sip_get_contact_sip_uri()

pjsip_sip_uri * ast_sip_get_contact_sip_uri ( pjsip_tx_data *  tdata)

Return the SIP URI of the Contact header.

Parameters
tdata
Return values
Pointerto SIP URI of Contact
NULLif Contact header not found or not a SIP(S) URI
Note
Do not free the returned object.

Definition at line 564 of file res_pjsip.c.

565{
566 pjsip_contact_hdr *contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL);
567
568 if (!contact || (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
569 return NULL;
570 }
571
572 return pjsip_uri_get_uri(contact->uri);
573}

References NULL.

Referenced by ast_sip_rewrite_uri_to_local(), ast_sip_set_request_transport_details(), and process_nat().

◆ ast_sip_get_contact_status()

struct ast_sip_contact_status * ast_sip_get_contact_status ( const struct ast_sip_contact contact)

Retrieve the current status for a contact.

Parameters
contactThe contact.
Return values
non-NULLSuccess
NULLStatus information not found
Note
The returned contact status object is immutable.

Definition at line 525 of file pjsip_options.c.

526{
529}
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
static struct ao2_container * sip_options_contact_statuses

References ao2_find, ast_sorcery_object_get_id(), OBJ_SEARCH_KEY, and sip_options_contact_statuses.

Referenced by add_outgoing_request_headers(), ast_sip_format_contact_ami(), cli_contact_print_body(), contact_add_security_headers_to_status(), contact_has_security_mechanisms(), contact_remove_unreachable(), format_ami_contactlist_handler(), pjsip_contact_function_read(), registrar_add_unreachable(), rfc3329_incoming_response(), sip_options_contact_update_task(), and vec_contact_cmp().

◆ ast_sip_get_contact_status_label()

const char * ast_sip_get_contact_status_label ( const enum ast_sip_contact_status_type  status)

◆ ast_sip_get_debug()

char * ast_sip_get_debug ( void  )

Retrieve the system debug setting (yes|no|host).

Note
returned string needs to be de-allocated by caller.
Return values
thesystem debug setting.

Definition at line 238 of file config_global.c.

239{
240 char *res;
241 struct global_config *cfg;
242
243 cfg = get_global_cfg();
244 if (!cfg) {
246 }
247
248 res = ast_strdup(cfg->debug);
249 ao2_ref(cfg, -1);
250 return res;
251}
#define DEFAULT_DEBUG
Definition: config_global.c:36
const ast_string_field debug
Definition: config_global.c:86

References ao2_ref, ast_strdup, global_config::debug, DEFAULT_DEBUG, and get_global_cfg().

Referenced by check_debug().

◆ ast_sip_get_default_from_user()

void ast_sip_get_default_from_user ( char *  from_user,
size_t  size 
)

Retrieve the global default from user.

This is the value placed in outbound requests' From header if there is no better option (such as an endpoint-configured from_user or caller ID number).

Parameters
[out]from_userThe default from user
sizeThe buffer size of from_user

Definition at line 394 of file config_global.c.

395{
396 struct global_config *cfg;
397
398 cfg = get_global_cfg();
399 if (!cfg) {
400 ast_copy_string(from_user, DEFAULT_FROM_USER, size);
401 } else {
402 ast_copy_string(from_user, cfg->default_from_user, size);
403 ao2_ref(cfg, -1);
404 }
405}
#define DEFAULT_FROM_USER
Definition: config_global.c:39
const ast_string_field default_from_user
Definition: config_global.c:86

References ao2_ref, ast_copy_string(), DEFAULT_FROM_USER, global_config::default_from_user, and get_global_cfg().

Referenced by sip_dialog_create_from().

◆ ast_sip_get_default_realm()

void ast_sip_get_default_realm ( char *  realm,
size_t  size 
)

Retrieve the global default realm.

This is the value placed in outbound challenges' realm if there is no better option (such as an auth-configured realm).

Parameters
[out]realmThe default realm
sizeThe buffer size of realm

Definition at line 381 of file config_global.c.

382{
383 struct global_config *cfg;
384
385 cfg = get_global_cfg();
386 if (!cfg) {
387 ast_copy_string(realm, DEFAULT_REALM, size);
388 } else {
389 ast_copy_string(realm, cfg->default_realm, size);
390 ao2_ref(cfg, -1);
391 }
392}
#define DEFAULT_REALM
Definition: config_global.c:40
const ast_string_field default_realm
Definition: config_global.c:86

References ao2_ref, ast_copy_string(), DEFAULT_REALM, global_config::default_realm, and get_global_cfg().

Referenced by create_artificial_auth(), and global_loaded().

◆ ast_sip_get_default_voicemail_extension()

char * ast_sip_get_default_voicemail_extension ( void  )

Retrieve the default voicemail extension.

Since
13.9.0
Note
returned string needs to be de-allocated by caller.
Return values
thedefault voicemail extension

Definition at line 269 of file config_global.c.

270{
271 char *res;
272 struct global_config *cfg;
273
274 cfg = get_global_cfg();
275 if (!cfg) {
277 }
278
280 ao2_ref(cfg, -1);
281
282 return res;
283}
#define DEFAULT_VOICEMAIL_EXTENSION
Definition: config_global.c:44
const ast_string_field default_voicemail_extension
Definition: config_global.c:86

References ao2_ref, ast_strdup, DEFAULT_VOICEMAIL_EXTENSION, global_config::default_voicemail_extension, and get_global_cfg().

Referenced by global_loaded().

◆ ast_sip_get_device_state()

const char * ast_sip_get_device_state ( const struct ast_sip_endpoint endpoint)

Retrieve the device state for an endpoint.

Parameters
endpointThe endpoint whose state is to be retrieved.
Return values
Thedevice state.

Definition at line 1647 of file pjsip_configuration.c.

1648{
1649 char device[MAX_OBJECT_FIELD];
1650
1651 snprintf(device, MAX_OBJECT_FIELD, "PJSIP/%s", ast_sorcery_object_get_id(endpoint));
1652 return ast_devstate2str(ast_device_state(device));
1653}
const char * ast_devstate2str(enum ast_device_state devstate) attribute_pure
Convert device state to text string for output.
Definition: devicestate.c:237
ast_device_state
Device States.
Definition: devicestate.h:52

References ast_devstate2str(), ast_sorcery_object_get_id(), and MAX_OBJECT_FIELD.

Referenced by cli_endpoint_print_body(), format_ami_endpoints(), and sip_endpoint_to_ami().

◆ ast_sip_get_disable_multi_domain()

unsigned int ast_sip_get_disable_multi_domain ( void  )

Retrieve the system setting 'disable multi domain'.

Since
13.9.0
Return values
nonzero if disable multi domain.

Definition at line 330 of file config_global.c.

331{
332 unsigned int disable_multi_domain;
333 struct global_config *cfg;
334
335 cfg = get_global_cfg();
336 if (!cfg) {
338 }
339
341 ao2_ref(cfg, -1);
343}
#define DEFAULT_DISABLE_MULTI_DOMAIN
Definition: config_global.c:43
unsigned int disable_multi_domain
Definition: config_global.c:96

References ao2_ref, DEFAULT_DISABLE_MULTI_DOMAIN, global_config::disable_multi_domain, and get_global_cfg().

Referenced by anonymous_identify(), find_endpoint(), request(), and sip_dialog_create_from().

◆ ast_sip_get_endpoint()

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?
Parameters
to'To' field with possible endpoint
get_default_outboundIf nonzero, try to retrieve the default outbound endpoint if no endpoint was found. Otherwise, return NULL if no endpoint was found.
uriPointer 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!
Note
The logic below could probably be condensed but then it wouldn't be as clear.

Definition at line 3249 of file res_pjsip.c.

3250{
3251 char *destination;
3252 char *slash = NULL;
3253 char *atsign = NULL;
3254 char *scheme = NULL;
3255 struct ast_sip_endpoint *endpoint = NULL;
3256
3257 destination = ast_strdupa(to);
3258
3259 slash = strchr(destination, '/');
3260 atsign = strchr(destination, '@');
3261 scheme = S_OR(strstr(destination, "sip:"), strstr(destination, "sips:"));
3262
3263 if (!slash && !atsign && !scheme) {
3264 /*
3265 * If there's only a single token, it can be either...
3266 * endpoint
3267 * host
3268 */
3269 return handle_single_token(to, destination, get_default_outbound, uri);
3270 }
3271
3272 if (slash) {
3273 /*
3274 * If there's a '/', then the form must be one of the following...
3275 * PJSIP/user@endpoint
3276 * endpoint/aor
3277 * endpoint/uri
3278 */
3279 return handle_slash(to, destination, uri, slash, atsign, scheme);
3280 }
3281
3282 if (atsign && !scheme) {
3283 /*
3284 * If there's an '@' but no scheme then it's either following an endpoint name
3285 * and being followed by a domain name (which we discard).
3286 * OR is's a user@host uri without a scheme. It's probably the latter but because
3287 * endpoint@domain looks just like user@host, we'll test for endpoint first.
3288 */
3289 return handle_atsign(to, destination, uri, slash, atsign, scheme, get_default_outbound);
3290 }
3291
3292 /*
3293 * If all else fails, we assume it's a URI or just a hostname.
3294 */
3295 if (scheme) {
3296 *uri = ast_strdup(destination);
3297 if (!(*uri)) {
3298 goto failure;
3299 }
3300 ast_debug(3, "Dest: '%s' Didn't find an endpoint but did find a scheme so using URI '%s'%s\n",
3301 to, *uri, get_default_outbound ? " with default endpoint" : "");
3302 } else {
3303 *uri = ast_malloc(strlen(destination) + strlen("sip:") + 1);
3304 if (!(*uri)) {
3305 goto failure;
3306 }
3307 sprintf(*uri, "sip:%s", destination);
3308 ast_debug(3, "Dest: '%s' Didn't find an endpoint and didn't find scheme so adding scheme and using URI '%s'%s\n",
3309 to, *uri, get_default_outbound ? " with default endpoint" : "");
3310 }
3311 if (get_default_outbound) {
3313 }
3314
3315 return endpoint;
3316
3317failure:
3318 ao2_cleanup(endpoint);
3319 *uri = NULL;
3320 return NULL;
3321}
#define ast_debug(level,...)
Log a DEBUG message.
static struct ast_sip_endpoint * handle_slash(const char *to, char *destination, char **uri, char *slash, char *atsign, char *scheme)
Definition: res_pjsip.c:3034
static struct ast_sip_endpoint * handle_single_token(const char *to, char *destination, int get_default_outbound, char **uri)
Definition: res_pjsip.c:2955
static struct ast_sip_endpoint * handle_atsign(const char *to, char *destination, char **uri, char *slash, char *atsign, char *scheme, int get_default_outbound)
Definition: res_pjsip.c:3191
struct ast_sip_endpoint * ast_sip_default_outbound_endpoint(void)
Retrieve the default outbound endpoint.

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().

◆ ast_sip_get_endpoint_identifier_order()

char * ast_sip_get_endpoint_identifier_order ( void  )

Retrieve the global endpoint_identifier_order setting.

Specifies the order by which endpoint identifiers should be regarded.

Return values
theglobal endpoint_identifier_order value

Definition at line 285 of file config_global.c.

286{
287 char *res;
288 struct global_config *cfg;
289
290 cfg = get_global_cfg();
291 if (!cfg) {
293 }
294
296 ao2_ref(cfg, -1);
297 return res;
298}
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER
Definition: config_global.c:37
const ast_string_field endpoint_identifier_order
Definition: config_global.c:86

References ao2_ref, ast_strdup, DEFAULT_ENDPOINT_IDENTIFIER_ORDER, global_config::endpoint_identifier_order, and get_global_cfg().

Referenced by ast_sip_register_endpoint_identifier_with_name(), and global_loaded().

◆ ast_sip_get_endpoint_snapshot()

struct ast_endpoint_snapshot * ast_sip_get_endpoint_snapshot ( const struct ast_sip_endpoint endpoint)

Retrieve the endpoint snapshot for an endpoint.

Parameters
endpointThe endpoint whose snapshot is to be retrieved.
Return values
Theendpoint snapshot

Definition at line 1655 of file pjsip_configuration.c.

1657{
1661}
const char * ast_endpoint_get_tech(const struct ast_endpoint *endpoint)
Gets the technology of the given endpoint.
const char * ast_endpoint_get_resource(const struct ast_endpoint *endpoint)
Gets the resource name of the given endpoint.
struct ast_endpoint_snapshot * ast_endpoint_latest_snapshot(const char *tech, const char *resource)
Retrieve the most recent snapshot for the endpoint with the given name.
struct ast_endpoint * persistent
Definition: res_pjsip.h:1015

References ast_endpoint_get_resource(), ast_endpoint_get_tech(), ast_endpoint_latest_snapshot(), and ast_sip_endpoint::persistent.

Referenced by active_channels_to_str(), ast_sip_for_each_channel(), and cli_endpoint_print_body().

◆ ast_sip_get_endpoints()

struct ao2_container * ast_sip_get_endpoints ( void  )

Retrieve any endpoints available to sorcery.

Return values
Endpointsavailable to sorcery, NULL if no endpoints found.

Definition at line 2509 of file pjsip_configuration.c.

2510{
2511 struct ao2_container *endpoints;
2512
2514
2515 return endpoints;
2516}
static struct ao2_container * endpoints
@ AST_RETRIEVE_FLAG_MULTIPLE
Return all matching objects.
Definition: sorcery.h:120
@ AST_RETRIEVE_FLAG_ALL
Perform no matching, return all objects.
Definition: sorcery.h:123
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
Definition: sorcery.c:1897

References AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sorcery_retrieve_by_fields(), endpoints, NULL, and sip_sorcery.

Referenced by ami_registrations_endpoints(), ami_show_endpoints(), and load_module().

◆ ast_sip_get_host_ip()

int ast_sip_get_host_ip ( int  af,
pj_sockaddr *  addr 
)

Retrieve the local host address in IP form.

Parameters
afThe address family to retrieve
addrA place to store the local host address
Return values
0success
-1failure
Since
13.6.0

Definition at line 2480 of file res_pjsip.c.

2481{
2482 if (af == pj_AF_INET() && !ast_strlen_zero(host_ip_ipv4_string)) {
2483 pj_sockaddr_copy_addr(addr, &host_ip_ipv4);
2484 return 0;
2485 } else if (af == pj_AF_INET6() && !ast_strlen_zero(host_ip_ipv6_string)) {
2486 pj_sockaddr_copy_addr(addr, &host_ip_ipv6);
2487 return 0;
2488 }
2489
2490 return -1;
2491}
static pj_sockaddr host_ip_ipv4
Definition: res_pjsip.c:79
static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN]
Definition: res_pjsip.c:88
static pj_sockaddr host_ip_ipv6
Definition: res_pjsip.c:85
static char host_ip_ipv4_string[PJ_INET6_ADDRSTRLEN]
Definition: res_pjsip.c:82

References ast_strlen_zero(), host_ip_ipv4, host_ip_ipv4_string, host_ip_ipv6, and host_ip_ipv6_string.

◆ ast_sip_get_host_ip_string()

const char * ast_sip_get_host_ip_string ( int  af)

Retrieve the local host address in string form.

Parameters
afThe address family to retrieve
Return values
non-NULLsuccess
NULLfailure
Since
13.6.0
Note
An empty string may be returned if the address family is valid but no local address exists

Definition at line 2493 of file res_pjsip.c.

2494{
2495 if (af == pj_AF_INET()) {
2496 return host_ip_ipv4_string;
2497 } else if (af == pj_AF_INET6()) {
2498 return host_ip_ipv6_string;
2499 }
2500
2501 return NULL;
2502}

References host_ip_ipv4_string, host_ip_ipv6_string, and NULL.

Referenced by create_local_sdp(), create_outgoing_sdp_stream(), and multihomed_rewrite_sdp().

◆ ast_sip_get_ignore_uri_user_options()

unsigned int ast_sip_get_ignore_uri_user_options ( void  )

Retrieve the global setting 'ignore_uri_user_options'.

Since
13.12.0
Return values
nonzero if ignore the user field options.

Definition at line 468 of file config_global.c.

469{
470 unsigned int ignore_uri_user_options;
471 struct global_config *cfg;
472
473 cfg = get_global_cfg();
474 if (!cfg) {
476 }
477
479 ao2_ref(cfg, -1);
481}
#define DEFAULT_IGNORE_URI_USER_OPTIONS
Definition: config_global.c:52
unsigned int ignore_uri_user_options

References ao2_ref, DEFAULT_IGNORE_URI_USER_OPTIONS, get_global_cfg(), and global_config::ignore_uri_user_options.

Referenced by find_registrar_aor().

◆ ast_sip_get_keep_alive_interval()

unsigned int ast_sip_get_keep_alive_interval ( void  )

Retrieve the system keep alive interval setting.

Return values
thekeep alive interval.

Definition at line 300 of file config_global.c.

301{
302 unsigned int interval;
303 struct global_config *cfg;
304
305 cfg = get_global_cfg();
306 if (!cfg) {
308 }
309
310 interval = cfg->keep_alive_interval;
311 ao2_ref(cfg, -1);
312 return interval;
313}
#define DEFAULT_KEEPALIVE_INTERVAL
Definition: config_global.c:33
unsigned int keep_alive_interval
Definition: config_global.c:90

References ao2_ref, DEFAULT_KEEPALIVE_INTERVAL, get_global_cfg(), and global_config::keep_alive_interval.

Referenced by keepalive_global_loaded().

◆ ast_sip_get_max_initial_qualify_time()

unsigned int ast_sip_get_max_initial_qualify_time ( void  )

Retrieve the system max initial qualify time.

Return values
themaximum initial qualify time.

Definition at line 345 of file config_global.c.

346{
347 unsigned int time;
348 struct global_config *cfg;
349
350 cfg = get_global_cfg();
351 if (!cfg) {
353 }
354
355 time = cfg->max_initial_qualify_time;
356 ao2_ref(cfg, -1);
357 return time;
358}
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME
Definition: config_global.c:38
unsigned int max_initial_qualify_time
Definition: config_global.c:92

References ao2_ref, DEFAULT_MAX_INITIAL_QUALIFY_TIME, get_global_cfg(), and global_config::max_initial_qualify_time.

Referenced by sip_options_determine_initial_qualify_time().

◆ ast_sip_get_mwi_disable_initial_unsolicited()

unsigned int ast_sip_get_mwi_disable_initial_unsolicited ( void  )

Retrieve the global setting 'disable sending unsolicited mwi on startup'.

Since
13.12.0
Return values
nonzero if disable.

Definition at line 438 of file config_global.c.

439{
440 unsigned int disable_initial_unsolicited;
441 struct global_config *cfg;
442
443 cfg = get_global_cfg();
444 if (!cfg) {
446 }
447
449 ao2_ref(cfg, -1);
451}
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED
Definition: config_global.c:50
unsigned int disable_initial_unsolicited
struct global_config::@451 mwi

References ao2_ref, DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED, global_config::disable_initial_unsolicited, get_global_cfg(), and global_config::mwi.

Referenced by load_module(), and reload().

◆ ast_sip_get_mwi_tps_queue_high()

unsigned int ast_sip_get_mwi_tps_queue_high ( void  )

Retrieve the global MWI taskprocessor high water alert trigger level.

Since
13.12.0
Return values
thesystem MWI taskprocessor high water alert trigger level

Definition at line 408 of file config_global.c.

409{
410 unsigned int tps_queue_high;
411 struct global_config *cfg;
412
413 cfg = get_global_cfg();
414 if (!cfg) {
416 }
417
419 ao2_ref(cfg, -1);
420 return tps_queue_high;
421}
#define DEFAULT_MWI_TPS_QUEUE_HIGH
Definition: config_global.c:48
unsigned int tps_queue_high

References ao2_ref, DEFAULT_MWI_TPS_QUEUE_HIGH, get_global_cfg(), global_config::mwi, and global_config::tps_queue_high.

Referenced by global_loaded().

◆ ast_sip_get_mwi_tps_queue_low()

int ast_sip_get_mwi_tps_queue_low ( void  )

Retrieve the global MWI taskprocessor low water clear alert level.

Since
13.12.0
Return values
thesystem MWI taskprocessor low water clear alert level

Definition at line 423 of file config_global.c.

424{
425 int tps_queue_low;
426 struct global_config *cfg;
427
428 cfg = get_global_cfg();
429 if (!cfg) {
431 }
432
434 ao2_ref(cfg, -1);
435 return tps_queue_low;
436}
#define DEFAULT_MWI_TPS_QUEUE_LOW
Definition: config_global.c:49

References ao2_ref, DEFAULT_MWI_TPS_QUEUE_LOW, get_global_cfg(), global_config::mwi, and global_config::tps_queue_low.

Referenced by global_loaded().

◆ ast_sip_get_norefersub()

unsigned int ast_sip_get_norefersub ( void  )

Retrieve the global setting 'norefersub'.

Return values
nonzero if norefersub is to be sent in "Supported" Headers

Definition at line 528 of file config_global.c.

529{
530 unsigned int norefersub;
531 struct global_config *cfg;
532
533 cfg = get_global_cfg();
534 if (!cfg) {
535 return DEFAULT_NOREFERSUB;
536 }
537
538 norefersub = cfg->norefersub;
539 ao2_ref(cfg, -1);
540 return norefersub;
541}
#define DEFAULT_NOREFERSUB
Definition: config_global.c:56
unsigned int norefersub

References ao2_ref, DEFAULT_NOREFERSUB, get_global_cfg(), and global_config::norefersub.

Referenced by load_module().

◆ ast_sip_get_pjsip_endpoint()

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.

Return values
NULLendpoint has not been created yet.
non-NULLPJSIP endpoint.

Definition at line 520 of file res_pjsip.c.

521{
522 return ast_pjsip_endpoint;
523}
static pjsip_endpoint * ast_pjsip_endpoint
Definition: res_pjsip.c:74

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().

◆ ast_sip_get_regcontext()

char * ast_sip_get_regcontext ( void  )

Retrieve the global regcontext setting.

Since
13.8.0
Note
returned string needs to be de-allocated by caller.
Return values
theglobal regcontext setting

Definition at line 253 of file config_global.c.

254{
255 char *res;
256 struct global_config *cfg;
257
258 cfg = get_global_cfg();
259 if (!cfg) {
261 }
262
263 res = ast_strdup(cfg->regcontext);
264 ao2_ref(cfg, -1);
265
266 return res;
267}
#define DEFAULT_REGCONTEXT
Definition: config_global.c:41
const ast_string_field regcontext
Definition: config_global.c:86

References ao2_ref, ast_strdup, DEFAULT_REGCONTEXT, get_global_cfg(), and global_config::regcontext.

Referenced by ast_sip_persistent_endpoint_update_state().

◆ ast_sip_get_send_contact_status_on_update_registration()

unsigned int ast_sip_get_send_contact_status_on_update_registration ( void  )

Retrieve the global setting 'send_contact_status_on_update_registration'.

Since
16.2.0
Return values
nonzero if need to send AMI ContactStatus event when a contact is updated.

Definition at line 498 of file config_global.c.

499{
500 unsigned int send_contact_status_on_update_registration;
501 struct global_config *cfg;
502
503 cfg = get_global_cfg();
504 if (!cfg) {
506 }
507
509 ao2_ref(cfg, -1);
511}
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION
Definition: config_global.c:54
unsigned int send_contact_status_on_update_registration

References ao2_ref, DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION, get_global_cfg(), and global_config::send_contact_status_on_update_registration.

Referenced by contact_observer_updated().

◆ ast_sip_get_sorcery()

struct ast_sorcery * ast_sip_get_sorcery ( void  )

Get a pointer to the SIP sorcery structure.

Return values
NULLsorcery has not been initialized
non-NULLsorcery structure

Definition at line 2569 of file pjsip_configuration.c.

2570{
2571 return sip_sorcery;
2572}

References sip_sorcery.

Referenced by acl_change_stasis_cb(), acl_on_rx_msg(), add_security_headers(), alloc_artificial_auth(), ami_show_endpoint(), ami_show_registration_contact_statuses(), ami_show_resource_lists(), ami_sip_qualify(), anonymous_identify(), aor_deleted_observer(), ast_res_pjsip_cleanup_options_handling(), ast_sip_cli_print_sorcery_objectset(), ast_sip_destroy_distributor(), ast_sip_destroy_sorcery_global(), ast_sip_destroy_sorcery_location(), ast_sip_destroy_transport_management(), ast_sip_for_each_auth(), ast_sip_initialize_distributor(), ast_sip_initialize_sorcery_auth(), ast_sip_initialize_sorcery_domain_alias(), ast_sip_initialize_sorcery_global(), ast_sip_initialize_sorcery_location(), ast_sip_initialize_sorcery_transport(), ast_sip_initialize_transport_management(), ast_sip_location_create_contact(), ast_sip_location_delete_contact(), ast_sip_location_prune_boot_contacts(), ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_aor_contacts_nolock_filtered(), ast_sip_location_retrieve_contact(), ast_sip_location_update_contact(), ast_sip_retrieve_auths(), ast_sip_retrieve_auths_vector(), ast_sip_rewrite_uri_to_local(), ast_sip_set_tpselector_from_transport_name(), ast_sip_sorcery_object_to_ami(), asterisk_publication_devicestate_state_change(), asterisk_publication_mwi_state_change(), asterisk_publication_new(), asterisk_publication_send_refresh(), auth_observer(), can_reuse_registration(), chan_pjsip_devicestate(), check_expiration_thread(), check_state(), cli_aor_get_container(), cli_aor_retrieve_by_id(), cli_complete_endpoint(), cli_complete_registration(), cli_contact_get_container(), cli_endpoint_retrieve_by_id(), cli_get_aors(), cli_get_auths(), cli_get_container(), cli_iterate(), cli_iterator(), cli_qualify(), cli_reload_qualify_aor(), cli_reload_qualify_endpoint(), cli_retrieve_by_id(), cli_show_qualify_endpoint(), common_identify(), contact_observer_updated(), create_artificial_endpoint(), create_mwi_subscriptions(), create_rtp(), find_aor2(), find_aor_name(), find_endpoint(), format_ami_endpoint_identify(), format_ami_endpoint_transport(), get_all_contacts(), get_publishes_and_update_state(), get_registrations(), get_write_timeout(), handle_atsign(), handle_export_primitives(), handle_registration_response(), handle_single_token(), handle_slash(), line_identify(), load_module(), mwi_contact_changed(), mwi_contact_deleted(), mwi_subscription_shutdown(), on_rx_process_symmetric_transport(), permanent_uri_handler(), pjsip_acf_dial_contacts_read(), pjsip_aor_function_read(), pjsip_contact_function_read(), pjsip_endpoint_function_read(), pjsip_outbound_registration_metrics_init(), pjsip_outbound_registration_metrics_unload_cb(), process_nat(), publish_request_initial(), push_notify(), reload_module(), request(), reregister_all(), retrieve_resource_list(), send_unsolicited_mwi_notify(), sip_aor_to_ami(), sip_cli_print_global(), sip_options_aor_observer_modified_task(), sip_options_apply_aor_configuration(), sip_options_contact_add_management_task(), sip_options_init_task(), sip_options_qualify_contact(), sip_options_synchronize_task(), sub_persistence_recreate(), subscription_persistence_create(), subscription_persistence_load(), subscription_persistence_recreate(), subscription_persistence_remove(), subscription_persistence_update(), t38_initialize_session(), transfer(), and unload_module().

◆ ast_sip_get_transport_name()

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.

Since
13.15.0
Parameters
endpoint
sip_uri
bufBuffer to receive transport name
buf_lenBuffer length
Return values
0Success
-1Failure
Note
If endpoint->transport is not NULL, it is returned in buf. Otherwise if sip_uri has an 'x-ast-txp' parameter AND the sip_uri host is an ip4 or ip6 address, its value is returned,

Definition at line 698 of file res_pjsip.c.

700{
701 char *host = NULL;
702 static const pj_str_t x_name = { AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN };
703 pjsip_param *x_transport;
704
705 if (!ast_strlen_zero(endpoint->transport)) {
706 ast_copy_string(buf, endpoint->transport, buf_len);
707 return 0;
708 }
709
710 x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
711 if (!x_transport) {
712 return -1;
713 }
714
715 /* Only use x_transport if the uri host is an ip (4 or 6) address */
716 host = ast_alloca(sip_uri->host.slen + 1);
717 ast_copy_pj_str(host, &sip_uri->host, sip_uri->host.slen + 1);
719 return -1;
720 }
721
722 ast_copy_pj_str(buf, &x_transport->value, buf_len);
723
724 return 0;
725}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Definition: netsock2.c:230
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.
Definition: res_pjsip.c:2201
#define AST_SIP_X_AST_TXP
Definition: res_pjsip.h:1077
#define AST_SIP_X_AST_TXP_LEN
Definition: res_pjsip.h:1078
const ast_string_field transport
Definition: res_pjsip.h:987

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().

◆ ast_sip_get_transport_state()

struct ast_sip_transport_state * ast_sip_get_transport_state ( const char *  transport_id)

Retrieve transport state.

Since
13.7.1
Parameters
transport_id
Return values
transport_state
Note
ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object

Definition at line 1744 of file config_transport.c.

1745{
1746 struct internal_state *state = NULL;
1747 struct ast_sip_transport_state *trans_state;
1748
1749 if (!transport_states) {
1750 return NULL;
1751 }
1752
1754 if (!state) {
1755 return NULL;
1756 }
1757
1758 trans_state = ao2_bump(state->state);
1759 ao2_ref(state, -1);
1760
1761 /* If this is a child transport see if the transport is actually dead */
1762 if (trans_state->flow) {
1763 ao2_lock(trans_state);
1764 if (trans_state->transport && trans_state->transport->is_shutdown == PJ_TRUE) {
1765 pjsip_transport_dec_ref(trans_state->transport);
1766 trans_state->transport = NULL;
1767 }
1768 ao2_unlock(trans_state);
1769 }
1770
1771 return trans_state;
1772}
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
Structure for SIP transport information.
Definition: res_pjsip.h:116
struct pjsip_transport * transport
Transport itself.
Definition: res_pjsip.h:118

References ao2_bump, ao2_find, ao2_lock, ao2_ref, ao2_unlock, ast_sip_transport_state::flow, NULL, OBJ_SEARCH_KEY, ast_sip_transport_state::transport, and transport_states.

Referenced by ast_sip_message_apply_transport(), ast_sip_set_tpselector_from_transport(), ast_sip_transport_state_set_preferred_identity(), ast_sip_transport_state_set_service_routes(), ast_sip_transport_state_set_transport(), change_outgoing_sdp_stream_media_address(), create_rtp(), session_outgoing_nat_hook(), t38_initialize_session(), and transport_tls_verify().

◆ ast_sip_get_transport_states()

struct ao2_container * ast_sip_get_transport_states ( void  )

Retrieves all transport states.

Since
13.7.1
Return values
ao2_container
Note
ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object

Definition at line 1784 of file config_transport.c.

1785{
1788
1789 if (!states) {
1790 return NULL;
1791 }
1792
1794 return states;
1795}
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_MULTIPLE
Definition: astobj2.h:1049
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
static int transport_state_hash(const void *obj, const int flags)
hashing function for state objects
static int transport_state_cmp(void *obj, void *arg, int flags)
comparator function for state objects
#define DEFAULT_STATE_BUCKETS
Default number of state container buckets.
static int populate_transport_states(void *obj, void *arg, int flags)

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_callback, ao2_container_alloc_hash, DEFAULT_STATE_BUCKETS, NULL, OBJ_MULTIPLE, OBJ_NODATA, populate_transport_states(), transport_state_cmp(), transport_state_hash(), and transport_states.

Referenced by anonymous_identify(), ast_sip_find_transport_state_in_use(), find_endpoint(), get_udp_transport(), and get_write_timeout().

◆ ast_sip_get_unidentified_request_thresholds()

void ast_sip_get_unidentified_request_thresholds ( unsigned int *  count,
unsigned int *  period,
unsigned int *  prune_interval 
)

Retrieve the unidentified request security event thresholds.

Since
13.8.0
Parameters
countThe maximum number of unidentified requests per source ip to accumulate before emitting a security event
periodThe period in seconds over which to accumulate unidentified requests
prune_intervalThe interval in seconds at which expired entries will be pruned

Definition at line 360 of file config_global.c.

362{
363 struct global_config *cfg;
364
365 cfg = get_global_cfg();
366 if (!cfg) {
370 return;
371 }
372
373 *count = cfg->unidentified_request_count;
374 *period = cfg->unidentified_request_period;
375 *prune_interval = cfg->unidentified_request_prune_interval;
376
377 ao2_ref(cfg, -1);
378 return;
379}
#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT
Definition: config_global.c:45
#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL
Definition: config_global.c:47
#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD
Definition: config_global.c:46
unsigned int unidentified_request_prune_interval
unsigned int unidentified_request_count
unsigned int unidentified_request_period

References ao2_ref, DEFAULT_UNIDENTIFIED_REQUEST_COUNT, DEFAULT_UNIDENTIFIED_REQUEST_PERIOD, DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL, get_global_cfg(), global_config::unidentified_request_count, global_config::unidentified_request_period, and global_config::unidentified_request_prune_interval.

Referenced by global_loaded(), and prune_task().

◆ ast_sip_get_use_callerid_contact()

unsigned int ast_sip_get_use_callerid_contact ( void  )

Retrieve the global setting 'use_callerid_contact'.

Since
13.24.0
Return values
nonzero if CALLERID(num) is to be used as the default username in the contact

Definition at line 483 of file config_global.c.

484{
485 unsigned int use_callerid_contact;
486 struct global_config *cfg;
487
488 cfg = get_global_cfg();
489 if (!cfg) {
491 }
492
494 ao2_ref(cfg, -1);
496}
#define DEFAULT_USE_CALLERID_CONTACT
Definition: config_global.c:53
unsigned int use_callerid_contact

References ao2_ref, DEFAULT_USE_CALLERID_CONTACT, get_global_cfg(), and global_config::use_callerid_contact.

Referenced by set_from_header().

◆ ast_sip_hangup_sip2cause()

const int ast_sip_hangup_sip2cause ( int  cause)

Convert SIP hangup causes to Asterisk hangup causes.

Parameters
causeSIP cause
Return values
matchedcause code from causes.h

Definition at line 3531 of file res_pjsip.c.

3532{
3533 /* Possible values taken from causes.h */
3534
3535 switch(cause) {
3536 case 401: /* Unauthorized */
3538 case 403: /* Not found */
3540 case 404: /* Not found */
3541 return AST_CAUSE_UNALLOCATED;
3542 case 405: /* Method not allowed */
3544 case 407: /* Proxy authentication required */
3546 case 408: /* No reaction */
3548 case 409: /* Conflict */
3550 case 410: /* Gone */
3552 case 411: /* Length required */
3554 case 413: /* Request entity too large */
3556 case 414: /* Request URI too large */
3558 case 415: /* Unsupported media type */
3560 case 420: /* Bad extension */
3562 case 480: /* No answer */
3563 return AST_CAUSE_NO_ANSWER;
3564 case 481: /* No answer */
3566 case 482: /* Loop detected */
3568 case 483: /* Too many hops */
3569 return AST_CAUSE_NO_ANSWER;
3570 case 484: /* Address incomplete */
3572 case 485: /* Ambiguous */
3573 return AST_CAUSE_UNALLOCATED;
3574 case 486: /* Busy everywhere */
3575 return AST_CAUSE_BUSY;
3576 case 487: /* Request terminated */
3578 case 488: /* No codecs approved */
3580 case 491: /* Request pending */
3582 case 493: /* Undecipherable */
3584 case 500: /* Server internal failure */
3585 return AST_CAUSE_FAILURE;
3586 case 501: /* Call rejected */
3588 case 502:
3590 case 503: /* Service unavailable */
3591 return AST_CAUSE_CONGESTION;
3592 case 504: /* Gateway timeout */
3594 case 505: /* SIP version not supported */
3596 case 600: /* Busy everywhere */
3597 return AST_CAUSE_USER_BUSY;
3598 case 603: /* Decline */
3600 case 604: /* Does not exist anywhere */
3601 return AST_CAUSE_UNALLOCATED;
3602 case 606: /* Not acceptable */
3604 default:
3605 if (cause < 500 && cause >= 400) {
3606 /* 4xx class error that is unknown - someting wrong with our request */
3608 } else if (cause < 600 && cause >= 500) {
3609 /* 5xx class error - problem in the remote end */
3610 return AST_CAUSE_CONGESTION;
3611 } else if (cause < 700 && cause >= 600) {
3612 /* 6xx - global errors in the 4xx class */
3614 }
3615 return AST_CAUSE_NORMAL;
3616 }
3617 /* Never reached */
3618 return 0;
3619}
#define AST_CAUSE_CONGESTION
Definition: causes.h:153
#define AST_CAUSE_UNALLOCATED
Definition: causes.h:98
#define AST_CAUSE_INTERWORKING
Definition: causes.h:146
#define AST_CAUSE_NUMBER_CHANGED
Definition: causes.h:112
#define AST_CAUSE_BEARERCAPABILITY_NOTAVAIL
Definition: causes.h:130
#define AST_CAUSE_INVALID_NUMBER_FORMAT
Definition: causes.h:116
#define AST_CAUSE_FAILURE
Definition: causes.h:150
#define AST_CAUSE_DESTINATION_OUT_OF_ORDER
Definition: causes.h:115
#define AST_CAUSE_NO_USER_RESPONSE
Definition: causes.h:108
#define AST_CAUSE_NORMAL_TEMPORARY_FAILURE
Definition: causes.h:122
#define AST_CAUSE_NORMAL
Definition: causes.h:151
#define AST_CAUSE_CALL_REJECTED
Definition: causes.h:111
#define AST_CAUSE_FACILITY_REJECTED
Definition: causes.h:117
#define AST_CAUSE_RECOVERY_ON_TIMER_EXPIRE
Definition: causes.h:143
#define AST_CAUSE_NO_ROUTE_DESTINATION
Definition: causes.h:100
#define AST_CAUSE_BUSY
Definition: causes.h:149
#define AST_CAUSE_NO_ANSWER
Definition: causes.h:109
#define AST_CAUSE_USER_BUSY
Definition: causes.h:107

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().

◆ ast_sip_header_to_security_mechanism()

void ast_sip_header_to_security_mechanism ( const pjsip_generic_string_hdr *  hdr,
struct ast_sip_security_mechanism_vector security_mechanisms 
)

Append to security mechanism vector from SIP header.

Parameters
hdrThe header of the security mechanisms.
security_mechanismsVector of security mechanisms to append to. Header name must be one of Security-Client, Security-Server, Security-Verify.

Definition at line 333 of file security_agreements.c.

334 {
335
336 struct ast_sip_security_mechanism *mech;
337 char buf[512];
338 char *hdr_val;
339 char *mechanism;
340
341 if (!security_mechanisms || !hdr) {
342 return;
343 }
344
345 if (pj_stricmp2(&hdr->name, "Security-Client") && pj_stricmp2(&hdr->name, "Security-Server") &&
346 pj_stricmp2(&hdr->name, "Security-Verify")) {
347 return;
348 }
349
350 ast_copy_pj_str(buf, &hdr->hvalue, sizeof(buf));
351 hdr_val = ast_skip_blanks(buf);
352
353 while ((mechanism = ast_strsep(&hdr_val, ',', AST_STRSEP_ALL))) {
354 if (!ast_sip_str_to_security_mechanism(&mech, mechanism)) {
355 AST_VECTOR_APPEND(security_mechanisms, mech);
356 }
357 }
358}
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.
Definition: res_pjsip.c:2201
int ast_sip_str_to_security_mechanism(struct ast_sip_security_mechanism **security_mechanism, const char *value)
Allocate a security mechanism from a string.
@ AST_STRSEP_ALL
Definition: strings.h:258
char * ast_strsep(char **s, const char sep, uint32_t flags)
Act like strsep but ignore separators inside quotes.
Definition: utils.c:1835
char * ast_skip_blanks(const char *str)
Gets a pointer to the first non-whitespace character in a string.
Definition: strings.h:161

References ast_copy_pj_str(), ast_sip_str_to_security_mechanism(), ast_skip_blanks(), ast_strsep(), AST_STRSEP_ALL, AST_VECTOR_APPEND, and buf.

Referenced by contact_add_security_headers_to_status(), and handle_registration_response().

◆ ast_sip_identify_endpoint()

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.

Parameters
rdataThe inbound SIP message to use when identifying the endpoint.
Return values
NULLNo matching endpoint
non-NULLThe matching endpoint

Definition at line 330 of file res_pjsip.c.

331{
332 struct endpoint_identifier_list *iter;
333 struct ast_sip_endpoint *endpoint = NULL;
337 endpoint = iter->identifier->identify_endpoint(rdata);
338 if (endpoint) {
339 break;
340 }
341 }
342 return endpoint;
343}
struct ast_sip_endpoint *(* identify_endpoint)(pjsip_rx_data *rdata)
Callback used to identify the source of a message. See ast_sip_identify_endpoint for more details.
Definition: res_pjsip.h:1294
struct ast_sip_endpoint_identifier * identifier
Definition: res_pjsip.c:227

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().

◆ ast_sip_is_allowed_uri()

int ast_sip_is_allowed_uri ( pjsip_uri *  uri)

Check whether a pjsip_uri is allowed or not.

Since
16.28.0
Parameters
uriThe pjsip_uri to check
Return values
1if allowed
0if not allowed

Definition at line 3472 of file res_pjsip.c.

3473{
3474 return (ast_sip_is_uri_sip_sips(uri) || PJSIP_URI_SCHEME_IS_TEL(uri));
3475}
int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
Check whether a pjsip_uri is SIP/SIPS or not.
Definition: res_pjsip.c:3467

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().

◆ ast_sip_is_content_type()

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.

Parameters
content_typeThe pjsip_media_type structure to compare
typeThe media type to compare
subtypeThe media subtype to compare
Return values
0No match
-1Match

Definition at line 2248 of file res_pjsip.c.

2249{
2250 pjsip_media_type compare;
2251
2252 if (!content_type) {
2253 return 0;
2254 }
2255
2256 pjsip_media_type_init2(&compare, type, subtype);
2257
2258 return pjsip_media_type_cmp(content_type, &compare, 0) ? 0 : -1;
2259}
static int compare(const char *text, const char *template)

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().

◆ ast_sip_is_media_type_in()

int ast_sip_is_media_type_in ( pjsip_media_type *  a,
  ... 
)

Check if a media type is in a list of others.

Parameters
apjsip_media_type to search for
...one or more pointers to pjsip_media_types the last of which must be "SENTINEL"
Return values
1Media types are equal
0Media types are not equal

Definition at line 2228 of file res_pjsip.c.

2229{
2230 int rc = 0;
2231 pjsip_media_type *b = NULL;
2232 va_list ap;
2233
2234 ast_assert(a != NULL);
2235 va_start(ap, a);
2236
2237 while ((b = va_arg(ap, pjsip_media_type *)) != (pjsip_media_type *)SENTINEL) {
2238 if (pjsip_media_type_cmp(a, b, 0) == 0) {
2239 rc = 1;
2240 break;
2241 }
2242 }
2243 va_end(ap);
2244
2245 return rc;
2246}
#define SENTINEL
Definition: compiler.h:87

References a, ast_assert, b, NULL, and SENTINEL.

Referenced by check_content_disposition().

◆ ast_sip_is_uri_sip_sips()

int ast_sip_is_uri_sip_sips ( pjsip_uri *  uri)

Check whether a pjsip_uri is SIP/SIPS or not.

Since
16.28.0
Parameters
uriThe pjsip_uri to check
Return values
1if true
0if false

Definition at line 3467 of file res_pjsip.c.

3468{
3469 return (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri));
3470}

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().

◆ ast_sip_location_add_contact()

int ast_sip_location_add_contact ( struct ast_sip_aor aor,
const char *  uri,
struct timeval  expiration_time,
const char *  path_info,
const char *  user_agent,
const char *  via_addr,
int  via_port,
const char *  call_id,
struct ast_sip_endpoint endpoint 
)

Add a new contact to an AOR.

Parameters
aorPointer to the AOR
uriFull contact URI
expiration_timeOptional expiration time of the contact
path_infoPath information
user_agentUser-Agent header from REGISTER request
via_addr
via_port
call_id
endpointThe endpoint that resulted in the contact being added
Return values
-1failure
0success
Warning
This function holds a named write lock on the aor. If you already hold the lock you should call ast_sip_location_add_contact_nolock instead.

Definition at line 429 of file location.c.

433{
434 int res;
435
436 ao2_lock(aor);
437 res = ast_sip_location_add_contact_nolock(aor, uri, expiration_time, path_info, user_agent,
438 via_addr, via_port, call_id,
439 endpoint);
440 ao2_unlock(aor);
441
442 return res;
443}
int ast_sip_location_add_contact_nolock(struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, struct ast_sip_endpoint *endpoint)
Add a new contact to an AOR without locking the AOR.
Definition: location.c:416

References ao2_lock, ao2_unlock, ast_sip_contact::aor, ast_sip_location_add_contact_nolock(), ast_sip_contact::call_id, ast_sip_contact::endpoint, ast_sip_contact::expiration_time, ast_sip_contact::uri, ast_sip_contact::user_agent, ast_sip_contact::via_addr, and ast_sip_contact::via_port.

◆ ast_sip_location_add_contact_nolock()

int ast_sip_location_add_contact_nolock ( struct ast_sip_aor aor,
const char *  uri,
struct timeval  expiration_time,
const char *  path_info,
const char *  user_agent,
const char *  via_addr,
int  via_port,
const char *  call_id,
struct ast_sip_endpoint endpoint 
)

Add a new contact to an AOR without locking the AOR.

Since
13.9.0
Parameters
aorPointer to the AOR
uriFull contact URI
expiration_timeOptional expiration time of the contact
path_infoPath information
user_agentUser-Agent header from REGISTER request
via_addr
via_port
call_id
endpointThe endpoint that resulted in the contact being added
Return values
-1failure
0success
Warning
This function should only be called if you already hold a named write lock on the aor.

Definition at line 416 of file location.c.

420{
421 struct ast_sip_contact *contact;
422
425 ao2_cleanup(contact);
426 return contact ? 0 : -1;
427}
struct ast_sip_contact * ast_sip_location_create_contact(struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, int prune_on_boot, struct ast_sip_endpoint *endpoint)
Create a new contact for an AOR without locking the AOR.
Definition: location.c:355
struct ast_sip_endpoint * endpoint
Definition: res_pjsip.h:421
const ast_string_field aor
Definition: res_pjsip.h:411

References ao2_cleanup, ast_sip_contact::aor, ast_sip_location_create_contact(), ast_sip_contact::call_id, ast_sip_contact::endpoint, ast_sip_contact::expiration_time, ast_sip_contact::uri, ast_sip_contact::user_agent, ast_sip_contact::via_addr, and ast_sip_contact::via_port.

Referenced by ast_sip_location_add_contact().

◆ ast_sip_location_create_contact()

struct ast_sip_contact * ast_sip_location_create_contact ( struct ast_sip_aor aor,
const char *  uri,
struct timeval  expiration_time,
const char *  path_info,
const char *  user_agent,
const char *  via_addr,
int  via_port,
const char *  call_id,
int  prune_on_boot,
struct ast_sip_endpoint endpoint 
)

Create a new contact for an AOR without locking the AOR.

Since
13.18.0
Parameters
aorPointer to the AOR
uriFull contact URI
expiration_timeOptional expiration time of the contact
path_infoPath information
user_agentUser-Agent header from REGISTER request
via_addr
via_port
call_id
prune_on_bootNon-zero if the contact cannot survive a restart/boot.
endpointThe endpoint that resulted in the contact being added
Returns
The created contact or NULL on failure.
Warning
This function should only be called if you already hold a named write lock on the aor.

Definition at line 355 of file location.c.

359{
360 struct ast_sip_contact *contact;
361 char name[MAX_OBJECT_FIELD * 2 + 3];
362 char hash[33];
363
364 ast_md5_hash(hash, uri);
365 snprintf(name, sizeof(name), "%s;@%s", ast_sorcery_object_get_id(aor), hash);
366
367 contact = ast_sorcery_alloc(ast_sip_get_sorcery(), "contact", name);
368 if (!contact) {
369 return NULL;
370 }
371
372 ast_string_field_set(contact, uri, uri);
374 contact->qualify_frequency = aor->qualify_frequency;
375 contact->qualify_timeout = aor->qualify_timeout;
376 contact->authenticate_qualify = aor->authenticate_qualify;
377 if (path_info && aor->support_path) {
378 ast_string_field_set(contact, path, path_info);
379 }
380
381 if (!ast_strlen_zero(aor->outbound_proxy)) {
382 ast_string_field_set(contact, outbound_proxy, aor->outbound_proxy);
383 }
384
387 }
388
391 }
392
395 }
396 contact->via_port = via_port;
397
398 if (!ast_strlen_zero(call_id)) {
400 }
401
402 contact->endpoint = ao2_bump(endpoint);
403 if (endpoint) {
405 }
406
407 contact->prune_on_boot = prune_on_boot;
408
409 if (ast_sorcery_create(ast_sip_get_sorcery(), contact)) {
410 ao2_ref(contact, -1);
411 return NULL;
412 }
413 return contact;
414}
const char * ast_config_AST_SYSTEM_NAME
Definition: options.c:170
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
Definition: sorcery.c:2062
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition: sorcery.c:1744
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
const ast_string_field reg_server
Definition: res_pjsip.h:411
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
Definition: utils.c:250

References ao2_bump, ao2_ref, ast_sip_contact::aor, ast_config_AST_SYSTEM_NAME, ast_md5_hash(), ast_sip_get_sorcery(), ast_sorcery_alloc(), ast_sorcery_create(), ast_sorcery_object_get_id(), ast_string_field_set, ast_strlen_zero(), ast_sip_contact::authenticate_qualify, ast_sip_contact::call_id, ast_sip_contact::endpoint, ast_sip_contact::endpoint_name, ast_sip_contact::expiration_time, MAX_OBJECT_FIELD, name, NULL, ast_sip_contact::outbound_proxy, ast_sip_contact::path, ast_sip_contact::prune_on_boot, ast_sip_contact::qualify_frequency, ast_sip_contact::qualify_timeout, ast_sip_contact::reg_server, ast_sip_contact::uri, ast_sip_contact::user_agent, ast_sip_contact::via_addr, and ast_sip_contact::via_port.

Referenced by ast_sip_location_add_contact_nolock().

◆ ast_sip_location_delete_contact()

int ast_sip_location_delete_contact ( struct ast_sip_contact contact)

Delete a contact.

Parameters
contactContact object to delete
Return values
-1failure
0success

Definition at line 450 of file location.c.

451{
452 return ast_sorcery_delete(ast_sip_get_sorcery(), contact);
453}
int ast_sorcery_delete(const struct ast_sorcery *sorcery, void *object)
Delete an object.
Definition: sorcery.c:2238

References ast_sip_get_sorcery(), and ast_sorcery_delete().

Referenced by contact_expire(), destroy_contact(), prune_boot_contacts_cb(), and registrar_contact_delete().

◆ ast_sip_location_prune_boot_contacts()

void ast_sip_location_prune_boot_contacts ( void  )

Prune the prune_on_boot contacts.

Since
13.18.0

Definition at line 469 of file location.c.

470{
471 struct ao2_container *contacts;
472
475 if (contacts) {
477 ao2_ref(contacts, -1);
478 }
479}
static int prune_boot_contacts_cb(void *obj, void *arg, int flags)
Definition: location.c:455

References ao2_callback, ao2_ref, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_fields(), NULL, and prune_boot_contacts_cb().

Referenced by load_module().

◆ ast_sip_location_retrieve_aor()

struct ast_sip_aor * ast_sip_location_retrieve_aor ( const char *  aor_name)

◆ ast_sip_location_retrieve_aor_contacts()

struct ao2_container * ast_sip_location_retrieve_aor_contacts ( const struct ast_sip_aor aor)

Retrieve all contacts currently available for an AOR.

Parameters
aorPointer to the AOR
Return values
NULLif no contacts available
non-NULLif contacts available
Warning
Since this function prunes expired contacts before returning, it holds a named write lock on the aor. If you already hold the lock, call ast_sip_location_retrieve_aor_contacts_nolock instead.

Definition at line 247 of file location.c.

248{
250}
struct ao2_container * ast_sip_location_retrieve_aor_contacts_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve all contacts currently available for an AOR and filter based on flags.
Definition: location.c:252

References AST_SIP_CONTACT_FILTER_DEFAULT, and ast_sip_location_retrieve_aor_contacts_filtered().

Referenced by ast_sip_for_each_contact(), find_contact(), format_ami_aor_handler(), gather_contacts_for_aor(), notify_endpoint(), pjsip_aor_function_read(), and send_unsolicited_mwi_notify().

◆ ast_sip_location_retrieve_aor_contacts_filtered()

struct ao2_container * ast_sip_location_retrieve_aor_contacts_filtered ( const struct ast_sip_aor aor,
unsigned int  flags 
)

Retrieve all contacts currently available for an AOR and filter based on flags.

Since
13.16.0
Parameters
aorPointer to the AOR
flagsFiltering flags
Return values
NULLif no contacts available
non-NULLif contacts available
Warning
Since this function prunes expired contacts before returning, it holds a named write lock on the aor. If you already hold the lock, call ast_sip_location_retrieve_aor_contacts_nolock instead.

Definition at line 252 of file location.c.

254{
255 struct ao2_container *contacts;
256
257 /* ao2_lock / ao2_unlock do not actually write aor since it has an ao2 lockobj. */
258 ao2_lock((void*)aor);
260 ao2_unlock((void*)aor);
261
262 return contacts;
263}
struct ao2_container * ast_sip_location_retrieve_aor_contacts_nolock_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve all contacts currently available for an AOR without locking the AOR and filter based on flag...
Definition: location.c:219

References ao2_lock, ao2_unlock, and ast_sip_location_retrieve_aor_contacts_nolock_filtered().

Referenced by ast_sip_location_retrieve_aor_contacts(), ast_sip_location_retrieve_first_aor_contact_filtered(), and pjsip_acf_dial_contacts_read().

◆ ast_sip_location_retrieve_aor_contacts_nolock()

struct ao2_container * ast_sip_location_retrieve_aor_contacts_nolock ( const struct ast_sip_aor aor)

Retrieve all contacts currently available for an AOR without locking the AOR.

Since
13.9.0
Parameters
aorPointer to the AOR
Return values
NULLif no contacts available
non-NULLif contacts available
Warning
This function should only be called if you already hold a named write lock on the aor.

Definition at line 214 of file location.c.

References AST_SIP_CONTACT_FILTER_DEFAULT, and ast_sip_location_retrieve_aor_contacts_nolock_filtered().

Referenced by register_aor().

◆ ast_sip_location_retrieve_aor_contacts_nolock_filtered()

struct ao2_container * ast_sip_location_retrieve_aor_contacts_nolock_filtered ( const struct ast_sip_aor aor,
unsigned int  flags 
)

Retrieve all contacts currently available for an AOR without locking the AOR and filter based on flags.

Since
13.16.0
Parameters
aorPointer to the AOR
flagsFiltering flags
Return values
NULLif no contacts available
non-NULLif contacts available
Warning
This function should only be called if you already hold a named write lock on the aor.

Definition at line 219 of file location.c.

221{
222 /* Give enough space for ;@ at the end, since that is our object naming scheme */
223 size_t prefix_len = strlen(ast_sorcery_object_get_id(aor)) + sizeof(";@") - 1;
224 char prefix[prefix_len + 1];
225 struct ao2_container *contacts;
226
227 sprintf(prefix, "%s;@", ast_sorcery_object_get_id(aor)); /* Safe */
228 if (!(contacts = ast_sorcery_retrieve_by_prefix(ast_sip_get_sorcery(), "contact", prefix, prefix_len))) {
229 return NULL;
230 }
231
232 /* Prune any expired contacts and delete them, we do this first because static contacts can never expire */
234
235 /* Add any permanent contacts from the AOR */
236 if (aor->permanent_contacts) {
238 }
239
242 }
243
244 return contacts;
245}
@ OBJ_UNLINK
Definition: astobj2.h:1039
static char prefix[MAX_PREFIX]
Definition: http.c:144
static int contact_link_static(void *obj, void *arg, int flags)
Internal callback function which links static contacts into another container.
Definition: location.c:168
static int contact_remove_unreachable(void *obj, void *arg, int flags)
Internal callback function which removes any contact which is unreachable.
Definition: location.c:177
static int contact_expire(void *obj, void *arg, int flags)
Internal callback function which deletes and unlinks any expired contacts.
Definition: location.c:153
struct ao2_container * ast_sorcery_retrieve_by_prefix(const struct ast_sorcery *sorcery, const char *type, const char *prefix, const size_t prefix_len)
Retrieve multiple objects whose id begins with the specified prefix.
Definition: sorcery.c:1989
struct ao2_container * permanent_contacts
Definition: res_pjsip.h:499

References ao2_callback, AST_SIP_CONTACT_FILTER_REACHABLE, ast_sip_get_sorcery(), ast_sorcery_object_get_id(), ast_sorcery_retrieve_by_prefix(), contact_expire(), contact_link_static(), contact_remove_unreachable(), NULL, OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, ast_sip_aor::permanent_contacts, and prefix.

Referenced by ast_sip_location_retrieve_aor_contacts_filtered(), and ast_sip_location_retrieve_aor_contacts_nolock().

◆ ast_sip_location_retrieve_contact()

struct ast_sip_contact * ast_sip_location_retrieve_contact ( const char *  contact_name)

Retrieve a named contact.

Parameters
contact_nameName of the contact
Return values
NULLif not found
non-NULLif found

Definition at line 350 of file location.c.

351{
352 return ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "contact", contact_name);
353}

References ast_sip_get_sorcery(), and ast_sorcery_retrieve_by_id().

Referenced by register_contact_transport_remove_cb().

◆ ast_sip_location_retrieve_contact_and_aor_from_list()

void ast_sip_location_retrieve_contact_and_aor_from_list ( const char *  aor_list,
struct ast_sip_aor **  aor,
struct ast_sip_contact **  contact 
)

Retrieve the first bound contact AND the AOR chosen from a list of AORs.

Parameters
aor_listA comma-separated list of AOR names
aorThe chosen AOR
contactThe chosen contact

Definition at line 266 of file location.c.

268{
270}
void ast_sip_location_retrieve_contact_and_aor_from_list_filtered(const char *aor_list, unsigned int flags, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags.
Definition: location.c:272

References AST_SIP_CONTACT_FILTER_DEFAULT, and ast_sip_location_retrieve_contact_and_aor_from_list_filtered().

Referenced by ast_sip_location_retrieve_contact_from_aor_list().

◆ ast_sip_location_retrieve_contact_and_aor_from_list_filtered()

void ast_sip_location_retrieve_contact_and_aor_from_list_filtered ( const char *  aor_list,
unsigned int  flags,
struct ast_sip_aor **  aor,
struct ast_sip_contact **  contact 
)

Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags.

Since
13.16.0
Parameters
aor_listA comma-separated list of AOR names
flagsFiltering flags
aorThe chosen AOR
contactThe chosen contact

Definition at line 272 of file location.c.

274{
275 char *aor_name;
276 char *rest;
277
278 /* If the location is still empty we have nowhere to go */
279 if (ast_strlen_zero(aor_list) || !(rest = ast_strdupa(aor_list))) {
280 ast_log(LOG_WARNING, "Unable to determine contacts from empty aor list\n");
281 return;
282 }
283
284 *aor = NULL;
285 *contact = NULL;
286
287 while ((aor_name = ast_strip(strsep(&rest, ",")))) {
288 *aor = ast_sip_location_retrieve_aor(aor_name);
289
290 if (!(*aor)) {
291 continue;
292 }
294 /* If a valid contact is available use its URI for dialing */
295 if (*contact) {
296 break;
297 }
298
299 ao2_ref(*aor, -1);
300 *aor = NULL;
301 }
302}
struct ast_sip_contact * ast_sip_location_retrieve_first_aor_contact_filtered(const struct ast_sip_aor *aor, unsigned int flags)
Retrieve the first bound contact for an AOR and filter based on flags.
Definition: location.c:199

References ao2_ref, ast_log, ast_sip_location_retrieve_aor(), ast_sip_location_retrieve_first_aor_contact_filtered(), ast_strdupa, ast_strip(), ast_strlen_zero(), LOG_WARNING, NULL, and strsep().

Referenced by ast_sip_location_retrieve_contact_and_aor_from_list(), and ast_sip_session_create_outgoing().

◆ ast_sip_location_retrieve_contact_from_aor_list()

struct ast_sip_contact * ast_sip_location_retrieve_contact_from_aor_list ( const char *  aor_list)

Retrieve the first bound contact from a list of AORs.

Parameters
aor_listA comma-separated list of AOR names
Return values
NULLif no contacts available
non-NULLif contacts available

Definition at line 304 of file location.c.

305{
306 struct ast_sip_aor *aor;
307 struct ast_sip_contact *contact;
308
310
312
313 return contact;
314}
void ast_sip_location_retrieve_contact_and_aor_from_list(const char *aor_list, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
Retrieve the first bound contact AND the AOR chosen from a list of AORs.
Definition: location.c:266

References ao2_cleanup, ast_sip_contact::aor, and ast_sip_location_retrieve_contact_and_aor_from_list().

Referenced by ast_sip_create_subscription(), create_out_of_dialog_request(), handle_atsign(), handle_single_token(), insert_user_in_contact_uri(), mwi_contact_deleted(), and transfer().

◆ ast_sip_location_retrieve_contacts_from_aor_list()

struct ao2_container * ast_sip_location_retrieve_contacts_from_aor_list ( const char *  aor_list)

Retrieve all contacts from a list of AORs.

Parameters
aor_listA comma-separated list of AOR names
Return values
NULLif no contacts available
non-NULLcontainer (which must be freed) if contacts available

Definition at line 335 of file location.c.

336{
337 struct ao2_container *contacts;
338
341 if (!contacts) {
342 return NULL;
343 }
344
346
347 return contacts;
348}
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
Definition: astobj2.h:1327
@ AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT
Reject objects with duplicate keys in container.
Definition: astobj2.h:1188
int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg)
For every aor in the comma separated aors string call the given 'on_aor' handler.
Definition: location.c:687
static int permanent_uri_sort_fn(const void *obj_left, const void *obj_right, int flags)
Definition: location.c:498
static int gather_contacts_for_aor(void *obj, void *arg, int flags)
Definition: location.c:319

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_container_alloc_list, AO2_CONTAINER_ALLOC_OPT_DUPS_REJECT, ast_sip_for_each_aor(), gather_contacts_for_aor(), NULL, and permanent_uri_sort_fn().

Referenced by add_security_headers(), and handle_registration_response().

◆ ast_sip_location_retrieve_first_aor_contact()

struct ast_sip_contact * ast_sip_location_retrieve_first_aor_contact ( const struct ast_sip_aor aor)

Retrieve the first bound contact for an AOR.

Parameters
aorPointer to the AOR
Return values
NULLif no contacts available
non-NULLif contacts available

Definition at line 194 of file location.c.

References ast_sip_contact::aor, AST_SIP_CONTACT_FILTER_DEFAULT, and ast_sip_location_retrieve_first_aor_contact_filtered().

Referenced by handle_slash().

◆ ast_sip_location_retrieve_first_aor_contact_filtered()

struct ast_sip_contact * ast_sip_location_retrieve_first_aor_contact_filtered ( const struct ast_sip_aor aor,
unsigned int  flags 
)

Retrieve the first bound contact for an AOR and filter based on flags.

Since
13.16.0
Parameters
aorPointer to the AOR
flagsFiltering flags
Return values
NULLif no contacts available
non-NULLif contacts available

Definition at line 199 of file location.c.

201{
202 struct ao2_container *contacts;
203 struct ast_sip_contact *contact = NULL;
204
206 if (contacts && ao2_container_count(contacts)) {
207 /* Get the first AOR contact in the container. */
208 contact = ao2_callback(contacts, 0, NULL, NULL);
209 }
210 ao2_cleanup(contacts);
211 return contact;
212}
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.

References ao2_callback, ao2_cleanup, ao2_container_count(), ast_sip_contact::aor, ast_sip_location_retrieve_aor_contacts_filtered(), and NULL.

Referenced by ast_sip_location_retrieve_contact_and_aor_from_list_filtered(), and ast_sip_location_retrieve_first_aor_contact().

◆ ast_sip_location_update_contact()

int ast_sip_location_update_contact ( struct ast_sip_contact contact)

Update a contact.

Parameters
contactNew contact object with details
Return values
-1failure
0success

Definition at line 445 of file location.c.

446{
447 return ast_sorcery_update(ast_sip_get_sorcery(), contact);
448}
int ast_sorcery_update(const struct ast_sorcery *sorcery, void *object)
Update an object.
Definition: sorcery.c:2150

References ast_sip_get_sorcery(), and ast_sorcery_update().

◆ ast_sip_message_apply_transport()

void ast_sip_message_apply_transport ( const char *  transport_name,
pjsip_tx_data *  tdata 
)

Apply the configuration for a transport to an outgoing message.

Since
17.0.0
Parameters
transport_nameThe name of the transport to apply configuration from
tdataThe SIP message

Definition at line 301 of file config_transport.c.

302{
303 struct ast_sip_transport_state *transport_state;
304
305 if (ast_strlen_zero(transport_name)) {
306 return;
307 }
308
309 /* We only currently care about requests that are of the INVITE, CANCEL, or OPTIONS
310 * type but in the future we could support other messages.
311 */
312 if (tdata->msg->type != PJSIP_REQUEST_MSG ||
313 (pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_invite_method) &&
314 pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_cancel_method) &&
315 pjsip_method_cmp(&tdata->msg->line.req.method, &pjsip_options_method))) {
316 return;
317 }
318
319 transport_state = ast_sip_get_transport_state(transport_name);
320 if (!transport_state) {
321 return;
322 }
323
324 if (!transport_state->flow) {
325 ao2_ref(transport_state, -1);
326 return;
327 }
328
329 ao2_lock(transport_state);
330
331 /* If a Preferred Identity has been set then add it to the request */
332 if (transport_state->preferred_identity) {
333 ast_sip_add_header(tdata, "P-Preferred-Identity", transport_state->preferred_identity);
334 }
335
336 /* If Service Routes have been set then add them to the request */
337 if (transport_state->service_routes) {
338 int idx;
339
340 for (idx = 0; idx < AST_VECTOR_SIZE(transport_state->service_routes); ++idx) {
341 char *service_route = AST_VECTOR_GET(transport_state->service_routes, idx);
342
343 ast_sip_add_header(tdata, "Route", service_route);
344 }
345 }
346
347 ao2_unlock(transport_state);
348
349 ao2_ref(transport_state, -1);
350}
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
struct ast_sip_service_route_vector * service_routes
Definition: res_pjsip.h:188

References ao2_lock, ao2_ref, ao2_unlock, ast_sip_add_header(), ast_sip_get_transport_state(), ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sip_transport_state::flow, ast_sip_transport_state::preferred_identity, and ast_sip_transport_state::service_routes.

Referenced by ast_sip_send_out_of_dialog_request(), handle_outgoing_request(), handle_outgoing_response(), and supplement_outgoing_response().

◆ ast_sip_modify_id_header()

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.

Parameters
poolMemory pool to use for string duplication
id_hdrA From, P-Asserted-Identity, or Remote-Party-ID header to modify
idThe identity information to apply to the header

Definition at line 2850 of file res_pjsip.c.

2851{
2852 pjsip_name_addr *id_name_addr;
2853 pjsip_sip_uri *id_uri;
2854
2855 id_name_addr = (pjsip_name_addr *) id_hdr->uri;
2856 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
2857
2858 if (id->name.valid) {
2859 if (!ast_strlen_zero(id->name.str)) {
2860 int name_buf_len = strlen(id->name.str) * 2 + 1;
2861 char *name_buf = ast_alloca(name_buf_len);
2862
2863 ast_escape_quoted(id->name.str, name_buf, name_buf_len);
2864 pj_strdup2(pool, &id_name_addr->display, name_buf);
2865 } else {
2866 pj_strdup2(pool, &id_name_addr->display, NULL);
2867 }
2868 }
2869
2870 if (id->number.valid) {
2871 pj_strdup2(pool, &id_uri->user, id->number.str);
2872 }
2873}
enum queue_result id
Definition: app_queue.c:1667
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.
Definition: utils.c:781

References ast_alloca, ast_escape_quoted(), ast_strlen_zero(), id, and NULL.

Referenced by add_pai_header(), add_rpid_header(), and set_from_header().

◆ ast_sip_persistent_endpoint_publish_contact_state()

void ast_sip_persistent_endpoint_publish_contact_state ( const char *  endpoint_name,
const struct ast_sip_contact_status contact_status 
)

Publish the change of state for a contact.

Parameters
endpoint_nameThe SIP endpoint name.
contact_statusThe contact status.

Definition at line 1489 of file pjsip_configuration.c.

1490{
1491 struct sip_persistent_endpoint *persistent;
1492 struct ast_json *blob;
1493 char rtt[32];
1494
1495 persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1496 if (!persistent) {
1497 return;
1498 }
1499
1500 snprintf(rtt, sizeof(rtt), "%" PRId64, contact_status->rtt);
1501 blob = ast_json_pack("{s: s, s: s, s: s, s: s, s: s}",
1502 "contact_status", ast_sip_get_contact_status_label(contact_status->status),
1503 "aor", contact_status->aor,
1504 "uri", contact_status->uri,
1505 "roundtrip_usec", rtt,
1506 "endpoint_name", ast_endpoint_get_resource(persistent->endpoint));
1507 if (blob) {
1509 ast_json_unref(blob);
1510 }
1511
1512 ao2_ref(persistent, -1);
1513}
void ast_endpoint_blob_publish(struct ast_endpoint *endpoint, struct stasis_message_type *type, struct ast_json *blob)
Creates and publishes a ast_endpoint_blob message.
struct stasis_message_type * ast_endpoint_contact_state_type(void)
Message type for endpoint contact state changes.
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
static struct ao2_container * persistent_endpoints
Container for persistent endpoint information.
const char * ast_sip_get_contact_status_label(const enum ast_sip_contact_status_type status)
translate ast_sip_contact_status_type to character string.
Abstract JSON element (object, array, string, int, ...).
const ast_string_field uri
Definition: res_pjsip.h:454
enum ast_sip_contact_status_type status
Definition: res_pjsip.h:465
const ast_string_field aor
Definition: res_pjsip.h:454
Persistent endpoint information.
struct ast_endpoint * endpoint
Asterisk endpoint itself.

References ao2_find, ao2_ref, ast_sip_contact_status::aor, ast_endpoint_blob_publish(), ast_endpoint_contact_state_type(), ast_endpoint_get_resource(), ast_json_pack(), ast_json_unref(), ast_sip_get_contact_status_label(), sip_persistent_endpoint::endpoint, OBJ_SEARCH_KEY, persistent_endpoints, ast_sip_contact_status::rtt, ast_sip_contact_status::status, and ast_sip_contact_status::uri.

Referenced by sip_options_publish_contact_state().

◆ ast_sip_persistent_endpoint_update_state()

int ast_sip_persistent_endpoint_update_state ( const char *  endpoint_name,
enum ast_endpoint_state  state 
)

Change state of a persistent endpoint.

Parameters
endpoint_nameThe SIP endpoint name to change state.
stateThe new state
Return values
0Success
-1Endpoint not found

Definition at line 1432 of file pjsip_configuration.c.

1433{
1434 struct sip_persistent_endpoint *persistent;
1435 struct ast_json *blob;
1436 char *regcontext;
1437
1438 persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1439 if (!persistent) {
1440 return -1;
1441 }
1442
1443 /* If there was no state change, don't publish anything. */
1444 if (ast_endpoint_get_state(persistent->endpoint) == state) {
1445 ao2_ref(persistent, -1);
1446 return 0;
1447 }
1448
1450
1451 if (state == AST_ENDPOINT_ONLINE) {
1453 blob = ast_json_pack("{s: s}", "peer_status", "Reachable");
1454
1458 "Noop", ast_strdup(ast_endpoint_get_resource(persistent->endpoint)), ast_free_ptr, "PJSIP");
1459 }
1460 }
1461
1462 ast_verb(2, "Endpoint %s is now Reachable\n", ast_endpoint_get_resource(persistent->endpoint));
1463 } else {
1465 blob = ast_json_pack("{s: s}", "peer_status", "Unreachable");
1466
1468 struct pbx_find_info q = { .stacklen = 0 };
1469
1472 }
1473 }
1474
1475 ast_verb(2, "Endpoint %s is now Unreachable\n", ast_endpoint_get_resource(persistent->endpoint));
1476 }
1477
1479
1481 ast_json_unref(blob);
1483
1484 ao2_ref(persistent, -1);
1485
1486 return 0;
1487}
void ast_free_ptr(void *ptr)
free() wrapper
Definition: astmm.c:1739
static char regcontext[AST_MAX_CONTEXT]
Definition: chan_iax2.c:325
@ AST_DEVSTATE_CACHABLE
Definition: devicestate.h:70
int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt,...)
Tells Asterisk the State for Device is changed.
Definition: devicestate.c:510
@ AST_DEVICE_UNKNOWN
Definition: devicestate.h:53
@ AST_ENDPOINT_OFFLINE
Definition: endpoints.h:55
@ AST_ENDPOINT_ONLINE
Definition: endpoints.h:57
void ast_endpoint_set_state(struct ast_endpoint *endpoint, enum ast_endpoint_state state)
Updates the state of the given endpoint.
enum ast_endpoint_state ast_endpoint_get_state(const struct ast_endpoint *endpoint)
Gets the state of the given endpoint.
@ E_MATCH
Definition: extconf.h:217
struct stasis_message_type * ast_endpoint_state_type(void)
Message type for endpoint state changes.
#define ast_verb(level,...)
int ast_add_extension(const char *context, int replace, const char *extension, int priority, const char *label, const char *callerid, const char *application, void *data, void(*datad)(void *), const char *registrar)
Add and extension to an extension context.
Definition: pbx.c:6928
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4175
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
Definition: pbx.c:4948
struct ast_exten * pbx_find_extension(struct ast_channel *chan, struct ast_context *bypass, struct pbx_find_info *q, const char *context, const char *exten, int priority, const char *label, const char *callerid, enum ext_match_t action)
Definition: ael_main.c:152
char * ast_sip_get_regcontext(void)
Retrieve the global regcontext setting.
int stacklen
Definition: extconf.h:237

References ao2_find, ao2_ref, ast_add_extension(), ast_context_remove_extension(), AST_DEVICE_UNKNOWN, AST_DEVSTATE_CACHABLE, ast_devstate_changed(), ast_endpoint_blob_publish(), ast_endpoint_get_resource(), ast_endpoint_get_state(), AST_ENDPOINT_OFFLINE, AST_ENDPOINT_ONLINE, ast_endpoint_set_state(), ast_endpoint_state_type(), ast_exists_extension(), ast_free, ast_free_ptr(), ast_json_pack(), ast_json_unref(), ast_sip_get_regcontext(), ast_strdup, ast_strlen_zero(), ast_verb, E_MATCH, sip_persistent_endpoint::endpoint, NULL, OBJ_SEARCH_KEY, pbx_find_extension(), persistent_endpoints, regcontext, and pbx_find_info::stacklen.

Referenced by sip_options_synchronize_endpoint(), sip_options_unused_endpoint_state_compositor(), and sip_options_update_endpoint_state_compositor_aor().

◆ ast_sip_pjsip_uri_get_hostname()

const pj_str_t * ast_sip_pjsip_uri_get_hostname ( pjsip_uri *  uri)

Get the host portion of the pjsip_uri.

Since
16.28.0
Parameters
uriThe pjsip_uri to get the host from
Note
This function will check what kind of URI it receives and return the host based off of that
Returns
Host string or empty string if not present

Definition at line 3496 of file res_pjsip.c.

3497{
3498 if (ast_sip_is_uri_sip_sips(uri)) {
3499 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3500 if (!sip_uri) {
3501 return &AST_PJ_STR_EMPTY;
3502 }
3503 return &sip_uri->host;
3504 } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3505 return &AST_PJ_STR_EMPTY;
3506 }
3507
3508 return &AST_PJ_STR_EMPTY;
3509}
static const pj_str_t AST_PJ_STR_EMPTY
Definition: res_pjsip.h:111

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().

◆ ast_sip_pjsip_uri_get_other_param()

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.

Since
16.28.0

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
Parameters
uriThe pjsip_uri to get the parameter from
param_strThe name of the parameter to find
Note
This function will check what kind of URI it receives and return the parameter based off of that
Returns
Find parameter or NULL if not present

Definition at line 3511 of file res_pjsip.c.

3512{
3513 if (ast_sip_is_uri_sip_sips(uri)) {
3514 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3515 if (!sip_uri) {
3516 return NULL;
3517 }
3518 return pjsip_param_find(&sip_uri->other_param, param_str);
3519 } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3520 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3521 if (!tel_uri) {
3522 return NULL;
3523 }
3524 return pjsip_param_find(&tel_uri->other_param, param_str);
3525 }
3526
3527 return NULL;
3528}

References ast_sip_is_uri_sip_sips(), and NULL.

Referenced by get_uri_option_line(), and set_redirecting_reason_by_cause().

◆ ast_sip_pjsip_uri_get_username()

const pj_str_t * ast_sip_pjsip_uri_get_username ( pjsip_uri *  uri)

Get the user portion of the pjsip_uri.

Since
16.28.0
Parameters
uriThe pjsip_uri to get the user from
Note
This function will check what kind of URI it receives and return the user based off of that
Returns
User string or empty string if not present

Definition at line 3477 of file res_pjsip.c.

3478{
3479 if (ast_sip_is_uri_sip_sips(uri)) {
3480 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3481 if (!sip_uri) {
3482 return &AST_PJ_STR_EMPTY;
3483 }
3484 return &sip_uri->user;
3485 } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3486 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3487 if (!tel_uri) {
3488 return &AST_PJ_STR_EMPTY;
3489 }
3490 return &tel_uri->number;
3491 }
3492
3493 return &AST_PJ_STR_EMPTY;
3494}

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().

◆ ast_sip_rdata_get_header_value()

char * ast_sip_rdata_get_header_value ( pjsip_rx_data *  rdata,
const pj_str_t  str 
)

Get a specific header value from rdata.

Note
The returned value does not need to be freed since it's from the rdata pool
Parameters
rdataThe rdata
strThe header to find
Return values
NULLon failure
Theheader value on success

Definition at line 345 of file res_pjsip.c.

346{
347 pjsip_generic_string_hdr *hdr;
348 pj_str_t hdr_val;
349
350 hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str, NULL);
351 if (!hdr) {
352 return NULL;
353 }
354
355 pj_strdup_with_null(rdata->tp_info.pool, &hdr_val, &hdr->hvalue);
356
357 return hdr_val.ptr;
358}
const char * str
Definition: app_jack.c:147

References NULL, and str.

Referenced by stir_shaken_incoming_request().

◆ ast_sip_register_authenticator()

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.

Parameters
authThe authenticator to register
Return values
0Success
-1Failure

Definition at line 140 of file res_pjsip.c.

141{
143 ast_log(LOG_WARNING, "Authenticator %p is already registered. Cannot register a new one\n", registered_authenticator);
144 return -1;
145 }
147 ast_debug(1, "Registered SIP authenticator module %p\n", auth);
148
149 return 0;
150}

References ast_debug, ast_log, LOG_WARNING, and registered_authenticator.

Referenced by load_module().

◆ ast_sip_register_endpoint_formatter()

void ast_sip_register_endpoint_formatter ( struct ast_sip_endpoint_formatter obj)

Register an endpoint formatter.

Parameters
objthe formatter to register

Definition at line 481 of file res_pjsip.c.

482{
485}
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:741

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().

◆ ast_sip_register_endpoint_identifier()

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

Note
endpoint identifiers registered using this method (no name specified) are placed at the front of the endpoint identifiers list ahead of any named identifiers.
Parameters
identifierThe SIP endpoint identifier to register
Return values
0Success
-1Failure

Definition at line 310 of file res_pjsip.c.

311{
313}
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.
Definition: res_pjsip.c:233

References ast_sip_register_endpoint_identifier_with_name(), endpoint_identifier_list::identifier, and NULL.

Referenced by load_module().

◆ ast_sip_register_endpoint_identifier_with_name()

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.

Parameters
identifierThe SIP endpoint identifier to register
nameThe name of the endpoint identifier
Return values
0Success
-1Failure

Definition at line 233 of file res_pjsip.c.

235{
236 char *prev, *current, *identifier_order;
237 struct endpoint_identifier_list *iter, *id_list_item;
239
240 id_list_item = ast_calloc(1, sizeof(*id_list_item));
241 if (!id_list_item) {
242 ast_log(LOG_ERROR, "Unable to add endpoint identifier. Out of memory.\n");
243 return -1;
244 }
245 id_list_item->identifier = identifier;
246 id_list_item->name = name;
247
248 ast_debug(1, "Register endpoint identifier %s(%p)\n", name ?: "", identifier);
249
250 if (ast_strlen_zero(name)) {
251 /* if an identifier has no name then place in front */
252 AST_RWLIST_INSERT_HEAD(&endpoint_identifiers, id_list_item, list);
253 return 0;
254 }
255
256 /* see if the name of the identifier is in the global endpoint_identifier_order list */
257 identifier_order = prev = current = ast_sip_get_endpoint_identifier_order();
258
259 if (ast_strlen_zero(identifier_order)) {
260 id_list_item->priority = UINT_MAX;
261 AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
262 ast_free(identifier_order);
263 return 0;
264 }
265
266 id_list_item->priority = 0;
267 while ((current = strchr(current, ','))) {
268 ++id_list_item->priority;
269 if (!strncmp(prev, name, current - prev)
270 && strlen(name) == current - prev) {
271 break;
272 }
273 prev = ++current;
274 }
275
276 if (!current) {
277 /* check to see if it is the only or last item */
278 if (!strcmp(prev, name)) {
279 ++id_list_item->priority;
280 } else {
281 id_list_item->priority = UINT_MAX;
282 }
283 }
284
285 if (id_list_item->priority == UINT_MAX || AST_RWLIST_EMPTY(&endpoint_identifiers)) {
286 /* if not in the endpoint_identifier_order list then consider it less in
287 priority and add it to the end */
288 AST_RWLIST_INSERT_TAIL(&endpoint_identifiers, id_list_item, list);
289 ast_free(identifier_order);
290 return 0;
291 }
292
294 if (id_list_item->priority < iter->priority) {
295 AST_RWLIST_INSERT_BEFORE_CURRENT(id_list_item, list);
296 break;
297 }
298
299 if (!AST_RWLIST_NEXT(iter, list)) {
300 AST_RWLIST_INSERT_AFTER(&endpoint_identifiers, iter, id_list_item, list);
301 break;
302 }
303 }
305
306 ast_free(identifier_order);
307 return 0;
308}
#define AST_RWLIST_EMPTY
Definition: linkedlists.h:452
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:545
#define AST_RWLIST_INSERT_AFTER
Definition: linkedlists.h:702
#define AST_RWLIST_NEXT
Definition: linkedlists.h:441
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:617
#define AST_RWLIST_INSERT_HEAD
Definition: linkedlists.h:718
#define AST_RWLIST_INSERT_BEFORE_CURRENT
Definition: linkedlists.h:610
size_t current
Definition: main/cli.c:113
char * ast_sip_get_endpoint_identifier_order(void)
Retrieve the global endpoint_identifier_order setting.
unsigned int priority
Definition: res_pjsip.c:226

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().

◆ ast_sip_register_outbound_authenticator()

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.

Parameters
outbound_authThe authenticator to register
Return values
0Success
-1Failure

Definition at line 191 of file res_pjsip.c.

192{
194 ast_log(LOG_WARNING, "Outbound authenticator %p is already registered. Cannot register a new one\n", registered_outbound_authenticator);
195 return -1;
196 }
198 ast_debug(1, "Registered SIP outbound authenticator module %p\n", auth);
199
200 return 0;
201}

References ast_debug, ast_log, LOG_WARNING, and registered_outbound_authenticator.

Referenced by load_module().

◆ ast_sip_register_service()

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.

Parameters
moduleThe module that is to be registered with PJSIP
Return values
0Success
-1Failure

Definition at line 117 of file res_pjsip.c.

118{
120}
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.
Definition: res_pjsip.c:2165
static int register_service(void *data)
Definition: res_pjsip.c:102

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().

◆ ast_sip_register_supplement()

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.

Parameters
supplementThe supplement to register

Definition at line 1456 of file res_pjsip.c.

1457{
1458 struct ast_sip_supplement *iter;
1459 int inserted = 0;
1461
1463 if (iter->priority > supplement->priority) {
1465 inserted = 1;
1466 break;
1467 }
1468 }
1470
1471 if (!inserted) {
1473 }
1474}
A supplement to SIP message processing.
Definition: res_pjsip.h:3197
enum ast_sip_supplement_priority priority
Definition: res_pjsip.h:3201
struct ast_sip_supplement * next
Definition: res_pjsip.h:3247

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().

◆ ast_sip_remove_headers_by_name_and_value()

void ast_sip_remove_headers_by_name_and_value ( pjsip_msg *  msg,
const pj_str_t *  hdr_name,
const char *  value 
)

Removes all headers of a specific name and value from a pjsip_msg.

Parameters
msgPJSIP message from which to remove headers.
hdr_nameName of the header to remove.
valueOptional string value of the header to remove. If NULL, remove all headers of given hdr_name.

Definition at line 203 of file security_agreements.c.

204{
205 struct pjsip_generic_string_hdr *hdr = pjsip_msg_find_hdr_by_name(msg, hdr_name, NULL);
206 for (; hdr; hdr = pjsip_msg_find_hdr_by_name(msg, hdr_name, hdr->next)) {
207 if (value == NULL || !pj_strcmp2(&hdr->hvalue, value)) {
208 pj_list_erase(hdr);
209 }
210 if (hdr->next == hdr) {
211 break;
212 }
213 }
214}

References NULL, and value.

Referenced by add_security_headers().

◆ ast_sip_report_auth_challenge_sent()

void ast_sip_report_auth_challenge_sent ( struct ast_sip_endpoint endpoint,
pjsip_rx_data *  rdata,
pjsip_tx_data *  tdata 
)

Send a security event notification for when an authentication challenge is sent.

Parameters
endpointPointer to the endpoint in use
rdataReceived message
tdataSent message

Definition at line 197 of file res/res_pjsip/security_events.c.

198{
199 pjsip_www_authenticate_hdr *auth = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_WWW_AUTHENTICATE, NULL);
200 enum ast_transport transport = security_event_get_transport(rdata);
201 char nonce[64] = "", call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
202 struct ast_sockaddr local, remote;
203
204 struct ast_security_event_chal_sent chal_sent = {
206 .common.version = AST_SECURITY_EVENT_CHAL_SENT_VERSION,
207 .common.service = "PJSIP",
208 .common.account_id = get_account_id(endpoint),
209 .common.local_addr = {
210 .addr = &local,
211 .transport = transport,
212 },
213 .common.remote_addr = {
214 .addr = &remote,
215 .transport = transport,
216 },
217 .common.session_id = call_id,
218 .challenge = nonce,
219 };
220
221 if (auth && !pj_strcmp2(&auth->scheme, "digest")) {
222 ast_copy_pj_str(nonce, &auth->challenge.digest.nonce, sizeof(nonce));
223 }
224
225 security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
226
228}
ast_transport
Definition: netsock2.h:59
static const char * get_account_id(struct ast_sip_endpoint *endpoint)
static void security_event_populate(pjsip_rx_data *rdata, char *call_id, size_t call_id_size, struct ast_sockaddr *local, struct ast_sockaddr *remote)
static enum ast_transport security_event_get_transport(pjsip_rx_data *rdata)
int ast_security_event_report(const struct ast_security_event_common *sec)
Report a security event.
@ AST_SECURITY_EVENT_CHAL_SENT
Challenge was sent out, informational.
#define AST_SECURITY_EVENT_CHAL_SENT_VERSION
Event descriptor version.
#define AST_SEC_EVT(e)
A challenge was sent out.
struct ast_security_event_common common
Common security event descriptor elements.
enum ast_security_event_type event_type
The security event sub-type.
Socket address structure.
Definition: netsock2.h:97

References ast_copy_pj_str(), AST_SEC_EVT, AST_SECURITY_EVENT_CHAL_SENT, AST_SECURITY_EVENT_CHAL_SENT_VERSION, ast_security_event_report(), ast_security_event_chal_sent::common, ast_security_event_common::event_type, get_account_id(), NULL, security_event_get_transport(), and security_event_populate().

Referenced by authenticate().

◆ ast_sip_report_auth_failed_challenge_response()

void ast_sip_report_auth_failed_challenge_response ( struct ast_sip_endpoint endpoint,
pjsip_rx_data *  rdata 
)

Send a security event notification for when a challenge response has failed.

Parameters
endpointPointer to the endpoint in use
rdataReceived message

Definition at line 130 of file res/res_pjsip/security_events.c.

131{
132 pjsip_authorization_hdr *auth = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_AUTHORIZATION, NULL);
133 enum ast_transport transport = security_event_get_transport(rdata);
134 char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
135 char nonce[64] = "", response[256] = "";
136 struct ast_sockaddr local, remote;
137
138 struct ast_security_event_chal_resp_failed chal_resp_failed = {
141 .common.service = "PJSIP",
142 .common.account_id = get_account_id(endpoint),
143 .common.local_addr = {
144 .addr = &local,
145 .transport = transport,
146 },
147 .common.remote_addr = {
148 .addr = &remote,
149 .transport = transport,
150 },
151 .common.session_id = call_id,
152
153 .challenge = nonce,
154 .response = response,
155 .expected_response = "",
156 };
157
158 if (auth && !pj_strcmp2(&auth->scheme, "Digest")) {
159 ast_copy_pj_str(nonce, &auth->credential.digest.nonce, sizeof(nonce));
160 ast_copy_pj_str(response, &auth->credential.digest.response, sizeof(response));
161 }
162
163 security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
164
165 ast_security_event_report(AST_SEC_EVT(&chal_resp_failed));
166}
#define AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION
Event descriptor version.
@ AST_SECURITY_EVENT_CHAL_RESP_FAILED
An attempt at challenge/response authentication failed.
An attempt at challenge/response auth failed.
const char * response
Response received.
struct ast_security_event_common common
Common security event descriptor elements.

References ast_copy_pj_str(), AST_SEC_EVT, AST_SECURITY_EVENT_CHAL_RESP_FAILED, AST_SECURITY_EVENT_CHAL_RESP_FAILED_VERSION, ast_security_event_report(), ast_security_event_chal_resp_failed::common, ast_security_event_common::event_type, get_account_id(), NULL, ast_security_event_chal_resp_failed::response, security_event_get_transport(), and security_event_populate().

Referenced by authenticate().

◆ ast_sip_report_auth_success()

void ast_sip_report_auth_success ( struct ast_sip_endpoint endpoint,
pjsip_rx_data *  rdata 
)

Send a security event notification for when authentication succeeds.

Parameters
endpointPointer to the endpoint in use
rdataReceived message

Definition at line 168 of file res/res_pjsip/security_events.c.

169{
170 pjsip_authorization_hdr *auth = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_AUTHORIZATION, NULL);
171 enum ast_transport transport = security_event_get_transport(rdata);
172 char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
173 struct ast_sockaddr local, remote;
174
175 struct ast_security_event_successful_auth successful_auth = {
178 .common.service = "PJSIP",
179 .common.account_id = get_account_id(endpoint),
180 .common.local_addr = {
181 .addr = &local,
182 .transport = transport,
183 },
184 .common.remote_addr = {
185 .addr = &remote,
186 .transport = transport,
187 },
188 .common.session_id = call_id,
189 .using_password = auth ? 1 : 0,
190 };
191
192 security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
193
194 ast_security_event_report(AST_SEC_EVT(&successful_auth));
195}
@ AST_SECURITY_EVENT_SUCCESSFUL_AUTH
FYI FWIW, Successful authentication has occurred.
#define AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION
Event descriptor version.
struct ast_security_event_common common
Common security event descriptor elements.

References AST_SEC_EVT, ast_security_event_report(), AST_SECURITY_EVENT_SUCCESSFUL_AUTH, AST_SECURITY_EVENT_SUCCESSFUL_AUTH_VERSION, ast_security_event_successful_auth::common, ast_security_event_common::event_type, get_account_id(), NULL, security_event_get_transport(), and security_event_populate().

Referenced by authenticate().

◆ ast_sip_report_failed_acl()

void ast_sip_report_failed_acl ( struct ast_sip_endpoint endpoint,
pjsip_rx_data *  rdata,
const char *  name 
)

Send a security event notification for when an ACL check fails.

Parameters
endpointPointer to the endpoint in use
rdataReceived message
nameName of the ACL

Definition at line 102 of file res/res_pjsip/security_events.c.

103{
104 enum ast_transport transport = security_event_get_transport(rdata);
105 char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
106 struct ast_sockaddr local, remote;
107
108 struct ast_security_event_failed_acl failed_acl_event = {
111 .common.service = "PJSIP",
112 .common.account_id = get_account_id(endpoint),
113 .common.local_addr = {
114 .addr = &local,
115 .transport = transport,
116 },
117 .common.remote_addr = {
118 .addr = &remote,
119 .transport = transport,
120 },
121 .common.session_id = call_id,
122 .acl_name = name,
123 };
124
125 security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
126
127 ast_security_event_report(AST_SEC_EVT(&failed_acl_event));
128}
#define AST_SECURITY_EVENT_FAILED_ACL_VERSION
Event descriptor version.
@ AST_SECURITY_EVENT_FAILED_ACL
Failed ACL.
Checking against an IP access control list failed.
struct ast_security_event_common common
Common security event descriptor elements.

References AST_SEC_EVT, AST_SECURITY_EVENT_FAILED_ACL, AST_SECURITY_EVENT_FAILED_ACL_VERSION, ast_security_event_report(), ast_security_event_failed_acl::common, ast_security_event_common::event_type, get_account_id(), name, security_event_get_transport(), and security_event_populate().

Referenced by apply_endpoint_acl(), apply_endpoint_contact_acl(), and registrar_on_rx_request().

◆ ast_sip_report_invalid_endpoint()

void ast_sip_report_invalid_endpoint ( const char *  name,
pjsip_rx_data *  rdata 
)

Send a security event notification for when an invalid endpoint is requested.

Parameters
nameName of the endpoint requested
rdataReceived message

Definition at line 75 of file res/res_pjsip/security_events.c.

76{
77 enum ast_transport transport = security_event_get_transport(rdata);
78 char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
79 struct ast_sockaddr local, remote;
80
81 struct ast_security_event_inval_acct_id inval_acct_id = {
84 .common.service = "PJSIP",
85 .common.account_id = name,
86 .common.local_addr = {
87 .addr = &local,
88 .transport = transport,
89 },
90 .common.remote_addr = {
91 .addr = &remote,
92 .transport = transport,
93 },
94 .common.session_id = call_id,
95 };
96
97 security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
98
100}
#define AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION
Event descriptor version.
@ AST_SECURITY_EVENT_INVAL_ACCT_ID
Invalid Account ID.
Invalid account ID specified (invalid username, for example)
struct ast_security_event_common common
Common security event descriptor elements.

References AST_SEC_EVT, AST_SECURITY_EVENT_INVAL_ACCT_ID, AST_SECURITY_EVENT_INVAL_ACCT_ID_VERSION, ast_security_event_report(), ast_security_event_inval_acct_id::common, ast_security_event_common::event_type, name, security_event_get_transport(), and security_event_populate().

Referenced by check_endpoint(), and endpoint_lookup().

◆ ast_sip_report_mem_limit()

void ast_sip_report_mem_limit ( struct ast_sip_endpoint endpoint,
pjsip_rx_data *  rdata 
)

Send a security event notification for when a memory limit is hit.

Parameters
endpointPointer to the endpoint in use
rdataReceived message

Definition at line 259 of file res/res_pjsip/security_events.c.

260{
261 enum ast_transport transport = security_event_get_transport(rdata);
262 char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
263 struct ast_sockaddr local, remote;
264
265 struct ast_security_event_mem_limit mem_limit_event = {
267 .common.version = AST_SECURITY_EVENT_MEM_LIMIT_VERSION,
268 .common.service = "PJSIP",
269 .common.account_id = get_account_id(endpoint),
270 .common.local_addr = {
271 .addr = &local,
272 .transport = transport,
273 },
274 .common.remote_addr = {
275 .addr = &remote,
276 .transport = transport,
277 },
278 .common.session_id = call_id
279 };
280
281 security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
282
283 ast_security_event_report(AST_SEC_EVT(&mem_limit_event));
284}
#define AST_SECURITY_EVENT_MEM_LIMIT_VERSION
Event descriptor version.
@ AST_SECURITY_EVENT_MEM_LIMIT
Memory limit reached.
Request denied because of a memory limit.
struct ast_security_event_common common
Common security event descriptor elements.

References AST_SEC_EVT, AST_SECURITY_EVENT_MEM_LIMIT, AST_SECURITY_EVENT_MEM_LIMIT_VERSION, ast_security_event_report(), ast_security_event_mem_limit::common, ast_security_event_common::event_type, get_account_id(), security_event_get_transport(), and security_event_populate().

◆ ast_sip_report_req_no_support()

void ast_sip_report_req_no_support ( struct ast_sip_endpoint endpoint,
pjsip_rx_data *  rdata,
const char *  req_type 
)

Send a security event notification for when a request is not supported.

Parameters
endpointPointer to the endpoint in use
rdataReceived message
req_typethe type of request

Definition at line 230 of file res/res_pjsip/security_events.c.

232{
233 enum ast_transport transport = security_event_get_transport(rdata);
234 char call_id[pj_strlen(&rdata->msg_info.cid->id) + 1];
235 struct ast_sockaddr local, remote;
236
237 struct ast_security_event_req_no_support req_no_support_event = {
240 .common.service = "PJSIP",
241 .common.account_id = get_account_id(endpoint),
242 .common.local_addr = {
243 .addr = &local,
244 .transport = transport,
245 },
246 .common.remote_addr = {
247 .addr = &remote,
248 .transport = transport,
249 },
250 .common.session_id = call_id,
251 .request_type = req_type
252 };
253
254 security_event_populate(rdata, call_id, sizeof(call_id), &local, &remote);
255
256 ast_security_event_report(AST_SEC_EVT(&req_no_support_event));
257}
#define AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION
Event descriptor version.
@ AST_SECURITY_EVENT_REQ_NO_SUPPORT
A request was made that we understand, but do not support.
Request denied because we don't support it.
struct ast_security_event_common common
Common security event descriptor elements.

References AST_SEC_EVT, ast_security_event_report(), AST_SECURITY_EVENT_REQ_NO_SUPPORT, AST_SECURITY_EVENT_REQ_NO_SUPPORT_VERSION, ast_security_event_req_no_support::common, ast_security_event_common::event_type, get_account_id(), security_event_get_transport(), and security_event_populate().

Referenced by find_registrar_aor(), and registrar_on_rx_request().

◆ ast_sip_requires_authentication()

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.

Parameters
endpointThe endpoint from which the request originates
rdataThe incoming SIP request
Return values
non-zeroThe request requires authentication
0The request does not require authentication

Definition at line 163 of file res_pjsip.c.

164{
166 && !pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_options_method)) {
167 ast_debug(3, "Skipping OPTIONS authentication due to endpoint configuration\n");
168 return 0;
169 }
170
172 ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is not required\n");
173 return 0;
174 }
175
176 return registered_authenticator->requires_authentication(endpoint, rdata);
177}
int(* requires_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Check if a request requires authentication See ast_sip_requires_authentication for more details.
Definition: res_pjsip.h:1251
unsigned int allow_unauthenticated_options
Definition: res_pjsip.h:1059

References ast_sip_endpoint::allow_unauthenticated_options, ast_debug, ast_log, LOG_WARNING, registered_authenticator, and ast_sip_authenticator::requires_authentication.

Referenced by authenticate().

◆ ast_sip_retrieve_auths()

int ast_sip_retrieve_auths ( const struct ast_sip_auth_vector auths,
struct ast_sip_auth **  out 
)

Retrieve relevant SIP auth structures from sorcery.

Parameters
authsVector of sorcery IDs of auth credentials to retrieve
[out]outThe retrieved auths are stored here

Definition at line 2525 of file pjsip_configuration.c.

2526{
2527 int i;
2528
2529 for (i = 0; i < AST_VECTOR_SIZE(auths); ++i) {
2530 /* Using AST_VECTOR_GET is safe since the vector is immutable */
2531 const char *name = AST_VECTOR_GET(auths, i);
2533 if (!out[i]) {
2534 ast_log(LOG_NOTICE, "Couldn't find auth '%s'. Cannot authenticate\n", name);
2535 return -1;
2536 }
2537 }
2538
2539 return 0;
2540}
#define LOG_NOTICE
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
FILE * out
Definition: utils/frame.c:33

References ast_log, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), AST_VECTOR_GET, AST_VECTOR_SIZE, LOG_NOTICE, name, out, and SIP_SORCERY_AUTH_TYPE.

Referenced by digest_check_auth(), and set_outbound_initial_authentication_credentials().

◆ ast_sip_retrieve_auths_vector()

int ast_sip_retrieve_auths_vector ( const struct ast_sip_auth_vector auth_ids,
struct ast_sip_auth_objects_vector auth_objects 
)

Retrieve relevant SIP auth structures from sorcery as a vector.

Parameters
auth_idsVector of sorcery IDs of auth credentials to retrieve
[out]auth_objectsA pointer ast_sip_auth_objects_vector to hold the objects
Return values
0Success
-1Number of auth objects found is less than the number of names supplied.
Warning
The number of auth objects retrieved may be less than the number of auth ids supplied if auth objects couldn't be found for some of them.
Note
Since the ref count on all auth objects returned has been bumped, you must call ast_sip_cleanup_auth_objects_vector() to decrement the ref count on all of the auth objects in the vector, then call AST_VECTOR_FREE() on the vector itself.

Definition at line 2550 of file pjsip_configuration.c.

2552{
2553 int i;
2554
2555 for (i = 0; i < AST_VECTOR_SIZE(auth_ids); ++i) {
2556 /* Using AST_VECTOR_GET is safe since the vector is immutable */
2557 const char *name = AST_VECTOR_GET(auth_ids, i);
2559 if (!auth_object) {
2560 ast_log(LOG_WARNING, "Auth object '%s' could not be found\n", name);
2561 } else {
2562 AST_VECTOR_APPEND(auth_objects, auth_object);
2563 }
2564 }
2565
2566 return AST_VECTOR_SIZE(auth_objects) == AST_VECTOR_SIZE(auth_ids) ? 0 : -1;
2567}

References ast_log, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_SIZE, LOG_WARNING, name, and SIP_SORCERY_AUTH_TYPE.

Referenced by digest_create_request_with_auth().

◆ ast_sip_rewrite_uri_to_local()

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.

Parameters
uri
tdata
Return values
0success
-1failure
Note
Uses domain and port in Contact header if it exists, otherwise the local URI of the dialog is used if the message is sent within the context of a dialog. Further, NAT settings are considered - i.e. if the target is not in the localnet, the external_signaling_address and port are used.

Definition at line 605 of file res_pjsip.c.

605 {
606 RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
607 RAII_VAR(struct ast_sip_transport_state *, transport_state, NULL, ao2_cleanup);
608 struct ast_sip_request_transport_details details = { 0, };
609 pjsip_sip_uri *tmp_uri;
610 pjsip_dialog *dlg;
611 struct ast_sockaddr addr = { { 0, } };
612
613 if ((tmp_uri = ast_sip_get_contact_sip_uri(tdata))) {
614 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
615 uri->port = tmp_uri->port;
616 } else if ((dlg = pjsip_tdata_get_dlg(tdata))
617 && (tmp_uri = pjsip_uri_get_uri(dlg->local.info->uri))
618 && (PJSIP_URI_SCHEME_IS_SIP(tmp_uri) || PJSIP_URI_SCHEME_IS_SIPS(tmp_uri))) {
619 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
620 uri->port = tmp_uri->port;
621 }
622
623 if (ast_sip_set_request_transport_details(&details, tdata, 1)
624 || !(transport_state = ast_sip_find_transport_state_in_use(&details))
625 || !(transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_state->id))) {
626 return 0;
627 }
628
629 if (transport_state->localnet) {
630 ast_sockaddr_parse(&addr, tdata->tp_info.dst_name, PARSE_PORT_FORBID);
631 ast_sockaddr_set_port(&addr, tdata->tp_info.dst_port);
632 if (ast_sip_transport_is_local(transport_state, &addr)) {
633 return 0;
634 }
635 }
636
637 if (!ast_sockaddr_isnull(&transport_state->external_signaling_address)) {
638 pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
639 }
640
641 if (transport->external_signaling_port) {
642 uri->port = transport->external_signaling_port;
643 }
644
645 return 0;
646}
static char * ast_sockaddr_stringify_host(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only, suitable for a URL (with brack...
Definition: netsock2.h:327
static int ast_sockaddr_isnull(const struct ast_sockaddr *addr)
Checks if the ast_sockaddr is null. "null" in this sense essentially means uninitialized,...
Definition: netsock2.h:127
#define ast_sockaddr_set_port(addr, port)
Sets the port number of a socket address.
Definition: netsock2.h:532
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.
Definition: res_pjsip.c:595
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.
Definition: res_pjsip.c:648
pjsip_sip_uri * ast_sip_get_contact_sip_uri(pjsip_tx_data *tdata)
Return the SIP URI of the Contact header.
Definition: res_pjsip.c:564
#define ast_sip_transport_is_local(transport_state, addr)
Definition: res_pjsip.h:212
Structure which contains information about a transport.
Definition: res_pjsip.h:334
Transport to bind to.
Definition: res_pjsip.h:218

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().

◆ ast_sip_security_mechanism_vector_init()

int ast_sip_security_mechanism_vector_init ( struct ast_sip_security_mechanism_vector security_mechanism,
const char *  value 
)

Initialize security mechanism vector from string of security mechanisms.

Parameters
security_mechanismPointer to vector of security mechanisms to initialize.
valueString of security mechanisms as defined in RFC 3329.
Return values
0Success
non-zeroFailure

Definition at line 360 of file security_agreements.c.

361{
362 char *val = value ? ast_strdupa(value) : NULL;
363 struct ast_sip_security_mechanism *mech;
364 char *mechanism;
365
367 if (AST_VECTOR_INIT(security_mechanisms, 1)) {
368 return -1;
369 }
370
371 if (!val) {
372 return 0;
373 }
374
375 while ((mechanism = ast_strsep(&val, ',', AST_STRSEP_ALL))) {
376 if (!ast_sip_str_to_security_mechanism(&mech, mechanism)) {
377 AST_VECTOR_APPEND(security_mechanisms, mech);
378 }
379 }
380
381 return 0;
382}
void ast_sip_security_mechanisms_vector_destroy(struct ast_sip_security_mechanism_vector *security_mechanisms)
Free contents of a security mechanism vector.

References ast_sip_security_mechanisms_vector_destroy(), ast_sip_str_to_security_mechanism(), ast_strdupa, ast_strsep(), AST_STRSEP_ALL, AST_VECTOR_APPEND, AST_VECTOR_INIT, NULL, and value.

Referenced by security_mechanism_handler(), and security_mechanisms_handler().

◆ ast_sip_security_mechanisms_to_str()

int ast_sip_security_mechanisms_to_str ( const struct ast_sip_security_mechanism_vector security_mechanisms,
int  add_qvalue,
char **  buf 
)

Writes the security mechanisms of an endpoint into a buffer as a string and returns the buffer.

Note
The buffer must be freed by the caller.
Parameters
endpointPointer to endpoint.
add_qvalueIf non-zero, the q-value is printed as well
bufThe buffer to write the string into
Return values
0Success
non-zeroFailure

Definition at line 162 of file security_agreements.c.

163{
164 size_t vec_size;
165 struct ast_sip_security_mechanism *mech;
166 char *tmp_buf;
168 size_t i;
169 int rc = 0;
170
171 if (str == NULL) {
172 return ENOMEM;
173 }
174
175 if (!security_mechanisms) {
176 return -1;
177 }
178
179 vec_size = AST_VECTOR_SIZE(security_mechanisms);
180 if (vec_size == 0) {
181 return -1;
182 }
183
184 for (i = 0; i < vec_size; ++i) {
185 mech = AST_VECTOR_GET(security_mechanisms, i);
186 rc = security_mechanism_to_str(mech, add_qvalue, &tmp_buf);
187 if (rc) {
188 return rc;
189 }
190 rc = ast_str_append(&str, 0, "%s, ", tmp_buf);
192 if (rc <= 0) {
193 return ENOMEM;
194 }
195 }
196
197 /* ast_str_truncate removes the trailing ", " on the last mechanism */
199
200 return 0;
201}
static struct ast_threadstorage tmp_buf
Definition: func_strings.c:48
char * ast_str_truncate(struct ast_str *buf, ssize_t len)
Truncates the enclosed string to the given length.
Definition: strings.h:786

References ast_free, ast_str_append(), ast_str_create, ast_str_truncate(), ast_strdup, AST_VECTOR_GET, AST_VECTOR_SIZE, buf, MAX_OBJECT_FIELD, NULL, RAII_VAR, security_mechanism_to_str(), str, and tmp_buf.

Referenced by security_mechanism_to_str().

◆ ast_sip_security_mechanisms_vector_copy()

void ast_sip_security_mechanisms_vector_copy ( struct ast_sip_security_mechanism_vector dst,
const struct ast_sip_security_mechanism_vector src 
)

Duplicate a security mechanism.

Parameters
dstSecurity mechanism to duplicate to.
srcSecurity mechanism to duplicate.

Definition at line 81 of file security_agreements.c.

83{
84 struct ast_sip_security_mechanism *mech;
85 int i;
86
88 for (i = 0; i < AST_VECTOR_SIZE(src); i++) {
89 mech = AST_VECTOR_GET(src, i);
91 }
92};
static struct ast_sip_security_mechanism * security_mechanisms_copy(const struct ast_sip_security_mechanism *src)

References ast_sip_security_mechanisms_vector_destroy(), AST_VECTOR_APPEND, AST_VECTOR_GET, AST_VECTOR_SIZE, and security_mechanisms_copy().

Referenced by sip_contact_status_copy(), and sip_outbound_registration_perform().

◆ ast_sip_security_mechanisms_vector_destroy()

void ast_sip_security_mechanisms_vector_destroy ( struct ast_sip_security_mechanism_vector security_mechanisms)

Free contents of a security mechanism vector.

Parameters
security_mechanismsVector whose contents are to be freed

Definition at line 94 of file security_agreements.c.

95{
96 if (!security_mechanisms) {
97 return;
98 }
99
100 AST_VECTOR_RESET(security_mechanisms, security_mechanism_destroy);
101 AST_VECTOR_FREE(security_mechanisms);
102}
static void security_mechanism_destroy(struct ast_sip_security_mechanism *mech)
#define AST_VECTOR_RESET(vec, cleanup)
Reset vector.
Definition: vector.h:625

References AST_VECTOR_FREE, AST_VECTOR_RESET, and security_mechanism_destroy().

Referenced by ast_sip_security_mechanism_vector_init(), ast_sip_security_mechanisms_vector_copy(), endpoint_destructor(), handle_client_state_destruction(), sip_contact_status_dtor(), sip_outbound_registration_destroy(), and sip_outbound_registration_perform().

◆ ast_sip_send_out_of_dialog_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.

Parameters
tdataThe request to send
endpointOptional. If specified, the out-of-dialog request is sent to the endpoint.
timeoutIf non-zero, after the timeout the transaction will be terminated and the callback will be called with the PJSIP_EVENT_TIMER type.
tokenData to be passed to the callback upon receipt of out-of-dialog response.
callbackCallback to be called upon receipt of out-of-dialog response.
Return values
0Success
-1Failure (out-of-dialog callback will not be called.)
Note
Timeout processing: There are 2 timers associated with this request, PJSIP timer_b which is set globally in the "system" section of pjsip.conf, and the timeout specified on this call. The timer that expires first (before normal completion) will cause the callback to be run with e->body.tsx_state.type = PJSIP_EVENT_TIMER. The timer that expires second is simply ignored and the callback is not run again.

Definition at line 1938 of file res_pjsip.c.

1941{
1942 struct ast_sip_supplement *supplement;
1943 struct send_request_data *req_data;
1944 struct ast_sip_contact *contact;
1945
1946 req_data = send_request_data_alloc(endpoint, token, callback);
1947 if (!req_data) {
1948 pjsip_tx_data_dec_ref(tdata);
1949 return -1;
1950 }
1951
1952 if (endpoint) {
1954 }
1955
1956 contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
1957
1959 AST_LIST_TRAVERSE(&supplements, supplement, next) {
1960 if (supplement->outgoing_request
1961 && does_method_match(&tdata->msg->line.req.method.name, supplement->method)) {
1962 supplement->outgoing_request(endpoint, contact, tdata);
1963 }
1964 }
1966
1967 ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
1968 ao2_cleanup(contact);
1969
1970 if (endpt_send_request(endpoint, tdata, timeout, req_data, send_request_cb)
1971 != PJ_SUCCESS) {
1972 ao2_cleanup(req_data);
1973 return -1;
1974 }
1975
1976 return 0;
1977}
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
static struct send_request_data * send_request_data_alloc(struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
Definition: res_pjsip.c:1534
static void send_request_cb(void *token, pjsip_event *e)
Definition: res_pjsip.c:1882
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)
Definition: res_pjsip.c:1696
static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
Definition: res_pjsip.c:1499
void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata)
Apply the configuration for a transport to an outgoing message.
#define ast_sip_mod_data_get(mod_data, id, key)
Using the dictionary stored in mod_data array at a given id, retrieve the value associated with the g...
Definition: res_pjsip.h:2947
void(* outgoing_request)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata)
Called on an outgoing SIP request This method is always called from a SIP servant thread.
Definition: res_pjsip.h:3240
const char * method
Definition: res_pjsip.h:3199
Structure to hold information about an outbound request.
Definition: res_pjsip.c:1516

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().

◆ ast_sip_send_request()

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.

Parameters
tdataThe request to send
dlgOptional. The dialog in which the request is sent. Otherwise it is out-of-dialog.
endpointOptional. If specified, the out-of-dialog request is sent to the endpoint.
tokenData to be passed to the callback upon receipt of out-of-dialog response.
callbackCallback to be called upon receipt of out-of-dialog response.
Return values
0Success
-1Failure (out-of-dialog callback will not be called.)

Definition at line 1979 of file res_pjsip.c.

1982{
1983 ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
1984
1985 if (dlg) {
1986 return send_in_dialog_request(tdata, dlg);
1987 } else {
1988 return ast_sip_send_out_of_dialog_request(tdata, endpoint, -1, token, callback);
1989 }
1990}
static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)
Definition: res_pjsip.c:1490
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.
Definition: res_pjsip.c:1938

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().

◆ ast_sip_send_response()

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.

Parameters
res_addrThe response address for this response
tdataThe response to send
sip_endpointThe ast_sip_endpoint associated with this response
Return values
0Success
-1Failure

Definition at line 2396 of file res_pjsip.c.

2397{
2398 pj_status_t status;
2399
2400 supplement_outgoing_response(tdata, sip_endpoint);
2401 status = pjsip_endpt_send_response(ast_sip_get_pjsip_endpoint(), res_addr, tdata, NULL, NULL);
2402 if (status != PJ_SUCCESS) {
2403 pjsip_tx_data_dec_ref(tdata);
2404 }
2405
2406 return status == PJ_SUCCESS ? 0 : -1;
2407}
static void supplement_outgoing_response(pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
Definition: res_pjsip.c:2374

References ast_sip_get_pjsip_endpoint(), NULL, status, and supplement_outgoing_response().

◆ ast_sip_send_stateful_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.

Parameters
rdataThe request that is being responded to
tdataThe response to send
sip_endpointThe ast_sip_endpoint associated with this response
Since
13.4.0
Return values
0Success
-1Failure

Definition at line 2424 of file res_pjsip.c.

2425{
2426 pjsip_transaction *tsx;
2427 pj_grp_lock_t *tsx_glock;
2428 pj_pool_t *pool;
2429
2430 /* Create and initialize global lock pool */
2431 pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "stateful response", PJSIP_POOL_TSX_LEN, PJSIP_POOL_TSX_INC);
2432 if (!pool){
2433 /* ast_sip_create_response bumps the refcount of the contact and adds it to the tdata.
2434 * We'll leak that reference if we don't get rid of it here.
2435 */
2437 return -1;
2438 }
2439 /* Create with handler so that we can release the pool once the glock derefs out */
2440 if(pj_grp_lock_create_w_handler(pool, NULL, pool, &pool_destroy_callback, &tsx_glock) != PJ_SUCCESS) {
2442 pool_destroy_callback((void *) pool);
2443 return -1;
2444 }
2445 /* We need an additional reference as the qualify thread may destroy this out
2446 * from under us. Add it now before it gets added to the tsx. */
2447 pj_grp_lock_add_ref(tsx_glock);
2448
2449 if (pjsip_tsx_create_uas2(NULL, rdata, tsx_glock, &tsx) != PJ_SUCCESS) {
2451 pj_grp_lock_dec_ref(tsx_glock);
2452 return -1;
2453 }
2454
2455 pjsip_tsx_recv_msg(tsx, rdata);
2456 supplement_outgoing_response(tdata, sip_endpoint);
2457
2458 if (pjsip_tsx_send_msg(tsx, tdata) != PJ_SUCCESS) {
2459 pj_grp_lock_dec_ref(tsx_glock);
2460 pjsip_tx_data_dec_ref(tdata);
2461 return -1;
2462 }
2463
2464 pj_grp_lock_dec_ref(tsx_glock);
2465 return 0;
2466}
static void clean_contact_from_tdata(pjsip_tx_data *tdata)
Definition: res_pjsip.c:2415
static void pool_destroy_callback(void *arg)
Definition: res_pjsip.c:2409

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().

◆ ast_sip_service_route_vector_alloc()

struct ast_sip_service_route_vector * ast_sip_service_route_vector_alloc ( void  )

Allocate a vector of service routes.

Since
17.0.0
Return values
non-NULLsuccess
NULLfailure

Definition at line 352 of file config_transport.c.

353{
354 struct ast_sip_service_route_vector *service_routes;
355
356 service_routes = ast_calloc(1, sizeof(*service_routes));
357 if (!service_routes) {
358 return NULL;
359 }
360
361 AST_VECTOR_INIT(service_routes, 0);
362
363 return service_routes;
364}

References ast_calloc, AST_VECTOR_INIT, and NULL.

Referenced by save_response_fields_to_transport().

◆ ast_sip_service_route_vector_destroy()

void ast_sip_service_route_vector_destroy ( struct ast_sip_service_route_vector service_routes)

Destroy a vector of service routes.

Since
17.0.0
Parameters
service_routesA vector of service routes

Definition at line 366 of file config_transport.c.

367{
368 if (!service_routes) {
369 return;
370 }
371
372 AST_VECTOR_CALLBACK_VOID(service_routes, ast_free);
373 ast_free(service_routes);
374}
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
Definition: vector.h:862

References ast_free, and AST_VECTOR_CALLBACK_VOID.

Referenced by ast_sip_transport_state_set_service_routes(), and save_response_fields_to_transport().

◆ ast_sip_set_id_connected_line()

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.

Return values
-1on failure, 0 on success

Definition at line 2822 of file res_pjsip.c.

2823{
2824 return !set_id_from_pai(rdata, id) || !set_id_from_rpid(rdata, id) ? 0 : -1;
2825}
static int set_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
Definition: res_pjsip.c:2710
static int set_id_from_rpid(pjsip_rx_data *rdata, struct ast_party_id *id)
Definition: res_pjsip.c:2751

References set_id_from_pai(), and set_id_from_rpid().

Referenced by update_incoming_connected_line().

◆ ast_sip_set_id_from_invite()

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.

Parameters
rdata
idID structure to fill
default_idDefault ID structure with data to use (for non-trusted endpoints)
trust_inboundWhether or not the endpoint is trusted (controls whether PAI or RPID can be used)
Return values
-1on failure, 0 on success

Definition at line 2827 of file res_pjsip.c.

2828{
2829 if (trust_inbound && (!set_id_from_pai(rdata, id) || !set_id_from_rpid(rdata, id))) {
2830 /* Trusted: Check PAI and RPID */
2831 ast_free(id->tag);
2832 id->tag = ast_strdup(default_id->tag);
2833 return 0;
2834 }
2835 /* Not trusted: check the endpoint config or use From. */
2836 ast_party_id_copy(id, default_id);
2837 if (!default_id->number.valid) {
2838 set_id_from_from(rdata, id);
2839 }
2840 return 0;
2841}
void ast_party_id_copy(struct ast_party_id *dest, const struct ast_party_id *src)
Copy the source party id information to the destination party id.
Definition: channel.c:1784
static int set_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
Definition: res_pjsip.c:2803
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:344
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:299

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().

◆ ast_sip_set_outbound_proxy()

int ast_sip_set_outbound_proxy ( pjsip_tx_data *  tdata,
const char *  proxy 
)

Set the outbound proxy for an outbound SIP message.

Parameters
tdataThe message to set the outbound proxy on
proxySIP uri of the proxy
Return values
0Success
-1Failure

Definition at line 1992 of file res_pjsip.c.

1993{
1994 pjsip_route_hdr *route;
1995 static const pj_str_t ROUTE_HNAME = { "Route", 5 };
1996 pj_str_t tmp;
1997
1998 pj_strdup2_with_null(tdata->pool, &tmp, proxy);
1999 if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
2000 return -1;
2001 }
2002
2003 pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
2004
2005 return 0;
2006}

References NULL, and tmp().

Referenced by create_out_of_dialog_request(), path_outgoing_request(), and sip_options_qualify_contact().

◆ ast_sip_set_request_transport_details()

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.

Parameters
detailspre-allocated request transport details to set
tdata
use_ipv6if non-zero, ipv6 transports will be considered
Return values
0success
-1failure

Definition at line 648 of file res_pjsip.c.

649 {
650 pjsip_sip_uri *uri;
651 pjsip_via_hdr *via;
652 long transport_type;
653
654 if (!details || !tdata) {
655 return -1;
656 }
657
658 /* If IPv6 should be considered, un-set Bit 7 to make TCP6 equal to TCP and TLS6 equal to TLS */
659 transport_type = use_ipv6 ? tdata->tp_info.transport->key.type & ~(PJSIP_TRANSPORT_IPV6)
660 : tdata->tp_info.transport->key.type;
661
662 if (tdata->tp_sel.type == PJSIP_TPSELECTOR_TRANSPORT) {
663 details->transport = tdata->tp_sel.u.transport;
664 } else if (tdata->tp_sel.type == PJSIP_TPSELECTOR_LISTENER) {
665 details->factory = tdata->tp_sel.u.listener;
666 } else if (transport_type == PJSIP_TRANSPORT_UDP || transport_type == PJSIP_TRANSPORT_UDP6) {
667 /* Connectionless uses the same transport for all requests */
668 details->type = AST_TRANSPORT_UDP;
669 details->transport = tdata->tp_info.transport;
670 } else {
671 if (transport_type == PJSIP_TRANSPORT_TCP) {
672 details->type = AST_TRANSPORT_TCP;
673 } else if (transport_type == PJSIP_TRANSPORT_TLS) {
674 details->type = AST_TRANSPORT_TLS;
675 } else {
676 /* Unknown transport type, we can't map. */
677 return -1;
678 }
679
680 if ((uri = ast_sip_get_contact_sip_uri(tdata))) {
681 details->local_address = uri->host;
682 details->local_port = uri->port;
683 } else if ((tdata->msg->type == PJSIP_REQUEST_MSG) &&
684 (via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL))) {
685 details->local_address = via->sent_by.host;
686 details->local_port = via->sent_by.port;
687 } else {
688 return -1;
689 }
690
691 if (!details->local_port) {
692 details->local_port = (details->type == AST_TRANSPORT_TLS) ? 5061 : 5060;
693 }
694 }
695 return 0;
696}
if(!yyg->yy_init)
Definition: ast_expr2f.c:854
@ AST_TRANSPORT_UDP
Definition: netsock2.h:60
@ AST_TRANSPORT_TLS
Definition: netsock2.h:62
@ AST_TRANSPORT_TCP
Definition: netsock2.h:61
int local_port
Local port for transport.
Definition: res_pjsip.h:344
pjsip_transport * transport
Potential pointer to the transport itself, if UDP.
Definition: res_pjsip.h:338
enum ast_transport type
Type of transport.
Definition: res_pjsip.h:336
pjsip_tpfactory * factory
Potential pointer to the transport factory itself, if TCP/TLS.
Definition: res_pjsip.h:340
pj_str_t local_address
Local address for transport.
Definition: res_pjsip.h:342

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().

◆ ast_sip_set_security_negotiation()

int ast_sip_set_security_negotiation ( enum ast_sip_security_negotiation security_negotiation,
const char *  val 
)

Set the security negotiation based on a given string.

Parameters
security_negotiationSecurity negotiation enum to set.
valString that represents a security_negotiation value.
Return values
0Success
non-zeroFailure

Definition at line 288 of file pjsip_configuration.c.

288 {
289 if (!strcasecmp("no", val)) {
290 *security_negotiation = AST_SIP_SECURITY_NEG_NONE;
291 } else if (!strcasecmp("mediasec", val)) {
292 *security_negotiation = AST_SIP_SECURITY_NEG_MEDIASEC;
293 } else {
294 return -1;
295 }
296 return 0;
297}

References AST_SIP_SECURITY_NEG_MEDIASEC, AST_SIP_SECURITY_NEG_NONE, and ast_sip_endpoint::security_negotiation.

Referenced by security_negotiation_handler().

◆ ast_sip_set_tpselector_from_ep_or_uri()

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.

Since
13.15.0
Parameters
endpointIf endpoint->transport is set, it's used
sip_uriIf sip_uri contains a x-ast-txp parameter, it's used
selectorThe selector to be populated
Return values
0success
-1failure

Definition at line 911 of file res_pjsip.c.

913{
914 char transport_name[128];
915
916 if (ast_sip_get_transport_name(endpoint, sip_uri, transport_name, sizeof(transport_name))) {
917 return 0;
918 }
919
920 return ast_sip_set_tpselector_from_transport_name(transport_name, selector);
921}
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.
Definition: res_pjsip.c:698
int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector)
Sets pjsip_tpselector from ast_sip_transport.
Definition: res_pjsip.c:893

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().

◆ ast_sip_set_tpselector_from_transport()

int ast_sip_set_tpselector_from_transport ( const struct ast_sip_transport transport,
pjsip_tpselector *  selector 
)

Sets pjsip_tpselector from ast_sip_transport.

Since
13.8.0
Parameters
transportThe transport to be used
selectorThe selector to be populated
Return values
0success
-1failure
Note
The transport selector must be unreffed using ast_sip_tpselector_unref

Definition at line 843 of file res_pjsip.c.

844{
845 int res = 0;
846 struct ast_sip_transport_state *transport_state;
847
849 if (!transport_state) {
850 ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport state for '%s'\n",
852 return -1;
853 }
854
855 /* Only flows maintain dynamic state which needs protection */
856 if (transport_state->flow) {
857 ao2_lock(transport_state);
858 }
859
860 if (transport_state->transport) {
861 selector->type = PJSIP_TPSELECTOR_TRANSPORT;
862 selector->u.transport = transport_state->transport;
863 pjsip_transport_add_ref(selector->u.transport);
864 } else if (transport_state->factory) {
865 selector->type = PJSIP_TPSELECTOR_LISTENER;
866 selector->u.listener = transport_state->factory;
867 } else if (transport->type == AST_TRANSPORT_WS || transport->type == AST_TRANSPORT_WSS) {
868 /* The WebSocket transport has no factory as it can not create outgoing connections, so
869 * even if an endpoint is locked to a WebSocket transport we let the PJSIP logic
870 * find the existing connection if available and use it.
871 */
872 } else if (transport->flow) {
873 /* This is a child of another transport, so we need to establish a new connection */
874#ifdef HAVE_PJSIP_TRANSPORT_DISABLE_CONNECTION_REUSE
875 selector->disable_connection_reuse = PJ_TRUE;
876#else
877 ast_log(LOG_WARNING, "Connection reuse could not be disabled on transport '%s' as support is not available\n",
879#endif
880 } else {
881 res = -1;
882 }
883
884 if (transport_state->flow) {
885 ao2_unlock(transport_state);
886 }
887
888 ao2_ref(transport_state, -1);
889
890 return res;
891}
@ AST_TRANSPORT_WSS
Definition: netsock2.h:64
@ AST_TRANSPORT_WS
Definition: netsock2.h:63
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
struct pjsip_tpfactory * factory
Transport factory.
Definition: res_pjsip.h:120

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().

◆ 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.

Since
13.8.0
Parameters
transport_nameThe name of the transport to be used
selectorThe selector to be populated
Return values
0success
-1failure
Note
The transport selector must be unreffed using ast_sip_tpselector_unref

Definition at line 893 of file res_pjsip.c.

894{
895 RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
896
897 if (ast_strlen_zero(transport_name)) {
898 return 0;
899 }
900
901 transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_name);
902 if (!transport) {
903 ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport '%s'\n",
904 transport_name);
905 return -1;
906 }
907
908 return ast_sip_set_tpselector_from_transport(transport, selector);
909}
int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector)
Sets pjsip_tpselector from ast_sip_transport.
Definition: res_pjsip.c:843

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().

◆ ast_sip_sorcery_object_to_ami()

int ast_sip_sorcery_object_to_ami ( const void *  obj,
struct ast_str **  buf 
)

Converts a sorcery object to a string of object properties.

Parameters
objthe sorcery object to convert
bufthe string buffer to write the object data
Return values
0Success, non-zero on failure

Definition at line 1749 of file pjsip_configuration.c.

1750{
1753 struct ast_variable *i;
1754
1755 if (!objset) {
1756 return -1;
1757 }
1758
1760
1761 for (i = objset; i; i = i->next) {
1762 RAII_VAR(char *, camel, ast_to_camel_case(i->name), ast_free);
1763 ast_str_append(buf, 0, "%s: %s\r\n", camel, i->value);
1764 }
1765
1766 return 0;
1767}
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
static void sip_sorcery_object_ami_set_type_name(const void *obj, struct ast_str **buf)
@ AST_HANDLER_ONLY_STRING
Use string handler only.
Definition: sorcery.h:137
struct ast_variable * ast_sorcery_objectset_create2(const struct ast_sorcery *sorcery, const void *object, enum ast_sorcery_field_handler_flags flags)
Create an object set (KVP list) for an object.
Definition: sorcery.c:1511
#define ast_to_camel_case(s)
Attempts to convert the given string to camel case using an underscore as the specified delimiter.
Definition: strings.h:546
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next

References ast_free, AST_HANDLER_ONLY_STRING, ast_sip_get_sorcery(), ast_sorcery_objectset_create2(), ast_str_append(), ast_to_camel_case, ast_variables_destroy(), buf, ast_variable::name, ast_variable::next, RAII_VAR, sip_sorcery_object_ami_set_type_name(), and ast_variable::value.

Referenced by ami_outbound_registration_task(), ami_registrations_aor(), format_ami_resource_lists(), sip_auth_to_ami(), sip_contact_to_ami(), sip_endpoint_to_ami(), sip_identify_to_ami(), and sip_transport_to_ami().

◆ ast_sip_str2rc()

int ast_sip_str2rc ( const char *  name)

Convert name to SIP response code.

Parameters
nameSIP 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.
Return values
SIPresponse code
-1if matching code not found

Definition at line 3714 of file res_pjsip.c.

3715{
3716 int i;
3717
3718 if (ast_strlen_zero(name)) {
3719 return -1;
3720 }
3721
3722 for (i = 0; i < ARRAY_LEN(rc_map); i++) {
3723 if (strcasecmp(rc_map[i].short_name, name) == 0 ||
3724 strcasecmp(rc_map[i].long_name, name) == 0) {
3725 return rc_map[i].code;
3726 }
3727 }
3728
3729 return -1;
3730}
static const struct response_code_map rc_map[]
Definition: res_pjsip.c:3634

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().

◆ ast_sip_str_to_dtmf()

int ast_sip_str_to_dtmf ( const char *  dtmf_mode)

Convert the DTMF mode name into an enum.

Since
13.18.0
Parameters
dtmf_modedtmf mode as a string
Return values
>=0 The enum value
-1Failure

Definition at line 2533 of file res_pjsip.c.

2534{
2535 int result = -1;
2536
2537 if (!strcasecmp(dtmf_mode, "info")) {
2539 } else if (!strcasecmp(dtmf_mode, "rfc4733")) {
2541 } else if (!strcasecmp(dtmf_mode, "inband")) {
2543 } else if (!strcasecmp(dtmf_mode, "none")) {
2545 } else if (!strcasecmp(dtmf_mode, "auto")) {
2547 } else if (!strcasecmp(dtmf_mode, "auto_info")) {
2549 }
2550
2551 return result;
2552}
static PGresult * result
Definition: cel_pgsql.c:84

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().

◆ ast_sip_str_to_security_mechanism()

int ast_sip_str_to_security_mechanism ( struct ast_sip_security_mechanism **  security_mechanism,
const char *  value 
)

Allocate a security mechanism from a string.

Parameters
security_mechanismPointer-pointer to the security mechanism to allocate.
valueThe security mechanism string as defined in RFC 3329 (section 2.2) in the form <mechanism_name>;q=<q_value>;<mechanism_parameters>
Return values
0Success
non-zeroFailure

Definition at line 242 of file security_agreements.c.

242 {
243 struct ast_sip_security_mechanism *mech;
244 char *param;
245 char *tmp;
246 char *mechanism = ast_strdupa(value);
247 int err = 0;
248 int type = -1;
249
251 if (!mech) {
252 err = ENOMEM;
253 goto out;
254 }
255
256 tmp = ast_strsep(&mechanism, ';', AST_STRSEP_ALL);
258 if (type == -1) {
259 err = EINVAL;
260 goto out;
261 }
262
263 mech->type = type;
264 while ((param = ast_strsep(&mechanism, ';', AST_STRSEP_ALL))) {
265 if (!param) {
266 err = EINVAL;
267 goto out;
268 }
269 if (!strncmp(param, "q=", 2)) {
270 mech->qvalue = parse_qvalue(&param[2]);
271 if (mech->qvalue < 0.0) {
272 err = EINVAL;
273 goto out;
274 }
275 continue;
276 }
277 param = ast_strdup(param);
279 }
280
281 *security_mechanism = mech;
282
283out:
284 if (err && (mech != NULL)) {
286 }
287 return err;
288}
static struct ast_sip_security_mechanism * security_mechanisms_alloc(size_t n_params)
static int str_to_security_mechanism_type(const char *security_mechanism)
static float parse_qvalue(const char *q_value)
struct ast_vector_string mechanism_parameters
Definition: res_pjsip.h:381
enum ast_sip_security_mechanism_type type
Definition: res_pjsip.h:377

References ast_strdup, ast_strdupa, ast_strsep(), AST_STRSEP_ALL, AST_VECTOR_APPEND, ast_sip_security_mechanism::mechanism_parameters, NULL, out, parse_qvalue(), ast_sip_security_mechanism::qvalue, security_mechanism_destroy(), security_mechanisms_alloc(), str_to_security_mechanism_type(), tmp(), type, ast_sip_security_mechanism::type, and value.

Referenced by ast_sip_header_to_security_mechanism(), ast_sip_security_mechanism_vector_init(), and rfc3329_incoming_response().

◆ ast_sip_threadpool()

struct ast_threadpool * ast_sip_threadpool ( void  )

Retrieve the SIP threadpool object.

Definition at line 3462 of file res_pjsip.c.

3463{
3464 return sip_threadpool;
3465}
static struct ast_threadpool * sip_threadpool
Definition: res_pjsip.c:76

References sip_threadpool.

Referenced by load_module().

◆ ast_sip_threadpool_queue_size()

long ast_sip_threadpool_queue_size ( void  )

Return the size of the SIP threadpool's task queue.

Since
13.7.0

Definition at line 3457 of file res_pjsip.c.

3458{
3460}
long ast_threadpool_queue_size(struct ast_threadpool *pool)
Return the size of the threadpool's task queue.
Definition: threadpool.c:1433

References ast_threadpool_queue_size(), and sip_threadpool.

◆ ast_sip_tpselector_unref()

void ast_sip_tpselector_unref ( pjsip_tpselector *  selector)

Unreference a pjsip_tpselector.

Since
17.0.0
Parameters
selectorThe selector to be unreffed

Definition at line 923 of file res_pjsip.c.

924{
925 if (selector->type == PJSIP_TPSELECTOR_TRANSPORT && selector->u.transport) {
926 pjsip_transport_dec_ref(selector->u.transport);
927 }
928}

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().

◆ ast_sip_transport_monitor_register()

enum ast_transport_monitor_reg ast_sip_transport_monitor_register ( pjsip_transport *  transport,
ast_transport_monitor_shutdown_cb  cb,
void *  ao2_data 
)

Register a reliable transport shutdown monitor callback.

Deprecated:
Replaced with ast_sip_transport_monitor_register_key().
Since
13.20.0
Parameters
transportTransport to monitor for shutdown.
cbWho to call when transport is shutdown.
ao2_dataData to pass with the callback.
Note
The data object passed will have its reference count automatically incremented by this call and automatically decremented after the callback runs or when the callback is unregistered.

There is no checking for duplicate registrations.

Returns
enum ast_transport_monitor_reg

Definition at line 478 of file pjsip_transport_events.c.

480{
483
484 return ast_sip_transport_monitor_register_replace_key(key, cb, ao2_data, NULL);
485}
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace_key(const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches)
Register a reliable transport shutdown monitor callback replacing any duplicate.
#define AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR(_transport, _dest)
Fill a buffer with a pjsip transport's remote ip address and port.
Definition: res_pjsip.h:90
#define IP6ADDR_COLON_PORT_BUFLEN
Definition: res_pjsip.h:82

References AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, ast_sip_transport_monitor_register_replace_key(), callback_data::cb, IP6ADDR_COLON_PORT_BUFLEN, and NULL.

◆ ast_sip_transport_monitor_register_key()

enum ast_transport_monitor_reg ast_sip_transport_monitor_register_key ( const char *  transport_key,
ast_transport_monitor_shutdown_cb  cb,
void *  ao2_data 
)

Register a reliable transport shutdown monitor callback.

Parameters
transport_keyKey for the transport to monitor for shutdown. Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
cbWho to call when transport is shutdown.
ao2_dataData to pass with the callback.
Note
The data object passed will have its reference count automatically incremented by this call and automatically decremented after the callback runs or when the callback is unregistered.

There is no checking for duplicate registrations.

Returns
enum ast_transport_monitor_reg

Definition at line 487 of file pjsip_transport_events.c.

489{
490 return ast_sip_transport_monitor_register_replace_key(transport_key, cb, ao2_data, NULL);
491}

References ast_sip_transport_monitor_register_replace_key(), callback_data::cb, and NULL.

Referenced by subscription_persistence_update().

◆ ast_sip_transport_monitor_register_replace()

enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace ( pjsip_transport *  transport,
ast_transport_monitor_shutdown_cb  cb,
void *  ao2_data,
ast_transport_monitor_data_matcher  matches 
)

Register a reliable transport shutdown monitor callback replacing any duplicate.

Deprecated:
Replaced with ast_sip_transport_monitor_register_replace_key().
Since
13.26.0
16.3.0
Parameters
transportTransport to monitor for shutdown.
cbWho to call when transport is shutdown.
ao2_dataData to pass with the callback.
matchesMatcher function that returns true if data matches a previously registered data object
Note
The data object passed will have its reference count automatically incremented by this call and automatically decremented after the callback runs or when the callback is unregistered.

This function checks for duplicates, and overwrites/replaces the old monitor with the given one.

Returns
enum ast_transport_monitor_reg

Definition at line 493 of file pjsip_transport_events.c.

495{
497
499 return ast_sip_transport_monitor_register_replace_key(key, cb, ao2_data, NULL);
500}

References AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, ast_sip_transport_monitor_register_replace_key(), callback_data::cb, IP6ADDR_COLON_PORT_BUFLEN, and NULL.

◆ ast_sip_transport_monitor_register_replace_key()

enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace_key ( const char *  transport_key,
ast_transport_monitor_shutdown_cb  cb,
void *  ao2_data,
ast_transport_monitor_data_matcher  matches 
)

Register a reliable transport shutdown monitor callback replacing any duplicate.

Parameters
transport_keyKey for the transport to monitor for shutdown. Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
cbWho to call when transport is shutdown.
ao2_dataData to pass with the callback.
matchesMatcher function that returns true if data matches a previously registered data object
Note
The data object passed will have its reference count automatically incremented by this call and automatically decremented after the callback runs or when the callback is unregistered.

This function checks for duplicates, and overwrites/replaces the old monitor with the given one.

Returns
enum ast_transport_monitor_reg

Definition at line 502 of file pjsip_transport_events.c.

504{
505 struct ao2_container *transports;
506 struct transport_monitor *monitored;
508
509 ast_assert(transport_key != NULL && cb != NULL);
510
511 transports = ao2_global_obj_ref(active_transports);
512 if (!transports) {
513 return res;
514 }
515
516 ao2_lock(transports);
517 monitored = ao2_find(transports, transport_key, OBJ_SEARCH_KEY | OBJ_NOLOCK);
518 if (monitored) {
519 struct transport_monitor_notifier new_monitor;
520 struct callback_data cb_data = {
521 .cb = cb,
522 .data = ao2_data,
523 .matches = matches ?: ptr_matcher,
524 };
525
526 transport_monitor_unregister_cb(monitored, &cb_data, 0);
527
528 /* Add new monitor to vector */
529 new_monitor.cb = cb;
530 new_monitor.data = ao2_bump(ao2_data);
531 if (AST_VECTOR_APPEND(&monitored->monitors, new_monitor)) {
532 ao2_cleanup(ao2_data);
534 ast_debug(3, "Transport %s(%s) RefCnt: %ld : Monitor registration failed %p(%p)\n",
535 monitored->key, monitored->transport_obj_name,
536 pj_atomic_get(monitored->transport->ref_cnt), cb, ao2_data);
537 } else {
539 ast_debug(3, "Transport %s(%s,%s) RefCnt: %ld : Registered monitor %p(%p)\n",
540 monitored->key, monitored->transport_obj_name,
541 monitored->transport->type_name,
542 pj_atomic_get(monitored->transport->ref_cnt), cb, ao2_data);
543 }
544
545 ao2_ref(monitored, -1);
546 }
547 ao2_unlock(transports);
548 ao2_ref(transports, -1);
549 return res;
550}
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
Definition: astobj2.h:1063
static int ptr_matcher(void *a, void *b)
static int transport_monitor_unregister_cb(void *obj, void *arg, int flags)
ast_transport_monitor_reg
Definition: res_pjsip.h:3934
ast_transport_monitor_data_matcher matches
ast_transport_monitor_shutdown_cb cb
Structure for transport to be monitored.
pjsip_transport * transport
The underlying PJSIP transport.
char key[IP6ADDR_COLON_PORT_BUFLEN]
Key <ipaddr>:<port>
struct transport_monitor::@456 monitors

References ao2_bump, ao2_cleanup, ao2_find, ao2_global_obj_ref, ao2_lock, ao2_ref, ao2_unlock, ast_assert, ast_debug, AST_TRANSPORT_MONITOR_REG_FAILED, AST_TRANSPORT_MONITOR_REG_NOT_FOUND, AST_TRANSPORT_MONITOR_REG_SUCCESS, AST_VECTOR_APPEND, transport_monitor_notifier::cb, callback_data::cb, transport_monitor_notifier::data, transport_monitor::key, callback_data::matches, transport_monitor::monitors, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, ptr_matcher(), transport_monitor::transport, transport_monitor_unregister_cb(), and transport_monitor::transport_obj_name.

Referenced by ast_sip_transport_monitor_register(), ast_sip_transport_monitor_register_key(), ast_sip_transport_monitor_register_replace(), and registration_transport_monitor_setup().

◆ ast_sip_transport_monitor_unregister()

void ast_sip_transport_monitor_unregister ( pjsip_transport *  transport,
ast_transport_monitor_shutdown_cb  cb,
void *  data,
ast_transport_monitor_data_matcher  matches 
)

Unregister a reliable transport shutdown monitor.

Deprecated:
Replaced with ast_sip_transport_monitor_unregister_key().
Since
13.20.0
Parameters
transportTransport to monitor for shutdown.
cbThe callback that was used for the original register.
dataData to pass to the matcher. May be NULL and does NOT need to be an ao2 object. If NULL, all monitors with the provided callback are unregistered.
matchesMatcher function that returns true if data matches the previously registered data object. If NULL, a simple pointer comparison is done.
Note
The data object passed into the original register will have its reference count automatically decremented.

Definition at line 441 of file pjsip_transport_events.c.

443{
446 ast_sip_transport_monitor_unregister_key(key, cb, data, matches);
447}
void ast_sip_transport_monitor_unregister_key(const char *transport_key, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
Unregister a reliable transport shutdown monitor.

References AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR, ast_sip_transport_monitor_unregister_key(), callback_data::cb, callback_data::data, IP6ADDR_COLON_PORT_BUFLEN, and callback_data::matches.

Referenced by registrar_contact_delete().

◆ ast_sip_transport_monitor_unregister_all()

void ast_sip_transport_monitor_unregister_all ( ast_transport_monitor_shutdown_cb  cb,
void *  data,
ast_transport_monitor_data_matcher  matches 
)

Unregister a transport shutdown monitor from all reliable transports.

Since
13.20.0
Parameters
cbThe callback that was used for the original register.
dataData to pass to the matcher. May be NULL and does NOT need to be an ao2 object. If NULL, all monitors with the provided callback are unregistered.
matchesMatcher function that returns true if ao2_data matches the previously registered data object. If NULL, a simple pointer comparison is done.
Note
The data object passed into the original register will have its reference count automatically decremented.

Definition at line 421 of file pjsip_transport_events.c.

423{
424 struct ao2_container *transports;
425 struct callback_data cb_data = {
426 .cb = cb,
427 .data = data,
428 .matches = matches ?: ptr_matcher,
429 };
430
431 ast_assert(cb != NULL);
432
433 transports = ao2_global_obj_ref(active_transports);
434 if (!transports) {
435 return;
436 }
438 ao2_ref(transports, -1);
439}

References ao2_callback, ao2_global_obj_ref, ao2_ref, ast_assert, callback_data::cb, callback_data::data, callback_data::matches, NULL, OBJ_MULTIPLE, OBJ_NODATA, ptr_matcher(), and transport_monitor_unregister_cb().

Referenced by registrar_contact_delete(), and unload_module().

◆ ast_sip_transport_monitor_unregister_key()

void ast_sip_transport_monitor_unregister_key ( const char *  transport_key,
ast_transport_monitor_shutdown_cb  cb,
void *  data,
ast_transport_monitor_data_matcher  matches 
)

Unregister a reliable transport shutdown monitor.

Parameters
transport_keyKey for the transport to monitor for shutdown. Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
cbThe callback that was used for the original register.
dataData to pass to the matcher. May be NULL and does NOT need to be an ao2 object. If NULL, all monitors with the provided callback are unregistered.
matchesMatcher function that returns true if data matches the previously registered data object. If NULL, a simple pointer comparison is done.
Note
The data object passed into the original register will have its reference count automatically decremented.

Definition at line 449 of file pjsip_transport_events.c.

451{
452 struct ao2_container *transports;
453 struct transport_monitor *monitored;
454
455 ast_assert(transport_key != NULL && cb != NULL);
456
457 transports = ao2_global_obj_ref(active_transports);
458 if (!transports) {
459 return;
460 }
461
462 ao2_lock(transports);
463 monitored = ao2_find(transports, transport_key, OBJ_SEARCH_KEY | OBJ_NOLOCK);
464 if (monitored) {
465 struct callback_data cb_data = {
466 .cb = cb,
467 .data = data,
468 .matches = matches ?: ptr_matcher,
469 };
470
471 transport_monitor_unregister_cb(monitored, &cb_data, 0);
472 ao2_ref(monitored, -1);
473 }
474 ao2_unlock(transports);
475 ao2_ref(transports, -1);
476}

References ao2_find, ao2_global_obj_ref, ao2_lock, ao2_ref, ao2_unlock, ast_assert, callback_data::cb, callback_data::data, callback_data::matches, NULL, OBJ_NOLOCK, OBJ_SEARCH_KEY, ptr_matcher(), and transport_monitor_unregister_cb().

Referenced by ast_sip_transport_monitor_unregister(), handle_registration_response(), and subscription_persistence_remove().

◆ ast_sip_transport_state_register()

void ast_sip_transport_state_register ( struct ast_sip_tpmgr_state_callback element)

Register a transport state notification callback element.

Since
13.18.0
Parameters
elementWhat we are registering.

Definition at line 559 of file pjsip_transport_events.c.

560{
561 struct ast_sip_tpmgr_state_callback *tpmgr_notifier;
562
564 AST_LIST_TRAVERSE(&transport_state_list, tpmgr_notifier, node) {
565 if (element == tpmgr_notifier) {
566 /* Already registered. */
568 return;
569 }
570 }
573}
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711
static struct @455 transport_state_list
Definition: test_heap.c:38

References AST_LIST_INSERT_HEAD, AST_LIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and transport_state_list.

Referenced by ast_sip_initialize_transport_management().

◆ ast_sip_transport_state_set_preferred_identity()

int ast_sip_transport_state_set_preferred_identity ( const char *  transport_name,
const char *  identity 
)

Sets the P-Preferred-Identity on a child transport.

Since
17.0.0
Parameters
transport_nameThe name of the transport to be set on
identityThe P-Preferred-Identity to use on requests on this transport
Return values
0success
-1failure

Definition at line 242 of file config_transport.c.

243{
244 struct ast_sip_transport_state *transport_state;
245
246 if (ast_strlen_zero(transport_name)) {
247 return 0;
248 }
249
250 transport_state = ast_sip_get_transport_state(transport_name);
251 if (!transport_state) {
252 return -1;
253 }
254
255 if (!transport_state->flow) {
256 ao2_ref(transport_state, -1);
257 return 0;
258 }
259
260 ao2_lock(transport_state);
261 ast_free(transport_state->preferred_identity);
262 transport_state->preferred_identity = ast_strdup(identity);
263 ao2_unlock(transport_state);
264
265 ao2_ref(transport_state, -1);
266
267 return 0;
268}

References ao2_lock, ao2_ref, ao2_unlock, ast_free, ast_sip_get_transport_state(), ast_strdup, ast_strlen_zero(), ast_sip_transport_state::flow, and ast_sip_transport_state::preferred_identity.

Referenced by save_response_fields_to_transport().

◆ ast_sip_transport_state_set_service_routes()

int ast_sip_transport_state_set_service_routes ( const char *  transport_name,
struct ast_sip_service_route_vector service_routes 
)

Sets the service routes on a child transport.

Since
17.0.0
Parameters
transport_nameThe name of the transport to be set on
service_routesA vector of service routes
Return values
0success
-1failure
Note
This assumes ownership of the service routes in both success and failure scenarios

Definition at line 270 of file config_transport.c.

271{
272 struct ast_sip_transport_state *transport_state;
273
274 if (ast_strlen_zero(transport_name)) {
276 return 0;
277 }
278
279 transport_state = ast_sip_get_transport_state(transport_name);
280 if (!transport_state) {
282 return -1;
283 }
284
285 if (!transport_state->flow) {
286 ao2_ref(transport_state, -1);
288 return 0;
289 }
290
291 ao2_lock(transport_state);
293 transport_state->service_routes = service_routes;
294 ao2_unlock(transport_state);
295
296 ao2_ref(transport_state, -1);
297
298 return 0;
299}
void ast_sip_service_route_vector_destroy(struct ast_sip_service_route_vector *service_routes)
Destroy a vector of service routes.

References ao2_lock, ao2_ref, ao2_unlock, ast_sip_get_transport_state(), ast_sip_service_route_vector_destroy(), ast_strlen_zero(), ast_sip_transport_state::flow, and ast_sip_transport_state::service_routes.

Referenced by save_response_fields_to_transport().

◆ ast_sip_transport_state_set_transport()

int ast_sip_transport_state_set_transport ( const char *  transport_name,
pjsip_transport *  transport 
)

Sets the PJSIP transport on a child transport.

Since
17.0.0
Parameters
transport_nameThe name of the transport to be updated
transportThe PJSIP transport
Return values
0success
-1failure

Definition at line 206 of file config_transport.c.

207{
208 struct ast_sip_transport_state *transport_state;
209
210 /* To make it easier on callers we allow an empty transport name */
211 if (ast_strlen_zero(transport_name)) {
212 return 0;
213 }
214
215 transport_state = ast_sip_get_transport_state(transport_name);
216 if (!transport_state) {
217 return -1;
218 }
219
220 if (!transport_state->flow) {
221 ao2_ref(transport_state, -1);
222 return 0;
223 }
224
225 ao2_lock(transport_state);
226 if (transport_state->transport != transport) {
227 if (transport_state->transport) {
228 pjsip_transport_dec_ref(transport_state->transport);
229 }
230 transport_state->transport = transport;
231 if (transport_state->transport) {
232 pjsip_transport_add_ref(transport_state->transport);
233 }
234 }
235 ao2_unlock(transport_state);
236
237 ao2_ref(transport_state, -1);
238
239 return 0;
240}

References ao2_lock, ao2_ref, ao2_unlock, ast_sip_get_transport_state(), ast_strlen_zero(), ast_sip_transport_state::flow, and ast_sip_transport_state::transport.

Referenced by save_response_fields_to_transport().

◆ ast_sip_transport_state_unregister()

void ast_sip_transport_state_unregister ( struct ast_sip_tpmgr_state_callback element)

Unregister a transport state notification callback element.

Since
13.18.0
Parameters
elementWhat we are unregistering.

Definition at line 552 of file pjsip_transport_events.c.

553{
557}
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856

References AST_LIST_REMOVE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and transport_state_list.

Referenced by ast_sip_destroy_transport_management().

◆ ast_sip_unregister_authenticator()

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.

Parameters
authThe authenticator to unregister

Definition at line 152 of file res_pjsip.c.

153{
154 if (registered_authenticator != auth) {
155 ast_log(LOG_WARNING, "Trying to unregister authenticator %p but authenticator %p registered\n",
157 return;
158 }
160 ast_debug(1, "Unregistered SIP authenticator %p\n", auth);
161}

References ast_debug, ast_log, LOG_WARNING, NULL, and registered_authenticator.

Referenced by unload_module().

◆ ast_sip_unregister_endpoint_formatter()

void ast_sip_unregister_endpoint_formatter ( struct ast_sip_endpoint_formatter obj)

◆ ast_sip_unregister_endpoint_identifier()

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.

Parameters
identifierThe SIP endoint identifier to unregister

Definition at line 315 of file res_pjsip.c.

316{
317 struct endpoint_identifier_list *iter;
320 if (iter->identifier == identifier) {
322 ast_free(iter);
323 ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
324 break;
325 }
326 }
328}

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().

◆ ast_sip_unregister_outbound_authenticator()

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.

Parameters
authThe authenticator to unregister

Definition at line 203 of file res_pjsip.c.

204{
206 ast_log(LOG_WARNING, "Trying to unregister outbound authenticator %p but outbound authenticator %p registered\n",
208 return;
209 }
211 ast_debug(1, "Unregistered SIP outbound authenticator %p\n", auth);
212}

References ast_debug, ast_log, LOG_WARNING, NULL, and registered_outbound_authenticator.

Referenced by unload_module().

◆ ast_sip_unregister_service()

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.

Parameters
moduleThe PJSIP module to unregister

Definition at line 133 of file res_pjsip.c.

134{
136}
static int unregister_service(void *data)
Definition: res_pjsip.c:122

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().

◆ ast_sip_unregister_supplement()

void ast_sip_unregister_supplement ( struct ast_sip_supplement supplement)

Unregister a an supplement to SIP out of dialog processing.

Parameters
supplementThe supplement to unregister

Definition at line 1476 of file res_pjsip.c.

1477{
1478 struct ast_sip_supplement *iter;
1480
1482 if (supplement == iter) {
1484 break;
1485 }
1486 }
1488}

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().

◆ ast_sip_update_from()

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.

Parameters
tdatathe outbound message data structure
frominfo to copy into the header. Can be either a SIP URI, or in the format user[@domain]
Return values
0success, -1: failure

Definition at line 3383 of file res_pjsip.c.

3384{
3385 pjsip_name_addr *name_addr;
3386 pjsip_sip_uri *uri;
3387 pjsip_name_addr *parsed_name_addr;
3388 pjsip_from_hdr *from_hdr;
3389
3390 if (ast_strlen_zero(from)) {
3391 return 0;
3392 }
3393
3394 from_hdr = PJSIP_MSG_FROM_HDR(tdata->msg);
3395 if (!from_hdr) {
3396 return -1;
3397 }
3398 name_addr = (pjsip_name_addr *) from_hdr->uri;
3399 uri = pjsip_uri_get_uri(name_addr);
3400
3401 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, from,
3402 strlen(from), PJSIP_PARSE_URI_AS_NAMEADDR);
3403 if (parsed_name_addr) {
3404 pjsip_sip_uri *parsed_uri;
3405
3406 if (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3407 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri)) {
3408 ast_log(LOG_WARNING, "From address '%s' is not a valid SIP/SIPS URI\n", from);
3409 return -1;
3410 }
3411
3412 parsed_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3413
3414 if (pj_strlen(&parsed_name_addr->display)) {
3415 pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
3416 }
3417
3418 /* Unlike the To header, we only want to replace the user, host and port */
3419 pj_strdup(tdata->pool, &uri->user, &parsed_uri->user);
3420 pj_strdup(tdata->pool, &uri->host, &parsed_uri->host);
3421 uri->port = parsed_uri->port;
3422
3423 return 0;
3424 } else {
3425 /* assume it is 'user[@domain]' format */
3426 char *domain = strchr(from, '@');
3427
3428 if (domain) {
3429 pj_str_t pj_from;
3430
3431 pj_strset3(&pj_from, from, domain);
3432 pj_strdup(tdata->pool, &uri->user, &pj_from);
3433
3434 pj_strdup2(tdata->pool, &uri->host, domain + 1);
3435 } else {
3436 pj_strdup2(tdata->pool, &uri->user, from);
3437 }
3438
3439 return 0;
3440 }
3441
3442 return -1;
3443}

References ast_log, ast_strlen_zero(), and LOG_WARNING.

Referenced by msg_send(), and refer_send().

◆ ast_sip_update_to_uri()

int ast_sip_update_to_uri ( pjsip_tx_data *  tdata,
const char *  to 
)

Replace the To URI in the tdata with the supplied one.

Parameters
tdatathe outbound message data structure
toURI to replace the To URI with. Must be a valid SIP URI.
Return values
0success, -1: failure

Definition at line 3323 of file res_pjsip.c.

3324{
3325 pjsip_name_addr *parsed_name_addr;
3326 pjsip_sip_uri *sip_uri;
3327 pjsip_name_addr *tdata_name_addr;
3328 pjsip_sip_uri *tdata_sip_uri;
3329 pjsip_to_hdr *to_hdr;
3330 char *buf = NULL;
3331#define DEBUG_BUF_SIZE 256
3332
3333 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, (char*)to, strlen(to),
3334 PJSIP_PARSE_URI_AS_NAMEADDR);
3335
3336 if (!parsed_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3337 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri))) {
3338 ast_log(LOG_WARNING, "To address '%s' is not a valid SIP/SIPS URI\n", to);
3339 return -1;
3340 }
3341
3342 sip_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3343 if (DEBUG_ATLEAST(3)) {
3345 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, sip_uri, buf, DEBUG_BUF_SIZE);
3346 ast_debug(3, "Parsed To: %.*s %s\n", (int)parsed_name_addr->display.slen,
3347 parsed_name_addr->display.ptr, buf);
3348 }
3349
3350 to_hdr = PJSIP_MSG_TO_HDR(tdata->msg);
3351 tdata_name_addr = to_hdr ? (pjsip_name_addr *) to_hdr->uri : NULL;
3352 if (!tdata_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(tdata_name_addr->uri)
3353 && !PJSIP_URI_SCHEME_IS_SIPS(tdata_name_addr->uri))) {
3354 /* Highly unlikely but we have to check */
3355 ast_log(LOG_WARNING, "tdata To address '%s' is not a valid SIP/SIPS URI\n", to);
3356 return -1;
3357 }
3358
3359 tdata_sip_uri = pjsip_uri_get_uri(tdata_name_addr->uri);
3360 if (DEBUG_ATLEAST(3)) {
3361 buf[0] = '\0';
3362 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, tdata_sip_uri, buf, DEBUG_BUF_SIZE);
3363 ast_debug(3, "Original tdata To: %.*s %s\n", (int)tdata_name_addr->display.slen,
3364 tdata_name_addr->display.ptr, buf);
3365 }
3366
3367 /* Replace the uri */
3368 pjsip_sip_uri_assign(tdata->pool, tdata_sip_uri, sip_uri);
3369 /* The display name isn't part of the URI so we need to replace it separately */
3370 pj_strdup(tdata->pool, &tdata_name_addr->display, &parsed_name_addr->display);
3371
3372 if (DEBUG_ATLEAST(3)) {
3373 buf[0] = '\0';
3374 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, tdata_sip_uri, buf, 256);
3375 ast_debug(3, "New tdata To: %.*s %s\n", (int)tdata_name_addr->display.slen,
3376 tdata_name_addr->display.ptr, buf);
3377 }
3378
3379 return 0;
3380#undef DEBUG_BUF_SIZE
3381}
#define DEBUG_ATLEAST(level)
#define DEBUG_BUF_SIZE

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().

Variable Documentation

◆ AST_PJ_STR_EMPTY

const pj_str_t AST_PJ_STR_EMPTY = { "", 0 }
static

Definition at line 111 of file res_pjsip.h.

Referenced by ast_sip_pjsip_uri_get_hostname(), and ast_sip_pjsip_uri_get_username().

◆ pjsip_media_type_application_cpim_xpidf_xml

pjsip_media_type pjsip_media_type_application_cpim_xpidf_xml
extern

Definition at line 3913 of file res_pjsip.c.

Referenced by load_module().

◆ pjsip_media_type_application_json

pjsip_media_type pjsip_media_type_application_json
extern

Common media types used throughout res_pjsip and pjproject

Definition at line 3909 of file res_pjsip.c.

Referenced by load_module().

◆ pjsip_media_type_application_media_control_xml

pjsip_media_type pjsip_media_type_application_media_control_xml
extern

Definition at line 3910 of file res_pjsip.c.

Referenced by load_module(), and video_info_incoming_request().

◆ pjsip_media_type_application_pidf_xml

pjsip_media_type pjsip_media_type_application_pidf_xml
extern

Definition at line 3911 of file res_pjsip.c.

Referenced by add_eprofile_to_tdata(), find_pidf(), and load_module().

◆ pjsip_media_type_application_rlmi_xml

pjsip_media_type pjsip_media_type_application_rlmi_xml
extern

Definition at line 3914 of file res_pjsip.c.

Referenced by load_module().

◆ pjsip_media_type_application_sdp

pjsip_media_type pjsip_media_type_application_sdp
extern

Definition at line 3916 of file res_pjsip.c.

Referenced by filter_on_tx_message(), load_module(), and session_outgoing_nat_hook().

◆ pjsip_media_type_application_simple_message_summary

pjsip_media_type pjsip_media_type_application_simple_message_summary
extern

Definition at line 3915 of file res_pjsip.c.

Referenced by load_module().

◆ pjsip_media_type_application_xpidf_xml

pjsip_media_type pjsip_media_type_application_xpidf_xml
extern

Definition at line 3912 of file res_pjsip.c.

Referenced by load_module().

◆ pjsip_media_type_multipart_alternative

pjsip_media_type pjsip_media_type_multipart_alternative
extern

Definition at line 3917 of file res_pjsip.c.

Referenced by check_content_disposition(), and load_module().

◆ pjsip_media_type_multipart_mixed

pjsip_media_type pjsip_media_type_multipart_mixed
extern

◆ pjsip_media_type_multipart_related

pjsip_media_type pjsip_media_type_multipart_related
extern

Definition at line 3919 of file res_pjsip.c.

Referenced by load_module().

◆ pjsip_media_type_text_plain

pjsip_media_type pjsip_media_type_text_plain
extern

Definition at line 3920 of file res_pjsip.c.

Referenced by load_module().