Asterisk - The Open Source Telephony Project GIT-master-4f2b068
Loading...
Searching...
No Matches
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_password_digest
 
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...
 
struct  pjsip_auth_algorithm
 
struct  pjsip_auth_algorithm_type_vector
 

Macros

#define AST_SIP_AUTH_MAX_REALM_LENGTH   255 /* From the auth/realm realtime column size */
 
#define AST_SIP_AUTH_MAX_SUPPORTED_ALGORITHMS_LENGTH   (255) /* From the supported algorithms 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.
 
#define ast_sip_cleanup_auth_objects_vector(auth_objects)   AST_VECTOR_RESET(auth_objects, ao2_cleanup)
 Clean up retrieved auth objects in vector.
 
#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.
 
#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.
 
#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.
 
#define ast_sip_push_task(serializer, sip_task, task_data)    __ast_sip_push_task(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#define ast_sip_push_task_synchronous(serializer, sip_task, task_data)    __ast_sip_push_task_synchronous(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#define ast_sip_push_task_wait_serializer(serializer, sip_task, task_data)    __ast_sip_push_task_wait_serializer(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#define ast_sip_push_task_wait_servant(serializer, sip_task, task_data)    __ast_sip_push_task_wait_servant(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
 
#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.
 
#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.
 

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.
 
typedef int(* ast_sip_task) (void *user_data)
 
typedef int(* ast_transport_monitor_data_matcher) (void *a, void *b)
 Transport shutdown monitor data matcher.
 
typedef void(* ast_transport_monitor_shutdown_cb) (void *data)
 Transport shutdown monitor callback.
 
typedef struct pjsip_auth_algorithm pjsip_auth_algorithm
 
typedef enum pjsip_auth_algorithm_type pjsip_auth_algorithm_type
 

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_cred_usage { AST_SIP_AUTH_CRED_USAGE_UAC , AST_SIP_AUTH_CRED_USAGE_UAS }
 
enum  ast_sip_auth_type {
  AST_SIP_AUTH_TYPE_NONE = -1 , AST_SIP_AUTH_TYPE_USER_PASS = 0 , AST_SIP_AUTH_TYPE_MD5 , AST_SIP_AUTH_TYPE_GOOGLE_OAUTH ,
  AST_SIP_AUTH_TYPE_ARTIFICIAL , AST_SIP_AUTH_TYPE_DIGEST
}
 Authentication methods. 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_redirect_method { AST_SIP_REDIRECT_METHOD_MESSAGE = (1 << 0) }
 SIP methods that are allowed to follow 3xx redirects. 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 }
 
enum  pjsip_auth_algorithm_type {
  PJSIP_AUTH_ALGORITHM_NOT_SET = 0 , PJSIP_AUTH_ALGORITHM_MD5 , PJSIP_AUTH_ALGORITHM_SHA256 , PJSIP_AUTH_ALGORITHM_SHA512_256 ,
  PJSIP_AUTH_ALGORITHM_AKAV1_MD5 , PJSIP_AUTH_ALGORITHM_COUNT
}
 

Functions

int __ast_sip_push_task (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
 Pushes a task to SIP servants.
 
int __ast_sip_push_task_synchronous (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
 Push a task to SIP servants and wait for it to complete.
 
int __ast_sip_push_task_wait_serializer (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
 Push a task to the serializer and wait for it to complete.
 
int __ast_sip_push_task_wait_servant (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
 Push a task to SIP servants and wait for it to complete.
 
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.
 
int ast_copy_pj_str2 (char **dest, const pj_str_t *src)
 Create and copy a pj_str_t into a standard character buffer.
 
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.
 
int ast_sip_add_body (pjsip_tx_data *tdata, const struct ast_sip_body *body)
 Add a body to an outbound SIP message.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
int ast_sip_append_body (pjsip_tx_data *tdata, const char *body_text)
 Append body data to a SIP message.
 
int ast_sip_are_media_types_equal (pjsip_media_type *a, pjsip_media_type *b)
 Compare pjsip media types.
 
int ast_sip_auth_digest_algorithms_vector_init (const char *id, struct pjsip_auth_algorithm_type_vector *algorithms, const char *agent_type, const char *value)
 Populate a vector of algorithm types from a string.
 
int ast_sip_auth_digest_algorithms_vector_to_str (const struct pjsip_auth_algorithm_type_vector *algorithms, char **buf)
 Dump a vector of algorithm types to a string.
 
const pjsip_auth_algorithmast_sip_auth_get_algorithm_by_iana_name (const pj_str_t *iana_name)
 Get algorithm by IANA name.
 
const pjsip_auth_algorithmast_sip_auth_get_algorithm_by_type (pjsip_auth_algorithm_type algorithm_type)
 Get algorithm by algorithm type.
 
const char * ast_sip_auth_get_creds (const struct ast_sip_auth *auth, const pjsip_auth_algorithm_type algorithm_type, int *cred_type)
 Get the plain text or digest password from an auth object.
 
int ast_sip_auth_is_algorithm_available (const struct ast_sip_auth *auth, const struct pjsip_auth_algorithm_type_vector *algorithms, pjsip_auth_algorithm_type algorithm_type)
 Checks an pjsip_auth_algorithm_type_vector to see if it contains an algorithm.
 
pj_bool_t ast_sip_auth_is_algorithm_supported (pjsip_auth_algorithm_type algorithm_type)
 Is algorithm supported by OpenSSL and pjproject?
 
const char * ast_sip_auth_type_to_str (enum ast_sip_auth_type type)
 Converts the given auth type to a string.
 
void ast_sip_auth_vector_destroy (struct ast_sip_auth_vector *vector)
 Free contents of an auth vector.
 
int ast_sip_auth_vector_init (struct ast_sip_auth_vector *vector, const char *auth_names)
 Initialize an auth vector with the configured values.
 
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.
 
const char * ast_sip_call_codec_pref_to_str (struct ast_flags pref)
 Convert the call codec preference flags to a string.
 
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.
 
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.
 
void ast_sip_cleanup_auths (struct ast_sip_auth *auths[], size_t num_auths)
 Clean up retrieved auth structures from memory.
 
int ast_sip_contact_to_str (void *object, void *arg, int flags)
 Handler used to convert a contact to a string.
 
struct ast_strast_sip_create_ami_event (const char *event, struct ast_sip_ami *ami)
 Creates a string to store AMI event data in.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
struct ast_taskprocessorast_sip_create_serializer (const char *name)
 Create a new serializer for SIP tasks.
 
struct ast_taskprocessorast_sip_create_serializer_group (const char *name, struct ast_serializer_shutdown_group *shutdown_group)
 Create a new serializer for SIP tasks.
 
struct ast_sip_endpointast_sip_default_outbound_endpoint (void)
 Retrieve the default outbound endpoint.
 
struct ast_sip_endpointast_sip_dialog_get_endpoint (pjsip_dialog *dlg)
 Get the endpoint associated with this dialog.
 
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.
 
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.
 
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.
 
void * ast_sip_dict_get (void *ht, const char *key)
 Retrieves the value associated with the given key.
 
void * ast_sip_dict_set (pj_pool_t *pool, void *ht, const char *key, void *val)
 Set the value for the given key.
 
int ast_sip_dlg_set_transport (const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg, pjsip_tpselector *selector)
 Set the transport on a dialog.
 
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.
 
void * ast_sip_endpoint_alloc (const char *name)
 Allocate a new SIP endpoint.
 
int ast_sip_failover_request (pjsip_tx_data *tdata)
 Set a request to use the next value in the list of resolved addresses.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
int ast_sip_format_auths_ami (const struct ast_sip_auth_vector *auths, struct ast_sip_ami *ami)
 Format auth details for AMI.
 
int ast_sip_format_contact_ami (void *obj, void *arg, int flags)
 Formats the contact and sends over 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.
 
unsigned int ast_sip_get_all_codecs_on_empty_reinvite (void)
 Retrieve the system setting 'all_codecs_on_empty_reinvite'.
 
unsigned int ast_sip_get_allow_sending_180_after_183 (void)
 Retrieve the global setting 'allow_sending_180_after_183'.
 
struct ast_sip_authast_sip_get_artificial_auth (void)
 Retrieves a reference to the artificial auth.
 
struct ast_sip_endpointast_sip_get_artificial_endpoint (void)
 Retrieves a reference to the artificial endpoint.
 
unsigned int ast_sip_get_contact_expiration_check_interval (void)
 Retrieve the system contact expiration check interval setting.
 
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.
 
struct ast_sip_contact_statusast_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.
 
char * ast_sip_get_debug (void)
 Retrieve the system debug setting (yes|no|host).
 
void ast_sip_get_default_auth_algorithms_uac (char *default_auth_algorithms_uac, size_t size)
 Retrieve the global auth algorithms for UAC.
 
void ast_sip_get_default_auth_algorithms_uas (char *default_auth_algorithms_uas, size_t size)
 Retrieve the global auth algorithms for UAS.
 
void ast_sip_get_default_from_user (char *from_user, size_t size)
 Retrieve the global default from user.
 
void ast_sip_get_default_realm (char *realm, size_t size)
 Retrieve the global default realm.
 
char * ast_sip_get_default_voicemail_extension (void)
 Retrieve the default voicemail extension.
 
const char * ast_sip_get_device_state (const struct ast_sip_endpoint *endpoint)
 Retrieve the device state for an endpoint.
 
unsigned int ast_sip_get_disable_multi_domain (void)
 Retrieve the system setting 'disable multi domain'.
 
struct ast_taskprocessorast_sip_get_distributor_serializer (pjsip_rx_data *rdata)
 Determine the distributor serializer for the SIP message.
 
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.
 
char * ast_sip_get_endpoint_identifier_order (void)
 Retrieve the global endpoint_identifier_order setting.
 
struct ast_endpoint_snapshotast_sip_get_endpoint_snapshot (const struct ast_sip_endpoint *endpoint)
 Retrieve the endpoint snapshot for an endpoint.
 
struct ao2_containerast_sip_get_endpoints (void)
 Retrieve any endpoints available to sorcery.
 
int ast_sip_get_host_ip (int af, pj_sockaddr *addr)
 Retrieve the local host address in IP form.
 
const char * ast_sip_get_host_ip_string (int af)
 Retrieve the local host address in string form.
 
unsigned int ast_sip_get_ignore_uri_user_options (void)
 Retrieve the global setting 'ignore_uri_user_options'.
 
unsigned int ast_sip_get_keep_alive_interval (void)
 Retrieve the system keep alive interval setting.
 
unsigned int ast_sip_get_max_initial_qualify_time (void)
 Retrieve the system max initial qualify time.
 
unsigned int ast_sip_get_mwi_disable_initial_unsolicited (void)
 Retrieve the global setting 'disable sending unsolicited mwi on startup'.
 
unsigned int ast_sip_get_mwi_tps_queue_high (void)
 Retrieve the global MWI taskprocessor high water alert trigger level.
 
int ast_sip_get_mwi_tps_queue_low (void)
 Retrieve the global MWI taskprocessor low water clear alert level.
 
unsigned int ast_sip_get_norefersub (void)
 Retrieve the global setting 'norefersub'.
 
pjsip_endpoint * ast_sip_get_pjsip_endpoint (void)
 Get a pointer to the PJSIP endpoint.
 
char * ast_sip_get_regcontext (void)
 Retrieve the global regcontext setting.
 
unsigned int ast_sip_get_send_contact_status_on_update_registration (void)
 Retrieve the global setting 'send_contact_status_on_update_registration'.
 
struct ast_sorceryast_sip_get_sorcery (void)
 Get a pointer to the SIP sorcery structure.
 
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.
 
struct ast_sip_transport_stateast_sip_get_transport_state (const char *transport_id)
 Retrieve transport state.
 
struct ao2_containerast_sip_get_transport_states (void)
 Retrieves all transport states.
 
void ast_sip_get_unidentified_request_thresholds (unsigned int *count, unsigned int *period, unsigned int *prune_interval)
 Retrieve the unidentified request security event thresholds.
 
unsigned int ast_sip_get_use_callerid_contact (void)
 Retrieve the global setting 'use_callerid_contact'.
 
const int ast_sip_hangup_sip2cause (int cause)
 Convert SIP hangup causes to Asterisk hangup causes.
 
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.
 
struct ast_sip_endpointast_sip_identify_endpoint (pjsip_rx_data *rdata)
 Determine the endpoint that has sent a SIP message.
 
int ast_sip_is_allowed_uri (pjsip_uri *uri)
 Check whether a pjsip_uri is allowed or not.
 
int ast_sip_is_content_type (pjsip_media_type *content_type, char *type, char *subtype)
 Checks if the given content type matches type/subtype.
 
int ast_sip_is_media_type_in (pjsip_media_type *a,...) attribute_sentinel
 Check if a media type is in a list of others.
 
int ast_sip_is_uri_sip_sips (pjsip_uri *uri)
 Check whether a pjsip_uri is SIP/SIPS or not.
 
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.
 
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.
 
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.
 
int ast_sip_location_delete_contact (struct ast_sip_contact *contact)
 Delete a contact.
 
void ast_sip_location_prune_boot_contacts (void)
 Prune the prune_on_boot contacts.
 
struct ast_sip_aorast_sip_location_retrieve_aor (const char *aor_name)
 Retrieve a named AOR.
 
struct ao2_containerast_sip_location_retrieve_aor_contacts (const struct ast_sip_aor *aor)
 Retrieve all contacts currently available for an AOR.
 
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.
 
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.
 
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.
 
struct ast_sip_contactast_sip_location_retrieve_contact (const char *contact_name)
 Retrieve a named contact.
 
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.
 
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.
 
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.
 
struct ao2_containerast_sip_location_retrieve_contacts_from_aor_list (const char *aor_list)
 Retrieve all contacts from a list of AORs.
 
struct ast_sip_contactast_sip_location_retrieve_first_aor_contact (const struct ast_sip_aor *aor)
 Retrieve the first bound contact for an AOR.
 
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.
 
int ast_sip_location_update_contact (struct ast_sip_contact *contact)
 Update a contact.
 
void ast_sip_message_apply_transport (const char *transport_name, pjsip_tx_data *tdata)
 Apply the configuration for a transport to an outgoing message.
 
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.
 
float ast_sip_parse_qvalue (const char *q_value)
 Parses a string representing a q_value to a float.
 
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.
 
int ast_sip_persistent_endpoint_update_state (const char *endpoint_name, enum ast_endpoint_state state)
 Change state of a persistent endpoint.
 
const pj_str_t * ast_sip_pjsip_uri_get_hostname (pjsip_uri *uri)
 Get the host portion of the pjsip_uri.
 
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.
 
const pj_str_t * ast_sip_pjsip_uri_get_username (pjsip_uri *uri)
 Get the user portion of the pjsip_uri.
 
char * ast_sip_rdata_get_header_value (pjsip_rx_data *rdata, const pj_str_t str)
 Get a specific header value from rdata.
 
int ast_sip_register_authenticator (struct ast_sip_authenticator *auth)
 Register a SIP authenticator.
 
void ast_sip_register_endpoint_formatter (struct ast_sip_endpoint_formatter *obj)
 Register an endpoint formatter.
 
int ast_sip_register_endpoint_identifier (struct ast_sip_endpoint_identifier *identifier)
 Register a SIP endpoint identifier.
 
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.
 
int ast_sip_register_outbound_authenticator (struct ast_sip_outbound_authenticator *outbound_auth)
 Register an outbound SIP authenticator.
 
int ast_sip_register_service (pjsip_module *module)
 Register a SIP service in Asterisk.
 
void ast_sip_register_supplement (struct ast_sip_supplement *supplement)
 Register a supplement to SIP out of dialog processing.
 
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.
 
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.
 
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.
 
void ast_sip_report_auth_success (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Send a security event notification for when authentication succeeds.
 
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.
 
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.
 
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.
 
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.
 
int ast_sip_requires_authentication (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Determine if an incoming request requires authentication.
 
int ast_sip_retrieve_auths (const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out)
 Retrieve relevant SIP auth structures from sorcery.
 
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.
 
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.
 
int ast_sip_sched_is_task_running (struct ast_sip_sched_task *schtd)
 Checks if the task is currently running.
 
int ast_sip_sched_is_task_running_by_name (const char *name)
 Checks if the task is currently running.
 
int ast_sip_sched_task_cancel (struct ast_sip_sched_task *schtd)
 Cancels the next invocation of a task.
 
int ast_sip_sched_task_cancel_by_name (const char *name)
 Cancels the next invocation of a task by name.
 
int ast_sip_sched_task_get_name (struct ast_sip_sched_task *schtd, char *name, size_t maxlen)
 Gets the task name.
 
int ast_sip_sched_task_get_next_run (struct ast_sip_sched_task *schtd)
 Gets the number of milliseconds until the next invocation.
 
int ast_sip_sched_task_get_next_run_by_name (const char *name)
 Gets the number of milliseconds until the next invocation.
 
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.
 
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.
 
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.
 
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.
 
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 taskpool.
 
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.
 
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.
 
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.
 
void ast_sip_security_mechanisms_vector_destroy (struct ast_sip_security_mechanism_vector *security_mechanisms)
 Free contents of a security mechanism vector.
 
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.
 
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.
 
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.
 
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.
 
struct ast_sip_service_route_vectorast_sip_service_route_vector_alloc (void)
 Allocate a vector of service routes.
 
void ast_sip_service_route_vector_destroy (struct ast_sip_service_route_vector *service_routes)
 Destroy a vector of service routes.
 
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.
 
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.
 
int ast_sip_set_outbound_proxy (pjsip_tx_data *tdata, const char *proxy)
 Set the outbound proxy for an outbound SIP message.
 
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.
 
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.
 
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.
 
int ast_sip_set_tpselector_from_transport (const struct ast_sip_transport *transport, pjsip_tpselector *selector)
 Sets pjsip_tpselector from ast_sip_transport.
 
int ast_sip_set_tpselector_from_transport_name (const char *transport_name, pjsip_tpselector *selector)
 Sets pjsip_tpselector from ast_sip_transport.
 
int ast_sip_sorcery_object_to_ami (const void *obj, struct ast_str **buf)
 Converts a sorcery object to a string of object properties.
 
int ast_sip_str2rc (const char *name)
 Convert name to SIP response code.
 
int ast_sip_str_to_dtmf (const char *dtmf_mode)
 Convert the DTMF mode name into an enum.
 
int ast_sip_str_to_security_mechanism (struct ast_sip_security_mechanism **security_mechanism, const char *value)
 Allocate a security mechanism from a string.
 
struct ast_taskpoolast_sip_taskpool (void)
 Retrieve the SIP taskpool object.
 
long ast_sip_taskpool_queue_size (void)
 Return the size of the SIP taskpool's task queue.
 
int ast_sip_thread_is_servant (void)
 Determine if the current thread is a SIP servant thread.
 
void ast_sip_tpselector_unref (pjsip_tpselector *selector)
 Unreference a pjsip_tpselector.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
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.
 
void ast_sip_transport_state_register (struct ast_sip_tpmgr_state_callback *element)
 Register a transport state notification callback element.
 
int ast_sip_transport_state_set_preferred_identity (const char *transport_name, const char *identity)
 Sets the P-Preferred-Identity on a child transport.
 
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.
 
int ast_sip_transport_state_set_transport (const char *transport_name, pjsip_transport *transport)
 Sets the PJSIP transport on a child transport.
 
void ast_sip_transport_state_unregister (struct ast_sip_tpmgr_state_callback *element)
 Unregister a transport state notification callback element.
 
void ast_sip_unregister_authenticator (struct ast_sip_authenticator *auth)
 Unregister a SIP authenticator.
 
void ast_sip_unregister_endpoint_formatter (struct ast_sip_endpoint_formatter *obj)
 Unregister an endpoint formatter.
 
void ast_sip_unregister_endpoint_identifier (struct ast_sip_endpoint_identifier *identifier)
 Unregister a SIP endpoint identifier.
 
void ast_sip_unregister_outbound_authenticator (struct ast_sip_outbound_authenticator *auth)
 Unregister an outbound SIP authenticator.
 
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.
 
int ast_sip_update_from (pjsip_tx_data *tdata, char *from)
 Overwrite fields in the outbound 'From' header.
 
int ast_sip_update_to_uri (pjsip_tx_data *tdata, const char *to)
 Replace the To URI in the tdata with the supplied one.
 

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_AUTH_MAX_SUPPORTED_ALGORITHMS_LENGTH

#define AST_SIP_AUTH_MAX_SUPPORTED_ALGORITHMS_LENGTH   (255) /* From the supported algorithms realtime column size */

Definition at line 75 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 797 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 2992 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 91 of file res_pjsip.h.

111 { "", 0 };
112
113/*!
114 * \brief Structure for SIP transport information
115 */
117 /*! \brief Transport itself */
118 struct pjsip_transport *transport;
119 /*! \brief Transport factory */
120 struct pjsip_tpfactory *factory;
121 /*!
122 * Transport id
123 * \since 13.8.0
124 */
125 char *id;
126 /*!
127 * Transport type
128 * \since 13.8.0
129 */
130 enum ast_transport type;
131 /*!
132 * Address and port to bind to
133 * \since 13.8.0
134 */
135 pj_sockaddr host;
136 /*!
137 * TLS settings
138 * \since 13.8.0
139 */
140 pjsip_tls_setting tls;
141 /*!
142 * Configured TLS ciphers
143 * \since 13.8.0
144 */
145 pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS];
146 /*!
147 * Optional local network information, used for NAT purposes.
148 * "deny" (set) means that it's in the local network. Use the
149 * ast_sip_transport_is_nonlocal and ast_sip_transport_is_local
150 * macro's.
151 * \since 13.8.0
152 */
153 struct ast_ha *localnet;
154 /*!
155 * DNS manager for refreshing the external signaling address
156 * \since 13.8.0
157 */
159 /*!
160 * Optional external signaling address information
161 * \since 13.8.0
162 */
164 /*!
165 * DNS manager for refreshing the external media address
166 * \since 13.18.0
167 */
169 /*!
170 * Optional external signaling address information
171 * \since 13.18.0
172 */
174 /*!
175 * Set when this transport is a flow of signaling to a target
176 * \since 17.0.0
177 */
178 int flow;
179 /*!
180 * The P-Preferred-Identity to use on traffic using this transport
181 * \since 17.0.0
182 */
183 char *preferred_identity;
184 /*!
185 * The Service Routes to use on traffic using this transport
186 * \since 17.0.0
187 */
189 /*!
190 * Disregard RFC5922 7.2, and allow wildcard certs (TLS only)
191 */
193 /*!
194 * If true, fail if server certificate cannot verify (TLS only)
195 */
196 int verify_server;
197#ifdef HAVE_PJSIP_TLS_TRANSPORT_RESTART
198 /*!
199 * The stats information for the certificate file, if configured
200 */
201 struct stat cert_file_stat;
202 /*!
203 * The stats information for the private key file, if configured
204 */
205 struct stat privkey_file_stat;
206#endif
207};
208
209#define ast_sip_transport_is_nonlocal(transport_state, addr) \
210 (!transport_state->localnet || ast_apply_ha(transport_state->localnet, addr) == AST_SENSE_ALLOW)
211
212#define ast_sip_transport_is_local(transport_state, addr) \
213 (transport_state->localnet && ast_apply_ha(transport_state->localnet, addr) != AST_SENSE_ALLOW)
214
215/*!
216 * \brief Transport to bind to
217 */
218struct ast_sip_transport {
219 /*! Sorcery object details */
220 SORCERY_OBJECT(details);
222 /*! Certificate of authority list file */
224 /*! Certificate of authority list path */
226 /*! Public certificate file */
228 /*! Optional private key of the certificate file */
230 /*! Password to open the private key */
232 /*! External signaling address */
234 /*! External media address */
236 /*! Optional domain to use for messages if provided could not be found */
238 );
239 /*! Type of transport */
240 enum ast_transport type;
241 /*!
242 * \deprecated Moved to ast_sip_transport_state
243 * \version 13.8.0 deprecated
244 * Address and port to bind to
245 */
246 pj_sockaddr host;
247 /*! Number of simultaneous asynchronous operations */
248 unsigned int async_operations;
249 /*! Optional external port for signaling */
250 unsigned int external_signaling_port;
251 /*!
252 * \deprecated Moved to ast_sip_transport_state
253 * \version 13.7.1 deprecated
254 * TLS settings
255 */
256 pjsip_tls_setting tls;
257 /*!
258 * \deprecated Moved to ast_sip_transport_state
259 * \version 13.7.1 deprecated
260 * Configured TLS ciphers
261 */
262 pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS];
263 /*!
264 * \deprecated Moved to ast_sip_transport_state
265 * \version 13.7.1 deprecated
266 * Optional local network information, used for NAT purposes
267 */
268 struct ast_ha *localnet;
269 /*!
270 * \deprecated Moved to ast_sip_transport_state
271 * \version 13.7.1 deprecated
272 * DNS manager for refreshing the external address
273 */
275 /*!
276 * \deprecated Moved to ast_sip_transport_state
277 * \version 13.7.1 deprecated
278 * Optional external address information
279 */
281 /*!
282 * \deprecated
283 * \version 13.7.1 deprecated
284 * Transport state information
285 */
287 /*! QOS DSCP TOS bits */
288 unsigned int tos;
289 /*! QOS COS value */
290 unsigned int cos;
291 /*! Write timeout */
292 int write_timeout;
293 /*! Allow reload */
294 int allow_reload;
295 /*! Automatically send requests out the same transport requests have come in on */
297 /*! This is a flow to another target */
298 int flow;
299 /*! Enable TCP keepalive */
301 /*! Time in seconds the connection needs to remain idle before TCP starts sending keepalive probes */
303 /*! The time in seconds between individual keepalive probes */
305 /*! The maximum number of keepalive probes TCP should send before dropping the connection */
307};
308
309#define SIP_SORCERY_DOMAIN_ALIAS_TYPE "domain_alias"
310
311/*!
312 * Details about a SIP domain alias
313 */
315 /*! Sorcery object details */
316 SORCERY_OBJECT(details);
318 /*! Domain to be aliased to */
320 );
321};
322
323/*!
324 * \brief Structure for SIP nat hook information
325 */
326struct ast_sip_nat_hook {
327 /*! Sorcery object details */
328 SORCERY_OBJECT(details);
329 /*! Callback for when a message is going outside of our local network */
330 void (*outgoing_external_message)(struct pjsip_tx_data *tdata, struct ast_sip_transport *transport);
331};
332
333/*! \brief Structure which contains information about a transport */
335 /*! \brief Type of transport */
336 enum ast_transport type;
337 /*! \brief Potential pointer to the transport itself, if UDP */
338 pjsip_transport *transport;
339 /*! \brief Potential pointer to the transport factory itself, if TCP/TLS */
340 pjsip_tpfactory *factory;
341 /*! \brief Local address for transport */
342 pj_str_t local_address;
343 /*! \brief Local port for transport */
344 int local_port;
345};
346
347/*!
348 * \brief The kind of security negotiation
349 */
351 /*! No security mechanism negotiation */
353 /*! Use mediasec security mechanism negotiation */
355 /* Add RFC 3329 (sec-agree) mechanism negotiation in the future */
356};
357
358/*!
359 * \brief The security mechanism type
360 */
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};
371
372/*!
373 * \brief Structure representing a security mechanism as defined in RFC 3329
374 */
376 /* Used to determine which security mechanism to use. */
378 /* The preference of this security mechanism. The higher the value, the more preferred. */
379 float qvalue;
380 /* Optional mechanism parameters. */
382};
383
385
386/*!
387 * \brief Contact associated with an address of record
388 */
389struct ast_sip_contact {
390 /*! Sorcery object details, the id is the aor name plus a random string */
391 SORCERY_OBJECT(details);
393 /*! Full URI of the contact */
395 /*! Outbound proxy to use for qualify */
397 /*! Path information to place in Route headers */
399 /*! Content of the User-Agent header in REGISTER request */
401 /*! The name of the aor this contact belongs to */
403 /*! Asterisk Server name */
405 /*! IP-address of the Via header in REGISTER request */
407 /*! Content of the Call-ID header in REGISTER request */
409 /*! The name of the endpoint that added the contact */
411 );
412 /*! Absolute time that this contact is no longer valid after */
413 struct timeval expiration_time;
414 /*! Frequency to send OPTIONS requests to contact. 0 is disabled. */
415 unsigned int qualify_frequency;
416 /*! If true authenticate the qualify challenge response if needed */
418 /*! Qualify timeout. 0 is diabled. */
419 double qualify_timeout;
420 /*! Endpoint that added the contact, only available in observers */
422 /*! Port of the Via header in REGISTER request */
423 int via_port;
424 /*! If true delete the contact on Asterisk restart/boot */
425 int prune_on_boot;
426 /*! If true only authenticate if OPTIONS response is 2XX */
428};
429
430/*!
431 * \brief Status type for a contact.
432 */
434 /*! Frequency > 0, but no response from remote uri */
436 /*! Frequency > 0, and got response from remote uri */
437 AVAILABLE,
438 /*! Default last status, and when a contact status object is not found */
439 UNKNOWN,
440 /*! Frequency == 0, has a contact, but don't know status (non-qualified) */
441 CREATED,
442 REMOVED,
443};
444
445/*!
446 * \brief A contact's status.
447 *
448 * Maintains a contact's current status and round trip time if available.
449 */
452 /*! The original contact's URI */
454 /*! The name of the aor this contact_status belongs to */
456 );
457 /*! The round trip time in microseconds */
458 int64_t rtt;
459 /*!
460 * The security mechanism list of the contact (RFC 3329).
461 * Stores the values of Security-Server headers in 401/421/494 responses to an
462 * in-dialog request or successful outbound registration which will be used to
463 * set the Security-Verify headers of all subsequent requests to the contact.
464 */
466 /*! Current status for a contact (default - unavailable) */
468 /*! Last status for a contact (default - unavailable) */
470 /*! Name of the contact */
471 char name[0];
472};
473
474/*!
475 * \brief A SIP address of record
476 */
477struct ast_sip_aor {
478 /*! Sorcery object details, the id is the AOR name */
479 SORCERY_OBJECT(details);
481 /*! Voicemail boxes for this AOR */
483 /*! Outbound proxy for OPTIONS requests */
485 );
486 /*! Minimum expiration time */
487 unsigned int minimum_expiration;
488 /*! Maximum expiration time */
489 unsigned int maximum_expiration;
490 /*! Default contact expiration if one is not provided in the contact */
491 unsigned int default_expiration;
492 /*! Frequency to send OPTIONS requests to AOR contacts. 0 is disabled. */
493 unsigned int qualify_frequency;
494 /*! If true authenticate the qualify challenge response if needed */
496 /*! Maximum number of external contacts, 0 to disable */
497 unsigned int max_contacts;
498 /*! Whether to remove any existing contacts not related to an incoming REGISTER when it comes in */
499 unsigned int remove_existing;
500 /*! Any permanent configured contacts */
502 /*! Determines whether SIP Path headers are supported */
503 unsigned int support_path;
504 /*! Qualify timeout. 0 is diabled. */
505 double qualify_timeout;
506 /*! Voicemail extension to set in Message-Account */
508 /*! Whether to remove unavailable contacts over max_contacts at all or first if remove_existing is enabled */
509 unsigned int remove_unavailable;
510 /*! If true only authenticate if OPTIONS response is 2XX */
512};
513
514/*!
515 * \brief A wrapper for contact that adds the aor_id and
516 * a consistent contact id. Used by ast_sip_for_each_contact.
517 */
519 /*! The id of the parent aor. */
520 char *aor_id;
521 /*! The id of contact in form of aor_id/contact_uri. */
522 char *contact_id;
523 /*! Pointer to the actual contact. */
524 struct ast_sip_contact *contact;
525};
526
527/*!
528 * \brief 100rel modes for SIP endpoints
529 */
531 /*! Do not support 100rel. (no) */
533 /*! As UAC, indicate 100rel support in Supported header. (yes) */
535 /*! As UAS, send 1xx responses reliably, if the UAC indicated its support. Otherwise same as AST_SIP_100REL_SUPPORTED. (peer_supported) */
537 /*! Require the use of 100rel. (required) */
539};
540
541/*!
542 * \brief DTMF modes for SIP endpoints
543 */
545 /*! No DTMF to be used */
547 /* XXX Should this be 2833 instead? */
548 /*! Use RFC 4733 events for DTMF */
550 /*! Use DTMF in the audio stream */
552 /*! Use SIP INFO DTMF (blech) */
554 /*! Use SIP 4733 if supported by the other side or INBAND if not */
556 /*! Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not */
558};
559
560/*!
561 * \brief Authentication methods.
562 *
563 * The meaning of this type has changed. It used to indicate how
564 * the credentials were stored, but now it indicates which authentication
565 * method will be used... Google Oauth, Artificial (fake auth) or Digest.
566 * The USER_PASS and MD5 types are still used for backwards compatibility
567 * but will map to DIGEST.
568 */
571 /*!
572 * Credentials stored as a username and password combination
573 * \deprecated Now automatically determined
574 */
576 /*!
577 * Credentials stored as an MD5 sum
578 * \deprecated Use AST_SIP_AUTH_TYPE_DIGEST instead
579 */
581 /*! Google Oauth */
583 /*! Credentials not stored this is a fake auth */
585 /*! Digest method will be used */
587};
588
590 /*! The credentials used as a UAC */
592 /*! The credentials used as a UAS */
594};
595
596#define SIP_SORCERY_AUTH_TYPE "auth"
597
598#ifndef HAVE_PJSIP_AUTH_NEW_DIGESTS
599/*
600 * These are needed if the version of pjproject in use
601 * does not have the new digests.
602 * NOTE: We don't support AKAV1_MD5 but we need to specify
603 * it to be compatible with the pjproject definition.
604 */
605typedef enum pjsip_auth_algorithm_type
606{
614
615typedef struct pjsip_auth_algorithm
616{
618 pj_str_t iana_name;
619 const char *openssl_name;
620 unsigned digest_length;
621 unsigned digest_str_length;
623#endif
624
625/*!
626 * \brief Get algorithm by algorithm type
627 *
628 * \param algorithm_type The algorithm type
629 * \retval The algorithm or NULL if not found
630 */
632 pjsip_auth_algorithm_type algorithm_type);
633
634/*!
635 * \brief Get algorithm by IANA name
636 *
637 * \param iana_name The algorithm IANA name
638 * \retval The algorithm or NULL if not found
639 */
641 const pj_str_t *iana_name);
642
643/*!
644 * \brief Is algorithm supported by OpenSSL and pjproject?
645 *
646 * \param algorithm_type The algorithm IANA name
647 * \retval The algorithm or NULL if not found
648 */
650 pjsip_auth_algorithm_type algorithm_type);
651
653
656 char digest[0];
657};
658
659struct ast_sip_auth {
660 /*! Sorcery ID of the auth is its name */
661 SORCERY_OBJECT(details);
663 /*! Identification for these credentials */
665 /*! Authentication username */
667 /*! Authentication password */
669 /*!
670 * Authentication credentials in MD5 format (hash of user:realm:pass)
671 * \deprecated Use password_digests[PJSIP_AUTH_ALGORITHM_MD5] instead.
672 */
674 /*! Refresh token to use for OAuth authentication */
676 /*! Client ID to use for OAuth authentication */
678 /*! Secret to use for OAuth authentication */
680 );
681 /*! The time period (in seconds) that a nonce may be reused */
682 unsigned int nonce_lifetime;
683 /*! Used to determine what to use when authenticating */
685 /*! Digest algorithms to support when UAC */
687 /*! Digest algorithms to send challenges for when UAS */
689 /*! Array of pre-digested passwords indexed by pjsip_auth_algorithm_type */
691};
692
693AST_VECTOR(ast_sip_auth_vector, const char *);
694
695/*!
696 * \brief Different methods by which incoming requests can be matched to endpoints
697 */
699 /*! Identify based on user name in From header */
701 /*! Identify based on user name in Auth header first, then From header */
703 /*! Identify based on source IP address */
705 /*! Identify based on arbitrary headers */
707 /*! Identify based on request uri */
709};
711
713 /*! Use reinvite to negotiate direct media */
715 /*! Use UPDATE to negotiate direct media */
717};
718
720 /*! Take no special action to mitigate reinvite glare */
722 /*! Do not send an initial direct media session refresh on outgoing call legs
723 * Subsequent session refreshes will be sent no matter the session direction
724 */
726 /*! Do not send an initial direct media session refresh on incoming call legs
727 * Subsequent session refreshes will be sent no matter the session direction
728 */
730};
731
733 /*! Invalid media encryption configuration */
735 /*! Do not allow any encryption of session media */
737 /*! Offer SDES-encrypted session media */
739 /*! Offer encrypted session media with datagram TLS key exchange */
741};
742
744 /*! User portion of the target URI should be used as the target in the dialplan */
746 /*! Target URI should be used as the target in the dialplan */
748 /*! Target URI should be used as the target within chan_pjsip itself */
750};
751
752/*!
753 * \brief SIP methods that are allowed to follow 3xx redirects.
754 *
755 * Used as bit flags in follow_redirect_methods field.
756 */
758 /*! Allow MESSAGE method to follow redirects */
760};
761
762/*!
763 * \brief Incoming/Outgoing call offer/answer joint codec preference.
764 *
765 * The default is INTERSECT ALL LOCAL.
766 */
768 /*! Two bits for merge */
769 /*! Intersection of local and remote */
771 /*! Union of local and remote */
773
774 /*! Two bits for filter */
775 /*! No filter */
777 /*! Only the first */
779
780 /*! Two bits for preference and sort */
781 /*! Prefer, and order by local values */
783 /*! Prefer, and order by remote values */
785};
786
787/*!
788 * \brief Returns true if the preference is set in the parameter
789 * \since 18.0.0
790 *
791 * \param __param A ast_flags struct with one or more of enum ast_sip_call_codec_pref set
792 * \param __codec_pref The last component of one of the enum values
793 * \retval 1 if the enum value is set
794 * \retval 0 if not
795 */
796#define ast_sip_call_codec_pref_test(__param, __codec_pref) (!!(ast_test_flag( &__param, AST_SIP_CALL_CODEC_PREF_ ## __codec_pref )))
797
798/*!
799 * \brief Session timers options
800 */
802 /*! Minimum session expiration period, in seconds */
803 unsigned int min_se;
804 /*! Session expiration period, in seconds */
805 unsigned int sess_expires;
806};
807
808/*!
809 * \brief Endpoint configuration for SIP extensions.
810 *
811 * SIP extensions, in this case refers to features
812 * indicated in Supported or Required headers.
813 */
815 /*! Enabled SIP extensions */
816 unsigned int flags;
817 /*! Timer options */
819};
820
821/*!
822 * \brief Endpoint configuration for unsolicited MWI
823 */
826 /*! Configured voicemail boxes for this endpoint. Used for MWI */
828 /*! Username to use when sending MWI NOTIFYs to this endpoint */
830 );
831 /*! Should mailbox states be combined into a single notification? */
832 unsigned int aggregate;
833 /*! Should a subscribe replace unsolicited notifies? */
835 /*! Voicemail extension to set in Message-Account */
837};
838
839/*!
840 * \brief Endpoint subscription configuration
841 */
843 /*! Indicates if endpoint is allowed to initiate subscriptions */
844 unsigned int allow;
845 /*! The minimum allowed expiration for subscriptions from endpoint */
846 unsigned int minexpiry;
847 /*! Message waiting configuration */
849 /*! Context for SUBSCRIBE requests */
851};
852
853/*!
854 * \brief NAT configuration options for endpoints
855 */
857 /*! Whether to force using the source IP address/port for sending responses */
858 unsigned int force_rport;
859 /*! Whether to rewrite the Contact header with the source IP address/port or not */
860 unsigned int rewrite_contact;
861};
862
863/*!
864 * \brief Party identification options for endpoints
865 *
866 * This includes caller ID, connected line, and redirecting-related options
867 */
869 struct ast_party_id self;
870 /*! Do we accept identification information from this endpoint */
871 unsigned int trust_inbound;
872 /*! Do we send private identification information to this endpoint? */
873 unsigned int trust_outbound;
874 /*! Do we send P-Asserted-Identity headers to this endpoint? */
875 unsigned int send_pai;
876 /*! Do we send Remote-Party-ID headers to this endpoint? */
877 unsigned int send_rpid;
878 /*! Do we send messages for connected line updates for unanswered incoming calls immediately to this endpoint? */
879 unsigned int rpid_immediate;
880 /*! Do we add Diversion headers to applicable outgoing requests/responses? */
881 unsigned int send_diversion;
882 /*! Do we accept connected line updates from this endpoint? */
883 unsigned int trust_connected_line;
884 /*! Do we send connected line updates to this endpoint? */
885 unsigned int send_connected_line;
886 /*! When performing connected line update, which method should be used */
888 /*! Do we add History-Info headers to applicable outgoing requests/responses? */
889 unsigned int send_history_info;
890};
891
892/*!
893 * \brief Call pickup configuration options for endpoints
894 */
896 /*! Call group */
898 /*! Pickup group */
900 /*! Named call group */
901 struct ast_namedgroups *named_callgroups;
902 /*! Named pickup group */
903 struct ast_namedgroups *named_pickupgroups;
904};
905
906/*!
907 * \brief Configuration for one-touch INFO recording
908 */
911 /*! Feature to enact when one-touch recording INFO with Record: On is received */
913 /*! Feature to enact when one-touch recording INFO with Record: Off is received */
915 );
916 /*! Is one-touch recording permitted? */
917 unsigned int enabled;
918};
919
920/*!
921 * \brief Endpoint configuration options for INFO packages
922 */
924 /*! Configuration for one-touch recording */
926};
927
928/*!
929 * \brief RTP configuration for SIP endpoints
930 */
933 /*! Configured RTP engine for this endpoint. */
935 );
936 /*! Whether IPv6 RTP is enabled or not */
937 unsigned int ipv6;
938 /*! Whether symmetric RTP is enabled or not */
939 unsigned int symmetric;
940 /*! Whether ICE support is enabled or not */
941 unsigned int ice_support;
942 /*! Whether to use the "ptime" attribute received from the endpoint or not */
943 unsigned int use_ptime;
944 /*! Do we use AVPF exclusively for this endpoint? */
945 unsigned int use_avpf;
946 /*! Do we force AVP, AVPF, SAVP, or SAVPF even for DTLS media streams? */
947 unsigned int force_avp;
948 /*! Do we use the received media transport in our answer SDP */
949 unsigned int use_received_transport;
950 /*! \brief DTLS-SRTP configuration information */
952 /*! Should SRTP use a 32 byte tag instead of an 80 byte tag? */
953 unsigned int srtp_tag_32;
954 /*! Do we use media encryption? what type? */
956 /*! Do we want to optimistically support encryption if possible? */
957 unsigned int encryption_optimistic;
958 /*! Number of seconds between RTP keepalive packets */
959 unsigned int keepalive;
960 /*! Number of seconds before terminating channel due to lack of RTP (when not on hold) */
961 unsigned int timeout;
962 /*! Number of seconds before terminating channel due to lack of RTP (when on hold) */
963 unsigned int timeout_hold;
964 /*! Follow forked media with a different To tag */
965 unsigned int follow_early_media_fork;
966 /*! Accept updated SDPs on non-100rel 18X and 2XX responses with the same To tag */
967 unsigned int accept_multiple_sdp_answers;
968};
969
970/*!
971 * \brief Direct media options for SIP endpoints
972 */
974 /*! Boolean indicating if direct_media is permissible */
975 unsigned int enabled;
976 /*! When using direct media, which method should be used */
978 /*! Take steps to mitigate glare for direct media */
980 /*! Do not attempt direct media session refreshes if a media NAT is detected */
981 unsigned int disable_on_nat;
982};
983
985 /*! Whether T.38 UDPTL support is enabled or not */
986 unsigned int enabled;
987 /*! Error correction setting for T.38 UDPTL */
989 /*! Explicit T.38 max datagram value, may be 0 to indicate the remote side can be trusted */
990 unsigned int maxdatagram;
991 /*! Whether NAT Support is enabled for T.38 UDPTL sessions or not */
992 unsigned int nat;
993 /*! Whether to use IPv6 for UDPTL or not */
994 unsigned int ipv6;
995 /*! Bind the UDPTL instance to the media_address */
996 unsigned int bind_udptl_to_media_address;
997};
998
999/*!
1000 * \brief Media configuration for SIP endpoints
1001 */
1004 /*! Optional media address to use in SDP */
1006 /*! SDP origin username */
1008 /*! SDP session name */
1010 );
1011 /*! RTP media configuration */
1013 /*! Direct media options */
1015 /*! T.38 (FoIP) options */
1017 /*! Configured codecs */
1018 struct ast_format_cap *codecs;
1019 /*! Capabilities in topology form */
1021 /*! DSCP TOS bits for audio streams */
1022 unsigned int tos_audio;
1023 /*! Priority for audio streams */
1024 unsigned int cos_audio;
1025 /*! DSCP TOS bits for video streams */
1026 unsigned int tos_video;
1027 /*! Priority for video streams */
1028 unsigned int cos_video;
1029 /*! Is g.726 packed in a non standard way */
1030 unsigned int g726_non_standard;
1031 /*! Bind the RTP instance to the media_address */
1032 unsigned int bind_rtp_to_media_address;
1033 /*! Use RTCP-MUX */
1034 unsigned int rtcp_mux;
1035 /*! Maximum number of audio streams to offer/accept */
1036 unsigned int max_audio_streams;
1037 /*! Maximum number of video streams to offer/accept */
1038 unsigned int max_video_streams;
1039 /*! Use BUNDLE */
1040 unsigned int bundle;
1041 /*! Enable webrtc settings and defaults */
1042 unsigned int webrtc;
1043 /*! Codec preference for an incoming offer */
1045 /*! Codec preference for an outgoing offer */
1047 /*! Codec negotiation prefs for incoming offers */
1049 /*! Codec negotiation prefs for outgoing offers */
1051 /*! Codec negotiation prefs for incoming answers */
1053 /*! Codec negotiation prefs for outgoing answers */
1055};
1056
1057/*!
1058 * \brief An entity with which Asterisk communicates
1059 */
1060struct ast_sip_endpoint {
1061 SORCERY_OBJECT(details);
1063 /*! Context to send incoming calls to */
1065 /*! Name of an explicit transport to use */
1067 /*! Outbound proxy to use */
1069 /*! Explicit AORs to dial if none are specified */
1071 /*! Musiconhold class to suggest that the other side use when placing on hold */
1073 /*! Configured tone zone for this endpoint. */
1075 /*! Configured language for this endpoint. */
1077 /*! Default username to place in From header */
1079 /*! Domain to place in From header */
1081 /*! Context to route incoming MESSAGE requests to */
1083 /*! Accountcode to auto-set on channels */
1085 /*! If set, we'll push incoming MWI NOTIFYs to stasis using this mailbox */
1087 /*! STIR/SHAKEN profile to use */
1089 );
1090 /*! Configuration for extensions */
1092 /*! Configuration relating to media */
1094 /*! SUBSCRIBE/NOTIFY configuration options */
1096 /*! NAT configuration */
1098 /*! Party identification options */
1100 /*! Configuration options for INFO packages */
1102 /*! Call pickup configuration */
1104 /*! Inbound authentication credentials */
1106 /*! Outbound authentication credentials */
1108 /*! DTMF mode to use with this endpoint */
1110 /*! Method(s) by which the endpoint should be identified. */
1112 /*! Order of the method(s) by which the endpoint should be identified. */
1114 /*! Boolean indicating if ringing should be sent as inband progress */
1115 unsigned int inband_progress;
1116 /*! Pointer to the persistent Asterisk endpoint */
1117 struct ast_endpoint *persistent;
1118 /*! The number of channels at which busy device state is returned */
1119 unsigned int devicestate_busy_at;
1120 /*! Whether fax detection is enabled or not (CNG tone detection) */
1121 unsigned int faxdetect;
1122 /*! Determines if transfers (using REFER) are allowed by this endpoint */
1123 unsigned int allowtransfer;
1124 /*! Method used when handling redirects */
1126 /*! SIP methods allowed to follow 3xx redirects */
1128 /*! Variables set on channel creation */
1129 struct ast_variable *channel_vars;
1130 /*! Whether to place a 'user=phone' parameter into the request URI if user is a number */
1131 unsigned int usereqphone;
1132 /*! Whether to pass through hold and unhold using re-invites with recvonly and sendrecv */
1133 unsigned int moh_passthrough;
1134 /*! Access control list */
1135 struct ast_acl_list *acl;
1136 /*! Restrict what IPs are allowed in the Contact header (for registration) */
1137 struct ast_acl_list *contact_acl;
1138 /*! The number of seconds into call to disable fax detection. (0 = disabled) */
1139 unsigned int faxdetect_timeout;
1140 /*! Override the user on the outgoing Contact header with this value. */
1141 char *contact_user;
1142 /*! Whether to response SDP offer with single most preferred codec. */
1143 unsigned int preferred_codec_only;
1144 /*! Do we allow an asymmetric RTP codec? */
1145 unsigned int asymmetric_rtp_codec;
1146 /*! Do we allow overlap dialling? */
1147 unsigned int allow_overlap;
1148 /*! Whether to notifies all the progress details on blind transfer */
1149 unsigned int refer_blind_progress;
1150 /*! Whether to notifies dialog-info 'early' on INUSE && RINGING state */
1151 unsigned int notify_early_inuse_ringing;
1152 /*! Suppress Q.850 Reason headers on this endpoint */
1153 unsigned int suppress_q850_reason_headers;
1154 /*! Ignore 183 if no SDP is present */
1155 unsigned int ignore_183_without_sdp;
1156 /*! Type of security negotiation to use (RFC 3329). */
1158 /*! Client security mechanisms (RFC 3329). */
1160 /*! Set which STIR/SHAKEN behaviors we want on this endpoint */
1161 unsigned int stir_shaken;
1162 /*! Should we authenticate OPTIONS requests per RFC 3261? */
1163 unsigned int allow_unauthenticated_options;
1164 /*! The name of the geoloc profile to apply when Asterisk receives a call from this endpoint */
1165 AST_STRING_FIELD_EXTENDED(geoloc_incoming_call_profile);
1166 /*! The name of the geoloc profile to apply when Asterisk sends a call to this endpoint */
1167 AST_STRING_FIELD_EXTENDED(geoloc_outgoing_call_profile);
1168 /*! The context to use for overlap dialing, if different from the endpoint's context */
1169 AST_STRING_FIELD_EXTENDED(overlap_context);
1170 /*! 100rel mode to use with this endpoint */
1172 /*! Send Advice-of-Charge messages */
1173 unsigned int send_aoc;
1174 /*! Tenant ID for the endpoint */
1175 AST_STRING_FIELD_EXTENDED(tenantid);
1176 /*! Ignore remote hold requests */
1178};
1179
1180/*! URI parameter for symmetric transport */
1181#define AST_SIP_X_AST_TXP "x-ast-txp"
1182#define AST_SIP_X_AST_TXP_LEN 9
1183
1184/*! Common media types used throughout res_pjsip and pjproject */
1185extern pjsip_media_type pjsip_media_type_application_json;
1187extern pjsip_media_type pjsip_media_type_application_pidf_xml;
1188extern pjsip_media_type pjsip_media_type_application_xpidf_xml;
1189extern pjsip_media_type pjsip_media_type_application_cpim_xpidf_xml;
1190extern pjsip_media_type pjsip_media_type_application_rlmi_xml;
1192extern pjsip_media_type pjsip_media_type_application_sdp;
1193extern pjsip_media_type pjsip_media_type_multipart_alternative;
1194extern pjsip_media_type pjsip_media_type_multipart_mixed;
1195extern pjsip_media_type pjsip_media_type_multipart_related;
1196extern pjsip_media_type pjsip_media_type_text_plain;
1197
1198/*!
1199 * \brief Compare pjsip media types
1200 *
1201 * \param a the first media type
1202 * \param b the second media type
1203 * \retval 1 Media types are equal
1204 * \retval 0 Media types are not equal
1205 */
1206int ast_sip_are_media_types_equal(pjsip_media_type *a, pjsip_media_type *b);
1207
1208/*!
1209 * \brief Check if a media type is in a list of others
1210 *
1211 * \param a pjsip_media_type to search for
1212 * \param ... one or more pointers to pjsip_media_types the last of which must be "SENTINEL"
1213 * \retval 1 Media types are equal
1214 * \retval 0 Media types are not equal
1215 */
1216int ast_sip_is_media_type_in(pjsip_media_type *a, ...) attribute_sentinel;
1217
1218/*!
1219 * \brief Add security headers to transmission data
1220 *
1221 * \param security_mechanisms Vector of security mechanisms.
1222 * \param header_name The header name under which to add the security mechanisms.
1223 * One of Security-Client, Security-Server, Security-Verify.
1224 * \param add_qval If zero, don't add the q-value to the header.
1225 * \param tdata The transmission data.
1226 * \retval 0 Success
1227 * \retval non-zero Failure
1228 */
1230 const char *header_name, int add_qval, pjsip_tx_data *tdata);
1231
1232/*!
1233 * \brief Append to security mechanism vector from SIP header
1234 *
1235 * \param hdr The header of the security mechanisms.
1236 * \param security_mechanisms Vector of security mechanisms to append to.
1237 * Header name must be one of Security-Client, Security-Server, Security-Verify.
1238 */
1239void ast_sip_header_to_security_mechanism(const pjsip_generic_string_hdr *hdr,
1240 struct ast_sip_security_mechanism_vector *security_mechanisms);
1241
1242/*!
1243 * \brief Initialize security mechanism vector from string of security mechanisms.
1244 *
1245 * \param security_mechanism Pointer to vector of security mechanisms to initialize.
1246 * \param value String of security mechanisms as defined in RFC 3329.
1247 * \retval 0 Success
1248 * \retval non-zero Failure
1249 */
1250int ast_sip_security_mechanism_vector_init(struct ast_sip_security_mechanism_vector *security_mechanism, const char *value);
1251
1252/*!
1253 * \brief Removes all headers of a specific name and value from a pjsip_msg.
1254 *
1255 * \param msg PJSIP message from which to remove headers.
1256 * \param hdr_name Name of the header to remove.
1257 * \param value Optional string value of the header to remove.
1258 * If NULL, remove all headers of given hdr_name.
1259 */
1260void ast_sip_remove_headers_by_name_and_value(pjsip_msg *msg, const pj_str_t *hdr_name, const char* value);
1261
1262/*!
1263 * \brief Duplicate a security mechanism.
1264 *
1265 * \param dst Security mechanism to duplicate to.
1266 * \param src Security mechanism to duplicate.
1267 */
1269 const struct ast_sip_security_mechanism_vector *src);
1270
1271/*!
1272 * \brief Free contents of a security mechanism vector.
1273 *
1274 * \param security_mechanisms Vector whose contents are to be freed
1275 */
1277
1278/*!
1279 * \brief Allocate a security mechanism from a string.
1280 *
1281 * \param security_mechanism Pointer-pointer to the security mechanism to allocate.
1282 * \param value The security mechanism string as defined in RFC 3329 (section 2.2)
1283 * in the form <mechanism_name>;q=<q_value>;<mechanism_parameters>
1284 * \retval 0 Success
1285 * \retval non-zero Failure
1286 */
1287int ast_sip_str_to_security_mechanism(struct ast_sip_security_mechanism **security_mechanism, const char *value);
1288
1289/*!
1290 * \brief Writes the security mechanisms of an endpoint into a buffer as a string and returns the buffer.
1291 *
1292 * \note The buffer must be freed by the caller.
1293 *
1294 * \param endpoint Pointer to endpoint.
1295 * \param add_qvalue If non-zero, the q-value is printed as well
1296 * \param buf The buffer to write the string into
1297 * \retval 0 Success
1298 * \retval non-zero Failure
1299 */
1300int ast_sip_security_mechanisms_to_str(const struct ast_sip_security_mechanism_vector *security_mechanisms, int add_qvalue, char **buf);
1301
1302/*!
1303 * \brief Set the security negotiation based on a given string.
1304 *
1305 * \param security_negotiation Security negotiation enum to set.
1306 * \param val String that represents a security_negotiation value.
1307 * \retval 0 Success
1308 * \retval non-zero Failure
1309 */
1310int ast_sip_set_security_negotiation(enum ast_sip_security_negotiation *security_negotiation, const char *val);
1311
1312/*!
1313 * \brief Initialize an auth vector with the configured values.
1314 *
1315 * \param vector Vector to initialize
1316 * \param auth_names Comma-separated list of names to set in the array
1317 * \retval 0 Success
1318 * \retval non-zero Failure
1319 */
1320int ast_sip_auth_vector_init(struct ast_sip_auth_vector *vector, const char *auth_names);
1321
1322/*!
1323 * \brief Free contents of an auth vector.
1324 *
1325 * \param vector Vector whose contents are to be freed
1326 */
1328
1329/*!
1330 * \brief Possible returns from ast_sip_check_authentication
1331 */
1333 /*! Authentication needs to be challenged */
1335 /*! Authentication succeeded */
1337 /*! Authentication failed */
1339 /*! Authentication encountered some internal error */
1341};
1342
1343/*!
1344 * \brief Populate a vector of algorithm types from a string.
1345 *
1346 * \param id The object id to use in error messages
1347 * \param algorithms The initialized but empty vector to populate
1348 * \param agent_type The type of agent to use in error messages ("UAC" or "UAS")
1349 * \param value The comma-separated string to parse for algorithms
1350 *
1351 * \retval 0 Success
1352 * \retval non-zero Failure
1353 */
1355 struct pjsip_auth_algorithm_type_vector *algorithms, const char *agent_type, const char *value);
1356
1357/*!
1358 * \brief Dump a vector of algorithm types to a string.
1359 *
1360 * \param algorithms The vector to dump
1361 * \param[out] buf Pointer to the buffer to dump the algorithms to
1362 * Must be freed by the caller.
1363 *
1364 * \retval 0 Success
1365 * \retval non-zero Failure
1366 */
1368 const struct pjsip_auth_algorithm_type_vector *algorithms, char **buf);
1369
1370/*!
1371 * \brief An interchangeable way of handling digest authentication for SIP.
1372 *
1373 * An authenticator is responsible for filling in the callbacks provided below. Each is called from a publicly available
1374 * function in res_sip. The authenticator can use configuration or other local policy to determine whether authentication
1375 * should take place and what credentials should be used when challenging and authenticating a request.
1376 */
1377struct ast_sip_authenticator {
1378 /*!
1379 * \brief Check if a request requires authentication
1380 * See ast_sip_requires_authentication for more details
1381 */
1382 int (*requires_authentication)(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
1383 /*!
1384 * \brief Check that an incoming request passes authentication.
1385 *
1386 * The tdata parameter is useful for adding information such as digest challenges.
1387 *
1388 * \param endpoint The endpoint sending the incoming request
1389 * \param rdata The incoming request
1390 * \param tdata Tentative outgoing request.
1391 */
1393 pjsip_rx_data *rdata, pjsip_tx_data *tdata);
1394};
1395
1396/*!
1397 * \brief an interchangeable way of responding to authentication challenges
1398 *
1399 * An outbound authenticator takes incoming challenges and formulates a new SIP request with
1400 * credentials.
1401 */
1403 /*!
1404 * \brief Create a new request with authentication credentials
1405 *
1406 * \param auths A vector of IDs of auth sorcery objects
1407 * \param challenge The SIP response with authentication challenge(s)
1408 * \param old_request The request that received the auth challenge(s)
1409 * \param new_request The new SIP request with challenge response(s)
1410 * \retval 0 Successfully created new request
1411 * \retval -1 Failed to create a new request
1412 */
1413 int (*create_request_with_auth)(const struct ast_sip_auth_vector *auths, struct pjsip_rx_data *challenge,
1414 struct pjsip_tx_data *old_request, struct pjsip_tx_data **new_request);
1415};
1416
1417/*!
1418 * \brief An entity responsible for identifying the source of a SIP message
1419 */
1421 /*!
1422 * \brief Callback used to identify the source of a message.
1423 * See ast_sip_identify_endpoint for more details
1424 */
1425 struct ast_sip_endpoint *(*identify_endpoint)(pjsip_rx_data *rdata);
1426};
1427
1428/*!
1429 * \brief Contact retrieval filtering flags
1430 */
1432 /*! \brief Default filter flags */
1434
1435 /*! \brief Return only reachable or unknown contacts */
1437};
1438
1439/*!
1440 * \brief Adds a Date header to the tdata, formatted like:
1441 * Date: Wed, 01 Jan 2021 14:53:01 GMT
1442 * \since 16.19.0
1443 *
1444 * \note There is no checking done to see if the header already exists
1445 * before adding it. It's up to the caller of this function to determine
1446 * if that needs to be done or not.
1447 */
1448void ast_sip_add_date_header(pjsip_tx_data *tdata);
1449
1450/*!
1451 * \brief Register a SIP service in Asterisk.
1452 *
1453 * This is more-or-less a wrapper around pjsip_endpt_register_module().
1454 * Registering a service makes it so that PJSIP will call into the
1455 * service at appropriate times. For more information about PJSIP module
1456 * callbacks, see the PJSIP documentation. Asterisk modules that call
1457 * this function will likely do so at module load time.
1458 *
1459 * \param module The module that is to be registered with PJSIP
1460 * \retval 0 Success
1461 * \retval -1 Failure
1462 */
1463int ast_sip_register_service(pjsip_module *module);
1464
1465/*!
1466 * This is the opposite of ast_sip_register_service(). Unregistering a
1467 * service means that PJSIP will no longer call into the module any more.
1468 * This will likely occur when an Asterisk module is unloaded.
1469 *
1470 * \param module The PJSIP module to unregister
1471 */
1472void ast_sip_unregister_service(pjsip_module *module);
1473
1474/*!
1475 * \brief Register a SIP authenticator
1476 *
1477 * An authenticator has three main purposes:
1478 * 1) Determining if authentication should be performed on an incoming request
1479 * 2) Gathering credentials necessary for issuing an authentication challenge
1480 * 3) Authenticating a request that has credentials
1481 *
1482 * Asterisk provides a default authenticator, but it may be replaced by a
1483 * custom one if desired.
1484 *
1485 * \param auth The authenticator to register
1486 * \retval 0 Success
1487 * \retval -1 Failure
1488 */
1490
1491/*!
1492 * \brief Unregister a SIP authenticator
1493 *
1494 * When there is no authenticator registered, requests cannot be challenged
1495 * or authenticated.
1496 *
1497 * \param auth The authenticator to unregister
1498 */
1500
1501 /*!
1502 * \brief Register an outbound SIP authenticator
1503 *
1504 * An outbound authenticator is responsible for creating responses to
1505 * authentication challenges by remote endpoints.
1506 *
1507 * \param outbound_auth The authenticator to register
1508 * \retval 0 Success
1509 * \retval -1 Failure
1510 */
1512
1513/*!
1514 * \brief Unregister an outbound SIP authenticator
1515 *
1516 * When there is no outbound authenticator registered, authentication challenges
1517 * will be handled as any other final response would be.
1518 *
1519 * \param auth The authenticator to unregister
1520 */
1522
1523/*!
1524 * \brief Register a SIP endpoint identifier with a name.
1525 *
1526 * An endpoint identifier's purpose is to determine which endpoint a given SIP
1527 * message has come from.
1528 *
1529 * Multiple endpoint identifiers may be registered so that if an endpoint
1530 * cannot be identified by one identifier, it may be identified by another.
1531 *
1532 * \param identifier The SIP endpoint identifier to register
1533 * \param name The name of the endpoint identifier
1534 * \retval 0 Success
1535 * \retval -1 Failure
1536 */
1538 const char *name);
1539
1540/*!
1541 * \brief Register a SIP endpoint identifier
1542 *
1543 * An endpoint identifier's purpose is to determine which endpoint a given SIP
1544 * message has come from.
1545 *
1546 * Multiple endpoint identifiers may be registered so that if an endpoint
1547 * cannot be identified by one identifier, it may be identified by another.
1548 *
1549 * Asterisk provides two endpoint identifiers. One identifies endpoints based
1550 * on the user part of the From header URI. The other identifies endpoints based
1551 * on the source IP address.
1552 *
1553 * If the order in which endpoint identifiers is run is important to you, then
1554 * be sure to load individual endpoint identifier modules in the order you wish
1555 * for them to be run in modules.conf
1556 *
1557 * \note endpoint identifiers registered using this method (no name specified)
1558 * are placed at the front of the endpoint identifiers list ahead of any
1559 * named identifiers.
1560 *
1561 * \param identifier The SIP endpoint identifier to register
1562 * \retval 0 Success
1563 * \retval -1 Failure
1564 */
1566
1567/*!
1568 * \brief Unregister a SIP endpoint identifier
1569 *
1570 * This stops an endpoint identifier from being used.
1571 *
1572 * \param identifier The SIP endoint identifier to unregister
1573 */
1575
1576/*!
1577 * \brief Allocate a new SIP endpoint
1578 *
1579 * This will return an endpoint with its refcount increased by one. This reference
1580 * can be released using ao2_ref().
1581 *
1582 * \param name The name of the endpoint.
1583 * \retval NULL Endpoint allocation failed
1584 * \retval non-NULL The newly allocated endpoint
1585 */
1586void *ast_sip_endpoint_alloc(const char *name);
1587
1588/*!
1589 * \brief Change state of a persistent endpoint.
1590 *
1591 * \param endpoint_name The SIP endpoint name to change state.
1592 * \param state The new state
1593 * \retval 0 Success
1594 * \retval -1 Endpoint not found
1595 */
1596int ast_sip_persistent_endpoint_update_state(const char *endpoint_name, enum ast_endpoint_state state);
1597
1598/*!
1599 * \brief Publish the change of state for a contact.
1600 *
1601 * \param endpoint_name The SIP endpoint name.
1602 * \param contact_status The contact status.
1603 */
1604void ast_sip_persistent_endpoint_publish_contact_state(const char *endpoint_name, const struct ast_sip_contact_status *contact_status);
1605
1606/*!
1607 * \brief Retrieve the current status for a contact.
1608 *
1609 * \param contact The contact.
1610 *
1611 * \retval non-NULL Success
1612 * \retval NULL Status information not found
1613 *
1614 * \note The returned contact status object is immutable.
1615 */
1617
1618/*!
1619 * \brief Get a pointer to the PJSIP endpoint.
1620 *
1621 * This is useful when modules have specific information they need
1622 * to register with the PJSIP core.
1623 * \retval NULL endpoint has not been created yet.
1624 * \retval non-NULL PJSIP endpoint.
1625 */
1626pjsip_endpoint *ast_sip_get_pjsip_endpoint(void);
1627
1628/*!
1629 * \brief Get a pointer to the SIP sorcery structure.
1630 *
1631 * \retval NULL sorcery has not been initialized
1632 * \retval non-NULL sorcery structure
1633 */
1634struct ast_sorcery *ast_sip_get_sorcery(void);
1635
1636/*!
1637 * \brief Retrieve a named AOR
1638 *
1639 * \param aor_name Name of the AOR
1640 *
1641 * \retval NULL if not found
1642 * \retval non-NULL if found
1643 */
1644struct ast_sip_aor *ast_sip_location_retrieve_aor(const char *aor_name);
1645
1646/*!
1647 * \brief Retrieve the first bound contact for an AOR
1648 *
1649 * \param aor Pointer to the AOR
1650 * \retval NULL if no contacts available
1651 * \retval non-NULL if contacts available
1652 */
1654
1655/*!
1656 * \brief Retrieve the first bound contact for an AOR and filter based on flags
1657 * \since 13.16.0
1658 *
1659 * \param aor Pointer to the AOR
1660 * \param flags Filtering flags
1661 * \retval NULL if no contacts available
1662 * \retval non-NULL if contacts available
1663 */
1665 unsigned int flags);
1666
1667/*!
1668 * \brief Retrieve all contacts currently available for an AOR
1669 *
1670 * \param aor Pointer to the AOR
1671 *
1672 * \retval NULL if no contacts available
1673 * \retval non-NULL if contacts available
1674 *
1675 * \warning
1676 * Since this function prunes expired contacts before returning, it holds a named write
1677 * lock on the aor. If you already hold the lock, call ast_sip_location_retrieve_aor_contacts_nolock instead.
1678 */
1680
1681/*!
1682 * \brief Retrieve all contacts currently available for an AOR and filter based on flags
1683 * \since 13.16.0
1684 *
1685 * \param aor Pointer to the AOR
1686 * \param flags Filtering flags
1687 *
1688 * \retval NULL if no contacts available
1689 * \retval non-NULL if contacts available
1690 *
1691 * \warning
1692 * Since this function prunes expired contacts before returning, it holds a named write
1693 * lock on the aor. If you already hold the lock, call ast_sip_location_retrieve_aor_contacts_nolock instead.
1694 */
1696 unsigned int flags);
1697
1698/*!
1699 * \brief Retrieve all contacts currently available for an AOR without locking the AOR
1700 * \since 13.9.0
1701 *
1702 * \param aor Pointer to the AOR
1703 *
1704 * \retval NULL if no contacts available
1705 * \retval non-NULL if contacts available
1706 *
1707 * \warning
1708 * This function should only be called if you already hold a named write lock on the aor.
1709 */
1711
1712/*!
1713 * \brief Retrieve all contacts currently available for an AOR without locking the AOR and filter based on flags
1714 * \since 13.16.0
1715 *
1716 * \param aor Pointer to the AOR
1717 * \param flags Filtering flags
1718 *
1719 * \retval NULL if no contacts available
1720 * \retval non-NULL if contacts available
1721 *
1722 * \warning
1723 * This function should only be called if you already hold a named write lock on the aor.
1724 */
1726 unsigned int flags);
1727
1728/*!
1729 * \brief Retrieve the first bound contact from a list of AORs
1730 *
1731 * \param aor_list A comma-separated list of AOR names
1732 * \retval NULL if no contacts available
1733 * \retval non-NULL if contacts available
1734 */
1736
1737/*!
1738 * \brief Retrieve all contacts from a list of AORs
1739 *
1740 * \param aor_list A comma-separated list of AOR names
1741 * \retval NULL if no contacts available
1742 * \retval non-NULL container (which must be freed) if contacts available
1743 */
1745
1746/*!
1747 * \brief Retrieve the first bound contact AND the AOR chosen from a list of AORs
1748 *
1749 * \param aor_list A comma-separated list of AOR names
1750 * \param aor The chosen AOR
1751 * \param contact The chosen contact
1752 */
1753 void ast_sip_location_retrieve_contact_and_aor_from_list(const char *aor_list, struct ast_sip_aor **aor,
1754 struct ast_sip_contact **contact);
1755
1756/*!
1757 * \brief Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags
1758 * \since 13.16.0
1759 *
1760 * \param aor_list A comma-separated list of AOR names
1761 * \param flags Filtering flags
1762 * \param aor The chosen AOR
1763 * \param contact The chosen contact
1764 */
1765void ast_sip_location_retrieve_contact_and_aor_from_list_filtered(const char *aor_list, unsigned int flags,
1766 struct ast_sip_aor **aor, struct ast_sip_contact **contact);
1767
1768/*!
1769 * \brief Retrieve a named contact
1770 *
1771 * \param contact_name Name of the contact
1772 *
1773 * \retval NULL if not found
1774 * \retval non-NULL if found
1775 */
1776struct ast_sip_contact *ast_sip_location_retrieve_contact(const char *contact_name);
1777
1778/*!
1779 * \brief Add a new contact to an AOR
1780 *
1781 * \param aor Pointer to the AOR
1782 * \param uri Full contact URI
1783 * \param expiration_time Optional expiration time of the contact
1784 * \param path_info Path information
1785 * \param user_agent User-Agent header from REGISTER request
1786 * \param via_addr
1787 * \param via_port
1788 * \param call_id
1789 * \param endpoint The endpoint that resulted in the contact being added
1790 *
1791 * \retval -1 failure
1792 * \retval 0 success
1793 *
1794 * \warning
1795 * This function holds a named write lock on the aor. If you already hold the lock
1796 * you should call ast_sip_location_add_contact_nolock instead.
1797 */
1798int ast_sip_location_add_contact(struct ast_sip_aor *aor, const char *uri,
1799 struct timeval expiration_time, const char *path_info, const char *user_agent,
1800 const char *via_addr, int via_port, const char *call_id,
1801 struct ast_sip_endpoint *endpoint);
1802
1803/*!
1804 * \brief Add a new contact to an AOR without locking the AOR
1805 * \since 13.9.0
1806 *
1807 * \param aor Pointer to the AOR
1808 * \param uri Full contact URI
1809 * \param expiration_time Optional expiration time of the contact
1810 * \param path_info Path information
1811 * \param user_agent User-Agent header from REGISTER request
1812 * \param via_addr
1813 * \param via_port
1814 * \param call_id
1815 * \param endpoint The endpoint that resulted in the contact being added
1816 *
1817 * \retval -1 failure
1818 * \retval 0 success
1819 *
1820 * \warning
1821 * This function should only be called if you already hold a named write lock on the aor.
1822 */
1824 struct timeval expiration_time, const char *path_info, const char *user_agent,
1825 const char *via_addr, int via_port, const char *call_id,
1826 struct ast_sip_endpoint *endpoint);
1827
1828/*!
1829 * \brief Create a new contact for an AOR without locking the AOR
1830 * \since 13.18.0
1831 *
1832 * \param aor Pointer to the AOR
1833 * \param uri Full contact URI
1834 * \param expiration_time Optional expiration time of the contact
1835 * \param path_info Path information
1836 * \param user_agent User-Agent header from REGISTER request
1837 * \param via_addr
1838 * \param via_port
1839 * \param call_id
1840 * \param prune_on_boot Non-zero if the contact cannot survive a restart/boot.
1841 * \param endpoint The endpoint that resulted in the contact being added
1842 *
1843 * \return The created contact or NULL on failure.
1844 *
1845 * \warning
1846 * This function should only be called if you already hold a named write lock on the aor.
1847 */
1849 const char *uri, struct timeval expiration_time, const char *path_info,
1850 const char *user_agent, const char *via_addr, int via_port, const char *call_id,
1852
1853/*!
1854 * \brief Update a contact
1855 *
1856 * \param contact New contact object with details
1857 *
1858 * \retval -1 failure
1859 * \retval 0 success
1860 */
1862
1863/*!
1864* \brief Delete a contact
1865*
1866* \param contact Contact object to delete
1867*
1868* \retval -1 failure
1869* \retval 0 success
1870*/
1872
1873/*!
1874 * \brief Prune the prune_on_boot contacts
1875 * \since 13.18.0
1876 */
1878
1879/*!
1880 * \brief Callback called when an outbound request with authentication credentials is to be sent in dialog
1881 *
1882 * This callback will have the created request on it. The callback's purpose is to do any extra
1883 * housekeeping that needs to be done as well as to send the request out.
1884 *
1885 * This callback is only necessary if working with a PJSIP API that sits between the application
1886 * and the dialog layer.
1887 *
1888 * \param dlg The dialog to which the request belongs
1889 * \param tdata The created request to be sent out
1890 * \param user_data Data supplied with the callback
1891 *
1892 * \retval 0 Success
1893 * \retval -1 Failure
1894 */
1895typedef int (*ast_sip_dialog_outbound_auth_cb)(pjsip_dialog *dlg, pjsip_tx_data *tdata, void *user_data);
1896
1897/*!
1898 * \brief Set up outbound authentication on a SIP dialog
1899 *
1900 * This sets up the infrastructure so that all requests associated with a created dialog
1901 * can be re-sent with authentication credentials if the original request is challenged.
1902 *
1903 * \param dlg The dialog on which requests will be authenticated
1904 * \param endpoint The endpoint whom this dialog pertains to
1905 * \param cb Callback to call to send requests with authentication
1906 * \param user_data Data to be provided to the callback when it is called
1907 *
1908 * \retval 0 Success
1909 * \retval -1 Failure
1910 */
1912 ast_sip_dialog_outbound_auth_cb cb, void *user_data);
1913
1914/*!
1915 * \brief Retrieves a reference to the artificial auth.
1916 *
1917 * \retval The artificial auth
1918 */
1920
1921/*!
1922 * \brief Retrieves a reference to the artificial endpoint.
1923 *
1924 * \retval The artificial endpoint
1925 */
1927
1928/*! \defgroup pjsip_threading PJSIP Threading Model
1929 * @{
1930 * \page PJSIP PJSIP Threading Model
1931 *
1932 * There are three major types of threads that SIP will have to deal with:
1933 * \li Asterisk threads
1934 * \li PJSIP threads
1935 * \li SIP taskpool threads (a.k.a. "servants")
1936 *
1937 * \par Asterisk Threads
1938 *
1939 * Asterisk threads are those that originate from outside of SIP but within
1940 * Asterisk. The most common of these threads are PBX (channel) threads and
1941 * the autoservice thread. Most interaction with these threads will be through
1942 * channel technology callbacks. Within these threads, it is fine to handle
1943 * Asterisk data from outside of SIP, but any handling of SIP data should be
1944 * left to servants, \b especially if you wish to call into PJSIP for anything.
1945 * Asterisk threads are not registered with PJLIB, so attempting to call into
1946 * PJSIP will cause an assertion to be triggered, thus causing the program to
1947 * crash.
1948 *
1949 * \par PJSIP Threads
1950 *
1951 * PJSIP threads are those that originate from handling of PJSIP events, such
1952 * as an incoming SIP request or response, or a transaction timeout. The role
1953 * of these threads is to process information as quickly as possible so that
1954 * the next item on the SIP socket(s) can be serviced. On incoming messages,
1955 * Asterisk automatically will push the request to a servant thread. When your
1956 * module callback is called, processing will already be in a servant. However,
1957 * for other PJSIP events, such as transaction state changes due to timer
1958 * expirations, your module will be called into from a PJSIP thread. If you
1959 * are called into from a PJSIP thread, then you should push whatever processing
1960 * is needed to a servant as soon as possible. You can discern if you are currently
1961 * in a SIP servant thread using the \ref ast_sip_thread_is_servant function.
1962 *
1963 * \par Servants
1964 *
1965 * Servants are where the bulk of SIP work should be performed. These threads
1966 * exist in order to do the work that Asterisk threads and PJSIP threads hand
1967 * off to them. Servant threads register themselves with PJLIB, meaning that
1968 * they are capable of calling PJSIP and PJLIB functions if they wish.
1969 *
1970 * \par Serializer
1971 *
1972 * Tasks are handed off to servant threads using the API call \ref ast_sip_push_task.
1973 * The first parameter of this call is a serializer. If this pointer
1974 * is NULL, then the work will be handed off to whatever servant can currently handle
1975 * the task. If this pointer is non-NULL, then the task will not be executed until
1976 * previous tasks pushed with the same serializer have completed. For more information
1977 * on serializers and the benefits they provide, see \ref ast_taskpool_serializer
1978 *
1979 * \par Scheduler
1980 *
1981 * Some situations require that a task run periodically or at a future time. Normally
1982 * the ast_sched functionality would be used but ast_sched only uses 1 thread for all
1983 * tasks and that thread isn't registered with PJLIB and therefore can't do any PJSIP
1984 * related work.
1985 *
1986 * ast_sip_sched uses ast_sched only as a scheduled queue. When a task is ready to run,
1987 * it's pushed to a Serializer to be invoked asynchronously by a Servant. This ensures
1988 * that the task is executed in a PJLIB registered thread and allows the ast_sched thread
1989 * to immediately continue processing the queue. The Serializer used by ast_sip_sched
1990 * is one of your choosing or a random one from the res_pjsip pool if you don't choose one.
1991 *
1992 * \note
1993 *
1994 * Do not make assumptions about individual threads based on a corresponding serializer.
1995 * In other words, just because several tasks use the same serializer when being pushed
1996 * to servants, it does not mean that the same thread is necessarily going to execute those
1997 * tasks, even though they are all guaranteed to be executed in sequence.
1998 */
1999
2000typedef int (*ast_sip_task)(void *user_data);
2001
2002/*!
2003 * \brief Create a new serializer for SIP tasks
2004 * \since 13.8.0
2005 *
2006 * See \ref ast_taskpool_serializer for more information on serializers.
2007 * SIP creates serializers so that tasks operating on similar data will run
2008 * in sequence.
2009 *
2010 * \param name Name of the serializer. (must be unique)
2011 *
2012 * \retval NULL Failure
2013 * \retval non-NULL Newly-created serializer
2014 */
2016
2018
2019/*!
2020 * \brief Create a new serializer for SIP tasks
2021 * \since 13.8.0
2022 *
2023 * See \ref ast_taskpool_serializer for more information on serializers.
2024 * SIP creates serializers so that tasks operating on similar data will run
2025 * in sequence.
2026 *
2027 * \param name Name of the serializer. (must be unique)
2028 * \param shutdown_group Group shutdown controller. (NULL if no group association)
2029 *
2030 * \retval NULL Failure
2031 * \retval non-NULL Newly-created serializer
2032 */
2034
2035/*!
2036 * \brief Determine the distributor serializer for the SIP message.
2037 * \since 13.10.0
2038 *
2039 * \param rdata The incoming message.
2040 *
2041 * \retval Calculated distributor serializer on success.
2042 * \retval NULL on error.
2043 */
2044struct ast_taskprocessor *ast_sip_get_distributor_serializer(pjsip_rx_data *rdata);
2045
2046/*!
2047 * \brief Set a serializer on a SIP dialog so requests and responses are automatically serialized
2048 *
2049 * Passing a NULL serializer is a way to remove a serializer from a dialog.
2050 *
2051 * \param dlg The SIP dialog itself
2052 * \param serializer The serializer to use
2053 */
2054void ast_sip_dialog_set_serializer(pjsip_dialog *dlg, struct ast_taskprocessor *serializer);
2055
2056/*!
2057 * \brief Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup.
2058 *
2059 * \param dlg The SIP dialog itself
2060 * \param endpoint The endpoint that this dialog is communicating with
2061 */
2062void ast_sip_dialog_set_endpoint(pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint);
2063
2064/*!
2065 * \brief Get the endpoint associated with this dialog
2066 *
2067 * This function increases the refcount of the endpoint by one. Release
2068 * the reference once you are finished with the endpoint.
2069 *
2070 * \param dlg The SIP dialog from which to retrieve the endpoint
2071 * \retval NULL No endpoint associated with this dialog
2072 * \retval non-NULL The endpoint.
2073 */
2074struct ast_sip_endpoint *ast_sip_dialog_get_endpoint(pjsip_dialog *dlg);
2075
2076/*!
2077 * \brief Pushes a task to SIP servants
2078 *
2079 * This uses the serializer provided to determine how to push the task.
2080 * If the serializer is NULL, then the task will be pushed to the
2081 * servants directly. If the serializer is non-NULL, then the task will be
2082 * queued behind other tasks associated with the same serializer.
2083 *
2084 * \param serializer The serializer to which the task belongs. Can be NULL
2085 * \param sip_task The task to execute
2086 * \param task_data The parameter to pass to the task when it executes
2087 * \retval 0 Success
2088 * \retval -1 Failure
2089 */
2090int __ast_sip_push_task(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data,
2091 const char *file, int line, const char *function);
2092
2093#define ast_sip_push_task(serializer, sip_task, task_data) \
2094 __ast_sip_push_task(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
2095
2096/*!
2097 * \brief Push a task to SIP servants and wait for it to complete.
2098 *
2099 * Like \ref ast_sip_push_task except that it blocks until the task
2100 * completes. If the current thread is a SIP servant thread then the
2101 * task executes immediately. Otherwise, the specified serializer
2102 * executes the task and the current thread waits for it to complete.
2103 *
2104 * \note PJPROJECT callbacks tend to have locks already held when
2105 * called.
2106 *
2107 * \warning \b Never hold locks that may be acquired by a SIP servant
2108 * thread when calling this function. Doing so may cause a deadlock
2109 * if all SIP servant threads are blocked waiting to acquire the lock
2110 * while the thread holding the lock is waiting for a free SIP servant
2111 * thread.
2112 *
2113 * \warning \b Use of this function in an ao2 destructor callback is a
2114 * bad idea. You don't have control over which thread executes the
2115 * destructor. Attempting to shift execution to another thread with
2116 * this function is likely to cause deadlock.
2117 *
2118 * \param serializer The SIP serializer to execute the task if the
2119 * current thread is not a SIP servant. NULL if any of the default
2120 * serializers can be used.
2121 * \param sip_task The task to execute
2122 * \param task_data The parameter to pass to the task when it executes
2123 *
2124 * \note The sip_task() return value may need to be distinguished from
2125 * the failure to push the task.
2126 *
2127 * \return sip_task() return value on success.
2128 * \retval -1 Failure to push the task.
2129 */
2130int __ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data,
2131 const char *file, int line, const char *function);
2132#define ast_sip_push_task_wait_servant(serializer, sip_task, task_data) \
2133 __ast_sip_push_task_wait_servant(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
2134
2135/*!
2136 * \brief Push a task to SIP servants and wait for it to complete.
2137 * \deprecated Replaced with ast_sip_push_task_wait_servant().
2138 */
2139int __ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data,
2140 const char *file, int line, const char *function);
2141#define ast_sip_push_task_synchronous(serializer, sip_task, task_data) \
2142 __ast_sip_push_task_synchronous(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
2143
2144/*!
2145 * \brief Push a task to the serializer and wait for it to complete.
2146 *
2147 * Like \ref ast_sip_push_task except that it blocks until the task is
2148 * completed by the specified serializer. If the specified serializer
2149 * is the current thread then the task executes immediately.
2150 *
2151 * \note PJPROJECT callbacks tend to have locks already held when
2152 * called.
2153 *
2154 * \warning \b Never hold locks that may be acquired by a SIP servant
2155 * thread when calling this function. Doing so may cause a deadlock
2156 * if all SIP servant threads are blocked waiting to acquire the lock
2157 * while the thread holding the lock is waiting for a free SIP servant
2158 * thread for the serializer to execute in.
2159 *
2160 * \warning \b Never hold locks that may be acquired by the serializer
2161 * when calling this function. Doing so will cause a deadlock.
2162 *
2163 * \warning \b Never use this function in the pjsip monitor thread (It
2164 * is a SIP servant thread). This is likely to cause a deadlock.
2165 *
2166 * \warning \b Use of this function in an ao2 destructor callback is a
2167 * bad idea. You don't have control over which thread executes the
2168 * destructor. Attempting to shift execution to another thread with
2169 * this function is likely to cause deadlock.
2170 *
2171 * \param serializer The SIP serializer to execute the task. NULL if
2172 * any of the default serializers can be used.
2173 * \param sip_task The task to execute
2174 * \param task_data The parameter to pass to the task when it executes
2175 *
2176 * \note It is generally better to call
2177 * ast_sip_push_task_wait_servant() if you pass NULL for the
2178 * serializer parameter.
2179 *
2180 * \note The sip_task() return value may need to be distinguished from
2181 * the failure to push the task.
2182 *
2183 * \return sip_task() return value on success.
2184 * \retval -1 Failure to push the task.
2185 */
2186int __ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int (*sip_task)(void *), void *task_data,
2187 const char *file, int line, const char *function);
2188#define ast_sip_push_task_wait_serializer(serializer, sip_task, task_data) \
2189 __ast_sip_push_task_wait_serializer(serializer, sip_task, task_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
2190
2191/*!
2192 * \brief Determine if the current thread is a SIP servant thread
2193 *
2194 * \retval 0 This is not a SIP servant thread
2195 * \retval 1 This is a SIP servant thread
2196 */
2198
2199/*!
2200 * \brief Task flags for the res_pjsip scheduler
2201 *
2202 * The default is AST_SIP_SCHED_TASK_FIXED
2203 * | AST_SIP_SCHED_TASK_DATA_NOT_AO2
2204 * | AST_SIP_SCHED_TASK_DATA_NO_CLEANUP
2205 * | AST_SIP_SCHED_TASK_PERIODIC
2206 */
2208 /*!
2209 * The defaults
2210 */
2211 AST_SIP_SCHED_TASK_DEFAULTS = (0 << 0),
2212
2213 /*!
2214 * Run at a fixed interval.
2215 * Stop scheduling if the callback returns <= 0.
2216 * Any other value is ignored.
2217 */
2218 AST_SIP_SCHED_TASK_FIXED = (0 << 0),
2219 /*!
2220 * Run at a variable interval.
2221 * Stop scheduling if the callback returns <= 0.
2222 * Any other return value is used as the new interval.
2223 */
2224 AST_SIP_SCHED_TASK_VARIABLE = (1 << 0),
2225
2226 /*!
2227 * Run just once.
2228 * Return values are ignored.
2229 */
2230 AST_SIP_SCHED_TASK_ONESHOT = (1 << 6),
2231
2232 /*!
2233 * The task data is not an AO2 object.
2234 */
2236 /*!
2237 * The task data is an AO2 object.
2238 * A reference count will be held by the scheduler until
2239 * after the task has run for the final time (if ever).
2240 */
2241 AST_SIP_SCHED_TASK_DATA_AO2 = (1 << 1),
2242
2243 /*!
2244 * Don't take any cleanup action on the data
2245 */
2247 /*!
2248 * If AST_SIP_SCHED_TASK_DATA_AO2 is set, decrement the reference count
2249 * otherwise call ast_free on it.
2250 */
2251 AST_SIP_SCHED_TASK_DATA_FREE = ( 1 << 3 ),
2252
2253 /*!
2254 * \brief The task is scheduled at multiples of interval
2255 * \see Interval
2256 */
2257 AST_SIP_SCHED_TASK_PERIODIC = (0 << 4),
2258 /*!
2259 * \brief The next invocation of the task is at last finish + interval
2260 * \see Interval
2261 */
2262 AST_SIP_SCHED_TASK_DELAY = (1 << 4),
2263 /*!
2264 * \brief The scheduled task's events are tracked in the debug log.
2265 * \details
2266 * Schedule events such as scheduling, running, rescheduling, canceling,
2267 * and destroying are logged about the task.
2268 */
2269 AST_SIP_SCHED_TASK_TRACK = (1 << 5),
2270};
2271
2272/*!
2273 * \brief Scheduler task data structure
2274 */
2275struct ast_sip_sched_task;
2276
2277/*!
2278 * \brief Schedule a task to run in the res_pjsip taskpool
2279 * \since 13.9.0
2280 *
2281 * \param serializer The serializer to use. If NULL, don't use a serializer (see note below)
2282 * \param interval The invocation interval in milliseconds (see note below)
2283 * \param sip_task The task to invoke
2284 * \param name An optional name to associate with the task
2285 * \param task_data Optional data to pass to the task
2286 * \param flags One of enum ast_sip_scheduler_task_type
2287 *
2288 * \returns Pointer to \ref ast_sip_sched_task ao2 object which must be dereferenced when done.
2289 *
2290 * \par Serialization
2291 *
2292 * Specifying a serializer guarantees serialized execution but NOT specifying a serializer
2293 * may still result in tasks being effectively serialized if the taskpool is busy.
2294 * The point of the serializer BTW is not to prevent parallel executions of the SAME task.
2295 * That happens automatically (see below). It's to prevent the task from running at the same
2296 * time as other work using the same serializer, whether or not it's being run by the scheduler.
2297 *
2298 * \par Interval
2299 *
2300 * The interval is used to calculate the next time the task should run. There are two models.
2301 *
2302 * \ref AST_SIP_SCHED_TASK_PERIODIC specifies that the invocations of the task occur at the
2303 * specific interval. That is, every \p interval milliseconds, regardless of how long the task
2304 * takes. If the task takes longer than \p interval, it will be scheduled at the next available
2305 * multiple of \p interval. For example: If the task has an interval of 60 seconds and the task
2306 * takes 70 seconds, the next invocation will happen at 120 seconds.
2307 *
2308 * \ref AST_SIP_SCHED_TASK_DELAY specifies that the next invocation of the task should start
2309 * at \p interval milliseconds after the current invocation has finished.
2310 *
2311 */
2313 int interval, ast_sip_task sip_task, const char *name, void *task_data,
2315
2316/*!
2317 * \brief Cancels the next invocation of a task
2318 * \since 13.9.0
2319 *
2320 * \param schtd The task structure pointer
2321 * \retval 0 Success
2322 * \retval -1 Failure
2323 * \note Only cancels future invocations not the currently running invocation.
2324 */
2326
2327/*!
2328 * \brief Cancels the next invocation of a task by name
2329 * \since 13.9.0
2330 *
2331 * \param name The task name
2332 * \retval 0 Success
2333 * \retval -1 Failure
2334 * \note Only cancels future invocations not the currently running invocation.
2335 */
2337
2338/*!
2339 * \brief Gets the last start and end times of the task
2340 * \since 13.9.0
2341 *
2342 * \param schtd The task structure pointer
2343 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2344 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2345 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2346 * \retval 0 Success
2347 * \retval -1 Failure
2348 * \note Any of the pointers can be NULL if you don't need them.
2349 */
2351 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end);
2352
2353/*!
2354 * \brief Gets the queued, last start, last_end, time left, interval, next run
2355 * \since 16.15.0
2356 * \since 18.1.0
2357 *
2358 * \param schtd The task structure pointer
2359 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2360 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2361 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2362 * \param[out] interval Pointer to an int to contain the interval in ms
2363 * \param[out] time_left Pointer to an int to contain the ms left to the next run
2364 * \param[out] next_start Pointer to a timeval structure to contain the next run time
2365 * \retval 0 Success
2366 * \retval -1 Failure
2367 * \note Any of the pointers can be NULL if you don't need them.
2368 */
2370 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end,
2371 int *interval, int *time_left, struct timeval *next_start);
2372
2373/*!
2374 * \brief Gets the last start and end times of the task by name
2375 * \since 13.9.0
2376 *
2377 * \param name The task name
2378 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2379 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2380 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2381 * \retval 0 Success
2382 * \retval -1 Failure
2383 * \note Any of the pointers can be NULL if you don't need them.
2384 */
2386 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end);
2387
2388/*!
2389 * \brief Gets the queued, last start, last_end, time left, interval, next run by task name
2390 * \since 16.15.0
2391 * \since 18.1.0
2392 *
2393 * \param name The task name
2394 * \param[out] when_queued Pointer to a timeval structure to contain the time when queued
2395 * \param[out] last_start Pointer to a timeval structure to contain the time when last started
2396 * \param[out] last_end Pointer to a timeval structure to contain the time when last ended
2397 * \param[out] interval Pointer to an int to contain the interval in ms
2398 * \param[out] time_left Pointer to an int to contain the ms left to the next run
2399 * \param[out] next_start Pointer to a timeval structure to contain the next run time
2400 * \retval 0 Success
2401 * \retval -1 Failure
2402 * \note Any of the pointers can be NULL if you don't need them.
2403 */
2405 struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end,
2406 int *interval, int *time_left, struct timeval *next_start);
2407
2408/*!
2409 * \brief Gets the number of milliseconds until the next invocation
2410 * \since 13.9.0
2411 *
2412 * \param schtd The task structure pointer
2413 * \return The number of milliseconds until the next invocation or -1 if the task isn't scheduled
2414 */
2416
2417/*!
2418 * \brief Gets the number of milliseconds until the next invocation
2419 * \since 13.9.0
2420 *
2421 * \param name The task name
2422 * \return The number of milliseconds until the next invocation or -1 if the task isn't scheduled
2423 */
2425
2426/*!
2427 * \brief Checks if the task is currently running
2428 * \since 13.9.0
2429 *
2430 * \param schtd The task structure pointer
2431 * \retval 0 not running
2432 * \retval 1 running
2433 */
2435
2436/*!
2437 * \brief Checks if the task is currently running
2438 * \since 13.9.0
2439 *
2440 * \param name The task name
2441 * \retval 0 not running or not found
2442 * \retval 1 running
2443 */
2445
2446/*!
2447 * \brief Gets the task name
2448 * \since 13.9.0
2449 *
2450 * \param schtd The task structure pointer
2451 * \param name, maxlen
2452 * \retval 0 success
2453 * \retval 1 failure
2454 */
2455int ast_sip_sched_task_get_name(struct ast_sip_sched_task *schtd, char *name, size_t maxlen);
2456
2457/*!
2458 * @}
2459 */
2460
2461/*!
2462 * \brief SIP body description
2463 *
2464 * This contains a type and subtype that will be added as
2465 * the "Content-Type" for the message as well as the body
2466 * text.
2467 */
2468struct ast_sip_body {
2469 /*! Type of the body, such as "application" */
2470 const char *type;
2471 /*! Subtype of the body, such as "sdp" */
2472 const char *subtype;
2473 /*! The text to go in the body */
2474 const char *body_text;
2475};
2476
2477/*!
2478 * \brief General purpose method for creating a UAC dialog with an endpoint
2479 *
2480 * \param endpoint A pointer to the endpoint
2481 * \param aor_name Optional name of the AOR to target, may even be an explicit SIP URI
2482 * \param request_user Optional user to place into the target URI
2483 *
2484 * \retval non-NULL success
2485 * \retval NULL failure
2486 */
2487pjsip_dialog *ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user);
2488
2489/*!
2490 * \brief General purpose method for creating a UAS dialog with an endpoint
2491 *
2492 * \deprecated This function is unsafe (due to the returned object not being locked nor
2493 * having its reference incremented) and should no longer be used. Instead
2494 * use ast_sip_create_dialog_uas_locked so a properly locked and referenced
2495 * object is returned.
2496 *
2497 * \param endpoint A pointer to the endpoint
2498 * \param rdata The request that is starting the dialog
2499 * \param[out] status On failure, the reason for failure in creating the dialog
2500 */
2501pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status);
2502
2503/*!
2504 * \brief General purpose method for creating a UAS dialog with an endpoint
2505 *
2506 * This function creates and returns a locked, and referenced counted pjsip
2507 * dialog object. The caller is thus responsible for freeing the allocated
2508 * memory, decrementing the reference, and releasing the lock when done with
2509 * the returned object.
2510 *
2511 * \note The safest way to unlock the object, and decrement its reference is by
2512 * calling pjsip_dlg_dec_lock. Alternatively, pjsip_dlg_dec_session can be
2513 * used to decrement the reference only.
2514 *
2515 * The dialog is returned locked and with a reference in order to ensure that the
2516 * dialog object, and any of its associated objects (e.g. transaction) are not
2517 * untimely destroyed. For instance, that could happen when a transport error
2518 * occurs.
2519 *
2520 * As long as the caller maintains a reference to the dialog there should be no
2521 * worry that it might unknowingly be destroyed. However, once the caller unlocks
2522 * the dialog there is a danger that some of the dialog's internal objects could
2523 * be lost and/or compromised. For example, when the aforementioned transport error
2524 * occurs the dialog's associated transaction gets destroyed (see pjsip_dlg_on_tsx_state
2525 * in sip_dialog.c, and mod_inv_on_tsx_state in sip_inv.c).
2526 *
2527 * In this case and before using the dialog again the caller should re-lock the
2528 * dialog, check to make sure the dialog is still established, and the transaction
2529 * still exists and has not been destroyed.
2530 *
2531 * \param endpoint A pointer to the endpoint
2532 * \param rdata The request that is starting the dialog
2533 * \param[out] status On failure, the reason for failure in creating the dialog
2534 *
2535 * \retval A locked, and reference counted pjsip_dialog object.
2536 * \retval NULL on failure
2537 */
2538pjsip_dialog *ast_sip_create_dialog_uas_locked(const struct ast_sip_endpoint *endpoint,
2539 pjsip_rx_data *rdata, pj_status_t *status);
2540
2541/*!
2542 * \brief General purpose method for creating an rdata structure using specific information
2543 * \since 13.15.0
2544 *
2545 * \param[out] rdata The rdata structure that will be populated
2546 * \param packet A SIP message
2547 * \param src_name The source IP address of the message
2548 * \param src_port The source port of the message
2549 * \param transport_type The type of transport the message was received on
2550 * \param local_name The local IP address the message was received on
2551 * \param local_port The local port the message was received on
2552 * \param contact_uri The contact URI of the message
2553 *
2554 * \retval 0 success
2555 * \retval -1 failure
2556 */
2557int ast_sip_create_rdata_with_contact(pjsip_rx_data *rdata, char *packet,
2558 const char *src_name, int src_port, char *transport_type, const char *local_name,
2559 int local_port, const char *contact_uri);
2560
2561/*!
2562 * \brief General purpose method for creating an rdata structure using specific information
2563 *
2564 * \param[out] rdata The rdata structure that will be populated
2565 * \param packet A SIP message
2566 * \param src_name The source IP address of the message
2567 * \param src_port The source port of the message
2568 * \param transport_type The type of transport the message was received on
2569 * \param local_name The local IP address the message was received on
2570 * \param local_port The local port the message was received on
2571 *
2572 * \retval 0 success
2573 * \retval -1 failure
2574 */
2575int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name,
2576 int src_port, char *transport_type, const char *local_name, int local_port);
2577
2578/*!
2579 * \brief General purpose method for creating a SIP request
2580 *
2581 * Its typical use would be to create one-off requests such as an out of dialog
2582 * SIP MESSAGE.
2583 *
2584 * The request can either be in- or out-of-dialog. If in-dialog, the
2585 * dlg parameter MUST be present. If out-of-dialog the endpoint parameter
2586 * MUST be present. If both are present, then we will assume that the message
2587 * is to be sent in-dialog.
2588 *
2589 * The uri parameter can be specified if the request should be sent to an explicit
2590 * URI rather than one configured on the endpoint.
2591 *
2592 * \param method The method of the SIP request to send
2593 * \param dlg Optional. If specified, the dialog on which to request the message.
2594 * \param endpoint Optional. If specified, the request will be created out-of-dialog to the endpoint.
2595 * \param uri Optional. If specified, the request will be sent to this URI rather
2596 * than one configured for the endpoint.
2597 * \param contact The contact with which this request is associated for out-of-dialog requests.
2598 * \param[out] tdata The newly-created request
2599 *
2600 * The provided contact is attached to tdata with its reference bumped, but will
2601 * not survive for the entire lifetime of tdata since the contact is cleaned up
2602 * when all supplements have completed execution.
2603 *
2604 * \retval 0 Success
2605 * \retval -1 Failure
2606 */
2607int ast_sip_create_request(const char *method, struct pjsip_dialog *dlg,
2608 struct ast_sip_endpoint *endpoint, const char *uri,
2609 struct ast_sip_contact *contact, pjsip_tx_data **tdata);
2610
2611/*!
2612 * \brief General purpose method for sending a SIP request
2613 *
2614 * This is a companion function for \ref ast_sip_create_request. The request
2615 * created there can be passed to this function, though any request may be
2616 * passed in.
2617 *
2618 * This will automatically set up handling outbound authentication challenges if
2619 * they arrive.
2620 *
2621 * \param tdata The request to send
2622 * \param dlg Optional. The dialog in which the request is sent. Otherwise it is out-of-dialog.
2623 * \param endpoint Optional. If specified, the out-of-dialog request is sent to the endpoint.
2624 * \param token Data to be passed to the callback upon receipt of out-of-dialog response.
2625 * \param callback Callback to be called upon receipt of out-of-dialog response.
2626 *
2627 * \retval 0 Success
2628 * \retval -1 Failure (out-of-dialog callback will not be called.)
2629 */
2630int ast_sip_send_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg,
2631 struct ast_sip_endpoint *endpoint, void *token,
2632 void (*callback)(void *token, pjsip_event *e));
2633
2634/*!
2635 * \brief General purpose method for sending an Out-Of-Dialog SIP request
2636 *
2637 * This is a companion function for \ref ast_sip_create_request. The request
2638 * created there can be passed to this function, though any request may be
2639 * passed in.
2640 *
2641 * This will automatically set up handling outbound authentication challenges if
2642 * they arrive.
2643 *
2644 * \param tdata The request to send
2645 * \param endpoint Optional. If specified, the out-of-dialog request is sent to the endpoint.
2646 * \param timeout If non-zero, after the timeout the transaction will be terminated
2647 * and the callback will be called with the PJSIP_EVENT_TIMER type.
2648 * \param token Data to be passed to the callback upon receipt of out-of-dialog response.
2649 * \param callback Callback to be called upon receipt of out-of-dialog response.
2650 *
2651 * \retval 0 Success
2652 * \retval -1 Failure (out-of-dialog callback will not be called.)
2653 *
2654 * \note Timeout processing:
2655 * There are 2 timers associated with this request, PJSIP timer_b which is
2656 * set globally in the "system" section of pjsip.conf, and the timeout specified
2657 * on this call. The timer that expires first (before normal completion) will
2658 * cause the callback to be run with e->body.tsx_state.type = PJSIP_EVENT_TIMER.
2659 * The timer that expires second is simply ignored and the callback is not run again.
2660 */
2661int ast_sip_send_out_of_dialog_request(pjsip_tx_data *tdata,
2662 struct ast_sip_endpoint *endpoint, int timeout, void *token,
2663 void (*callback)(void *token, pjsip_event *e));
2664
2665/*!
2666 * \brief General purpose method for creating a SIP response
2667 *
2668 * Its typical use would be to create responses for out of dialog
2669 * requests.
2670 *
2671 * \param rdata The rdata from the incoming request.
2672 * \param st_code The response code to transmit.
2673 * \param contact The contact with which this request is associated.
2674 * \param[out] p_tdata The newly-created response
2675 *
2676 * The provided contact is attached to tdata with its reference bumped, but will
2677 * not survive for the entire lifetime of tdata since the contact is cleaned up
2678 * when all supplements have completed execution.
2679 *
2680 * \retval 0 Success
2681 * \retval -1 Failure
2682 */
2683int ast_sip_create_response(const pjsip_rx_data *rdata, int st_code,
2684 struct ast_sip_contact *contact, pjsip_tx_data **p_tdata);
2685
2686/*!
2687 * \brief Send a response to an out of dialog request
2688 *
2689 * Use this function sparingly, since this does not create a transaction
2690 * within PJSIP. This means that if the request is retransmitted, it is
2691 * your responsibility to detect this and not process the same request
2692 * twice, and to send the same response for each retransmission.
2693 *
2694 * \param res_addr The response address for this response
2695 * \param tdata The response to send
2696 * \param sip_endpoint The ast_sip_endpoint associated with this response
2697 *
2698 * \retval 0 Success
2699 * \retval -1 Failure
2700 */
2701int ast_sip_send_response(pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint);
2702
2703/*!
2704 * \brief Send a stateful response to an out of dialog request
2705 *
2706 * This creates a transaction within PJSIP, meaning that if the request
2707 * that we are responding to is retransmitted, we will not attempt to
2708 * re-handle the request.
2709 *
2710 * \param rdata The request that is being responded to
2711 * \param tdata The response to send
2712 * \param sip_endpoint The ast_sip_endpoint associated with this response
2713 *
2714 * \since 13.4.0
2715 *
2716 * \retval 0 Success
2717 * \retval -1 Failure
2718 */
2719int ast_sip_send_stateful_response(pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint);
2720
2721/*!
2722 * \brief Determine if an incoming request requires authentication
2723 *
2724 * This calls into the registered authenticator's requires_authentication callback
2725 * in order to determine if the request requires authentication.
2726 *
2727 * If there is no registered authenticator, then authentication will be assumed
2728 * not to be required.
2729 *
2730 * \param endpoint The endpoint from which the request originates
2731 * \param rdata The incoming SIP request
2732 * \retval non-zero The request requires authentication
2733 * \retval 0 The request does not require authentication
2734 */
2735int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
2736
2737/*!
2738 * \brief Method to determine authentication status of an incoming request
2739 *
2740 * This will call into a registered authenticator. The registered authenticator will
2741 * do what is necessary to determine whether the incoming request passes authentication.
2742 * A tentative response is passed into this function so that if, say, a digest authentication
2743 * challenge should be sent in the ensuing response, it can be added to the response.
2744 *
2745 * \param endpoint The endpoint from the request was sent
2746 * \param rdata The request to potentially authenticate
2747 * \param tdata Tentative response to the request
2748 * \return The result of checking authentication.
2749 */
2751 pjsip_rx_data *rdata, pjsip_tx_data *tdata);
2752
2753/*!
2754 * \brief Create a response to an authentication challenge
2755 *
2756 * This will call into an outbound authenticator's create_request_with_auth callback
2757 * to create a new request with authentication credentials. See the create_request_with_auth
2758 * callback in the \ref ast_sip_outbound_authenticator structure for details about
2759 * the parameters and return values.
2760 */
2761int ast_sip_create_request_with_auth(const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge,
2762 pjsip_tx_data *tdata, pjsip_tx_data **new_request);
2763
2764/*!
2765 * \brief Determine the endpoint that has sent a SIP message
2766 *
2767 * This will call into each of the registered endpoint identifiers'
2768 * identify_endpoint() callbacks until one returns a non-NULL endpoint.
2769 * This will return an ao2 object. Its reference count will need to be
2770 * decremented when completed using the endpoint.
2771 *
2772 * \param rdata The inbound SIP message to use when identifying the endpoint.
2773 * \retval NULL No matching endpoint
2774 * \retval non-NULL The matching endpoint
2775 */
2776struct ast_sip_endpoint *ast_sip_identify_endpoint(pjsip_rx_data *rdata);
2777
2778/*!
2779 * \brief Get a specific header value from rdata
2780 *
2781 * \note The returned value does not need to be freed since it's from the rdata pool
2782 *
2783 * \param rdata The rdata
2784 * \param str The header to find
2785 *
2786 * \retval NULL on failure
2787 * \retval The header value on success
2788 */
2789char *ast_sip_rdata_get_header_value(pjsip_rx_data *rdata, const pj_str_t str);
2790
2791/*!
2792 * \brief Set the outbound proxy for an outbound SIP message
2793 *
2794 * \param tdata The message to set the outbound proxy on
2795 * \param proxy SIP uri of the proxy
2796 * \retval 0 Success
2797 * \retval -1 Failure
2798 */
2799int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy);
2800
2801/*!
2802 * \brief Add a header to an outbound SIP message
2803 *
2804 * \param tdata The message to add the header to
2805 * \param name The header name
2806 * \param value The header value
2807 * \retval 0 Success
2808 * \retval -1 Failure
2809 */
2810int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value);
2811
2812/*!
2813 * \brief Add a header to an outbound SIP message, returning a pointer to the header
2814 *
2815 * \param tdata The message to add the header to
2816 * \param name The header name
2817 * \param value The header value
2818 * \return The pjsip_generic_string_hdr * added.
2819 */
2820pjsip_generic_string_hdr *ast_sip_add_header2(pjsip_tx_data *tdata,
2821 const char *name, const char *value);
2822
2823/*!
2824 * \brief Add a body to an outbound SIP message
2825 *
2826 * If this is called multiple times, the latest body will replace the current
2827 * body.
2828 *
2829 * \param tdata The message to add the body to
2830 * \param body The message body to add
2831 * \retval 0 Success
2832 * \retval -1 Failure
2833 */
2834int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body);
2835
2836/*!
2837 * \brief Add a multipart body to an outbound SIP message
2838 *
2839 * This will treat each part of the input vector as part of a multipart body and
2840 * add each part to the SIP message.
2841 *
2842 * \param tdata The message to add the body to
2843 * \param bodies The message bodies to add
2844 * \param num_bodies The parts of the body to add
2845 * \retval 0 Success
2846 * \retval -1 Failure
2847 */
2848int ast_sip_add_body_multipart(pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies);
2849
2850/*!
2851 * \brief Append body data to a SIP message
2852 *
2853 * This acts mostly the same as ast_sip_add_body, except that rather than replacing
2854 * a body if it currently exists, it appends data to an existing body.
2855 *
2856 * \param tdata The message to append the body to
2857 * \param body_text The string to append to the end of the current body
2858 * \retval 0 Success
2859 * \retval -1 Failure
2860 */
2861int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text);
2862
2863/*!
2864 * \brief Copy a pj_str_t into a standard character buffer.
2865 *
2866 * pj_str_t is not NULL-terminated. Any place that expects a NULL-
2867 * terminated string needs to have the pj_str_t copied into a separate
2868 * buffer.
2869 *
2870 * This method copies the pj_str_t contents into the destination buffer
2871 * and NULL-terminates the buffer.
2872 *
2873 * \param dest The destination buffer
2874 * \param src The pj_str_t to copy
2875 * \param size The size of the destination buffer.
2876 */
2877void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size);
2878
2879/*!
2880 * \brief Create and copy a pj_str_t into a standard character buffer.
2881 *
2882 * pj_str_t is not NULL-terminated. Any place that expects a NULL-
2883 * terminated string needs to have the pj_str_t copied into a separate
2884 * buffer.
2885 *
2886 * Copies the pj_str_t contents into a newly allocated buffer pointed to
2887 * by dest. NULL-terminates the buffer.
2888 *
2889 * \note Caller is responsible for freeing the allocated memory.
2890 *
2891 * \param[out] dest The destination buffer
2892 * \param src The pj_str_t to copy
2893 * \return Number of characters copied or negative value on error
2894 */
2895int ast_copy_pj_str2(char **dest, const pj_str_t *src);
2896
2897/*!
2898 * \brief Get the looked-up endpoint on an out-of dialog request or response
2899 *
2900 * The function may ONLY be called on out-of-dialog requests or responses. For
2901 * in-dialog requests and responses, it is required that the user of the dialog
2902 * has the looked-up endpoint stored locally.
2903 *
2904 * This function should never return NULL if the message is out-of-dialog. It will
2905 * always return NULL if the message is in-dialog.
2906 *
2907 * This function will increase the reference count of the returned endpoint by one.
2908 * Release your reference using the ao2_ref function when finished.
2909 *
2910 * \param rdata Out-of-dialog request or response
2911 * \return The looked up endpoint
2912 */
2913struct ast_sip_endpoint *ast_pjsip_rdata_get_endpoint(pjsip_rx_data *rdata);
2914
2915/*!
2916 * \brief Add 'user=phone' parameter to URI if enabled and user is a phone number.
2917 *
2918 * \param endpoint The endpoint to use for configuration
2919 * \param pool The memory pool to allocate the parameter from
2920 * \param uri The URI to check for user and to add parameter to
2921 */
2922void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri);
2923
2924/*!
2925 * \brief Retrieve any endpoints available to sorcery.
2926 *
2927 * \retval Endpoints available to sorcery, NULL if no endpoints found.
2928 */
2930
2931/*!
2932 * \brief Retrieve the default outbound endpoint.
2933 *
2934 * \retval The default outbound endpoint, NULL if not found.
2935 */
2937
2938/*!
2939 * \brief Retrieve relevant SIP auth structures from sorcery
2940 *
2941 * \param auths Vector of sorcery IDs of auth credentials to retrieve
2942 * \param[out] out The retrieved auths are stored here
2943 */
2944int ast_sip_retrieve_auths(const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out);
2945
2946/*!
2947 * \brief Clean up retrieved auth structures from memory
2948 *
2949 * Call this function once you have completed operating on auths
2950 * retrieved from \ref ast_sip_retrieve_auths
2951 *
2952 * \param auths An array of auth object pointers to clean up
2953 * \param num_auths The number of auths in the array
2954 */
2955void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths);
2956
2958/*!
2959 * \brief Retrieve relevant SIP auth structures from sorcery as a vector
2960 *
2961 * \param auth_ids Vector of sorcery IDs of auth credentials to retrieve
2962 * \param[out] auth_objects A pointer ast_sip_auth_objects_vector to hold the objects
2963 *
2964 * \retval 0 Success
2965 * \retval -1 Number of auth objects found is less than the number of names supplied.
2966 *
2967 * \warning The number of auth objects retrieved may be less than the
2968 * number of auth ids supplied if auth objects couldn't be found for
2969 * some of them.
2970 *
2971 * \note Since the ref count on all auth objects returned has been
2972 * bumped, you must call ast_sip_cleanup_auth_objects_vector() to decrement
2973 * the ref count on all of the auth objects in the vector,
2974 * then call AST_VECTOR_FREE() on the vector itself.
2975 *
2976 */
2977int ast_sip_retrieve_auths_vector(const struct ast_sip_auth_vector *auth_ids,
2978 struct ast_sip_auth_objects_vector *auth_objects);
2979
2980/*!
2981 * \brief Clean up retrieved auth objects in vector
2982 *
2983 * Call this function once you have completed operating on auths
2984 * retrieved from \ref ast_sip_retrieve_auths_vector. All
2985 * auth objects will have their reference counts decremented and
2986 * the vector size will be reset to 0. You must still call
2987 * AST_VECTOR_FREE() on the vector itself.
2988 *
2989 * \param auth_objects A vector of auth structures to clean up
2990 */
2991#define ast_sip_cleanup_auth_objects_vector(auth_objects) AST_VECTOR_RESET(auth_objects, ao2_cleanup)
2992
2993/*!
2994 * \brief Checks if the given content type matches type/subtype.
2995 *
2996 * Compares the pjsip_media_type with the passed type and subtype and
2997 * returns the result of that comparison. The media type parameters are
2998 * ignored.
2999 *
3000 * \param content_type The pjsip_media_type structure to compare
3001 * \param type The media type to compare
3002 * \param subtype The media subtype to compare
3003 * \retval 0 No match
3004 * \retval -1 Match
3005 */
3006int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype);
3007
3008/*!
3009 * \brief Send a security event notification for when an invalid endpoint is requested
3010 *
3011 * \param name Name of the endpoint requested
3012 * \param rdata Received message
3013 */
3014void ast_sip_report_invalid_endpoint(const char *name, pjsip_rx_data *rdata);
3015
3016/*!
3017 * \brief Send a security event notification for when an ACL check fails
3018 *
3019 * \param endpoint Pointer to the endpoint in use
3020 * \param rdata Received message
3021 * \param name Name of the ACL
3022 */
3023void ast_sip_report_failed_acl(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *name);
3024
3025/*!
3026 * \brief Send a security event notification for when a challenge response has failed
3027 *
3028 * \param endpoint Pointer to the endpoint in use
3029 * \param rdata Received message
3030 */
3031void ast_sip_report_auth_failed_challenge_response(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
3032
3033/*!
3034 * \brief Send a security event notification for when authentication succeeds
3035 *
3036 * \param endpoint Pointer to the endpoint in use
3037 * \param rdata Received message
3038 */
3039void ast_sip_report_auth_success(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
3040
3041/*!
3042 * \brief Send a security event notification for when an authentication challenge is sent
3043 *
3044 * \param endpoint Pointer to the endpoint in use
3045 * \param rdata Received message
3046 * \param tdata Sent message
3047 */
3048void ast_sip_report_auth_challenge_sent(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata);
3049
3050/*!
3051 * \brief Send a security event notification for when a request is not supported
3052 *
3053 * \param endpoint Pointer to the endpoint in use
3054 * \param rdata Received message
3055 * \param req_type the type of request
3056 */
3057void ast_sip_report_req_no_support(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata,
3058 const char* req_type);
3059
3060/*!
3061 * \brief Send a security event notification for when a memory limit is hit.
3062 *
3063 * \param endpoint Pointer to the endpoint in use
3064 * \param rdata Received message
3065 */
3066void ast_sip_report_mem_limit(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata);
3067
3068int ast_sip_add_global_request_header(const char *name, const char *value, int replace);
3069int ast_sip_add_global_response_header(const char *name, const char *value, int replace);
3070
3071/*!
3072 * \brief Retrieves the value associated with the given key.
3073 *
3074 * \param ht the hash table/dictionary to search
3075 * \param key the key to find
3076 *
3077 * \retval the value associated with the key, NULL otherwise.
3078 */
3079void *ast_sip_dict_get(void *ht, const char *key);
3080
3081/*!
3082 * \brief Using the dictionary stored in mod_data array at a given id,
3083 * retrieve the value associated with the given key.
3084 *
3085 * \param mod_data a module data array
3086 * \param id the mod_data array index
3087 * \param key the key to find
3088 *
3089 * \retval the value associated with the key, NULL otherwise.
3090 */
3091#define ast_sip_mod_data_get(mod_data, id, key) \
3092 ast_sip_dict_get(mod_data[id], key)
3093
3094/*!
3095 * \brief Set the value for the given key.
3096 *
3097 * Note - if the hash table does not exist one is created first, the key/value
3098 * pair is set, and the hash table returned.
3099 *
3100 * \param pool the pool to allocate memory in
3101 * \param ht the hash table/dictionary in which to store the key/value pair
3102 * \param key the key to associate a value with
3103 * \param val the value to associate with a key
3104 *
3105 * \retval the given, or newly created, hash table.
3106 */
3107void *ast_sip_dict_set(pj_pool_t* pool, void *ht,
3108 const char *key, void *val);
3109
3110/*!
3111 * \brief Utilizing a mod_data array for a given id, set the value
3112 * associated with the given key.
3113 *
3114 * For a given structure's mod_data array set the element indexed by id to
3115 * be a dictionary containing the key/val pair.
3116 *
3117 * \param pool a memory allocation pool
3118 * \param mod_data a module data array
3119 * \param id the mod_data array index
3120 * \param key the key to find
3121 * \param val the value to associate with a key
3122 */
3123#define ast_sip_mod_data_set(pool, mod_data, id, key, val) \
3124 mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)
3125
3126/*!
3127 * \brief For every contact on an AOR call the given 'on_contact' handler.
3128 *
3129 * \param aor the aor containing a list of contacts to iterate
3130 * \param on_contact callback on each contact on an AOR. The object
3131 * received by the callback will be a ast_sip_contact_wrapper structure.
3132 * \param arg user data passed to handler
3133 * \retval 0 Success, non-zero on failure
3134 */
3135int ast_sip_for_each_contact(const struct ast_sip_aor *aor,
3136 ao2_callback_fn on_contact, void *arg);
3137
3138/*!
3139 * \brief Handler used to convert a contact to a string.
3140 *
3141 * \param object the ast_sip_aor_contact_pair containing a list of contacts to iterate and the contact
3142 * \param arg user data passed to handler
3143 * \param flags
3144 * \retval 0 Success, non-zero on failure
3145 */
3146int ast_sip_contact_to_str(void *object, void *arg, int flags);
3147
3148/*!
3149 * \brief For every aor in the comma separated aors string call the
3150 * given 'on_aor' handler.
3151 *
3152 * \param aors a comma separated list of aors
3153 * \param on_aor callback for each aor
3154 * \param arg user data passed to handler
3155 * \retval 0 Success, non-zero on failure
3156 */
3157int ast_sip_for_each_aor(const char *aors, ao2_callback_fn on_aor, void *arg);
3158
3159/*!
3160 * \brief For every auth in the array call the given 'on_auth' handler.
3161 *
3162 * \param array an array of auths
3163 * \param on_auth callback for each auth
3164 * \param arg user data passed to handler
3165 * \retval 0 Success, non-zero on failure
3166 */
3168 ao2_callback_fn on_auth, void *arg);
3169
3170/*!
3171 * \brief Converts the given auth type to a string
3172 *
3173 * \param type the auth type to convert
3174 * \retval a string representative of the auth type
3175 */
3177
3178/*!
3179 * \brief Converts an auths array to a string of comma separated values
3180 *
3181 * \param auths an auth array
3182 * \param buf the string buffer to write the object data
3183 * \retval 0 Success, non-zero on failure
3184 */
3185int ast_sip_auths_to_str(const struct ast_sip_auth_vector *auths, char **buf);
3186
3187/*!
3188 * \brief Checks an pjsip_auth_algorithm_type_vector to see if it contains an algorithm
3189 *
3190 * \param auth The auth object
3191 * \param algorithms The auth object's supported_algorithms_uac or supported_algorithms_uas
3192 * \param algorithm_type The algorithm_type to check
3193 *
3194 * \retval 1 The algorithm-type is in the vector
3195 * \retval 0 The algorithm-type is not in the vector
3196 */
3198 const struct pjsip_auth_algorithm_type_vector *algorithms,
3199 pjsip_auth_algorithm_type algorithm_type);
3200
3201/*!
3202 * \brief Get the plain text or digest password from an auth object
3203 *
3204 * \param auth The auth object
3205 * \param algorithm_type The algorithm type to retrieve the password for
3206 * \param cred_type [out]Pointer to an int to receive the credential type
3207 *
3208 * \note cred_type will contain one of the following values:
3209 * - PJSIP_CRED_DATA_DIGEST
3210 * - PJSIP_CRED_DATA_PLAIN_PASSWD
3211
3212 * If a password digest is available for the algorithm type it will
3213 * be returned, otherwise if a plain text password is available
3214 * that will be returned instead.
3215 *
3216 * \retval The plain text or digest password or NULL if not found for the algorithm type
3217 */
3218const char *ast_sip_auth_get_creds(const struct ast_sip_auth *auth,
3219 const pjsip_auth_algorithm_type algorithm_type, int *cred_type);
3220
3221/*!
3222 * \brief AMI variable container
3223 */
3224struct ast_sip_ami {
3225 /*! Manager session */
3226 struct mansession *s;
3227 /*! Manager message */
3228 const struct message *m;
3229 /*! Manager Action ID */
3230 const char *action_id;
3231 /*! user specified argument data */
3232 void *arg;
3233 /*! count of objects */
3234 int count;
3235};
3236
3237/*!
3238 * \brief Creates a string to store AMI event data in.
3239 *
3240 * \param event the event to set
3241 * \param ami AMI session and message container
3242 * \retval an initialized ast_str or NULL on error.
3243 */
3244struct ast_str *ast_sip_create_ami_event(const char *event,
3245 struct ast_sip_ami *ami);
3246
3247/*!
3248 * \brief An entity responsible formatting endpoint information.
3249 */
3251 /*!
3252 * \brief Callback used to format endpoint information over AMI.
3253 */
3254 int (*format_ami)(const struct ast_sip_endpoint *endpoint,
3255 struct ast_sip_ami *ami);
3257};
3258
3259/*!
3260 * \brief Register an endpoint formatter.
3261 *
3262 * \param obj the formatter to register
3263 */
3265
3266/*!
3267 * \brief Unregister an endpoint formatter.
3268 *
3269 * \param obj the formatter to unregister
3270 */
3272
3273/*!
3274 * \brief Converts a sorcery object to a string of object properties.
3275 *
3276 * \param obj the sorcery object to convert
3277 * \param buf the string buffer to write the object data
3278 * \retval 0 Success, non-zero on failure
3279 */
3280int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf);
3281
3282/*!
3283 * \brief Formats the endpoint and sends over AMI.
3284 *
3285 * \param endpoint the endpoint to format and send
3286 * \param ami AMI variable container
3287 * \param count the number of formatters operated on
3288 * \retval 0 Success, otherwise non-zero on error
3289 */
3291 struct ast_sip_ami *ami, int *count);
3292
3293/*!
3294 * \brief Formats the contact and sends over AMI.
3295 *
3296 * \param obj a pointer an ast_sip_contact_wrapper structure
3297 * \param arg a pointer to an ast_sip_ami structure
3298 * \param flags ignored
3299 * \retval 0 Success, otherwise non-zero on error
3300 */
3301int ast_sip_format_contact_ami(void *obj, void *arg, int flags);
3302
3303/*!
3304 * \brief Format auth details for AMI.
3305 *
3306 * \param auths an auth array
3307 * \param ami ami variable container
3308 * \retval 0 Success, non-zero on failure
3309 */
3310int ast_sip_format_auths_ami(const struct ast_sip_auth_vector *auths,
3311 struct ast_sip_ami *ami);
3312
3313/*!
3314 * \brief Retrieve the endpoint snapshot for an endpoint
3315 *
3316 * \param endpoint The endpoint whose snapshot is to be retrieved.
3317 * \retval The endpoint snapshot
3318 */
3320 const struct ast_sip_endpoint *endpoint);
3321
3322/*!
3323 * \brief Retrieve the device state for an endpoint.
3324 *
3325 * \param endpoint The endpoint whose state is to be retrieved.
3326 * \retval The device state.
3327 */
3328const char *ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint);
3329
3330/*!
3331 * \brief For every channel snapshot on an endpoint snapshot call the given
3332 * 'on_channel_snapshot' handler.
3333 *
3334 * \param endpoint_snapshot snapshot of an endpoint
3335 * \param on_channel_snapshot callback for each channel snapshot
3336 * \param arg user data passed to handler
3337 * \retval 0 Success, non-zero on failure
3338 */
3339int ast_sip_for_each_channel_snapshot(const struct ast_endpoint_snapshot *endpoint_snapshot,
3340 ao2_callback_fn on_channel_snapshot,
3341 void *arg);
3342
3343/*!
3344 * \brief For every channel snapshot on an endpoint all the given
3345 * 'on_channel_snapshot' handler.
3346 *
3347 * \param endpoint endpoint
3348 * \param on_channel_snapshot callback for each channel snapshot
3349 * \param arg user data passed to handler
3350 * \retval 0 Success, non-zero on failure
3351 */
3352int ast_sip_for_each_channel(const struct ast_sip_endpoint *endpoint,
3353 ao2_callback_fn on_channel_snapshot,
3354 void *arg);
3355
3357 /*! Top priority. Supplements with this priority are those that need to run before any others */
3359 /*! Channel creation priority.
3360 * chan_pjsip creates a channel at this priority. If your supplement depends on being run before
3361 * or after channel creation, then set your priority to be lower or higher than this value.
3362 */
3364 /*! Lowest priority. Supplements with this priority should be run after all other supplements */
3366};
3367
3368/*!
3369 * \brief A supplement to SIP message processing
3370 *
3371 * These can be registered by any module in order to add
3372 * processing to incoming and outgoing SIP out of dialog
3373 * requests and responses
3374 */
3375struct ast_sip_supplement {
3376 /*! Method on which to call the callbacks. If NULL, call on all methods */
3377 const char *method;
3378 /*! Priority for this supplement. Lower numbers are visited before higher numbers */
3380 /*!
3381 * \brief Called on incoming SIP request
3382 * This method can indicate a failure in processing in its return. If there
3383 * is a failure, it is required that this method sends a response to the request.
3384 * This method is always called from a SIP servant thread.
3385 *
3386 * \note
3387 * The following PJSIP methods will not work properly:
3388 * pjsip_rdata_get_dlg()
3389 * pjsip_rdata_get_tsx()
3390 * The reason is that the rdata passed into this function is a cloned rdata structure,
3391 * and its module data is not copied during the cloning operation.
3392 * If you need to get the dialog, you can get it via session->inv_session->dlg.
3393 *
3394 * \note
3395 * There is no guarantee that a channel will be present on the session when this is called.
3396 */
3397 int (*incoming_request)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata);
3398 /*!
3399 * \brief Called on an incoming SIP response
3400 * This method is always called from a SIP servant thread.
3401 *
3402 * \note
3403 * The following PJSIP methods will not work properly:
3404 * pjsip_rdata_get_dlg()
3405 * pjsip_rdata_get_tsx()
3406 * The reason is that the rdata passed into this function is a cloned rdata structure,
3407 * and its module data is not copied during the cloning operation.
3408 * If you need to get the dialog, you can get it via session->inv_session->dlg.
3409 *
3410 * \note
3411 * There is no guarantee that a channel will be present on the session when this is called.
3412 */
3413 void (*incoming_response)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata);
3414 /*!
3415 * \brief Called on an outgoing SIP request
3416 * This method is always called from a SIP servant thread.
3417 */
3418 void (*outgoing_request)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata);
3419 /*!
3420 * \brief Called on an outgoing SIP response
3421 * This method is always called from a SIP servant thread.
3422 */
3423 void (*outgoing_response)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata);
3424 /*! Next item in the list */
3426};
3427
3428/*!
3429 * \brief Register a supplement to SIP out of dialog processing
3430 *
3431 * This allows for someone to insert themselves in the processing of out
3432 * of dialog SIP requests and responses. This, for example could allow for
3433 * a module to set channel data based on headers in an incoming message.
3434 * Similarly, a module could reject an incoming request if desired.
3435 *
3436 * \param supplement The supplement to register
3437 */
3438void ast_sip_register_supplement(struct ast_sip_supplement *supplement);
3439
3440/*!
3441 * \brief Unregister a an supplement to SIP out of dialog processing
3442 *
3443 * \param supplement The supplement to unregister
3444 */
3445void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement);
3446
3447/*!
3448 * \brief Retrieve the global MWI taskprocessor high water alert trigger level.
3449 *
3450 * \since 13.12.0
3451 *
3452 * \retval the system MWI taskprocessor high water alert trigger level
3453 */
3454unsigned int ast_sip_get_mwi_tps_queue_high(void);
3455
3456/*!
3457 * \brief Retrieve the global MWI taskprocessor low water clear alert level.
3458 *
3459 * \since 13.12.0
3460 *
3461 * \retval the system MWI taskprocessor low water clear alert level
3462 */
3464
3465/*!
3466 * \brief Retrieve the global setting 'disable sending unsolicited mwi on startup'.
3467 * \since 13.12.0
3468 *
3469 * \retval non zero if disable.
3470 */
3472
3473/*!
3474 * \brief Retrieve the global setting 'allow_sending_180_after_183'.
3475 *
3476 * \retval non zero if disable.
3477 */
3479
3480/*!
3481 * \brief Retrieve the global setting 'use_callerid_contact'.
3482 * \since 13.24.0
3483 *
3484 * \retval non zero if CALLERID(num) is to be used as the default username in the contact
3485 */
3486unsigned int ast_sip_get_use_callerid_contact(void);
3487
3488/*!
3489 * \brief Retrieve the global setting 'norefersub'.
3490 *
3491 * \retval non zero if norefersub is to be sent in "Supported" Headers
3492 */
3493unsigned int ast_sip_get_norefersub(void);
3494
3495/*!
3496 * \brief Retrieve the global setting 'ignore_uri_user_options'.
3497 * \since 13.12.0
3498 *
3499 * \retval non zero if ignore the user field options.
3500 */
3501unsigned int ast_sip_get_ignore_uri_user_options(void);
3502
3503/*!
3504 * \brief Retrieve the global setting 'send_contact_status_on_update_registration'.
3505 * \since 16.2.0
3506 *
3507 * \retval non zero if need to send AMI ContactStatus event when a contact is updated.
3508 */
3510
3511
3512/*!
3513 * \brief Truncate the URI user field options string if enabled.
3514 * \since 13.12.0
3515 *
3516 * \param str URI user field string to truncate if enabled
3517 *
3518 * \details
3519 * We need to be able to handle URI's looking like
3520 * "sip:1235557890;phone-context=national@x.x.x.x;user=phone"
3521 *
3522 * Where the URI user field is:
3523 * "1235557890;phone-context=national"
3524 *
3525 * When truncated the string will become:
3526 * "1235557890"
3527 */
3528#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str) \
3529 do { \
3530 char *__semi = strchr((str), ';'); \
3531 if (__semi && ast_sip_get_ignore_uri_user_options()) { \
3532 *__semi = '\0'; \
3533 } \
3534 } while (0)
3535
3536/*!
3537 * \brief Retrieve the system debug setting (yes|no|host).
3538 *
3539 * \note returned string needs to be de-allocated by caller.
3540 *
3541 * \retval the system debug setting.
3542 */
3543char *ast_sip_get_debug(void);
3544
3545/*!
3546 * \brief Retrieve the global regcontext setting.
3547 *
3548 * \since 13.8.0
3549 *
3550 * \note returned string needs to be de-allocated by caller.
3551 *
3552 * \retval the global regcontext setting
3553 */
3554char *ast_sip_get_regcontext(void);
3555
3556/*!
3557 * \brief Retrieve the global endpoint_identifier_order setting.
3558 *
3559 * Specifies the order by which endpoint identifiers should be regarded.
3560 *
3561 * \retval the global endpoint_identifier_order value
3562 */
3564
3565/*!
3566 * \brief Retrieve the default voicemail extension.
3567 * \since 13.9.0
3568 *
3569 * \note returned string needs to be de-allocated by caller.
3570 *
3571 * \retval the default voicemail extension
3572 */
3574
3575/*!
3576 * \brief Retrieve the global default realm.
3577 *
3578 * This is the value placed in outbound challenges' realm if there
3579 * is no better option (such as an auth-configured realm).
3580 *
3581 * \param[out] realm The default realm
3582 * \param size The buffer size of realm
3583 */
3584void ast_sip_get_default_realm(char *realm, size_t size);
3585
3586/*!
3587 * \brief Retrieve the global auth algorithms for UAS.
3588 *
3589 * \param[out] default_auth_algorithms_uas The default algorithms
3590 * \param size The buffer size of default_auth_algorithms_uas
3591 */
3592void ast_sip_get_default_auth_algorithms_uas(char *default_auth_algorithms_uas, size_t size);
3593
3594/*!
3595 * \brief Retrieve the global auth algorithms for UAC.
3596 *
3597 * \param[out] default_auth_algorithms_uac The default algorithms
3598 * \param size The buffer size of default_auth_algorithms_uac
3599 */
3600void ast_sip_get_default_auth_algorithms_uac(char *default_auth_algorithms_uac, size_t size);
3601
3602/*!
3603 * \brief Retrieve the global default from user.
3604 *
3605 * This is the value placed in outbound requests' From header if there
3606 * is no better option (such as an endpoint-configured from_user or
3607 * caller ID number).
3608 *
3609 * \param[out] from_user The default from user
3610 * \param size The buffer size of from_user
3611 */
3612void ast_sip_get_default_from_user(char *from_user, size_t size);
3613
3614/*!
3615 * \brief Retrieve the system keep alive interval setting.
3616 *
3617 * \retval the keep alive interval.
3618 */
3619unsigned int ast_sip_get_keep_alive_interval(void);
3620
3621/*!
3622 * \brief Retrieve the system contact expiration check interval setting.
3623 *
3624 * \retval the contact expiration check interval.
3625 */
3627
3628/*!
3629 * \brief Retrieve the system setting 'disable multi domain'.
3630 * \since 13.9.0
3631 *
3632 * \retval non zero if disable multi domain.
3633 */
3634unsigned int ast_sip_get_disable_multi_domain(void);
3635
3636/*!
3637 * \brief Retrieve the system max initial qualify time.
3638 *
3639 * \retval the maximum initial qualify time.
3640 */
3641unsigned int ast_sip_get_max_initial_qualify_time(void);
3642
3643/*!
3644 * \brief translate ast_sip_contact_status_type to character string.
3645 *
3646 * \retval the character string equivalent.
3647 */
3648
3651
3652/*!
3653 * \brief Set a request to use the next value in the list of resolved addresses.
3654 *
3655 * \param tdata the tx data from the original request
3656 * \retval 0 No more addresses to try
3657 * \retval 1 The request was successfully re-intialized
3658 */
3659int ast_sip_failover_request(pjsip_tx_data *tdata);
3660
3661/*!
3662 * \brief Retrieve the local host address in IP form
3663 *
3664 * \param af The address family to retrieve
3665 * \param addr A place to store the local host address
3666 *
3667 * \retval 0 success
3668 * \retval -1 failure
3669 *
3670 * \since 13.6.0
3671 */
3672int ast_sip_get_host_ip(int af, pj_sockaddr *addr);
3673
3674/*!
3675 * \brief Retrieve the local host address in string form
3676 *
3677 * \param af The address family to retrieve
3678 *
3679 * \retval non-NULL success
3680 * \retval NULL failure
3681 *
3682 * \since 13.6.0
3683 *
3684 * \note An empty string may be returned if the address family is valid but no local address exists
3685 */
3686const char *ast_sip_get_host_ip_string(int af);
3687
3688/*!
3689 * \brief Return the size of the SIP taskpool's task queue
3690 * \since 13.7.0
3691 */
3693
3694/*!
3695 * \brief Retrieve the SIP taskpool object
3696 */
3697struct ast_taskpool *ast_sip_taskpool(void);
3698
3699/*!
3700 * \brief Retrieve transport state
3701 * \since 13.7.1
3702 *
3703 * \param transport_id
3704 * \retval transport_state
3705 *
3706 * \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
3707 */
3708struct ast_sip_transport_state *ast_sip_get_transport_state(const char *transport_id);
3709
3710/*!
3711 * \brief Return the SIP URI of the Contact header
3712 *
3713 * \param tdata
3714 * \retval Pointer to SIP URI of Contact
3715 * \retval NULL if Contact header not found or not a SIP(S) URI
3716 *
3717 * \note Do not free the returned object.
3718 */
3719pjsip_sip_uri *ast_sip_get_contact_sip_uri(pjsip_tx_data *tdata);
3720
3721/*!
3722 * \brief Returns the transport state currently in use based on request transport details
3723 *
3724 * \param details
3725 * \retval transport_state
3726 *
3727 * \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
3728 */
3730
3731/*!
3732 * \brief Sets request transport details based on tdata
3733 *
3734 * \param details pre-allocated request transport details to set
3735 * \param tdata
3736 * \param use_ipv6 if non-zero, ipv6 transports will be considered
3737 * \retval 0 success
3738 * \retval -1 failure
3739 */
3740int ast_sip_set_request_transport_details(struct ast_sip_request_transport_details *details, pjsip_tx_data *tdata, int use_ipv6);
3741
3742/*!
3743 * \brief Replace domain and port of SIP URI to point to (external) signaling address of this Asterisk instance
3744 *
3745 * \param uri
3746 * \param tdata
3747 *
3748 * \retval 0 success
3749 * \retval -1 failure
3750 *
3751 * \note Uses domain and port in Contact header if it exists, otherwise the local URI of the dialog is used if the
3752 * message is sent within the context of a dialog. Further, NAT settings are considered - i.e. if the target
3753 * is not in the localnet, the external_signaling_address and port are used.
3754 */
3755int ast_sip_rewrite_uri_to_local(pjsip_sip_uri *uri, pjsip_tx_data *tdata);
3756
3757/*!
3758 * \brief Retrieves all transport states
3759 * \since 13.7.1
3760 *
3761 * \retval ao2_container
3762 *
3763 * \note ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object
3764 */
3766
3767/*!
3768 * \brief Sets pjsip_tpselector from ast_sip_transport
3769 * \since 13.8.0
3770 *
3771 * \param transport The transport to be used
3772 * \param selector The selector to be populated
3773 * \retval 0 success
3774 * \retval -1 failure
3775 *
3776 * \note The transport selector must be unreffed using ast_sip_tpselector_unref
3777 */
3778int ast_sip_set_tpselector_from_transport(const struct ast_sip_transport *transport, pjsip_tpselector *selector);
3779
3780/*!
3781 * \brief Sets pjsip_tpselector from ast_sip_transport
3782 * \since 13.8.0
3783 *
3784 * \param transport_name The name of the transport to be used
3785 * \param selector The selector to be populated
3786 * \retval 0 success
3787 * \retval -1 failure
3788 *
3789 * \note The transport selector must be unreffed using ast_sip_tpselector_unref
3790 */
3791int ast_sip_set_tpselector_from_transport_name(const char *transport_name, pjsip_tpselector *selector);
3792
3793/*!
3794 * \brief Unreference a pjsip_tpselector
3795 * \since 17.0.0
3796 *
3797 * \param selector The selector to be unreffed
3798 */
3799void ast_sip_tpselector_unref(pjsip_tpselector *selector);
3800
3801/*!
3802 * \brief Sets the PJSIP transport on a child transport
3803 * \since 17.0.0
3804 *
3805 * \param transport_name The name of the transport to be updated
3806 * \param transport The PJSIP transport
3807 * \retval 0 success
3808 * \retval -1 failure
3809 */
3810int ast_sip_transport_state_set_transport(const char *transport_name, pjsip_transport *transport);
3811
3812/*!
3813 * \brief Sets the P-Preferred-Identity on a child transport
3814 * \since 17.0.0
3815 *
3816 * \param transport_name The name of the transport to be set on
3817 * \param identity The P-Preferred-Identity to use on requests on this transport
3818 * \retval 0 success
3819 * \retval -1 failure
3820 */
3821int ast_sip_transport_state_set_preferred_identity(const char *transport_name, const char *identity);
3822
3823/*!
3824 * \brief Sets the service routes on a child transport
3825 * \since 17.0.0
3826 *
3827 * \param transport_name The name of the transport to be set on
3828 * \param service_routes A vector of service routes
3829 * \retval 0 success
3830 * \retval -1 failure
3831 *
3832 * \note This assumes ownership of the service routes in both success and failure scenarios
3833 */
3834int ast_sip_transport_state_set_service_routes(const char *transport_name, struct ast_sip_service_route_vector *service_routes);
3835
3836/*!
3837 * \brief Apply the configuration for a transport to an outgoing message
3838 * \since 17.0.0
3839 *
3840 * \param transport_name The name of the transport to apply configuration from
3841 * \param tdata The SIP message
3842 */
3843void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata);
3844
3845/*!
3846 * \brief Allocate a vector of service routes
3847 * \since 17.0.0
3848 *
3849 * \retval non-NULL success
3850 * \retval NULL failure
3851 */
3853
3854/*!
3855 * \brief Destroy a vector of service routes
3856 * \since 17.0.0
3857 *
3858 * \param service_routes A vector of service routes
3859 */
3861
3862/*!
3863 * \brief Set the ID for a connected line update
3864 *
3865 * \retval -1 on failure, 0 on success
3866 */
3867int ast_sip_set_id_connected_line(struct pjsip_rx_data *rdata, struct ast_party_id *id);
3868
3869/*!
3870 * \brief Set the ID from an INVITE
3871 *
3872 * \param rdata
3873 * \param id ID structure to fill
3874 * \param default_id Default ID structure with data to use (for non-trusted endpoints)
3875 * \param trust_inbound Whether or not the endpoint is trusted (controls whether PAI or RPID can be used)
3876 *
3877 * \retval -1 on failure, 0 on success
3878 */
3879int 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);
3880
3881/*!
3882 * \brief Set name and number information on an identity header.
3883 *
3884 * \param pool Memory pool to use for string duplication
3885 * \param id_hdr A From, P-Asserted-Identity, or Remote-Party-ID header to modify
3886 * \param id The identity information to apply to the header
3887 */
3888void ast_sip_modify_id_header(pj_pool_t *pool, pjsip_fromto_hdr *id_hdr,
3889 const struct ast_party_id *id);
3890
3891/*!
3892 * \brief Retrieves an endpoint and URI from the "to" string.
3893 *
3894 * This URI is used as the Request URI.
3895 *
3896 * Expects the given 'to' to be in one of the following formats:
3897 * Why we allow so many is a mystery.
3898 *
3899 * Basic:
3900 *
3901 * endpoint : We'll get URI from the default aor/contact
3902 * endpoint/aor : We'll get the URI from the specific aor/contact
3903 * endpoint@domain : We toss the domain part and just use the endpoint
3904 *
3905 * These all use the endpoint and specified URI:
3906 * \verbatim
3907 endpoint/<sip[s]:host>
3908 endpoint/<sip[s]:user@host>
3909 endpoint/"Bob" <sip[s]:host>
3910 endpoint/"Bob" <sip[s]:user@host>
3911 endpoint/sip[s]:host
3912 endpoint/sip[s]:user@host
3913 endpoint/host
3914 endpoint/user@host
3915 \endverbatim
3916 *
3917 * These all use the default endpoint and specified URI:
3918 * \verbatim
3919 <sip[s]:host>
3920 <sip[s]:user@host>
3921 "Bob" <sip[s]:host>
3922 "Bob" <sip[s]:user@host>
3923 sip[s]:host
3924 sip[s]:user@host
3925 \endverbatim
3926 *
3927 * These use the default endpoint and specified host:
3928 * \verbatim
3929 host
3930 user@host
3931 \endverbatim
3932 *
3933 * This form is similar to a dialstring:
3934 * \verbatim
3935 PJSIP/user@endpoint
3936 \endverbatim
3937 *
3938 * In this case, the user will be added to the endpoint contact's URI.
3939 * If the contact URI already has a user, it will be replaced.
3940 *
3941 * The ones that have the sip[s] scheme are the easiest to parse.
3942 * The rest all have some issue.
3943 *
3944 * endpoint vs host : We have to test for endpoint first
3945 * endpoint/aor vs endpoint/host : We have to test for aor first
3946 * What if there's an aor with the same
3947 * name as the host?
3948 * endpoint@domain vs user@host : We have to test for endpoint first.
3949 * What if there's an endpoint with the
3950 * same name as the user?
3951 *
3952 * \param to 'To' field with possible endpoint
3953 * \param get_default_outbound If nonzero, try to retrieve the default
3954 * outbound endpoint if no endpoint was found.
3955 * Otherwise, return NULL if no endpoint was found.
3956 * \param uri Pointer to a char* which will be set to the URI.
3957 * Always must be ast_free'd by the caller - even if the return value is NULL!
3958 *
3959 * \note The logic below could probably be condensed but then it wouldn't be
3960 * as clear.
3961 */
3962struct ast_sip_endpoint *ast_sip_get_endpoint(const char *to, int get_default_outbound, char **uri);
3963
3964/*!
3965 * \brief Replace the To URI in the tdata with the supplied one
3966 *
3967 * \param tdata the outbound message data structure
3968 * \param to URI to replace the To URI with. Must be a valid SIP URI.
3969 *
3970 * \retval 0: success, -1: failure
3971 */
3972int ast_sip_update_to_uri(pjsip_tx_data *tdata, const char *to);
3973
3974/*!
3975 * \brief Overwrite fields in the outbound 'From' header
3976 *
3977 * The outbound 'From' header is created/added in ast_sip_create_request with
3978 * default data. If available that data may be info specified in the 'from_user'
3979 * and 'from_domain' options found on the endpoint. That information will be
3980 * overwritten with data in the given 'from' parameter.
3981 *
3982 * \param tdata the outbound message data structure
3983 * \param from info to copy into the header.
3984 * Can be either a SIP URI, or in the format user[@domain]
3985 *
3986 * \retval 0: success, -1: failure
3987 */
3988int ast_sip_update_from(pjsip_tx_data *tdata, char *from);
3989
3990/*!
3991 * \brief Retrieve the unidentified request security event thresholds
3992 * \since 13.8.0
3993 *
3994 * \param count The maximum number of unidentified requests per source ip to accumulate before emitting a security event
3995 * \param period The period in seconds over which to accumulate unidentified requests
3996 * \param prune_interval The interval in seconds at which expired entries will be pruned
3997 */
3998void ast_sip_get_unidentified_request_thresholds(unsigned int *count, unsigned int *period,
3999 unsigned int *prune_interval);
4000
4001/*!
4002 * \brief Get the transport name from an endpoint or request uri
4003 * \since 13.15.0
4004 *
4005 * \param endpoint
4006 * \param sip_uri
4007 * \param buf Buffer to receive transport name
4008 * \param buf_len Buffer length
4009 *
4010 * \retval 0 Success
4011 * \retval -1 Failure
4012 *
4013 * \note
4014 * If endpoint->transport is not NULL, it is returned in buf.
4015 * Otherwise if sip_uri has an 'x-ast-txp' parameter AND the sip_uri host is
4016 * an ip4 or ip6 address, its value is returned,
4017 */
4018int ast_sip_get_transport_name(const struct ast_sip_endpoint *endpoint,
4019 pjsip_sip_uri *sip_uri, char *buf, size_t buf_len);
4020
4021/*!
4022 * \brief Sets pjsip_tpselector from an endpoint or uri
4023 * \since 13.15.0
4024 *
4025 * \param endpoint If endpoint->transport is set, it's used
4026 * \param sip_uri If sip_uri contains a x-ast-txp parameter, it's used
4027 * \param selector The selector to be populated
4028 *
4029 * \retval 0 success
4030 * \retval -1 failure
4031 */
4033 pjsip_sip_uri *sip_uri, pjsip_tpselector *selector);
4034
4035/*!
4036 * \brief Set the transport on a dialog
4037 * \since 13.15.0
4038 *
4039 * \param endpoint
4040 * \param dlg
4041 * \param selector (optional)
4042 *
4043 * \note
4044 * This API calls ast_sip_get_transport_name(endpoint, dlg->target) and if the result is
4045 * non-NULL, calls pjsip_dlg_set_transport. If 'selector' is non-NULL, it is updated with
4046 * the selector used.
4047 *
4048 * \note
4049 * It is the responsibility of the caller to unref the passed in selector if one is provided.
4050 */
4051int ast_sip_dlg_set_transport(const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg,
4052 pjsip_tpselector *selector);
4053
4054/*!
4055 * \brief Convert the DTMF mode enum value into a string
4056 * \since 13.18.0
4057 *
4058 * \param dtmf the dtmf mode
4059 * \param buf Buffer to receive dtmf mode string
4060 * \param buf_len Buffer length
4061 *
4062 * \retval 0 Success
4063 * \retval -1 Failure
4064 *
4065 */
4067 char *buf, size_t buf_len);
4068
4069/*!
4070 * \brief Convert the DTMF mode name into an enum
4071 * \since 13.18.0
4072 *
4073 * \param dtmf_mode dtmf mode as a string
4074 *
4075 * \retval >= 0 The enum value
4076 * \retval -1 Failure
4077 *
4078 */
4079int ast_sip_str_to_dtmf(const char *dtmf_mode);
4080
4081/*!
4082 * \brief Convert the call codec preference flags to a string
4083 * \since 18.0.0
4084 *
4085 * \param pref the call codec preference setting
4086 *
4087 * \returns a constant string with either the setting value or 'unknown'
4088 * \note Don't try to free the string!
4089 *
4090 */
4091const char *ast_sip_call_codec_pref_to_str(struct ast_flags pref);
4092
4093/*!
4094 * \brief Convert a call codec preference string to preference flags
4095 * \since 18.0.0
4096 *
4097 * \param pref A pointer to an ast_flags structure to receive the preference flags
4098 * \param pref_str The call codec preference setting string
4099 * \param is_outgoing Is for outgoing calls?
4100 *
4101 * \retval 0 The string was parsed successfully
4102 * \retval -1 The string option was invalid
4103 */
4104int ast_sip_call_codec_str_to_pref(struct ast_flags *pref, const char *pref_str, int is_outgoing);
4105
4106/*!
4107 * \brief Transport shutdown monitor callback.
4108 * \since 13.18.0
4109 *
4110 * \param data User data to know what to do when transport shuts down.
4111 *
4112 * \note The callback does not need to care that data is an ao2 object.
4113 */
4114typedef void (*ast_transport_monitor_shutdown_cb)(void *data);
4115
4116/*!
4117 * \brief Transport shutdown monitor data matcher
4118 * \since 13.20.0
4119 *
4120 * \param a User data to compare.
4121 * \param b User data to compare.
4122 *
4123 * \retval 1 The data objects match
4124 * \retval 0 The data objects don't match
4125 */
4126typedef int (*ast_transport_monitor_data_matcher)(void *a, void *b);
4127
4129 /*! \brief Successfully registered the transport monitor */
4131 /*! \brief Replaced the already existing transport monitor with new one. */
4133 /*!
4134 * \brief Transport not found to monitor.
4135 * \note Transport is either already shutdown or is not reliable.
4136 */
4138 /*! \brief Error while registering transport monitor. */
4140};
4141
4142/*!
4143 * \brief Register a reliable transport shutdown monitor callback.
4144 * \deprecated Replaced with ast_sip_transport_monitor_register_key().
4145 * \since 13.20.0
4146 *
4147 * \param transport Transport to monitor for shutdown.
4148 * \param cb Who to call when transport is shutdown.
4149 * \param ao2_data Data to pass with the callback.
4150 *
4151 * \note The data object passed will have its reference count automatically
4152 * incremented by this call and automatically decremented after the callback
4153 * runs or when the callback is unregistered.
4154 *
4155 * There is no checking for duplicate registrations.
4156 *
4157 * \return enum ast_transport_monitor_reg
4158 */
4160 ast_transport_monitor_shutdown_cb cb, void *ao2_data);
4161
4162/*!
4163 * \brief Register a reliable transport shutdown monitor callback.
4164 *
4165 * \param transport_key Key for the transport to monitor for shutdown.
4166 * Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
4167 * \param cb Who to call when transport is shutdown.
4168 * \param ao2_data Data to pass with the callback.
4169 *
4170 * \note The data object passed will have its reference count automatically
4171 * incremented by this call and automatically decremented after the callback
4172 * runs or when the callback is unregistered.
4173 *
4174 * There is no checking for duplicate registrations.
4175 *
4176 * \return enum ast_transport_monitor_reg
4177 */
4179 const char *transport_key, ast_transport_monitor_shutdown_cb cb,
4180 void *ao2_data);
4181
4182/*!
4183 * \brief Register a reliable transport shutdown monitor callback replacing any duplicate.
4184 * \deprecated Replaced with ast_sip_transport_monitor_register_replace_key().
4185 * \since 13.26.0
4186 * \since 16.3.0
4187 *
4188 * \param transport Transport to monitor for shutdown.
4189 * \param cb Who to call when transport is shutdown.
4190 * \param ao2_data Data to pass with the callback.
4191 * \param matches Matcher function that returns true if data matches a previously
4192 * registered data object
4193 *
4194 * \note The data object passed will have its reference count automatically
4195 * incremented by this call and automatically decremented after the callback
4196 * runs or when the callback is unregistered.
4197 *
4198 * This function checks for duplicates, and overwrites/replaces the old monitor
4199 * with the given one.
4200 *
4201 * \return enum ast_transport_monitor_reg
4202 */
4205
4206/*!
4207 * \brief Register a reliable transport shutdown monitor callback replacing any duplicate.
4208 *
4209 * \param transport_key Key for the transport to monitor for shutdown.
4210 * Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
4211 * \param cb Who to call when transport is shutdown.
4212 * \param ao2_data Data to pass with the callback.
4213 * \param matches Matcher function that returns true if data matches a previously
4214 * registered data object
4215 *
4216 * \note The data object passed will have its reference count automatically
4217 * incremented by this call and automatically decremented after the callback
4218 * runs or when the callback is unregistered.
4219 *
4220 * This function checks for duplicates, and overwrites/replaces the old monitor
4221 * with the given one.
4222 *
4223 * \return enum ast_transport_monitor_reg
4224 */
4226 const char *transport_key, ast_transport_monitor_shutdown_cb cb,
4227 void *ao2_data, ast_transport_monitor_data_matcher matches);
4228
4229/*!
4230 * \brief Unregister a reliable transport shutdown monitor
4231 * \deprecated Replaced with ast_sip_transport_monitor_unregister_key().
4232 * \since 13.20.0
4233 *
4234 * \param transport Transport to monitor for shutdown.
4235 * \param cb The callback that was used for the original register.
4236 * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
4237 * If NULL, all monitors with the provided callback are unregistered.
4238 * \param matches Matcher function that returns true if data matches the previously
4239 * registered data object. If NULL, a simple pointer comparison is done.
4240 *
4241 * \note The data object passed into the original register will have its reference count
4242 * automatically decremented.
4243 */
4246
4247/*!
4248 * \brief Unregister a reliable transport shutdown monitor
4249 *
4250 * \param transport_key Key for the transport to monitor for shutdown.
4251 * Create the key with AST_SIP_MAKE_REMOTE_IPADDR_PORT_STR.
4252 * \param cb The callback that was used for the original register.
4253 * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
4254 * If NULL, all monitors with the provided callback are unregistered.
4255 * \param matches Matcher function that returns true if data matches the previously
4256 * registered data object. If NULL, a simple pointer comparison is done.
4257 *
4258 * \note The data object passed into the original register will have its reference count
4259 * automatically decremented.
4260 */
4261void ast_sip_transport_monitor_unregister_key(const char *transport_key,
4263
4264/*!
4265 * \brief Unregister a transport shutdown monitor from all reliable transports
4266 * \since 13.20.0
4267 *
4268 * \param cb The callback that was used for the original register.
4269 * \param data Data to pass to the matcher. May be NULL and does NOT need to be an ao2 object.
4270 * If NULL, all monitors with the provided callback are unregistered.
4271 * \param matches Matcher function that returns true if ao2_data matches the previously
4272 * registered data object. If NULL, a simple pointer comparison is done.
4273 *
4274 * \note The data object passed into the original register will have its reference count
4275 * automatically decremented.
4276 */
4278 void *data, ast_transport_monitor_data_matcher matches);
4279
4280/*! Transport state notification registration element. */
4282 /*! PJPROJECT transport state notification callback */
4283 pjsip_tp_state_callback cb;
4285};
4286
4287/*!
4288 * \brief Register a transport state notification callback element.
4289 * \since 13.18.0
4290 *
4291 * \param element What we are registering.
4292 */
4294
4295/*!
4296 * \brief Unregister a transport state notification callback element.
4297 * \since 13.18.0
4298 *
4299 * \param element What we are unregistering.
4300 */
4302
4303/*!
4304 * \brief Check whether a pjsip_uri is SIP/SIPS or not
4305 * \since 16.28.0
4306 *
4307 * \param uri The pjsip_uri to check
4308 *
4309 * \retval 1 if true
4310 * \retval 0 if false
4311 */
4312int ast_sip_is_uri_sip_sips(pjsip_uri *uri);
4313
4314/*!
4315 * \brief Check whether a pjsip_uri is allowed or not
4316 * \since 16.28.0
4317 *
4318 * \param uri The pjsip_uri to check
4319 *
4320 * \retval 1 if allowed
4321 * \retval 0 if not allowed
4322 */
4323int ast_sip_is_allowed_uri(pjsip_uri *uri);
4324
4325/*!
4326 * \brief Get the user portion of the pjsip_uri
4327 * \since 16.28.0
4328 *
4329 * \param uri The pjsip_uri to get the user from
4330 *
4331 * \note This function will check what kind of URI it receives and return
4332 * the user based off of that
4333 *
4334 * \return User string or empty string if not present
4335 */
4336const pj_str_t *ast_sip_pjsip_uri_get_username(pjsip_uri *uri);
4337
4338/*!
4339 * \brief Get the host portion of the pjsip_uri
4340 * \since 16.28.0
4341 *
4342 * \param uri The pjsip_uri to get the host from
4343 *
4344 * \note This function will check what kind of URI it receives and return
4345 * the host based off of that
4346 *
4347 * \return Host string or empty string if not present
4348 */
4349const pj_str_t *ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri);
4350
4351/*!
4352 * \brief Find an 'other' SIP/SIPS URI parameter by name
4353 * \since 16.28.0
4354 *
4355 * A convenience function to find a named parameter from a SIP/SIPS URI. This
4356 * function will not find the following standard SIP/SIPS URI parameters which
4357 * are stored separately by PJSIP:
4358 *
4359 * \li `user`
4360 * \li `method`
4361 * \li `transport`
4362 * \li `ttl`
4363 * \li `lr`
4364 * \li `maddr`
4365 *
4366 * \param uri The pjsip_uri to get the parameter from
4367 * \param param_str The name of the parameter to find
4368 *
4369 * \note This function will check what kind of URI it receives and return
4370 * the parameter based off of that
4371 *
4372 * \return Find parameter or NULL if not present
4373 */
4374struct pjsip_param *ast_sip_pjsip_uri_get_other_param(pjsip_uri *uri, const pj_str_t *param_str);
4375
4376/*!
4377 * \brief Retrieve the system setting 'all_codecs_on_empty_reinvite'.
4378 *
4379 * \retval non zero if we should return all codecs on empty re-INVITE
4380 */
4382
4383
4384/*!
4385 * \brief Convert SIP hangup causes to Asterisk hangup causes
4386 *
4387 * \param cause SIP cause
4388 *
4389 * \retval matched cause code from causes.h
4390 */
4391const int ast_sip_hangup_sip2cause(int cause);
4392
4393/*!
4394 * \brief Convert name to SIP response code
4395 *
4396 * \param name SIP response code name matching one of the
4397 * enum names defined in "enum pjsip_status_code"
4398 * defined in sip_msg.h. May be specified with or
4399 * without the PJSIP_SC_ prefix.
4400 *
4401 * \retval SIP response code
4402 * \retval -1 if matching code not found
4403 */
4404int ast_sip_str2rc(const char *name);
4405
4406/*!
4407 * \brief Parses a string representing a q_value to a float.
4408 *
4409 * Valid q values must be in the range from 0.0 to 1.0 inclusively.
4410 *
4411 * \param q_value String representing a floating point value
4412 *
4413 * \retval The parsed qvalue or -1.0 on failure.
4414 */
4415float ast_sip_parse_qvalue(const char *q_value);
4416
4417#endif /* _RES_PJSIP_H */
static struct aco_type agent_type
jack_status_t status
Definition app_jack.c:149
const char * str
Definition app_jack.c:150
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
Definition astobj2.h:1226
static const char type[]
unsigned long long ast_group_t
Definition channel.h:215
#define AST_MAX_CONTEXT
Definition channel.h:135
static struct ast_channel * callback(struct ast_channelstorage_instance *driver, ao2_callback_data_fn *cb_fn, void *arg, void *data, int ao2_flags, int rdlock)
#define attribute_sentinel
Definition compiler.h:65
char buf[BUFSIZE]
Definition eagi_proxy.c:66
ast_endpoint_state
Valid states for an endpoint.
Definition endpoints.h:51
char * address
Definition f2c.h:59
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)
static int array(struct ast_channel *chan, const char *cmd, char *var, const char *value)
struct ast_sip_endpoint * ast_sip_dialog_get_endpoint(pjsip_dialog *dlg)
Get the endpoint associated with this dialog.
int(* ast_sip_task)(void *user_data)
Definition res_pjsip.h:2001
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.
struct ast_taskprocessor * ast_sip_get_distributor_serializer(pjsip_rx_data *rdata)
Determine the distributor serializer for the SIP message.
int __ast_sip_push_task_synchronous(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Push a task to SIP servants and wait for it to complete.
Definition res_pjsip.c:2156
int __ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Push a task to SIP servants and wait for it to complete.
Definition res_pjsip.c:2146
ast_sip_scheduler_task_flags
Task flags for the res_pjsip scheduler.
Definition res_pjsip.h:2208
int ast_sip_sched_task_cancel_by_name(const char *name)
Cancels the next invocation of a task by name.
struct ast_taskprocessor * ast_sip_create_serializer(const char *name)
Create a new serializer for SIP tasks.
Definition res_pjsip.c:2088
struct ast_taskprocessor * ast_sip_create_serializer_group(const char *name, struct ast_serializer_shutdown_group *shutdown_group)
Create a new serializer for SIP tasks.
Definition res_pjsip.c:2083
struct ast_sip_sched_task * ast_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 taskpool.
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.
int ast_sip_sched_task_cancel(struct ast_sip_sched_task *schtd)
Cancels the next invocation of a task.
int ast_sip_sched_is_task_running(struct ast_sip_sched_task *schtd)
Checks if the task is currently running.
int ast_sip_thread_is_servant(void)
Determine if the current thread is a SIP servant thread.
Definition res_pjsip.c:2281
int ast_sip_sched_task_get_name(struct ast_sip_sched_task *schtd, char *name, size_t maxlen)
Gets the task name.
int ast_sip_sched_task_get_next_run(struct ast_sip_sched_task *schtd)
Gets the number of milliseconds until the next invocation.
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.
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.
int __ast_sip_push_task_wait_serializer(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Push a task to the serializer and wait for it to complete.
Definition res_pjsip.c:2162
int ast_sip_sched_task_get_next_run_by_name(const char *name)
Gets the number of milliseconds until the next invocation.
int __ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data, const char *file, int line, const char *function)
Pushes a task to SIP servants.
Definition res_pjsip.c:2096
int ast_sip_sched_is_task_running_by_name(const char *name)
Checks if the task is currently running.
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.
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.
@ AST_SIP_SCHED_TASK_ONESHOT
Definition res_pjsip.h:2231
@ AST_SIP_SCHED_TASK_DELAY
The next invocation of the task is at last finish + interval.
Definition res_pjsip.h:2263
@ AST_SIP_SCHED_TASK_TRACK
The scheduled task's events are tracked in the debug log.
Definition res_pjsip.h:2270
@ AST_SIP_SCHED_TASK_DATA_NOT_AO2
Definition res_pjsip.h:2236
@ AST_SIP_SCHED_TASK_DEFAULTS
Definition res_pjsip.h:2212
@ AST_SIP_SCHED_TASK_FIXED
Definition res_pjsip.h:2219
@ AST_SIP_SCHED_TASK_PERIODIC
The task is scheduled at multiples of interval.
Definition res_pjsip.h:2258
@ AST_SIP_SCHED_TASK_DATA_AO2
Definition res_pjsip.h:2242
@ AST_SIP_SCHED_TASK_DATA_FREE
Definition res_pjsip.h:2252
@ AST_SIP_SCHED_TASK_DATA_NO_CLEANUP
Definition res_pjsip.h:2247
@ AST_SIP_SCHED_TASK_VARIABLE
Definition res_pjsip.h:2225
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
#define AST_RWLIST_ENTRY
ast_transport
Definition netsock2.h:59
static struct ast_serializer_shutdown_group * shutdown_group
Shutdown group for options serializers.
const char * method
Definition res_pjsip.c:1273
ast_sip_security_mechanism_type
The security mechanism type.
Definition res_pjsip.h:362
@ AST_SIP_SECURITY_MECH_DTLS_SRTP
Definition res_pjsip.h:369
@ AST_SIP_SECURITY_MECH_SDES_SRTP
Definition res_pjsip.h:367
@ AST_SIP_SECURITY_MECH_MSRP_TLS
Definition res_pjsip.h:365
@ AST_SIP_SECURITY_MECH_NONE
Definition res_pjsip.h:363
struct ast_sip_auth * ast_sip_get_artificial_auth(void)
Retrieves a reference to the artificial auth.
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.
void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement)
Unregister a an supplement to SIP out of dialog processing.
Definition res_pjsip.c:1470
ast_sip_redirect_method
SIP methods that are allowed to follow 3xx redirects.
Definition res_pjsip.h:758
@ AST_SIP_REDIRECT_METHOD_MESSAGE
Definition res_pjsip.h:760
pjsip_auth_algorithm_type
Definition res_pjsip.h:607
@ PJSIP_AUTH_ALGORITHM_COUNT
Definition res_pjsip.h:613
@ PJSIP_AUTH_ALGORITHM_AKAV1_MD5
Definition res_pjsip.h:612
@ PJSIP_AUTH_ALGORITHM_NOT_SET
Definition res_pjsip.h:608
@ PJSIP_AUTH_ALGORITHM_SHA512_256
Definition res_pjsip.h:611
@ PJSIP_AUTH_ALGORITHM_SHA256
Definition res_pjsip.h:610
@ PJSIP_AUTH_ALGORITHM_MD5
Definition res_pjsip.h:609
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.
Definition res_pjsip.c:3220
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:924
unsigned int ast_sip_get_norefersub(void)
Retrieve the global setting 'norefersub'.
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.
Definition res_pjsip.c:3482
const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_iana_name(const pj_str_t *iana_name)
Get algorithm by IANA name.
Definition config_auth.c:83
const pj_str_t * ast_sip_pjsip_uri_get_username(pjsip_uri *uri)
Get the user portion of the pjsip_uri.
Definition res_pjsip.c:3448
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.
unsigned int ast_sip_get_max_initial_qualify_time(void)
Retrieve the system max initial qualify time.
unsigned int ast_sip_get_keep_alive_interval(void)
Retrieve the system keep alive interval setting.
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.
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.
void ast_sip_unregister_service(pjsip_module *module)
Definition res_pjsip.c:127
const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_type(pjsip_auth_algorithm_type algorithm_type)
Get algorithm by algorithm type.
Definition config_auth.c:66
unsigned int ast_sip_get_allow_sending_180_after_183(void)
Retrieve the global setting 'allow_sending_180_after_183'.
ast_sip_endpoint_identifier_type
Different methods by which incoming requests can be matched to endpoints.
Definition res_pjsip.h:699
@ AST_SIP_ENDPOINT_IDENTIFY_BY_HEADER
Definition res_pjsip.h:707
@ AST_SIP_ENDPOINT_IDENTIFY_BY_USERNAME
Definition res_pjsip.h:701
@ AST_SIP_ENDPOINT_IDENTIFY_BY_REQUEST_URI
Definition res_pjsip.h:709
@ AST_SIP_ENDPOINT_IDENTIFY_BY_IP
Definition res_pjsip.h:705
@ AST_SIP_ENDPOINT_IDENTIFY_BY_AUTH_USERNAME
Definition res_pjsip.h:703
const char * ast_sip_get_host_ip_string(int af)
Retrieve the local host address in string form.
Definition res_pjsip.c:2464
char * ast_sip_get_endpoint_identifier_order(void)
Retrieve the global endpoint_identifier_order setting.
int(* ast_transport_monitor_data_matcher)(void *a, void *b)
Transport shutdown monitor data matcher.
Definition res_pjsip.h:4127
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.
pjsip_media_type pjsip_media_type_application_media_control_xml
Definition res_pjsip.c:3900
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.
Definition res_pjsip.c:2548
int ast_sip_transport_state_set_transport(const char *transport_name, pjsip_transport *transport)
Sets the PJSIP transport on a child transport.
char * ast_sip_rdata_get_header_value(pjsip_rx_data *rdata, const pj_str_t str)
Get a specific header value from rdata.
Definition res_pjsip.c:339
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.
Definition res_pjsip.c:1170
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.
Definition location.c:304
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.
Definition location.c:430
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
struct ast_sip_endpoint * ast_sip_get_artificial_endpoint(void)
Retrieves a reference to the artificial endpoint.
pjsip_media_type pjsip_media_type_application_json
Definition res_pjsip.c:3899
int ast_sip_requires_authentication(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Determine if an incoming request requires authentication.
Definition res_pjsip.c:157
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.
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.
Definition res_pjsip.c:2367
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.
Definition res_pjsip.c:2017
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.
struct ao2_container * ast_sip_get_endpoints(void)
Retrieve any endpoints available to sorcery.
int ast_copy_pj_str2(char **dest, const pj_str_t *src)
Create and copy a pj_str_t into a standard character buffer.
Definition res_pjsip.c:2179
int ast_sip_get_host_ip(int af, pj_sockaddr *addr)
Retrieve the local host address in IP form.
Definition res_pjsip.c:2451
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.
void ast_sip_report_auth_success(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
Send a security event notification for when authentication succeeds.
struct ao2_container * ast_sip_get_transport_states(void)
Retrieves all transport states.
ast_sip_session_redirect
Definition res_pjsip.h:744
@ AST_SIP_REDIRECT_URI_CORE
Definition res_pjsip.h:748
@ AST_SIP_REDIRECT_URI_PJSIP
Definition res_pjsip.h:750
@ AST_SIP_REDIRECT_USER
Definition res_pjsip.h:746
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.
Definition res_pjsip.c:2439
int ast_sip_register_service(pjsip_module *module)
Register a SIP service in Asterisk.
Definition res_pjsip.c:111
void * ast_sip_endpoint_alloc(const char *name)
Allocate a new SIP endpoint.
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition location.c:147
int ast_sip_is_allowed_uri(pjsip_uri *uri)
Check whether a pjsip_uri is allowed or not.
Definition res_pjsip.c:3443
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.
Definition res_pjsip.c:958
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 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
void ast_sip_transport_state_register(struct ast_sip_tpmgr_state_callback *element)
Register a transport state notification callback element.
void ast_sip_cleanup_auths(struct ast_sip_auth *auths[], size_t num_auths)
Clean up retrieved auth structures from memory.
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.
Definition location.c:723
const int ast_sip_hangup_sip2cause(int cause)
Convert SIP hangup causes to Asterisk hangup causes.
Definition res_pjsip.c:3521
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.
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...
Definition res_pjsip.c:599
int ast_sip_format_auths_ami(const struct ast_sip_auth_vector *auths, struct ast_sip_ami *ami)
Format auth details for AMI.
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.
Definition res_pjsip.c:208
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:688
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
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.
Definition res_pjsip.c:2793
pjsip_media_type pjsip_media_type_application_sdp
Definition res_pjsip.c:3906
ast_sip_session_media_encryption
Definition res_pjsip.h:733
@ AST_SIP_MEDIA_ENCRYPT_SDES
Definition res_pjsip.h:739
@ AST_SIP_MEDIA_TRANSPORT_INVALID
Definition res_pjsip.h:735
@ AST_SIP_MEDIA_ENCRYPT_NONE
Definition res_pjsip.h:737
@ AST_SIP_MEDIA_ENCRYPT_DTLS
Definition res_pjsip.h:741
void ast_sip_register_supplement(struct ast_sip_supplement *supplement)
Register a supplement to SIP out of dialog processing.
Definition res_pjsip.c:1450
void ast_sip_add_date_header(pjsip_tx_data *tdata)
Adds a Date header to the tdata, formatted like: Date: Wed, 01 Jan 2021 14:53:01 GMT.
Definition res_pjsip.c:84
ast_sip_auth_cred_usage
Definition res_pjsip.h:590
@ AST_SIP_AUTH_CRED_USAGE_UAS
Definition res_pjsip.h:594
@ AST_SIP_AUTH_CRED_USAGE_UAC
Definition res_pjsip.h:592
pjsip_media_type pjsip_media_type_text_plain
Definition res_pjsip.c:3910
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.
void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata)
Apply the configuration for a transport to an outgoing message.
void ast_sip_unregister_outbound_authenticator(struct ast_sip_outbound_authenticator *auth)
Unregister an outbound SIP authenticator.
Definition res_pjsip.c:197
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.
Definition res_pjsip.c:2798
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.
pjsip_media_type pjsip_media_type_application_pidf_xml
Definition res_pjsip.c:3901
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.
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.
int ast_sip_auth_digest_algorithms_vector_init(const char *id, struct pjsip_auth_algorithm_type_vector *algorithms, const char *agent_type, const char *value)
Populate a vector of algorithm types from a string.
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.
Definition res_pjsip.c:1260
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.
Definition res_pjsip.c:173
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition res_pjsip.c:514
int ast_sip_register_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Register a SIP endpoint identifier.
Definition res_pjsip.c:304
struct ast_endpoint_snapshot * ast_sip_get_endpoint_snapshot(const struct ast_sip_endpoint *endpoint)
Retrieve the endpoint snapshot for an endpoint.
void * ast_sip_dict_get(void *ht, const char *key)
Retrieves the value associated with the given key.
Definition res_pjsip.c:2298
unsigned int ast_sip_get_send_contact_status_on_update_registration(void)
Retrieve the global setting 'send_contact_status_on_update_registration'.
int ast_sip_update_from(pjsip_tx_data *tdata, char *from)
Overwrite fields in the outbound 'From' header.
Definition res_pjsip.c:3354
ast_sip_supplement_priority
Definition res_pjsip.h:3357
@ AST_SIP_SUPPLEMENT_PRIORITY_CHANNEL
Definition res_pjsip.h:3364
@ AST_SIP_SUPPLEMENT_PRIORITY_FIRST
Definition res_pjsip.h:3359
@ AST_SIP_SUPPLEMENT_PRIORITY_LAST
Definition res_pjsip.h:3366
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.
Definition res_pjsip.c:495
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.
Definition res_pjsip.c:2475
int ast_sip_str2rc(const char *name)
Convert name to SIP response code.
Definition res_pjsip.c:3704
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:837
int ast_sip_retrieve_auths(const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out)
Retrieve relevant SIP auth structures from sorcery.
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.
int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
Check whether a pjsip_uri is SIP/SIPS or not.
Definition res_pjsip.c:3438
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:905
void ast_sip_service_route_vector_destroy(struct ast_sip_service_route_vector *service_routes)
Destroy a vector of service routes.
void ast_sip_unregister_endpoint_identifier(struct ast_sip_endpoint_identifier *identifier)
Unregister a SIP endpoint identifier.
Definition res_pjsip.c:309
pj_bool_t ast_sip_auth_is_algorithm_supported(pjsip_auth_algorithm_type algorithm_type)
Is algorithm supported by OpenSSL and pjproject?
const char * ast_sip_get_contact_short_status_label(const enum ast_sip_contact_status_type status)
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:2172
void ast_sip_security_mechanisms_vector_destroy(struct ast_sip_security_mechanism_vector *security_mechanisms)
Free contents of a security mechanism vector.
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.
const char * ast_sip_call_codec_pref_to_str(struct ast_flags pref)
Convert the call codec preference flags to a string.
Definition res_pjsip.c:2525
struct ast_sip_endpoint * ast_sip_identify_endpoint(pjsip_rx_data *rdata)
Determine the endpoint that has sent a SIP message.
Definition res_pjsip.c:324
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:1932
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.
Definition res_pjsip.c:1186
pjsip_media_type pjsip_media_type_application_simple_message_summary
Definition res_pjsip.c:3905
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:589
int ast_sip_format_contact_ami(void *obj, void *arg, int flags)
Formats the contact and sends over AMI.
#define SIP_TLS_MAX_CIPHERS
Maximum number of ciphers supported for a TLS transport.
Definition res_pjsip.h:105
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:721
int ast_sip_is_media_type_in(pjsip_media_type *a,...) attribute_sentinel
Check if a media type is in a list of others.
Definition res_pjsip.c:2199
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.
unsigned int ast_sip_get_use_callerid_contact(void)
Retrieve the global setting 'use_callerid_contact'.
char * ast_sip_get_default_voicemail_extension(void)
Retrieve the default voicemail extension.
long ast_sip_taskpool_queue_size(void)
Return the size of the SIP taskpool's task queue.
Definition res_pjsip.c:3428
ast_sip_contact_filter
Contact retrieval filtering flags.
Definition res_pjsip.h:1432
@ AST_SIP_CONTACT_FILTER_REACHABLE
Return only reachable or unknown contacts.
Definition res_pjsip.h:1437
@ AST_SIP_CONTACT_FILTER_DEFAULT
Default filter flags.
Definition res_pjsip.h:1434
void ast_sip_unregister_authenticator(struct ast_sip_authenticator *auth)
Unregister a SIP authenticator.
Definition res_pjsip.c:146
unsigned int ast_sip_get_contact_expiration_check_interval(void)
Retrieve the system contact expiration check interval setting.
int ast_sip_persistent_endpoint_update_state(const char *endpoint_name, enum ast_endpoint_state state)
Change state of a persistent endpoint.
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.
Definition res_pjsip.c:1973
const char * ast_sip_get_device_state(const struct ast_sip_endpoint *endpoint)
Retrieve the device state for an endpoint.
struct ast_sip_endpoint * ast_sip_default_outbound_endpoint(void)
Retrieve the default outbound endpoint.
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:642
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.
int ast_sip_register_outbound_authenticator(struct ast_sip_outbound_authenticator *outbound_auth)
Register an outbound SIP authenticator.
Definition res_pjsip.c:185
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
Definition res_pjsip.c:475
int ast_sip_add_global_request_header(const char *name, const char *value, int replace)
int ast_sip_add_body(pjsip_tx_data *tdata, const struct ast_sip_body *body)
Add a body to an outbound SIP message.
Definition res_pjsip.c:2046
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.
void * ast_sip_dict_set(pj_pool_t *pool, void *ht, const char *key, void *val)
Set the value for the given key.
Definition res_pjsip.c:2309
int ast_sip_are_media_types_equal(pjsip_media_type *a, pjsip_media_type *b)
Compare pjsip media types.
Definition res_pjsip.c:2190
void ast_sip_tpselector_unref(pjsip_tpselector *selector)
Unreference a pjsip_tpselector.
Definition res_pjsip.c:917
void ast_sip_get_default_realm(char *realm, size_t size)
Retrieve the global default realm.
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.
Definition location.c:214
int ast_sip_auth_digest_algorithms_vector_to_str(const struct pjsip_auth_algorithm_type_vector *algorithms, char **buf)
Dump a vector of algorithm types to a string.
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:692
unsigned int ast_sip_get_disable_multi_domain(void)
Retrieve the system setting 'disable multi domain'.
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
Definition res_pjsip.c:481
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.
ast_sip_dtmf_mode
DTMF modes for SIP endpoints.
Definition res_pjsip.h:545
@ AST_SIP_DTMF_NONE
Definition res_pjsip.h:547
@ AST_SIP_DTMF_AUTO_INFO
Definition res_pjsip.h:558
@ AST_SIP_DTMF_AUTO
Definition res_pjsip.h:556
@ AST_SIP_DTMF_INBAND
Definition res_pjsip.h:552
@ AST_SIP_DTMF_INFO
Definition res_pjsip.h:554
@ AST_SIP_DTMF_RFC_4733
Definition res_pjsip.h:550
unsigned int ast_sip_get_ignore_uri_user_options(void)
Retrieve the global setting 'ignore_uri_user_options'.
int ast_sip_register_authenticator(struct ast_sip_authenticator *auth)
Register a SIP authenticator.
Definition res_pjsip.c:134
struct ast_sip_service_route_vector * ast_sip_service_route_vector_alloc(void)
Allocate a vector of service routes.
struct ast_sip_contact * ast_sip_location_retrieve_contact(const char *contact_name)
Retrieve a named contact.
Definition location.c:350
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.
int ast_sip_str_to_security_mechanism(struct ast_sip_security_mechanism **security_mechanism, const char *value)
Allocate a security mechanism from a string.
int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
Converts a sorcery object to a string of object properties.
void ast_sip_transport_state_unregister(struct ast_sip_tpmgr_state_callback *element)
Unregister a transport state notification callback element.
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.
Definition res_pjsip.c:2053
ast_sip_auth_type
Authentication methods.
Definition res_pjsip.h:570
@ AST_SIP_AUTH_TYPE_GOOGLE_OAUTH
Definition res_pjsip.h:583
@ AST_SIP_AUTH_TYPE_NONE
Definition res_pjsip.h:571
@ AST_SIP_AUTH_TYPE_ARTIFICIAL
Definition res_pjsip.h:585
@ AST_SIP_AUTH_TYPE_DIGEST
Definition res_pjsip.h:587
@ AST_SIP_AUTH_TYPE_MD5
Definition res_pjsip.h:581
@ AST_SIP_AUTH_TYPE_USER_PASS
Definition res_pjsip.h:576
pjsip_media_type pjsip_media_type_application_rlmi_xml
Definition res_pjsip.c:3904
ast_transport_monitor_reg
Definition res_pjsip.h:4129
@ AST_TRANSPORT_MONITOR_REG_NOT_FOUND
Transport not found to monitor.
Definition res_pjsip.h:4138
@ AST_TRANSPORT_MONITOR_REG_REPLACED
Replaced the already existing transport monitor with new one.
Definition res_pjsip.h:4133
@ AST_TRANSPORT_MONITOR_REG_FAILED
Error while registering transport monitor.
Definition res_pjsip.h:4140
@ AST_TRANSPORT_MONITOR_REG_SUCCESS
Successfully registered the transport monitor.
Definition res_pjsip.h:4131
void(* ast_transport_monitor_shutdown_cb)(void *data)
Transport shutdown monitor callback.
Definition res_pjsip.h:4115
int ast_sip_add_global_response_header(const char *name, const char *value, int replace)
float ast_sip_parse_qvalue(const char *q_value)
Parses a string representing a q_value to a float.
Definition res_pjsip.c:3501
struct ao2_container * ast_sip_location_retrieve_contacts_from_aor_list(const char *aor_list)
Retrieve all contacts from a list of AORs.
Definition location.c:335
int ast_sip_update_to_uri(pjsip_tx_data *tdata, const char *to)
Replace the To URI in the tdata with the supplied one.
Definition res_pjsip.c:3294
pjsip_media_type pjsip_media_type_multipart_mixed
Definition res_pjsip.c:3908
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.
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.
pjsip_media_type pjsip_media_type_application_xpidf_xml
Definition res_pjsip.c:3902
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
int ast_sip_set_outbound_proxy(pjsip_tx_data *tdata, const char *proxy)
Set the outbound proxy for an outbound SIP message.
Definition res_pjsip.c:1986
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void)
Retrieve the global setting 'disable sending unsolicited mwi on startup'.
void ast_sip_auth_vector_destroy(struct ast_sip_auth_vector *vector)
Free contents of an auth vector.
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:227
pjsip_media_type pjsip_media_type_multipart_alternative
Definition res_pjsip.c:3907
ast_sip_security_negotiation
The kind of security negotiation.
Definition res_pjsip.h:351
@ AST_SIP_SECURITY_NEG_MEDIASEC
Definition res_pjsip.h:355
@ AST_SIP_SECURITY_NEG_NONE
Definition res_pjsip.h:353
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:887
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.
Definition res_pjsip.c:1429
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.
int ast_sip_get_mwi_tps_queue_low(void)
Retrieve the global MWI taskprocessor low water clear alert level.
const char * ast_sip_auth_get_creds(const struct ast_sip_auth *auth, const pjsip_auth_algorithm_type algorithm_type, int *cred_type)
Get the plain text or digest password from an auth object.
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
int ast_sip_auth_is_algorithm_available(const struct ast_sip_auth *auth, const struct pjsip_auth_algorithm_type_vector *algorithms, pjsip_auth_algorithm_type algorithm_type)
Checks an pjsip_auth_algorithm_type_vector to see if it contains an algorithm.
int ast_sip_str_to_dtmf(const char *dtmf_mode)
Convert the DTMF mode name into an enum.
Definition res_pjsip.c:2504
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:2002
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
const pj_str_t * ast_sip_pjsip_uri_get_hostname(pjsip_uri *uri)
Get the host portion of the pjsip_uri.
Definition res_pjsip.c:3467
char * ast_sip_get_regcontext(void)
Retrieve the global regcontext setting.
ast_sip_check_auth_result
Possible returns from ast_sip_check_authentication.
Definition res_pjsip.h:1333
@ AST_SIP_AUTHENTICATION_CHALLENGE
Definition res_pjsip.h:1335
@ AST_SIP_AUTHENTICATION_ERROR
Definition res_pjsip.h:1341
@ AST_SIP_AUTHENTICATION_SUCCESS
Definition res_pjsip.h:1337
@ AST_SIP_AUTHENTICATION_FAILED
Definition res_pjsip.h:1339
ast_sip_call_codec_pref
Incoming/Outgoing call offer/answer joint codec preference.
Definition res_pjsip.h:768
@ AST_SIP_CALL_CODEC_PREF_ALL
Definition res_pjsip.h:777
@ AST_SIP_CALL_CODEC_PREF_LOCAL
Definition res_pjsip.h:783
@ AST_SIP_CALL_CODEC_PREF_REMOTE
Definition res_pjsip.h:785
@ AST_SIP_CALL_CODEC_PREF_UNION
Definition res_pjsip.h:773
@ AST_SIP_CALL_CODEC_PREF_FIRST
Definition res_pjsip.h:779
@ AST_SIP_CALL_CODEC_PREF_INTERSECT
Definition res_pjsip.h:771
const char * ast_sip_auth_type_to_str(enum ast_sip_auth_type type)
Converts the given auth type to a string.
struct ast_taskpool * ast_sip_taskpool(void)
Retrieve the SIP taskpool object.
Definition res_pjsip.c:3433
struct ast_sip_contact_status * ast_sip_get_contact_status(const struct ast_sip_contact *contact)
Retrieve the current status for a contact.
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.
Definition res_pjsip.h:1896
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.
int ast_sip_location_update_contact(struct ast_sip_contact *contact)
Update a contact.
Definition location.c:446
void ast_sip_get_default_auth_algorithms_uac(char *default_auth_algorithms_uac, size_t size)
Retrieve the global auth algorithms for UAC.
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.
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.
Definition res_pjsip.c:2395
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.
int ast_sip_auth_vector_init(struct ast_sip_auth_vector *vector, const char *auth_names)
Initialize an auth vector with the configured values.
ast_sip_contact_status_type
Status type for a contact.
Definition res_pjsip.h:434
@ AVAILABLE
Definition res_pjsip.h:438
@ UNAVAILABLE
Definition res_pjsip.h:436
@ REMOVED
Definition res_pjsip.h:443
@ UNKNOWN
Definition res_pjsip.h:440
@ CREATED
Definition res_pjsip.h:442
void ast_sip_get_default_from_user(char *from_user, size_t size)
Retrieve the global default from user.
unsigned int ast_sip_get_mwi_tps_queue_high(void)
Retrieve the global MWI taskprocessor high water alert trigger level.
int ast_sip_is_content_type(pjsip_media_type *content_type, char *type, char *subtype)
Checks if the given content type matches type/subtype.
Definition res_pjsip.c:2219
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.
int ast_sip_append_body(pjsip_tx_data *tdata, const char *body_text)
Append body data to a SIP message.
Definition res_pjsip.c:2069
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.
int ast_sip_contact_to_str(void *object, void *arg, int flags)
Handler used to convert a contact to a string.
Definition location.c:771
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.
Definition location.c:194
int ast_sip_transport_state_set_preferred_identity(const char *transport_name, const char *identity)
Sets the P-Preferred-Identity on a child transport.
unsigned int ast_sip_get_all_codecs_on_empty_reinvite(void)
Retrieve the system setting 'all_codecs_on_empty_reinvite'.
void ast_sip_location_prune_boot_contacts(void)
Prune the prune_on_boot contacts.
Definition location.c:470
ast_sip_100rel_mode
100rel modes for SIP endpoints
Definition res_pjsip.h:531
@ AST_SIP_100REL_PEER_SUPPORTED
Definition res_pjsip.h:537
@ AST_SIP_100REL_UNSUPPORTED
Definition res_pjsip.h:533
@ AST_SIP_100REL_SUPPORTED
Definition res_pjsip.h:535
@ AST_SIP_100REL_REQUIRED
Definition res_pjsip.h:539
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
ast_sip_direct_media_glare_mitigation
Definition res_pjsip.h:720
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_NONE
Definition res_pjsip.h:722
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_INCOMING
Definition res_pjsip.h:730
@ AST_SIP_DIRECT_MEDIA_GLARE_MITIGATION_OUTGOING
Definition res_pjsip.h:726
pjsip_media_type pjsip_media_type_application_cpim_xpidf_xml
Definition res_pjsip.c:3903
void ast_sip_get_default_auth_algorithms_uas(char *default_auth_algorithms_uas, size_t size)
Retrieve the global auth algorithms for UAS.
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
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:558
int ast_sip_location_delete_contact(struct ast_sip_contact *contact)
Delete a contact.
Definition location.c:451
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.
Definition res_pjsip.c:1208
pjsip_media_type pjsip_media_type_multipart_related
Definition res_pjsip.c:3909
int ast_sip_failover_request(pjsip_tx_data *tdata)
Set a request to use the next value in the list of resolved addresses.
Definition res_pjsip.c:1810
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.
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:417
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.
ast_sip_session_refresh_method
Definition res_pjsip.h:713
@ AST_SIP_SESSION_REFRESH_METHOD_UPDATE
Definition res_pjsip.h:717
@ AST_SIP_SESSION_REFRESH_METHOD_INVITE
Definition res_pjsip.h:715
void ast_sip_get_unidentified_request_thresholds(unsigned int *count, unsigned int *period, unsigned int *prune_interval)
Retrieve the unidentified request security event thresholds.
char * ast_sip_get_debug(void)
Retrieve the system debug setting (yes|no|host).
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.
Definition res_pjsip.c:2821
static void challenge(const char *endpoint_id, struct ast_sip_auth *auth, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale, const pjsip_auth_algorithm *algorithm)
Send a WWW-Authenticate challenge.
#define SORCERY_OBJECT(details)
Macro which must be used at the beginning of each sorcery capable object.
Definition sorcery.h:356
#define AST_DECLARE_STRING_FIELDS(field_list)
Declare the fields needed in a structure.
#define AST_STRING_FIELD(name)
Declare a string field.
#define AST_STRING_FIELD_EXTENDED(name)
Declare an extended string field.
Generic container type.
Wrapper for an ast_acl linked list.
Definition acl.h:76
Definition dnsmgr.c:66
A snapshot of an endpoint's state.
Structure used to handle boolean flags.
Definition utils.h:220
Format capabilities structure, holds formats + preference order + etc.
Definition format_cap.c:54
internal representation of ACL entries In principle user applications would have no need for this,...
Definition acl.h:51
Information needed to identify an endpoint in a call.
Definition channel.h:340
DTLS configuration structure.
Definition rtp_engine.h:605
AMI variable container.
Definition res_pjsip.h:3225
const char * action_id
Definition res_pjsip.h:3231
struct mansession * s
Definition res_pjsip.h:3227
const struct message * m
Definition res_pjsip.h:3229
A SIP address of record.
Definition res_pjsip.h:478
unsigned int minimum_expiration
Definition res_pjsip.h:488
unsigned int remove_existing
Definition res_pjsip.h:500
double qualify_timeout
Definition res_pjsip.h:506
char * voicemail_extension
Definition res_pjsip.h:508
unsigned int max_contacts
Definition res_pjsip.h:498
int qualify_2xx_only
Definition res_pjsip.h:512
unsigned int support_path
Definition res_pjsip.h:504
struct ao2_container * permanent_contacts
Definition res_pjsip.h:502
unsigned int remove_unavailable
Definition res_pjsip.h:510
const ast_string_field outbound_proxy
Definition res_pjsip.h:486
unsigned int maximum_expiration
Definition res_pjsip.h:490
const ast_string_field mailboxes
Definition res_pjsip.h:486
unsigned int default_expiration
Definition res_pjsip.h:492
int authenticate_qualify
Definition res_pjsip.h:496
unsigned int qualify_frequency
Definition res_pjsip.h:494
pjsip_auth_algorithm_type algorithm_type
Definition res_pjsip.h:656
struct pjsip_auth_algorithm_type_vector supported_algorithms_uac
Definition res_pjsip.h:687
const ast_string_field oauth_clientid
Definition res_pjsip.h:681
const ast_string_field oauth_secret
Definition res_pjsip.h:681
const ast_string_field md5_creds
Definition res_pjsip.h:681
const ast_string_field realm
Definition res_pjsip.h:681
unsigned int nonce_lifetime
Definition res_pjsip.h:683
const ast_string_field auth_user
Definition res_pjsip.h:681
struct ast_sip_auth_password_digest * password_digests[PJSIP_AUTH_ALGORITHM_COUNT]
Definition res_pjsip.h:691
struct pjsip_auth_algorithm_type_vector supported_algorithms_uas
Definition res_pjsip.h:689
const ast_string_field refresh_token
Definition res_pjsip.h:681
const ast_string_field auth_pass
Definition res_pjsip.h:681
enum ast_sip_auth_type type
Definition res_pjsip.h:685
An interchangeable way of handling digest authentication for SIP.
Definition res_pjsip.h:1378
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:1393
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:1383
SIP body description.
Definition res_pjsip.h:2469
const char * type
Definition res_pjsip.h:2471
const char * body_text
Definition res_pjsip.h:2475
const char * subtype
Definition res_pjsip.h:2473
A contact's status.
Definition res_pjsip.h:451
const ast_string_field uri
Definition res_pjsip.h:457
enum ast_sip_contact_status_type status
Definition res_pjsip.h:468
enum ast_sip_contact_status_type last_status
Definition res_pjsip.h:470
const ast_string_field aor
Definition res_pjsip.h:457
struct ast_sip_security_mechanism_vector security_mechanisms
Definition res_pjsip.h:466
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:519
struct ast_sip_contact * contact
Definition res_pjsip.h:525
Contact associated with an address of record.
Definition res_pjsip.h:390
const ast_string_field uri
Definition res_pjsip.h:412
double qualify_timeout
Definition res_pjsip.h:420
struct ast_sip_endpoint * endpoint
Definition res_pjsip.h:422
const ast_string_field via_addr
Definition res_pjsip.h:412
const ast_string_field call_id
Definition res_pjsip.h:412
const ast_string_field aor
Definition res_pjsip.h:412
const ast_string_field outbound_proxy
Definition res_pjsip.h:412
struct timeval expiration_time
Definition res_pjsip.h:414
const ast_string_field path
Definition res_pjsip.h:412
const ast_string_field endpoint_name
Definition res_pjsip.h:412
int authenticate_qualify
Definition res_pjsip.h:418
const ast_string_field reg_server
Definition res_pjsip.h:412
const ast_string_field user_agent
Definition res_pjsip.h:412
unsigned int qualify_frequency
Definition res_pjsip.h:416
Direct media options for SIP endpoints.
Definition res_pjsip.h:974
enum ast_sip_direct_media_glare_mitigation glare_mitigation
Definition res_pjsip.h:980
enum ast_sip_session_refresh_method method
Definition res_pjsip.h:978
const ast_string_field domain
Definition res_pjsip.h:321
Endpoint configuration for SIP extensions.
Definition res_pjsip.h:815
struct ast_sip_timer_options timer
Definition res_pjsip.h:819
An entity responsible formatting endpoint information.
Definition res_pjsip.h:3251
struct ast_sip_endpoint_formatter * next
Definition res_pjsip.h:3257
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:3255
Party identification options for endpoints.
Definition res_pjsip.h:869
enum ast_sip_session_refresh_method refresh_method
Definition res_pjsip.h:888
An entity responsible for identifying the source of a SIP message.
Definition res_pjsip.h:1421
Endpoint configuration options for INFO packages.
Definition res_pjsip.h:924
struct ast_sip_info_recording_configuration recording
Definition res_pjsip.h:926
Media configuration for SIP endpoints.
Definition res_pjsip.h:1003
struct ast_sip_media_rtp_configuration rtp
Definition res_pjsip.h:1013
struct ast_stream_topology * topology
Definition res_pjsip.h:1021
struct ast_format_cap * codecs
Definition res_pjsip.h:1019
const ast_string_field sdpowner
Definition res_pjsip.h:1011
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_offer
Definition res_pjsip.h:1049
struct ast_stream_codec_negotiation_prefs codec_prefs_incoming_answer
Definition res_pjsip.h:1053
struct ast_sip_direct_media_configuration direct_media
Definition res_pjsip.h:1015
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_offer
Definition res_pjsip.h:1051
struct ast_flags incoming_call_offer_pref
Definition res_pjsip.h:1045
struct ast_flags outgoing_call_offer_pref
Definition res_pjsip.h:1047
struct ast_sip_t38_configuration t38
Definition res_pjsip.h:1017
const ast_string_field sdpsession
Definition res_pjsip.h:1011
struct ast_stream_codec_negotiation_prefs codec_prefs_outgoing_answer
Definition res_pjsip.h:1055
NAT configuration options for endpoints.
Definition res_pjsip.h:857
Call pickup configuration options for endpoints.
Definition res_pjsip.h:896
struct ast_namedgroups * named_pickupgroups
Definition res_pjsip.h:904
struct ast_namedgroups * named_callgroups
Definition res_pjsip.h:902
Endpoint subscription configuration.
Definition res_pjsip.h:843
struct ast_sip_mwi_configuration mwi
Definition res_pjsip.h:849
An entity with which Asterisk communicates.
Definition res_pjsip.h:1061
struct ast_sip_auth_vector outbound_auths
Definition res_pjsip.h:1108
const ast_string_field language
Definition res_pjsip.h:1090
struct ast_flags follow_redirect_methods
Definition res_pjsip.h:1128
const ast_string_field zone
Definition res_pjsip.h:1090
enum ast_sip_endpoint_identifier_type ident_method
Definition res_pjsip.h:1112
struct ast_endpoint * persistent
Definition res_pjsip.h:1118
enum ast_sip_session_redirect redirect_method
Definition res_pjsip.h:1126
unsigned int faxdetect_timeout
Definition res_pjsip.h:1140
const ast_string_field incoming_mwi_mailbox
Definition res_pjsip.h:1090
const ast_string_field transport
Definition res_pjsip.h:1090
struct ast_sip_endpoint_id_configuration id
Definition res_pjsip.h:1100
const ast_string_field mohsuggest
Definition res_pjsip.h:1090
const ast_string_field aors
Definition res_pjsip.h:1090
const ast_string_field accountcode
Definition res_pjsip.h:1090
unsigned int send_aoc
Definition res_pjsip.h:1174
unsigned int moh_passthrough
Definition res_pjsip.h:1134
struct ast_sip_endpoint_pickup_configuration pickup
Definition res_pjsip.h:1104
enum ast_sip_security_negotiation security_negotiation
Definition res_pjsip.h:1158
unsigned int refer_blind_progress
Definition res_pjsip.h:1150
unsigned int preferred_codec_only
Definition res_pjsip.h:1144
struct ast_sip_identify_by_vector ident_method_order
Definition res_pjsip.h:1114
struct ast_sip_endpoint_extensions extensions
Definition res_pjsip.h:1092
struct ast_sip_auth_vector inbound_auths
Definition res_pjsip.h:1106
const ast_string_field context
Definition res_pjsip.h:1090
const ast_string_field message_context
Definition res_pjsip.h:1090
struct ast_sip_endpoint_media_configuration media
Definition res_pjsip.h:1094
int suppress_moh_on_sendonly
Definition res_pjsip.h:1178
const ast_string_field outbound_proxy
Definition res_pjsip.h:1090
unsigned int notify_early_inuse_ringing
Definition res_pjsip.h:1152
const ast_string_field fromdomain
Definition res_pjsip.h:1090
unsigned int stir_shaken
Definition res_pjsip.h:1162
const ast_string_field stir_shaken_profile
Definition res_pjsip.h:1090
unsigned int suppress_q850_reason_headers
Definition res_pjsip.h:1154
unsigned int ignore_183_without_sdp
Definition res_pjsip.h:1156
unsigned int allow_unauthenticated_options
Definition res_pjsip.h:1164
struct ast_acl_list * contact_acl
Definition res_pjsip.h:1138
unsigned int allow_overlap
Definition res_pjsip.h:1148
unsigned int usereqphone
Definition res_pjsip.h:1132
enum ast_sip_dtmf_mode dtmf
Definition res_pjsip.h:1110
struct ast_acl_list * acl
Definition res_pjsip.h:1136
const ast_string_field fromuser
Definition res_pjsip.h:1090
unsigned int inband_progress
Definition res_pjsip.h:1116
struct ast_sip_endpoint_subscription_configuration subscription
Definition res_pjsip.h:1096
struct ast_sip_endpoint_nat_configuration nat
Definition res_pjsip.h:1098
enum ast_sip_100rel_mode rel100
Definition res_pjsip.h:1172
unsigned int allowtransfer
Definition res_pjsip.h:1124
struct ast_sip_endpoint_info_configuration info
Definition res_pjsip.h:1102
unsigned int devicestate_busy_at
Definition res_pjsip.h:1120
unsigned int asymmetric_rtp_codec
Definition res_pjsip.h:1146
unsigned int faxdetect
Definition res_pjsip.h:1122
struct ast_sip_security_mechanism_vector security_mechanisms
Definition res_pjsip.h:1160
struct ast_variable * channel_vars
Definition res_pjsip.h:1130
Configuration for one-touch INFO recording.
Definition res_pjsip.h:910
const ast_string_field onfeature
Definition res_pjsip.h:916
const ast_string_field offfeature
Definition res_pjsip.h:916
RTP configuration for SIP endpoints.
Definition res_pjsip.h:932
struct ast_rtp_dtls_cfg dtls_cfg
DTLS-SRTP configuration information.
Definition res_pjsip.h:952
const ast_string_field engine
Definition res_pjsip.h:936
enum ast_sip_session_media_encryption encryption
Definition res_pjsip.h:956
unsigned int accept_multiple_sdp_answers
Definition res_pjsip.h:968
Endpoint configuration for unsolicited MWI.
Definition res_pjsip.h:825
const ast_string_field mailboxes
Definition res_pjsip.h:831
const ast_string_field fromuser
Definition res_pjsip.h:831
unsigned int subscribe_replaces_unsolicited
Definition res_pjsip.h:835
Structure for SIP nat hook information.
Definition res_pjsip.h:327
void(* outgoing_external_message)(struct pjsip_tx_data *tdata, struct ast_sip_transport *transport)
Definition res_pjsip.h:331
an interchangeable way of responding to authentication challenges
Definition res_pjsip.h:1403
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:1414
Structure which contains information about a transport.
Definition res_pjsip.h:335
int local_port
Local port for transport.
Definition res_pjsip.h:345
pjsip_transport * transport
Potential pointer to the transport itself, if UDP.
Definition res_pjsip.h:339
enum ast_transport type
Type of transport.
Definition res_pjsip.h:337
pjsip_tpfactory * factory
Potential pointer to the transport factory itself, if TCP/TLS.
Definition res_pjsip.h:341
pj_str_t local_address
Local address for transport.
Definition res_pjsip.h:343
struct timeval last_start
struct timeval when_queued
struct timeval last_end
enum ast_sip_scheduler_task_flags flags
Structure representing a security mechanism as defined in RFC 3329.
Definition res_pjsip.h:376
struct ast_vector_string mechanism_parameters
Definition res_pjsip.h:382
enum ast_sip_security_mechanism_type type
Definition res_pjsip.h:378
A supplement to SIP message processing.
Definition res_pjsip.h:3376
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:3419
int(* incoming_request)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata)
Called on incoming SIP request This method can indicate a failure in processing in its return....
Definition res_pjsip.h:3398
void(* outgoing_response)(struct ast_sip_endpoint *endpoint, struct ast_sip_contact *contact, struct pjsip_tx_data *tdata)
Called on an outgoing SIP response This method is always called from a SIP servant thread.
Definition res_pjsip.h:3424
void(* incoming_response)(struct ast_sip_endpoint *endpoint, struct pjsip_rx_data *rdata)
Called on an incoming SIP response This method is always called from a SIP servant thread.
Definition res_pjsip.h:3414
const char * method
Definition res_pjsip.h:3378
enum ast_sip_supplement_priority priority
Definition res_pjsip.h:3380
struct ast_sip_supplement * next
Definition res_pjsip.h:3426
unsigned int bind_udptl_to_media_address
Definition res_pjsip.h:997
enum ast_t38_ec_modes error_correction
Definition res_pjsip.h:989
Session timers options.
Definition res_pjsip.h:802
unsigned int sess_expires
Definition res_pjsip.h:806
unsigned int min_se
Definition res_pjsip.h:804
struct ast_sip_tpmgr_state_callback::@276 node
pjsip_tp_state_callback cb
Definition res_pjsip.h:4284
Structure for SIP transport information.
Definition res_pjsip.h:117
struct pjsip_tpfactory * factory
Transport factory.
Definition res_pjsip.h:121
pjsip_tls_setting tls
Definition res_pjsip.h:141
struct ast_dnsmgr_entry * external_media_address_refresher
Definition res_pjsip.h:169
enum ast_transport type
Definition res_pjsip.h:131
struct ast_sip_service_route_vector * service_routes
Definition res_pjsip.h:189
struct pjsip_transport * transport
Transport itself.
Definition res_pjsip.h:119
struct ast_ha * localnet
Definition res_pjsip.h:154
struct ast_dnsmgr_entry * external_signaling_address_refresher
Definition res_pjsip.h:159
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
Definition res_pjsip.h:146
struct ast_sockaddr external_signaling_address
Definition res_pjsip.h:164
struct ast_sockaddr external_media_address
Definition res_pjsip.h:174
Transport to bind to.
Definition res_pjsip.h:219
unsigned int tos
Definition res_pjsip.h:289
pjsip_tls_setting tls
Definition res_pjsip.h:257
struct ast_sockaddr external_address
Definition res_pjsip.h:281
const ast_string_field privkey_file
Definition res_pjsip.h:239
const ast_string_field ca_list_path
Definition res_pjsip.h:239
const ast_string_field domain
Definition res_pjsip.h:239
enum ast_transport type
Definition res_pjsip.h:241
const ast_string_field cert_file
Definition res_pjsip.h:239
const ast_string_field password
Definition res_pjsip.h:239
int tcp_keepalive_probe_count
Definition res_pjsip.h:307
const ast_string_field external_signaling_address
Definition res_pjsip.h:239
const ast_string_field ca_list_file
Definition res_pjsip.h:239
unsigned int external_signaling_port
Definition res_pjsip.h:251
struct ast_sip_transport_state * state
Definition res_pjsip.h:287
struct ast_ha * localnet
Definition res_pjsip.h:269
unsigned int async_operations
Definition res_pjsip.h:249
pj_sockaddr host
Definition res_pjsip.h:247
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
Definition res_pjsip.h:263
const ast_string_field external_media_address
Definition res_pjsip.h:239
int tcp_keepalive_interval_time
Definition res_pjsip.h:305
struct ast_dnsmgr_entry * external_address_refresher
Definition res_pjsip.h:275
int tcp_keepalive_idle_time
Definition res_pjsip.h:303
unsigned int cos
Definition res_pjsip.h:291
Socket address structure.
Definition netsock2.h:97
Full structure for sorcery.
Definition sorcery.c:231
Support for dynamic strings.
Definition strings.h:623
An opaque taskpool structure.
Definition taskpool.c:62
A ast_taskprocessor structure is a singleton by name.
Structure for variables, used for configurations and for channel variables.
String vector definitions.
Definition vector.h:55
In case you didn't read that giant block of text above the mansession_session struct,...
Definition manager.c:323
const char * openssl_name
Definition res_pjsip.h:620
pjsip_auth_algorithm_type algorithm_type
Definition res_pjsip.h:618
unsigned digest_str_length
Definition res_pjsip.h:622
userdata associated with baseline taskprocessor test
int value
Definition syslog.c:37
static struct test_val b
static struct test_val a
ast_t38_ec_modes
Definition udptl.h:37
FILE * out
Definition utils/frame.c:33
#define AST_VECTOR(name, type)
Define a vector structure.
Definition vector.h:44

◆ 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 3092 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 3124 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 213 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 210 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 3529 of file res_pjsip.h.

3530 { \
3531 char *__semi = strchr((str), ';'); \
3532 if (__semi && ast_sip_get_ignore_uri_user_options()) { \
3533 *__semi = '\0'; \
3534 } \
3535 } while (0)

◆ AST_SIP_X_AST_TXP

#define AST_SIP_X_AST_TXP   "x-ast-txp"

URI parameter for symmetric transport

Definition at line 1182 of file res_pjsip.h.

◆ AST_SIP_X_AST_TXP_LEN

#define AST_SIP_X_AST_TXP_LEN   9

Definition at line 1183 of file res_pjsip.h.

◆ COLON_PORT_STRLEN

#define COLON_PORT_STRLEN   6

Definition at line 78 of file res_pjsip.h.

◆ IP6ADDR_COLON_PORT_BUFLEN

#define IP6ADDR_COLON_PORT_BUFLEN   (PJ_INET6_ADDRSTRLEN + COLON_PORT_STRLEN)

Definition at line 83 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 108 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 597 of file res_pjsip.h.

◆ SIP_SORCERY_DOMAIN_ALIAS_TYPE

#define SIP_SORCERY_DOMAIN_ALIAS_TYPE   "domain_alias"

Definition at line 310 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 105 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 1896 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 4127 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 4115 of file res_pjsip.h.

◆ pjsip_auth_algorithm

◆ pjsip_auth_algorithm_type

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 531 of file res_pjsip.h.

531 {
532 /*! Do not support 100rel. (no) */
534 /*! As UAC, indicate 100rel support in Supported header. (yes) */
536 /*! As UAS, send 1xx responses reliably, if the UAC indicated its support. Otherwise same as AST_SIP_100REL_SUPPORTED. (peer_supported) */
538 /*! Require the use of 100rel. (required) */
540};

◆ ast_sip_auth_cred_usage

Enumerator
AST_SIP_AUTH_CRED_USAGE_UAC 

The credentials used as a UAC

AST_SIP_AUTH_CRED_USAGE_UAS 

The credentials used as a UAS

Definition at line 590 of file res_pjsip.h.

590 {
591 /*! The credentials used as a UAC */
593 /*! The credentials used as a UAS */
595};

◆ ast_sip_auth_type

Authentication methods.

The meaning of this type has changed. It used to indicate how the credentials were stored, but now it indicates which authentication method will be used... Google Oauth, Artificial (fake auth) or Digest. The USER_PASS and MD5 types are still used for backwards compatibility but will map to DIGEST.

Enumerator
AST_SIP_AUTH_TYPE_NONE 
AST_SIP_AUTH_TYPE_USER_PASS 

Credentials stored as a username and password combination

Deprecated:
Now automatically determined
AST_SIP_AUTH_TYPE_MD5 

Credentials stored as an MD5 sum

Deprecated:
Use AST_SIP_AUTH_TYPE_DIGEST instead
AST_SIP_AUTH_TYPE_GOOGLE_OAUTH 

Google Oauth

AST_SIP_AUTH_TYPE_ARTIFICIAL 

Credentials not stored this is a fake auth

AST_SIP_AUTH_TYPE_DIGEST 

Digest method will be used

Definition at line 570 of file res_pjsip.h.

570 {
572 /*!
573 * Credentials stored as a username and password combination
574 * \deprecated Now automatically determined
575 */
577 /*!
578 * Credentials stored as an MD5 sum
579 * \deprecated Use AST_SIP_AUTH_TYPE_DIGEST instead
580 */
582 /*! Google Oauth */
584 /*! Credentials not stored this is a fake auth */
586 /*! Digest method will be used */
588};

◆ 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 768 of file res_pjsip.h.

768 {
769 /*! Two bits for merge */
770 /*! Intersection of local and remote */
772 /*! Union of local and remote */
774
775 /*! Two bits for filter */
776 /*! No filter */
778 /*! Only the first */
780
781 /*! Two bits for preference and sort */
782 /*! Prefer, and order by local values */
784 /*! Prefer, and order by remote values */
786};

◆ 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 1333 of file res_pjsip.h.

1333 {
1334 /*! Authentication needs to be challenged */
1336 /*! Authentication succeeded */
1338 /*! Authentication failed */
1340 /*! Authentication encountered some internal error */
1342};

◆ 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 1432 of file res_pjsip.h.

1432 {
1433 /*! \brief Default filter flags */
1435
1436 /*! \brief Return only reachable or unknown contacts */
1438};

◆ 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 434 of file res_pjsip.h.

434 {
435 /*! Frequency > 0, but no response from remote uri */
437 /*! Frequency > 0, and got response from remote uri */
438 AVAILABLE,
439 /*! Default last status, and when a contact status object is not found */
440 UNKNOWN,
441 /*! Frequency == 0, has a contact, but don't know status (non-qualified) */
442 CREATED,
443 REMOVED,
444};

◆ 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 720 of file res_pjsip.h.

720 {
721 /*! Take no special action to mitigate reinvite glare */
723 /*! Do not send an initial direct media session refresh on outgoing call legs
724 * Subsequent session refreshes will be sent no matter the session direction
725 */
727 /*! Do not send an initial direct media session refresh on incoming call legs
728 * Subsequent session refreshes will be sent no matter the session direction
729 */
731};

◆ 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 545 of file res_pjsip.h.

545 {
546 /*! No DTMF to be used */
548 /* XXX Should this be 2833 instead? */
549 /*! Use RFC 4733 events for DTMF */
551 /*! Use DTMF in the audio stream */
553 /*! Use SIP INFO DTMF (blech) */
555 /*! Use SIP 4733 if supported by the other side or INBAND if not */
557 /*! Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not */
559};

◆ 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 699 of file res_pjsip.h.

699 {
700 /*! Identify based on user name in From header */
702 /*! Identify based on user name in Auth header first, then From header */
704 /*! Identify based on source IP address */
706 /*! Identify based on arbitrary headers */
708 /*! Identify based on request uri */
710};

◆ ast_sip_redirect_method

SIP methods that are allowed to follow 3xx redirects.

Used as bit flags in follow_redirect_methods field.

Enumerator
AST_SIP_REDIRECT_METHOD_MESSAGE 

Allow MESSAGE method to follow redirects

Definition at line 758 of file res_pjsip.h.

758 {
759 /*! Allow MESSAGE method to follow redirects */
761};

◆ 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 362 of file res_pjsip.h.

362 {
364 /* Use msrp-tls as security mechanism */
366 /* Use sdes-srtp as security mechanism */
368 /* Use dtls-srtp as security mechanism */
370 /* Add RFC 3329 (sec-agree) mechanisms like tle, digest, ipsec-ike in the future */
371};

◆ 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 351 of file res_pjsip.h.

351 {
352 /*! No security mechanism negotiation */
354 /*! Use mediasec security mechanism negotiation */
356 /* Add RFC 3329 (sec-agree) mechanism negotiation in the future */
357};

◆ 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 733 of file res_pjsip.h.

733 {
734 /*! Invalid media encryption configuration */
736 /*! Do not allow any encryption of session media */
738 /*! Offer SDES-encrypted session media */
740 /*! Offer encrypted session media with datagram TLS key exchange */
742};

◆ 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 744 of file res_pjsip.h.

744 {
745 /*! User portion of the target URI should be used as the target in the dialplan */
747 /*! Target URI should be used as the target in the dialplan */
749 /*! Target URI should be used as the target within chan_pjsip itself */
751};

◆ 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 713 of file res_pjsip.h.

713 {
714 /*! Use reinvite to negotiate direct media */
716 /*! Use UPDATE to negotiate direct media */
718};

◆ 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 3357 of file res_pjsip.h.

3357 {
3358 /*! Top priority. Supplements with this priority are those that need to run before any others */
3360 /*! Channel creation priority.
3361 * chan_pjsip creates a channel at this priority. If your supplement depends on being run before
3362 * or after channel creation, then set your priority to be lower or higher than this value.
3363 */
3365 /*! Lowest priority. Supplements with this priority should be run after all other supplements */
3367};

◆ 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 4129 of file res_pjsip.h.

4129 {
4130 /*! \brief Successfully registered the transport monitor */
4132 /*! \brief Replaced the already existing transport monitor with new one. */
4134 /*!
4135 * \brief Transport not found to monitor.
4136 * \note Transport is either already shutdown or is not reliable.
4137 */
4139 /*! \brief Error while registering transport monitor. */
4141};

◆ pjsip_auth_algorithm_type

Enumerator
PJSIP_AUTH_ALGORITHM_NOT_SET 
PJSIP_AUTH_ALGORITHM_MD5 
PJSIP_AUTH_ALGORITHM_SHA256 
PJSIP_AUTH_ALGORITHM_SHA512_256 
PJSIP_AUTH_ALGORITHM_AKAV1_MD5 
PJSIP_AUTH_ALGORITHM_COUNT 

Definition at line 606 of file res_pjsip.h.

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 2172 of file res_pjsip.c.

2173{
2174 size_t chars_to_copy = MIN(size - 1, pj_strlen(src));
2175 memcpy(dest, pj_strbuf(src), chars_to_copy);
2176 dest[chars_to_copy] = '\0';
2177}
#define MIN(a, b)
Definition utils.h:252

References MIN.

Referenced by apply_dtls_attrib(), apply_negotiated_sdp_stream(), 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(), change_outgoing_sdp_stream_media_address(), channel_read_pjsip(), cli_complete_subscription_common(), cli_list_subscriptions_detail(), cli_show_subscriptions_detail(), copy_string(), determine_sip_publish_type(), dialog_info_generate_body_content(), endpoint_lookup(), evaluate_like(), extract_contact_addr(), extract_contact_addr(), extract_oli(), find_aor2(), find_aor_name(), find_authorization(), 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(), 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_ari_request(), refer_incoming_blind_request(), refer_incoming_refer_request(), register_aor_core(), 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_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 2179 of file res_pjsip.c.

2180{
2181 int res = ast_asprintf(dest, "%.*s", (int)pj_strlen(src), pj_strbuf(src));
2182
2183 if (res < 0) {
2184 *dest = NULL;
2185 }
2186
2187 return res;
2188}
#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 981 of file pjsip_distributor.c.

982{
983 struct ast_sip_endpoint *endpoint = rdata->endpt_info.mod_data[endpoint_mod.id];
984 if (endpoint) {
985 ao2_ref(endpoint, +1);
986 }
987 return endpoint;
988}
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition astobj2.h:459
static pjsip_module endpoint_mod

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 2046 of file res_pjsip.c.

2047{
2048 pjsip_msg_body *pjsip_body = ast_body_to_pjsip_body(tdata->pool, body);
2049 tdata->msg->body = pjsip_body;
2050 return 0;
2051}
static pjsip_msg_body * ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
Definition res_pjsip.c:2033

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_message_to_uri(), 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 2053 of file res_pjsip.c.

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

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 84 of file res_pjsip.c.

85{
86 char date[256];
87 struct tm tm;
88 time_t t = time(NULL);
89
90 gmtime_r(&t, &tm);
91 strftime(date, sizeof(date), "%a, %d %b %Y %T GMT", &tm);
92
93 ast_sip_add_header(tdata, "Date", date);
94}
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:2002

References ast_sip_add_header(), and NULL.

Referenced by add_date_header(), and register_aor_core().

◆ 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 int add_header(struct header_list *headers, const char *name, const char *value, int replace)
static struct header_list request_headers

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 2002 of file res_pjsip.c.

2003{
2004 pj_str_t hdr_name;
2005 pj_str_t hdr_value;
2006 pjsip_generic_string_hdr *hdr;
2007
2008 pj_cstr(&hdr_name, name);
2009 pj_cstr(&hdr_value, value);
2010
2011 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2012
2013 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2014 return 0;
2015}

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(), outgoing_request(), rfc3326_add_reason_header(), send_options_response(), sip_publication_respond(), transfer_refer(), vars_to_headers(), 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 2017 of file res_pjsip.c.

2019{
2020 pj_str_t hdr_name;
2021 pj_str_t hdr_value;
2022 pjsip_generic_string_hdr *hdr;
2023
2024 pj_cstr(&hdr_name, name);
2025 pj_cstr(&hdr_value, value);
2026
2027 hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
2028
2029 pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
2030 return hdr;
2031}

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 264 of file security_agreements.c.

265 {
266 struct ast_sip_security_mechanism *mech;
267 char *buf;
268 int mech_cnt;
269 int i;
270 int add_qvalue = 1;
271 static const pj_str_t proxy_require = { "Proxy-Require", 13 };
272 static const pj_str_t require = { "Require", 7 };
273
274 if (!security_mechanisms || !tdata) {
275 return EINVAL;
276 }
277
278 if (!strcmp(header_name, "Security-Client")) {
279 add_qvalue = 0;
280 } else if (strcmp(header_name, "Security-Server") &&
281 strcmp(header_name, "Security-Verify")) {
282 return EINVAL;
283 }
284 /* If we're adding Security-Client headers, don't add q-value
285 * even if the function caller requested it. */
286 add_qvalue = add_qvalue && add_qval;
287
288 mech_cnt = AST_VECTOR_SIZE(security_mechanisms);
289 for (i = 0; i < mech_cnt; ++i) {
290 mech = AST_VECTOR_GET(security_mechanisms, i);
291 if (security_mechanism_to_str(mech, add_qvalue, &buf)) {
292 continue;
293 }
294 ast_sip_add_header(tdata, header_name, buf);
295 ast_free(buf);
296 }
297
298 if (pjsip_msg_find_hdr_by_name(tdata->msg, &require, NULL) == NULL) {
299 ast_sip_add_header(tdata, "Require", "mediasec");
300 }
301 if (pjsip_msg_find_hdr_by_name(tdata->msg, &proxy_require, NULL) == NULL) {
302 ast_sip_add_header(tdata, "Proxy-Require", "mediasec");
303 }
304 return 0;
305}
#define ast_free(a)
Definition astmm.h:180
static int security_mechanism_to_str(const struct ast_sip_security_mechanism *security_mechanism, int add_qvalue, char **buf)
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition vector.h:620
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition vector.h:691

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 924 of file res_pjsip.c.

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

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 2069 of file res_pjsip.c.

2070{
2071 size_t combined_size = strlen(body_text) + tdata->msg->body->len;
2072 struct ast_str *body_buffer = ast_str_alloca(combined_size);
2073
2074 ast_str_set(&body_buffer, 0, "%.*s%s", (int) tdata->msg->body->len, (char *) tdata->msg->body->data, body_text);
2075
2076 tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
2077 pj_memcpy(tdata->msg->body->data, ast_str_buffer(body_buffer), combined_size);
2078 tdata->msg->body->len = combined_size;
2079
2080 return 0;
2081}
#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
char *attribute_pure ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition strings.h:761

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 2190 of file res_pjsip.c.

2191{
2192 int rc = 0;
2193 if (a != NULL && b != NULL) {
2194 rc = pjsip_media_type_cmp(a, b, 0) ? 0 : 1;
2195 }
2196 return rc;
2197}

References a, b, and NULL.

Referenced by find_pidf(), and video_info_incoming_request().

◆ ast_sip_auth_digest_algorithms_vector_init()

int ast_sip_auth_digest_algorithms_vector_init ( const char *  id,
struct pjsip_auth_algorithm_type_vector algorithms,
const char *  agent_type,
const char *  value 
)

Populate a vector of algorithm types from a string.

Parameters
idThe object id to use in error messages
algorithmsThe initialized but empty vector to populate
agent_typeThe type of agent to use in error messages ("UAC" or "UAS")
valueThe comma-separated string to parse for algorithms
Return values
0Success
non-zeroFailure

Definition at line 192 of file config_auth.c.

195{
196 char *iana_names = ast_strdupa(value);
197 pj_str_t val;
198 int res = 0;
199
200 ast_assert(algorithms != NULL);
201
202 while ((val.ptr = ast_strip(strsep(&iana_names, ",")))) {
203 const pjsip_auth_algorithm *algo;
204
205 if (ast_strlen_zero(val.ptr)) {
206 continue;
207 }
208 val.slen = strlen(val.ptr);
209
211 if (!algo) {
212 ast_log(LOG_WARNING, "%s: Unknown %s digest algorithm '%s' specified\n",
213 id, agent_type, val.ptr);
214 res = -1;
215 continue;
216 }
218 ast_log(LOG_WARNING, "%s: %s digest algorithm '%s' is not supported by the version of OpenSSL in use\n",
219 id, agent_type, val.ptr);
220 res = -1;
221 continue;
222 }
223
224 if (AST_VECTOR_APPEND(algorithms, algo->algorithm_type)) {
225 AST_VECTOR_FREE(algorithms);
226 return -1;
227 }
228 }
229 return res;
230}
char * strsep(char **str, const char *delims)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition astmm.h:298
#define ast_log
Definition astobj2.c:42
const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_iana_name(const pj_str_t *iana_name)
Get algorithm by IANA name.
Definition config_auth.c:83
pj_bool_t ast_sip_auth_is_algorithm_supported(pjsip_auth_algorithm_type algorithm_type)
Is algorithm supported by OpenSSL and pjproject?
#define LOG_WARNING
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
#define ast_assert(a)
Definition utils.h:779
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition vector.h:185
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition vector.h:267

References agent_type, pjsip_auth_algorithm::algorithm_type, ast_assert, ast_log, ast_sip_auth_get_algorithm_by_iana_name(), ast_sip_auth_is_algorithm_supported(), ast_strdupa, ast_strip(), ast_strlen_zero(), AST_VECTOR_APPEND, AST_VECTOR_FREE, LOG_WARNING, NULL, strsep(), and value.

Referenced by alloc_artificial_auth(), auth_apply(), global_apply(), uac_algorithms_handler(), and uas_algorithms_handler().

◆ ast_sip_auth_digest_algorithms_vector_to_str()

int ast_sip_auth_digest_algorithms_vector_to_str ( const struct pjsip_auth_algorithm_type_vector algorithms,
char **  buf 
)

Dump a vector of algorithm types to a string.

Parameters
algorithmsThe vector to dump
[out]bufPointer to the buffer to dump the algorithms to Must be freed by the caller.
Return values
0Success
non-zeroFailure

Definition at line 248 of file config_auth.c.

250{
251 struct ast_str *str = NULL;
252 int i = 0;
253
254 if (!algorithms || !AST_VECTOR_SIZE(algorithms)) {
255 return 0;
256 }
257
258 str = ast_str_alloca(256);
259 if (!str) {
260 return -1;
261 }
262
263 for (i = 0; i < AST_VECTOR_SIZE(algorithms); ++i) {
265 AST_VECTOR_GET(algorithms, i));
266 ast_str_append(&str, 0, "%s" PJSTR_PRINTF_SPEC, i > 0 ? "," : "",
267 PJSTR_PRINTF_VAR(algo->iana_name));
268 }
269
271
272 return *buf ? 0 : -1;
273}
#define ast_strdup(str)
A wrapper for strdup()
Definition astmm.h:241
const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_type(pjsip_auth_algorithm_type algorithm_type)
Get algorithm by algorithm type.
Definition config_auth.c:66
#define PJSTR_PRINTF_VAR(_v)
Definition res_pjsip.h:72
#define PJSTR_PRINTF_SPEC
Definition res_pjsip.h:71
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

References ast_sip_auth_get_algorithm_by_type(), ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_strdup, AST_VECTOR_GET, AST_VECTOR_SIZE, buf, pjsip_auth_algorithm::iana_name, NULL, PJSTR_PRINTF_SPEC, PJSTR_PRINTF_VAR, and str.

Referenced by uac_algorithms_to_str(), and uas_algorithms_to_str().

◆ ast_sip_auth_get_algorithm_by_iana_name()

const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_iana_name ( const pj_str_t *  iana_name)

Get algorithm by IANA name.

Parameters
iana_nameThe algorithm IANA name
Return values
Thealgorithm or NULL if not found

Definition at line 83 of file config_auth.c.

85{
86#ifdef HAVE_PJSIP_AUTH_NEW_DIGESTS
87 return pjsip_auth_get_algorithm_by_iana_name(iana_name);
88#else
89 if (!iana_name) {
90 return NULL;
91 }
92 /*
93 * If we don't have a pjproject with the new algorithms, the
94 * only one we support is MD5. If iana_name is empty (but not NULL),
95 * the default is MD5.
96 */
97 if (iana_name->slen == 0 || pj_stricmp2(iana_name, "MD5") == 0) {
99 }
100 return NULL;
101#endif
102}
const pjsip_auth_algorithm pjsip_auth_algorithms[]
Definition config_auth.c:46

References NULL, PJSIP_AUTH_ALGORITHM_MD5, and pjsip_auth_algorithms.

Referenced by ast_sip_auth_digest_algorithms_vector_init(), digest_lookup(), get_supported_algorithm(), and password_digest_handler().

◆ ast_sip_auth_get_algorithm_by_type()

const pjsip_auth_algorithm * ast_sip_auth_get_algorithm_by_type ( pjsip_auth_algorithm_type  algorithm_type)

Get algorithm by algorithm type.

Parameters
algorithm_typeThe algorithm type
Return values
Thealgorithm or NULL if not found

Definition at line 66 of file config_auth.c.

68{
69#ifdef HAVE_PJSIP_AUTH_NEW_DIGESTS
70 return pjsip_auth_get_algorithm_by_type(algorithm_type);
71#else
72 /*
73 * If we don't have a pjproject with the new algorithms, the
74 * only one we support is MD5.
75 */
76 if (algorithm_type == PJSIP_AUTH_ALGORITHM_MD5) {
77 return &pjsip_auth_algorithms[algorithm_type];
78 }
79 return NULL;
80#endif
81}

References NULL, PJSIP_AUTH_ALGORITHM_MD5, and pjsip_auth_algorithms.

Referenced by ast_sip_auth_digest_algorithms_vector_to_str(), check_algorithm(), digest_check_auth(), and password_digest_to_str().

◆ ast_sip_auth_get_creds()

const char * ast_sip_auth_get_creds ( const struct ast_sip_auth auth,
const pjsip_auth_algorithm_type  algorithm_type,
int *  cred_type 
)

Get the plain text or digest password from an auth object.

Parameters
authThe auth object
algorithm_typeThe algorithm type to retrieve the password for
cred_type[out]Pointer to an int to receive the credential type
Note
cred_type will contain one of the following values:
  • PJSIP_CRED_DATA_DIGEST
  • PJSIP_CRED_DATA_PLAIN_PASSWD

If a password digest is available for the algorithm type it will be returned, otherwise if a plain text password is available that will be returned instead.

Return values
Theplain text or digest password or NULL if not found for the algorithm type

Definition at line 407 of file config_auth.c.

409{
410 struct ast_sip_auth_password_digest *pw_digest =
412
413 if (pw_digest) {
414 *cred_type = PJSIP_CRED_DATA_DIGEST;
415 return pw_digest->digest;
416 }
417
418 *cred_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
419 return auth->auth_pass;
420}

References ast_sip_auth_password_digest::algorithm_type, ast_sip_auth::auth_pass, ast_sip_auth_password_digest::digest, and ast_sip_auth::password_digests.

Referenced by digest_lookup(), and get_creds_for_header().

◆ ast_sip_auth_is_algorithm_available()

int ast_sip_auth_is_algorithm_available ( const struct ast_sip_auth auth,
const struct pjsip_auth_algorithm_type_vector algorithms,
pjsip_auth_algorithm_type  algorithm_type 
)

Checks an pjsip_auth_algorithm_type_vector to see if it contains an algorithm.

Parameters
authThe auth object
algorithmsThe auth object's supported_algorithms_uac or supported_algorithms_uas
algorithm_typeThe algorithm_type to check
Return values
1The algorithm-type is in the vector
0The algorithm-type is not in the vector

Definition at line 386 of file config_auth.c.

389{
390 int i;
391
392 if (!algorithms) {
393 return 0;
394 }
395
396 for (i = 0; i < AST_VECTOR_SIZE(algorithms); ++i) {
397 if (AST_VECTOR_GET(algorithms, i) == algorithm_type) {
398 if (auth->password_digests[algorithm_type] || !ast_strlen_zero(auth->auth_pass)) {
399 return 1;
400 }
401 }
402 }
403
404 return 0;
405}

References ast_strlen_zero(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_sip_auth::auth_pass, and ast_sip_auth::password_digests.

Referenced by digest_lookup(), and get_creds_for_header().

◆ ast_sip_auth_is_algorithm_supported()

pj_bool_t ast_sip_auth_is_algorithm_supported ( pjsip_auth_algorithm_type  algorithm_type)

Is algorithm supported by OpenSSL and pjproject?

Parameters
algorithm_typeThe algorithm IANA name
Return values
Thealgorithm or NULL if not found

Definition at line 104 of file config_auth.c.

106{
107#ifdef HAVE_PJSIP_AUTH_NEW_DIGESTS
108 return pjsip_auth_is_algorithm_supported(algorithm_type);
109#else
110 return algorithm_type == PJSIP_AUTH_ALGORITHM_MD5;
111#endif
112}

References PJSIP_AUTH_ALGORITHM_MD5.

Referenced by ast_sip_auth_digest_algorithms_vector_init(), get_supported_algorithm(), and password_digest_handler().

◆ 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 179 of file config_auth.c.

180{
182 auth_types_map[type] : "";
183}
static const char * auth_types_map[]
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
Definition utils.h:727

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_REMOVE_UNORDERED(vec, idx)
Remove an element from an unordered vector by index.
Definition vector.h:449

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}
void ast_sip_auth_vector_destroy(struct ast_sip_auth_vector *auths)
Free contents of an auth vector.
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition vector.h:124

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(), outbound_auth_handler(), outbound_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:2414
const char ** elems
Definition res_pjsip.h:694

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(), outbound_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 2525 of file res_pjsip.c.

2526{
2527 const char *value;
2528
2529 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)) {
2530 value = "local";
2531 } 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)) {
2532 value = "local_merge";
2533 } 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)) {
2534 value = "local_first";
2535 } 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)) {
2536 value = "remote";
2537 } 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)) {
2538 value = "remote_merge";
2539 } 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)) {
2540 value = "remote_first";
2541 } else {
2542 value = "unknown";
2543 }
2544
2545 return value;
2546}
#define ast_sip_call_codec_pref_test(__param, __codec_pref)
Returns true if the preference is set in the parameter.
Definition res_pjsip.h:797

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 2548 of file res_pjsip.c.

2549{
2550 pref->flags = 0;
2551
2552 if (strcmp(pref_str, "local") == 0) {
2554 } else if (is_outgoing && strcmp(pref_str, "local_merge") == 0) {
2556 } else if (strcmp(pref_str, "local_first") == 0) {
2558 } else if (strcmp(pref_str, "remote") == 0) {
2560 } else if (is_outgoing && strcmp(pref_str, "remote_merge") == 0) {
2562 } else if (strcmp(pref_str, "remote_first") == 0) {
2564 } else {
2565 return -1;
2566 }
2567
2568 return 0;
2569}
unsigned int flags
Definition utils.h:221
#define ast_set_flag(p, flag)
Definition utils.h:71

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 173 of file res_pjsip.c.

175{
177 ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is successful\n");
179 }
180 return registered_authenticator->check_authentication(endpoint, rdata, tdata);
181}
static struct ast_sip_authenticator * registered_authenticator
Definition res_pjsip.c:132

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 2619 of file pjsip_configuration.c.

2620{
2621 int i;
2622 for (i = 0; i < num_auths; ++i) {
2623 ao2_cleanup(auths[i]);
2624 }
2625}
#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 771 of file location.c.

772{
773 struct ast_sip_contact_wrapper *wrapper = object;
774 struct ast_str **buf = arg;
775
776 ast_str_append(buf, 0, "%s,", wrapper->contact_id);
777
778 return 0;
779}

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 1800 of file pjsip_configuration.c.

1801{
1803
1804 if (!(buf)) {
1805 astman_send_error_va(ami->s, ami->m, "Unable create event "
1806 "for %s\n", event);
1807 return NULL;
1808 }
1809
1810 ast_str_set(&buf, 0, "Event: %s\r\n", event);
1811 if (!ast_strlen_zero(ami->action_id)) {
1812 ast_str_append(&buf, 0, "ActionID: %s\r\n", ami->action_id);
1813 }
1814 return buf;
1815}
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:1987
#define AMI_DEFAULT_STR_SIZE
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition strings.h:659

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 958 of file res_pjsip.c.

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

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, and sip_dialog_create_from().

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 1170 of file res_pjsip.c.

1171{
1172#ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
1173 pjsip_dialog *dlg;
1174
1175 dlg = create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas_and_inc_lock);
1176 if (dlg) {
1177 pjsip_dlg_dec_lock(dlg);
1178 }
1179
1180 return dlg;
1181#else
1182 return create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas);
1183#endif
1184}
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:1112

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 1186 of file res_pjsip.c.

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

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 1260 of file res_pjsip.c.

1262{
1263 return ast_sip_create_rdata_with_contact(rdata, packet, src_name, src_port, transport_type,
1264 local_name, local_port, NULL);
1265}
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:1208

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 1208 of file res_pjsip.c.

1210{
1211 pj_str_t tmp;
1212
1213 /*
1214 * Initialize the error list in case there is a parse error
1215 * in the given packet.
1216 */
1217 pj_list_init(&rdata->msg_info.parse_err);
1218
1219 rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
1220 if (!rdata->tp_info.transport) {
1221 return -1;
1222 }
1223
1224 ast_copy_string(rdata->pkt_info.packet, packet, sizeof(rdata->pkt_info.packet));
1225 ast_copy_string(rdata->pkt_info.src_name, src_name, sizeof(rdata->pkt_info.src_name));
1226 rdata->pkt_info.src_port = src_port;
1227 pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
1228 pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
1229
1230 pjsip_parse_rdata(packet, strlen(packet), rdata);
1231 if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
1232 return -1;
1233 }
1234
1235 if (!ast_strlen_zero(contact)) {
1236 pjsip_contact_hdr *contact_hdr;
1237
1238 contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
1239 if (contact_hdr) {
1240 contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (char *)contact,
1241 strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
1242 if (!contact_hdr->uri) {
1243 ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact);
1244 return -1;
1245 }
1246 }
1247 }
1248
1249 pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
1250 rdata->msg_info.via->rport_param = -1;
1251
1252 rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
1253 rdata->tp_info.transport->type_name = transport_type;
1254 pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
1255 rdata->tp_info.transport->local_name.port = local_port;
1256
1257 return 0;
1258}
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, and NULL.

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 1429 of file res_pjsip.c.

1432{
1433 const pjsip_method *pmethod = get_pjsip_method(method);
1434
1435 if (!pmethod) {
1436 ast_log(LOG_WARNING, "Unknown method '%s'. Cannot send request\n", method);
1437 return -1;
1438 }
1439
1440 if (dlg) {
1441 return create_in_dialog_request(pmethod, dlg, tdata);
1442 } else {
1443 ast_assert(endpoint != NULL);
1444 return create_out_of_dialog_request(pmethod, endpoint, uri, contact, tdata);
1445 }
1446}
static int create_in_dialog_request(const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata)
Definition res_pjsip.c:1301
static const pjsip_method * get_pjsip_method(const char *method)
Definition res_pjsip.c:1290
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:1319
const pjsip_method * pmethod
Definition res_pjsip.c:1274

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_message_to_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 208 of file res_pjsip.c.

210{
212 ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
213 return -1;
214 }
215 return registered_outbound_authenticator->create_request_with_auth(auths, challenge, old_request, new_request);
216}
static struct ast_sip_outbound_authenticator * registered_outbound_authenticator
Definition res_pjsip.c:183

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 2439 of file res_pjsip.c.

2441{
2442 int res = pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, st_code, NULL, tdata);
2443
2444 if (!res) {
2445 ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
2446 }
2447
2448 return res;
2449}
#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:514
static pjsip_module supplement_module
Definition res_pjsip.c:1312
#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:3124

References ao2_bump, ast_sip_get_pjsip_endpoint(), ast_sip_mod_data_set, MOD_DATA_CONTACT, NULL, and supplement_module.

Referenced by register_aor_core(), 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 2595 of file pjsip_configuration.c.

2596{
2599 sip_sorcery, "endpoint", name);
2600}
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:1917
#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:981

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 2298 of file res_pjsip.c.

2299{
2300 unsigned int hval = 0;
2301
2302 if (!ht) {
2303 return NULL;
2304 }
2305
2306 return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
2307}

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 2309 of file res_pjsip.c.

2311{
2312 if (!ht) {
2313 ht = pj_hash_create(pool, 11);
2314 }
2315
2316 pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0, val);
2317
2318 return ht;
2319}

◆ 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 721 of file res_pjsip.c.

723{
724 pjsip_sip_uri *uri;
725 pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
726
727 uri = pjsip_uri_get_uri(dlg->target);
728 if (!selector) {
729 selector = &sel;
730 }
731
732 ast_sip_set_tpselector_from_ep_or_uri(endpoint, uri, selector);
733
734 pjsip_dlg_set_transport(dlg, selector);
735
736 if (selector == &sel) {
738 }
739
740 return 0;
741}
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:905

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 2475 of file res_pjsip.c.

2477{
2478 switch (dtmf) {
2479 case AST_SIP_DTMF_NONE:
2480 ast_copy_string(buf, "none", buf_len);
2481 break;
2483 ast_copy_string(buf, "rfc4733", buf_len);
2484 break;
2486 ast_copy_string(buf, "inband", buf_len);
2487 break;
2488 case AST_SIP_DTMF_INFO:
2489 ast_copy_string(buf, "info", buf_len);
2490 break;
2491 case AST_SIP_DTMF_AUTO:
2492 ast_copy_string(buf, "auto", buf_len);
2493 break;
2495 ast_copy_string(buf, "auto_info", buf_len);
2496 break;
2497 default:
2498 buf[0] = '\0';
2499 return -1;
2500 }
2501 return 0;
2502}

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 2534 of file pjsip_configuration.c.

2535{
2536 struct ast_sip_endpoint *endpoint = ast_sorcery_generic_alloc(sizeof(*endpoint), endpoint_destructor);
2537 if (!endpoint) {
2538 return NULL;
2539 }
2540 if (ast_string_field_init(endpoint, 128)) {
2541 ao2_cleanup(endpoint);
2542 return NULL;
2543 }
2544
2545 if (ast_string_field_init_extended(endpoint, geoloc_incoming_call_profile) ||
2546 ast_string_field_init_extended(endpoint, geoloc_outgoing_call_profile)) {
2547 ao2_cleanup(endpoint);
2548 return NULL;
2549 }
2550 if (ast_string_field_init_extended(endpoint, overlap_context)) {
2551 ao2_cleanup(endpoint);
2552 return NULL;
2553 }
2554 if (ast_string_field_init_extended(endpoint, tenantid)) {
2555 ao2_cleanup(endpoint);
2556 return NULL;
2557 }
2558
2560 ao2_cleanup(endpoint);
2561 return NULL;
2562 }
2564 ao2_cleanup(endpoint);
2565 return NULL;
2566 }
2567 if (init_info_configuration(&endpoint->info)) {
2568 ao2_cleanup(endpoint);
2569 return NULL;
2570 }
2571 if (init_media_configuration(&endpoint->media)) {
2572 ao2_cleanup(endpoint);
2573 return NULL;
2574 }
2575
2576 ast_party_id_init(&endpoint->id.self);
2577 endpoint->id.self.tag = ast_strdup("");
2578
2579 if (AST_VECTOR_INIT(&endpoint->ident_method_order, 1)) {
2580 return NULL;
2581 }
2582
2583 return endpoint;
2584}
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition channel.c:1743
@ 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:1792
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define ast_string_field_init_extended(x, field)
Initialize an extended string field.
char * tag
User-set "tag".
Definition channel.h:356

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 1810 of file res_pjsip.c.

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

References NULL, and send_request_wrapper::tdata.

Referenced by check_request_status(), 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 589 of file res_pjsip.c.

589 {
591
593 return NULL;
594 }
595
597}
#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:570

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 688 of file location.c.

689{
690 char *copy;
691 char *name;
692 int res;
693
694 if (!on_aor || ast_strlen_zero(aors)) {
695 return 0;
696 }
697
698 copy = ast_strdupa(aors);
699 while ((name = ast_strip(strsep(&copy, ",")))) {
700 struct ast_sip_aor *aor;
701
703 if (aor) {
704 res = on_aor(aor, arg, 0);
705 ao2_ref(aor, -1);
706 if (res) {
707 return -1;
708 }
709 }
710 }
711 return 0;
712}
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

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 484 of file config_auth.c.

486{
487 int i;
488
489 if (!vector || !AST_VECTOR_SIZE(vector)) {
490 return 0;
491 }
492
493 for (i = 0; i < AST_VECTOR_SIZE(vector); ++i) {
494 /* AST_VECTOR_GET is safe to use since the vector is immutable */
497 AST_VECTOR_GET(vector,i)), ao2_cleanup);
498
499 if (!auth) {
500 continue;
501 }
502
503 if (on_auth(auth, arg, 0)) {
504 return -1;
505 }
506 }
507
508 return 0;
509}
#define SIP_SORCERY_AUTH_TYPE
Definition res_pjsip.h:597

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 1779 of file pjsip_configuration.c.

1782{
1783 RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup);
1784 return ast_sip_for_each_channel_snapshot(endpoint_snapshot, on_channel_snapshot, arg);
1785}
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.

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 1752 of file pjsip_configuration.c.

1755{
1756 int num, num_channels = endpoint_snapshot->num_channels;
1757
1758 if (!on_channel_snapshot || !num_channels) {
1759 return 0;
1760 }
1761
1762 for (num = 0; num < num_channels; ++num) {
1763 RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
1764 int res;
1765
1766 snapshot = ast_channel_snapshot_get_latest(endpoint_snapshot->channel_ids[num]);
1767 if (!snapshot) {
1768 continue;
1769 }
1770
1771 res = on_channel_snapshot(snapshot, arg, 0);
1772 if (res) {
1773 return -1;
1774 }
1775 }
1776 return 0;
1777}
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 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 723 of file location.c.

725{
726 struct ao2_container *contacts;
727 struct ao2_iterator i;
728 int res = 0;
729 void *object = NULL;
730
731 if (!on_contact ||
732 !(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
733 return 0;
734 }
735
736 i = ao2_iterator_init(contacts, 0);
737 while ((object = ao2_iterator_next(&i))) {
738 RAII_VAR(struct ast_sip_contact *, contact, object, ao2_cleanup);
740 const char *aor_id = ast_sorcery_object_get_id(aor);
741
742 wrapper = ao2_alloc_options(sizeof(struct ast_sip_contact_wrapper),
744 if (!wrapper) {
745 res = -1;
746 break;
747 }
748 wrapper->contact_id = ast_malloc(strlen(aor_id) + strlen(contact->uri) + 2);
749 if (!wrapper->contact_id) {
750 res = -1;
751 break;
752 }
753 sprintf(wrapper->contact_id, "%s/%s", aor_id, contact->uri);
754 wrapper->aor_id = ast_strdup(aor_id);
755 if (!wrapper->aor_id) {
756 res = -1;
757 break;
758 }
759 wrapper->contact = contact;
760 ao2_bump(wrapper->contact);
761
762 if ((res = on_contact(wrapper, arg, 0))) {
763 break;
764 }
765 }
767 ao2_ref(contacts, -1);
768 return res;
769}
#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:714
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

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 544 of file config_auth.c.

546{
548}
static int format_ami_auth_handler(void *obj, void *arg, int flags)
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.

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 2730 of file pjsip_options.c.

2731{
2732 struct ast_sip_contact_wrapper *wrapper = obj;
2733 struct ast_sip_contact *contact = wrapper->contact;
2734 struct ast_sip_ami *ami = arg;
2736 struct ast_str *buf;
2737 const struct ast_sip_endpoint *endpoint = ami->arg;
2738 char secs[AST_TIME_T_LEN];
2739
2740 buf = ast_sip_create_ami_event("ContactStatusDetail", ami);
2741 if (!buf) {
2742 return -1;
2743 }
2744
2746
2747 ast_str_append(&buf, 0, "AOR: %s\r\n", wrapper->aor_id);
2748 ast_str_append(&buf, 0, "URI: %s\r\n", contact->uri);
2749 ast_str_append(&buf, 0, "UserAgent: %s\r\n", contact->user_agent);
2750 ast_time_t_to_string(contact->expiration_time.tv_sec, secs, sizeof(secs));
2751 ast_str_append(&buf, 0, "RegExpire: %s\r\n", secs);
2752 if (!ast_strlen_zero(contact->via_addr)) {
2753 ast_str_append(&buf, 0, "ViaAddress: %s", contact->via_addr);
2754 if (contact->via_port) {
2755 ast_str_append(&buf, 0, ":%d", contact->via_port);
2756 }
2757 ast_str_append(&buf, 0, "\r\n");
2758 }
2759 if (!ast_strlen_zero(contact->call_id)) {
2760 ast_str_append(&buf, 0, "CallID: %s\r\n", contact->call_id);
2761 }
2762 ast_str_append(&buf, 0, "Status: %s\r\n",
2764 if (!status || status->status != AVAILABLE) {
2765 ast_str_append(&buf, 0, "RoundtripUsec: N/A\r\n");
2766 } else {
2767 ast_str_append(&buf, 0, "RoundtripUsec: %" PRId64 "\r\n", status->rtt);
2768 }
2769 ast_str_append(&buf, 0, "EndpointName: %s\r\n",
2770 endpoint ? ast_sorcery_object_get_id(endpoint) : S_OR(contact->endpoint_name, ""));
2771
2772 ast_str_append(&buf, 0, "ID: %s\r\n", ast_sorcery_object_get_id(contact));
2773 ast_str_append(&buf, 0, "AuthenticateQualify: %d\r\n", contact->authenticate_qualify);
2774 ast_str_append(&buf, 0, "OutboundProxy: %s\r\n", contact->outbound_proxy);
2775 ast_str_append(&buf, 0, "Path: %s\r\n", contact->path);
2776 ast_str_append(&buf, 0, "QualifyFrequency: %u\r\n", contact->qualify_frequency);
2777 ast_str_append(&buf, 0, "QualifyTimeout: %.3f\r\n", contact->qualify_timeout);
2778 ast_str_append(&buf, 0, "Qualify2xxOnly: %d\r\n", contact->qualify_2xx_only);
2779
2780 astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
2781 ami->count++;
2782
2783 ast_free(buf);
2785 return 0;
2786}
void astman_append(struct mansession *s, const char *fmt,...)
Definition manager.c:1903
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.
#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
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_2xx_only, 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 495 of file res_pjsip.c.

497{
498 int res = 0;
501 *count = 0;
503 if (i->format_ami && ((res = i->format_ami(endpoint, ami)) < 0)) {
504 return res;
505 }
506
507 if (!res) {
508 (*count)++;
509 }
510 }
511 return 0;
512}
ast_mutex_t lock
Definition app_sla.c:337
#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.
#define AST_RWLIST_TRAVERSE
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition lock.h:590

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sip_endpoint_formatter::format_ami, lock, ast_sip_endpoint_formatter::next, 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 596 of file config_global.c.

597{
598 unsigned int all_codecs_on_empty_reinvite;
599 struct global_config *cfg;
600
601 cfg = get_global_cfg();
602 if (!cfg) {
604 }
605
607 ao2_ref(cfg, -1);
609}
static struct global_config * get_global_cfg(void)
#define DEFAULT_ALL_CODECS_ON_EMPTY_REINVITE
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 506 of file config_global.c.

507{
508 unsigned int allow_sending_180_after_183;
509 struct global_config *cfg;
510
511 cfg = get_global_cfg();
512 if (!cfg) {
514 }
515
517 ao2_ref(cfg, -1);
519}
#define DEFAULT_ALLOW_SENDING_180_AFTER_183
unsigned int allow_sending_180_after_183

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 643 of file pjsip_distributor.c.

644{
645 return ao2_global_obj_ref(artificial_auth);
646}
#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().

◆ 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 666 of file pjsip_distributor.c.

667{
669 return artificial_endpoint;
670}
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 342 of file config_global.c.

343{
344 unsigned int interval;
345 struct global_config *cfg;
346
347 cfg = get_global_cfg();
348 if (!cfg) {
350 }
351
352 interval = cfg->contact_expiration_check_interval;
353 ao2_ref(cfg, -1);
354 return interval;
355}
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL
unsigned int contact_expiration_check_interval

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 341 of file pjsip_options.c.

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

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 558 of file res_pjsip.c.

559{
560 pjsip_contact_hdr *contact = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_CONTACT, NULL);
561
562 if (!contact || (!PJSIP_URI_SCHEME_IS_SIP(contact->uri) && !PJSIP_URI_SCHEME_IS_SIPS(contact->uri))) {
563 return NULL;
564 }
565
566 return pjsip_uri_get_uri(contact->uri);
567}

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 527 of file pjsip_options.c.

528{
531}
#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 265 of file config_global.c.

266{
267 char *res;
268 struct global_config *cfg;
269
270 cfg = get_global_cfg();
271 if (!cfg) {
273 }
274
275 res = ast_strdup(cfg->debug);
276 ao2_ref(cfg, -1);
277 return res;
278}
#define DEFAULT_DEBUG
const ast_string_field debug

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

Referenced by check_debug().

◆ ast_sip_get_default_auth_algorithms_uac()

void ast_sip_get_default_auth_algorithms_uac ( char *  default_auth_algorithms_uac,
size_t  size 
)

Retrieve the global auth algorithms for UAC.

Parameters
[out]default_auth_algorithms_uacThe default algorithms
sizeThe buffer size of default_auth_algorithms_uac

Definition at line 434 of file config_global.c.

435{
436 struct global_config *cfg;
437
438 cfg = get_global_cfg();
439 if (!cfg) {
441 } else {
443 ao2_ref(cfg, -1);
444 }
445}
#define DEFAULT_AUTH_ALGORITHMS_UAC
const ast_string_field default_auth_algorithms_uac

References ao2_ref, ast_copy_string(), DEFAULT_AUTH_ALGORITHMS_UAC, global_config::default_auth_algorithms_uac, and get_global_cfg().

Referenced by auth_apply(), and create_artificial_auth().

◆ ast_sip_get_default_auth_algorithms_uas()

void ast_sip_get_default_auth_algorithms_uas ( char *  default_auth_algorithms_uas,
size_t  size 
)

Retrieve the global auth algorithms for UAS.

Parameters
[out]default_auth_algorithms_uasThe default algorithms
sizeThe buffer size of default_auth_algorithms_uas

Definition at line 421 of file config_global.c.

422{
423 struct global_config *cfg;
424
425 cfg = get_global_cfg();
426 if (!cfg) {
428 } else {
430 ao2_ref(cfg, -1);
431 }
432}
#define DEFAULT_AUTH_ALGORITHMS_UAS
const ast_string_field default_auth_algorithms_uas

References ao2_ref, ast_copy_string(), DEFAULT_AUTH_ALGORITHMS_UAS, global_config::default_auth_algorithms_uas, and get_global_cfg().

Referenced by auth_apply(), and create_artificial_auth().

◆ 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 447 of file config_global.c.

448{
449 struct global_config *cfg;
450
451 cfg = get_global_cfg();
452 if (!cfg) {
453 ast_copy_string(from_user, DEFAULT_FROM_USER, size);
454 } else {
455 ast_copy_string(from_user, cfg->default_from_user, size);
456 ao2_ref(cfg, -1);
457 }
458}
#define DEFAULT_FROM_USER
const ast_string_field default_from_user

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 408 of file config_global.c.

409{
410 struct global_config *cfg;
411
412 cfg = get_global_cfg();
413 if (!cfg) {
414 ast_copy_string(realm, DEFAULT_REALM, size);
415 } else {
416 ast_copy_string(realm, cfg->default_realm, size);
417 ao2_ref(cfg, -1);
418 }
419}
#define DEFAULT_REALM
const ast_string_field default_realm

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 296 of file config_global.c.

297{
298 char *res;
299 struct global_config *cfg;
300
301 cfg = get_global_cfg();
302 if (!cfg) {
304 }
305
307 ao2_ref(cfg, -1);
308
309 return res;
310}
#define DEFAULT_VOICEMAIL_EXTENSION
const ast_string_field default_voicemail_extension

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 1736 of file pjsip_configuration.c.

1737{
1738 char device[MAX_OBJECT_FIELD];
1739
1740 snprintf(device, MAX_OBJECT_FIELD, "PJSIP/%s", ast_sorcery_object_get_id(endpoint));
1741 return ast_devstate2str(ast_device_state(device));
1742}
const char * ast_devstate2str(enum ast_device_state devstate) attribute_pure
Convert device state to text string for output.
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 357 of file config_global.c.

358{
359 unsigned int disable_multi_domain;
360 struct global_config *cfg;
361
362 cfg = get_global_cfg();
363 if (!cfg) {
365 }
366
368 ao2_ref(cfg, -1);
370}
#define DEFAULT_DISABLE_MULTI_DOMAIN
unsigned int disable_multi_domain

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 3220 of file res_pjsip.c.

3221{
3222 char *destination;
3223 char *slash = NULL;
3224 char *atsign = NULL;
3225 char *scheme = NULL;
3226 struct ast_sip_endpoint *endpoint = NULL;
3227
3228 destination = ast_strdupa(to);
3229
3230 slash = strchr(destination, '/');
3231 atsign = strchr(destination, '@');
3232 scheme = S_OR(strstr(destination, "sip:"), strstr(destination, "sips:"));
3233
3234 if (!slash && !atsign && !scheme) {
3235 /*
3236 * If there's only a single token, it can be either...
3237 * endpoint
3238 * host
3239 */
3240 return handle_single_token(to, destination, get_default_outbound, uri);
3241 }
3242
3243 if (slash) {
3244 /*
3245 * If there's a '/', then the form must be one of the following...
3246 * PJSIP/user@endpoint
3247 * endpoint/aor
3248 * endpoint/uri
3249 */
3250 return handle_slash(to, destination, uri, slash, atsign, scheme);
3251 }
3252
3253 if (atsign && !scheme) {
3254 /*
3255 * If there's an '@' but no scheme then it's either following an endpoint name
3256 * and being followed by a domain name (which we discard).
3257 * OR is's a user@host uri without a scheme. It's probably the latter but because
3258 * endpoint@domain looks just like user@host, we'll test for endpoint first.
3259 */
3260 return handle_atsign(to, destination, uri, slash, atsign, scheme, get_default_outbound);
3261 }
3262
3263 /*
3264 * If all else fails, we assume it's a URI or just a hostname.
3265 */
3266 if (scheme) {
3267 *uri = ast_strdup(destination);
3268 if (!(*uri)) {
3269 goto failure;
3270 }
3271 ast_debug(3, "Dest: '%s' Didn't find an endpoint but did find a scheme so using URI '%s'%s\n",
3272 to, *uri, get_default_outbound ? " with default endpoint" : "");
3273 } else {
3274 *uri = ast_malloc(strlen(destination) + strlen("sip:") + 1);
3275 if (!(*uri)) {
3276 goto failure;
3277 }
3278 sprintf(*uri, "sip:%s", destination);
3279 ast_debug(3, "Dest: '%s' Didn't find an endpoint and didn't find scheme so adding scheme and using URI '%s'%s\n",
3280 to, *uri, get_default_outbound ? " with default endpoint" : "");
3281 }
3282 if (get_default_outbound) {
3284 }
3285
3286 return endpoint;
3287
3288failure:
3289 ao2_cleanup(endpoint);
3290 *uri = NULL;
3291 return NULL;
3292}
#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:3005
static struct ast_sip_endpoint * handle_single_token(const char *to, char *destination, int get_default_outbound, char **uri)
Definition res_pjsip.c:2926
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:3162

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 312 of file config_global.c.

313{
314 char *res;
315 struct global_config *cfg;
316
317 cfg = get_global_cfg();
318 if (!cfg) {
320 }
321
323 ao2_ref(cfg, -1);
324 return res;
325}
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER
const ast_string_field endpoint_identifier_order

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 1744 of file pjsip_configuration.c.

1746{
1750}
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.

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 2586 of file pjsip_configuration.c.

2587{
2588 struct ao2_container *endpoints;
2589
2591
2592 return endpoints;
2593}
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:1961

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 2451 of file res_pjsip.c.

2452{
2453 if (af == pj_AF_INET() && !ast_strlen_zero(host_ip_ipv4_string)) {
2454 pj_sockaddr_copy_addr(addr, &host_ip_ipv4);
2455 return 0;
2456 } else if (af == pj_AF_INET6() && !ast_strlen_zero(host_ip_ipv6_string)) {
2457 pj_sockaddr_copy_addr(addr, &host_ip_ipv6);
2458 return 0;
2459 }
2460
2461 return -1;
2462}
static pj_sockaddr host_ip_ipv4
Definition res_pjsip.c:73
static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN]
Definition res_pjsip.c:82
static pj_sockaddr host_ip_ipv6
Definition res_pjsip.c:79
static char host_ip_ipv4_string[PJ_INET6_ADDRSTRLEN]
Definition res_pjsip.c:76

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 2464 of file res_pjsip.c.

2465{
2466 if (af == pj_AF_INET()) {
2467 return host_ip_ipv4_string;
2468 } else if (af == pj_AF_INET6()) {
2469 return host_ip_ipv6_string;
2470 }
2471
2472 return NULL;
2473}

References host_ip_ipv4_string, host_ip_ipv6_string, and NULL.

Referenced by create_local_sdp(), create_outgoing_sdp_stream(), 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 521 of file config_global.c.

522{
523 unsigned int ignore_uri_user_options;
524 struct global_config *cfg;
525
526 cfg = get_global_cfg();
527 if (!cfg) {
529 }
530
532 ao2_ref(cfg, -1);
534}
#define DEFAULT_IGNORE_URI_USER_OPTIONS
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 327 of file config_global.c.

328{
329 unsigned int interval;
330 struct global_config *cfg;
331
332 cfg = get_global_cfg();
333 if (!cfg) {
335 }
336
337 interval = cfg->keep_alive_interval;
338 ao2_ref(cfg, -1);
339 return interval;
340}
#define DEFAULT_KEEPALIVE_INTERVAL
unsigned int keep_alive_interval

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 372 of file config_global.c.

373{
374 unsigned int time;
375 struct global_config *cfg;
376
377 cfg = get_global_cfg();
378 if (!cfg) {
380 }
381
382 time = cfg->max_initial_qualify_time;
383 ao2_ref(cfg, -1);
384 return time;
385}
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME
unsigned int max_initial_qualify_time

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 491 of file config_global.c.

492{
493 unsigned int disable_initial_unsolicited;
494 struct global_config *cfg;
495
496 cfg = get_global_cfg();
497 if (!cfg) {
499 }
500
502 ao2_ref(cfg, -1);
504}
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED
unsigned int disable_initial_unsolicited
struct global_config::@489 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 461 of file config_global.c.

462{
463 unsigned int tps_queue_high;
464 struct global_config *cfg;
465
466 cfg = get_global_cfg();
467 if (!cfg) {
469 }
470
472 ao2_ref(cfg, -1);
473 return tps_queue_high;
474}
#define DEFAULT_MWI_TPS_QUEUE_HIGH
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 476 of file config_global.c.

477{
478 int tps_queue_low;
479 struct global_config *cfg;
480
481 cfg = get_global_cfg();
482 if (!cfg) {
484 }
485
487 ao2_ref(cfg, -1);
488 return tps_queue_low;
489}
#define DEFAULT_MWI_TPS_QUEUE_LOW

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 581 of file config_global.c.

582{
583 unsigned int norefersub;
584 struct global_config *cfg;
585
586 cfg = get_global_cfg();
587 if (!cfg) {
588 return DEFAULT_NOREFERSUB;
589 }
590
591 norefersub = cfg->norefersub;
592 ao2_ref(cfg, -1);
593 return norefersub;
594}
#define DEFAULT_NOREFERSUB
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 514 of file res_pjsip.c.

515{
516 return ast_pjsip_endpoint;
517}
static pjsip_endpoint * ast_pjsip_endpoint
Definition res_pjsip.c:68

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(), load_module(), load_module(), load_module(), load_module(), load_module(), 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(), register_aor_core(), 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 280 of file config_global.c.

281{
282 char *res;
283 struct global_config *cfg;
284
285 cfg = get_global_cfg();
286 if (!cfg) {
288 }
289
290 res = ast_strdup(cfg->regcontext);
291 ao2_ref(cfg, -1);
292
293 return res;
294}
#define DEFAULT_REGCONTEXT
const ast_string_field regcontext

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 551 of file config_global.c.

552{
553 unsigned int send_contact_status_on_update_registration;
554 struct global_config *cfg;
555
556 cfg = get_global_cfg();
557 if (!cfg) {
559 }
560
562 ao2_ref(cfg, -1);
564}
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION
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 2646 of file pjsip_configuration.c.

2647{
2648 return sip_sorcery;
2649}

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_auth(), 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_get_container(), cli_get_container(), cli_get_container(), cli_iterate(), cli_iterator(), cli_qualify(), cli_reload_qualify_aor(), cli_reload_qualify_endpoint(), cli_retrieve_by_id(), cli_retrieve_by_id(), cli_retrieve_by_id(), 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(), global_loaded(), handle_atsign(), handle_export_primitives(), handle_registration_response(), handle_single_token(), handle_slash(), line_identify(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), 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(), register_aor_core(), reload_module(), reload_module(), reload_module(), reload_module(), 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(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), 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 692 of file res_pjsip.c.

694{
695 char *host = NULL;
696 static const pj_str_t x_name = { AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN };
697 pjsip_param *x_transport;
698
699 if (!ast_strlen_zero(endpoint->transport)) {
700 ast_copy_string(buf, endpoint->transport, buf_len);
701 return 0;
702 }
703
704 x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
705 if (!x_transport) {
706 return -1;
707 }
708
709 /* Only use x_transport if the uri host is an ip (4 or 6) address */
710 host = ast_alloca(sip_uri->host.slen + 1);
711 ast_copy_pj_str(host, &sip_uri->host, sip_uri->host.slen + 1);
713 return -1;
714 }
715
716 ast_copy_pj_str(buf, &x_transport->value, buf_len);
717
718 return 0;
719}
#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:2172
#define AST_SIP_X_AST_TXP
Definition res_pjsip.h:1182
#define AST_SIP_X_AST_TXP_LEN
Definition res_pjsip.h:1183

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

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(), 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 387 of file config_global.c.

389{
390 struct global_config *cfg;
391
392 cfg = get_global_cfg();
393 if (!cfg) {
397 return;
398 }
399
400 *count = cfg->unidentified_request_count;
401 *period = cfg->unidentified_request_period;
402 *prune_interval = cfg->unidentified_request_prune_interval;
403
404 ao2_ref(cfg, -1);
405 return;
406}
#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT
#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL
#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD
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 536 of file config_global.c.

537{
538 unsigned int use_callerid_contact;
539 struct global_config *cfg;
540
541 cfg = get_global_cfg();
542 if (!cfg) {
544 }
545
547 ao2_ref(cfg, -1);
549}
#define DEFAULT_USE_CALLERID_CONTACT
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 3521 of file res_pjsip.c.

3522{
3523 /* Possible values taken from causes.h */
3524
3525 switch(cause) {
3526 case 401: /* Unauthorized */
3528 case 403: /* Not found */
3530 case 404: /* Not found */
3531 return AST_CAUSE_UNALLOCATED;
3532 case 405: /* Method not allowed */
3534 case 407: /* Proxy authentication required */
3536 case 408: /* No reaction */
3538 case 409: /* Conflict */
3540 case 410: /* Gone */
3542 case 411: /* Length required */
3544 case 413: /* Request entity too large */
3546 case 414: /* Request URI too large */
3548 case 415: /* Unsupported media type */
3550 case 420: /* Bad extension */
3552 case 480: /* No answer */
3553 return AST_CAUSE_NO_ANSWER;
3554 case 481: /* No answer */
3556 case 482: /* Loop detected */
3558 case 483: /* Too many hops */
3559 return AST_CAUSE_NO_ANSWER;
3560 case 484: /* Address incomplete */
3562 case 485: /* Ambiguous */
3563 return AST_CAUSE_UNALLOCATED;
3564 case 486: /* Busy everywhere */
3565 return AST_CAUSE_BUSY;
3566 case 487: /* Request terminated */
3568 case 488: /* No codecs approved */
3570 case 491: /* Request pending */
3572 case 493: /* Undecipherable */
3574 case 500: /* Server internal failure */
3575 return AST_CAUSE_FAILURE;
3576 case 501: /* Call rejected */
3578 case 502:
3580 case 503: /* Service unavailable */
3581 return AST_CAUSE_CONGESTION;
3582 case 504: /* Gateway timeout */
3584 case 505: /* SIP version not supported */
3586 case 600: /* Busy everywhere */
3587 return AST_CAUSE_USER_BUSY;
3588 case 603: /* Decline */
3590 case 604: /* Does not exist anywhere */
3591 return AST_CAUSE_UNALLOCATED;
3592 case 606: /* Not acceptable */
3594 default:
3595 if (cause < 500 && cause >= 400) {
3596 /* 4xx class error that is unknown - someting wrong with our request */
3598 } else if (cause < 600 && cause >= 500) {
3599 /* 5xx class error - problem in the remote end */
3600 return AST_CAUSE_CONGESTION;
3601 } else if (cause < 700 && cause >= 600) {
3602 /* 6xx - global errors in the 4xx class */
3604 }
3605 return AST_CAUSE_NORMAL;
3606 }
3607 /* Never reached */
3608 return 0;
3609}
#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 307 of file security_agreements.c.

308 {
309
310 struct ast_sip_security_mechanism *mech;
311 char buf[512];
312 char *hdr_val;
313 char *mechanism;
314
315 if (!security_mechanisms || !hdr) {
316 return;
317 }
318
319 if (pj_stricmp2(&hdr->name, "Security-Client") && pj_stricmp2(&hdr->name, "Security-Server") &&
320 pj_stricmp2(&hdr->name, "Security-Verify")) {
321 return;
322 }
323
324 ast_copy_pj_str(buf, &hdr->hvalue, sizeof(buf));
325 hdr_val = ast_skip_blanks(buf);
326
327 while ((mechanism = ast_strsep(&hdr_val, ',', AST_STRSEP_ALL))) {
328 if (!ast_sip_str_to_security_mechanism(&mech, mechanism)) {
329 AST_VECTOR_APPEND(security_mechanisms, mech);
330 }
331 }
332}
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:1871
char *attribute_pure 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 324 of file res_pjsip.c.

325{
326 struct endpoint_identifier_list *iter;
327 struct ast_sip_endpoint *endpoint = NULL;
331 endpoint = iter->identifier->identify_endpoint(rdata);
332 if (endpoint) {
333 break;
334 }
335 }
336 return endpoint;
337}
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:1426
struct ast_sip_endpoint_identifier * identifier
Definition res_pjsip.c:221

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 3443 of file res_pjsip.c.

3444{
3445 return (ast_sip_is_uri_sip_sips(uri) || PJSIP_URI_SCHEME_IS_TEL(uri));
3446}
int ast_sip_is_uri_sip_sips(pjsip_uri *uri)
Check whether a pjsip_uri is SIP/SIPS or not.
Definition res_pjsip.c:3438

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 2219 of file res_pjsip.c.

2220{
2221 pjsip_media_type compare;
2222
2223 if (!content_type) {
2224 return 0;
2225 }
2226
2227 pjsip_media_type_init2(&compare, type, subtype);
2228
2229 return pjsip_media_type_cmp(content_type, &compare, 0) ? 0 : -1;
2230}
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 2199 of file res_pjsip.c.

2200{
2201 int rc = 0;
2202 pjsip_media_type *b = NULL;
2203 va_list ap;
2204
2205 ast_assert(a != NULL);
2206 va_start(ap, a);
2207
2208 while ((b = va_arg(ap, pjsip_media_type *)) != (pjsip_media_type *)SENTINEL) {
2209 if (pjsip_media_type_cmp(a, b, 0) == 0) {
2210 rc = 1;
2211 break;
2212 }
2213 }
2214 va_end(ap);
2215
2216 return rc;
2217}
#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 3438 of file res_pjsip.c.

3439{
3440 return (PJSIP_URI_SCHEME_IS_SIP(uri) || PJSIP_URI_SCHEME_IS_SIPS(uri));
3441}

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(), sanitize_tdata(), and set_id_from_oli().

◆ 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 430 of file location.c.

434{
435 int res;
436
437 ao2_lock(aor);
438 res = ast_sip_location_add_contact_nolock(aor, uri, expiration_time, path_info, user_agent,
439 via_addr, via_port, call_id,
440 endpoint);
441 ao2_unlock(aor);
442
443 return res;
444}
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:417

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 417 of file location.c.

421{
422 struct ast_sip_contact *contact;
423
426 ao2_cleanup(contact);
427 return contact ? 0 : -1;
428}
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

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->qualify_2xx_only = aor->qualify_2xx_only;
377 contact->authenticate_qualify = aor->authenticate_qualify;
378 if (path_info && aor->support_path) {
379 ast_string_field_set(contact, path, path_info);
380 }
381
382 if (!ast_strlen_zero(aor->outbound_proxy)) {
383 ast_string_field_set(contact, outbound_proxy, aor->outbound_proxy);
384 }
385
388 }
389
392 }
393
396 }
397 contact->via_port = via_port;
398
399 if (!ast_strlen_zero(call_id)) {
401 }
402
403 contact->endpoint = ao2_bump(endpoint);
404 if (endpoint) {
406 }
407
408 contact->prune_on_boot = prune_on_boot;
409
410 if (ast_sorcery_create(ast_sip_get_sorcery(), contact)) {
411 ao2_ref(contact, -1);
412 return NULL;
413 }
414 return contact;
415}
const char * ast_config_AST_SYSTEM_NAME
Definition options.c:171
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
Definition sorcery.c:2126
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition sorcery.c:1808
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
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_2xx_only, 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(), and register_aor_core().

◆ 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 451 of file location.c.

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

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 470 of file location.c.

471{
472 struct ao2_container *contacts;
473
476 if (contacts) {
478 ao2_ref(contacts, -1);
479 }
480}
static int prune_boot_contacts_cb(void *obj, void *arg, int flags)
Definition location.c:456

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:2053

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:688
static int permanent_uri_sort_fn(const void *obj_left, const void *obj_right, int flags)
Definition location.c:499
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 446 of file location.c.

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

References ast_sip_get_sorcery(), and ast_sorcery_update().

Referenced by register_aor_core().

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

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 2821 of file res_pjsip.c.

2822{
2823 pjsip_name_addr *id_name_addr;
2824 pjsip_sip_uri *id_uri;
2825
2826 id_name_addr = (pjsip_name_addr *) id_hdr->uri;
2827 id_uri = pjsip_uri_get_uri(id_name_addr->uri);
2828
2829 if (id->name.valid) {
2830 if (!ast_strlen_zero(id->name.str)) {
2831 int name_buf_len = strlen(id->name.str) * 2 + 1;
2832 char *name_buf = ast_alloca(name_buf_len);
2833
2834 ast_escape_quoted(id->name.str, name_buf, name_buf_len);
2835 pj_strdup2(pool, &id_name_addr->display, name_buf);
2836 } else {
2837 pj_strdup2(pool, &id_name_addr->display, NULL);
2838 }
2839 }
2840
2841 if (id->number.valid) {
2842 pj_strdup2(pool, &id_uri->user, id->number.str);
2843 }
2844}
enum queue_result id
Definition app_queue.c:1790
char * ast_escape_quoted(const char *string, char *outbuf, int buflen)
Escape characters found in a quoted string.
Definition utils.c:817

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

float ast_sip_parse_qvalue ( const char *  q_value)

Parses a string representing a q_value to a float.

Valid q values must be in the range from 0.0 to 1.0 inclusively.

Parameters
q_valueString representing a floating point value
Return values
Theparsed qvalue or -1.0 on failure.

Definition at line 3501 of file res_pjsip.c.

3501 {
3502 char *end = NULL;
3503 float ret = strtof(q_value, &end);
3504
3505 if (end == q_value) {
3506 return -1.0f; /* Not a number. */
3507 }
3508 if ('\0' != *end) {
3509 return -1.0f; /* Extra characters at end of input. */
3510 }
3511 if (!isfinite(ret)) {
3512 return -1.0f; /* NaN or Infinity. */
3513 }
3514 if (ret > 1.0f || ret < 0.0f) {
3515 return -1.0f; /* Out of valid range. */
3516 }
3517 return ret;
3518}
char * end
Definition eagi_proxy.c:73

References end, and NULL.

Referenced by ast_sip_str_to_security_mechanism(), and extract_q_value().

◆ 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 1578 of file pjsip_configuration.c.

1579{
1580 struct sip_persistent_endpoint *persistent;
1581 struct ast_json *blob;
1582 char rtt[32];
1583
1584 persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1585 if (!persistent) {
1586 return;
1587 }
1588
1589 snprintf(rtt, sizeof(rtt), "%" PRId64, contact_status->rtt);
1590 blob = ast_json_pack("{s: s, s: s, s: s, s: s, s: s}",
1591 "contact_status", ast_sip_get_contact_status_label(contact_status->status),
1592 "aor", contact_status->aor,
1593 "uri", contact_status->uri,
1594 "roundtrip_usec", rtt,
1595 "endpoint_name", ast_endpoint_get_resource(persistent->endpoint));
1596 if (blob) {
1598 ast_json_unref(blob);
1599 }
1600
1601 ao2_ref(persistent, -1);
1602}
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.
Abstract JSON element (object, array, string, int, ...).
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 1521 of file pjsip_configuration.c.

1522{
1523 struct sip_persistent_endpoint *persistent;
1524 struct ast_json *blob;
1525 char *regcontext;
1526
1527 persistent = ao2_find(persistent_endpoints, endpoint_name, OBJ_SEARCH_KEY);
1528 if (!persistent) {
1529 return -1;
1530 }
1531
1532 /* If there was no state change, don't publish anything. */
1533 if (ast_endpoint_get_state(persistent->endpoint) == state) {
1534 ao2_ref(persistent, -1);
1535 return 0;
1536 }
1537
1539
1540 if (state == AST_ENDPOINT_ONLINE) {
1542 blob = ast_json_pack("{s: s}", "peer_status", "Reachable");
1543
1547 "Noop", ast_strdup(ast_endpoint_get_resource(persistent->endpoint)), ast_free_ptr, "PJSIP");
1548 }
1549 }
1550
1551 ast_verb(2, "Endpoint %s is now Reachable\n", ast_endpoint_get_resource(persistent->endpoint));
1552 } else {
1554 blob = ast_json_pack("{s: s}", "peer_status", "Unreachable");
1555
1557 struct pbx_find_info q = { .stacklen = 0 };
1558
1561 }
1562 }
1563
1564 ast_verb(2, "Endpoint %s is now Unreachable\n", ast_endpoint_get_resource(persistent->endpoint));
1565 }
1566
1568
1570 ast_json_unref(blob);
1572
1573 ao2_ref(persistent, -1);
1574
1575 return 0;
1576}
void ast_free_ptr(void *ptr)
free() wrapper
Definition astmm.c:1739
static char regcontext[AST_MAX_CONTEXT]
Definition chan_iax2.c:349
@ 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.
@ 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:6953
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:4196
int ast_context_remove_extension(const char *context, const char *extension, int priority, const char *registrar)
Simply remove extension from context.
Definition pbx.c:4969
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

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 3467 of file res_pjsip.c.

3468{
3469 if (ast_sip_is_uri_sip_sips(uri)) {
3470 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3471 if (!sip_uri) {
3472 return &AST_PJ_STR_EMPTY;
3473 }
3474 return &sip_uri->host;
3475 } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3476 return &AST_PJ_STR_EMPTY;
3477 }
3478
3479 return &AST_PJ_STR_EMPTY;
3480}
static const pj_str_t AST_PJ_STR_EMPTY
Definition res_pjsip.h:112

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(), rx_data_to_ast_msg(), 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 3482 of file res_pjsip.c.

3483{
3484 if (ast_sip_is_uri_sip_sips(uri)) {
3485 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3486 if (!sip_uri) {
3487 return NULL;
3488 }
3489 return pjsip_param_find(&sip_uri->other_param, param_str);
3490 } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3491 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3492 if (!tel_uri) {
3493 return NULL;
3494 }
3495 return pjsip_param_find(&tel_uri->other_param, param_str);
3496 }
3497
3498 return NULL;
3499}

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 3448 of file res_pjsip.c.

3449{
3450 if (ast_sip_is_uri_sip_sips(uri)) {
3451 pjsip_sip_uri *sip_uri = pjsip_uri_get_uri(uri);
3452 if (!sip_uri) {
3453 return &AST_PJ_STR_EMPTY;
3454 }
3455 return &sip_uri->user;
3456 } else if (PJSIP_URI_SCHEME_IS_TEL(uri)) {
3457 pjsip_tel_uri *tel_uri = pjsip_uri_get_uri(uri);
3458 if (!tel_uri) {
3459 return &AST_PJ_STR_EMPTY;
3460 }
3461 return &tel_uri->number;
3462 }
3463
3464 return &AST_PJ_STR_EMPTY;
3465}

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 339 of file res_pjsip.c.

340{
341 pjsip_generic_string_hdr *hdr;
342 pj_str_t hdr_val;
343
344 hdr = pjsip_msg_find_hdr_by_name(rdata->msg_info.msg, &str, NULL);
345 if (!hdr) {
346 return NULL;
347 }
348
349 pj_strdup_with_null(rdata->tp_info.pool, &hdr_val, &hdr->hvalue);
350
351 return hdr_val.ptr;
352}

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 134 of file res_pjsip.c.

135{
137 ast_log(LOG_WARNING, "Authenticator %p is already registered. Cannot register a new one\n", registered_authenticator);
138 return -1;
139 }
141 ast_debug(1, "Registered SIP authenticator module %p\n", auth);
142
143 return 0;
144}

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 475 of file res_pjsip.c.

476{
479}
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition linkedlists.h:52
#define AST_RWLIST_INSERT_TAIL

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 304 of file res_pjsip.c.

305{
307}
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:227

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 227 of file res_pjsip.c.

229{
230 char *prev, *current, *identifier_order;
231 struct endpoint_identifier_list *iter, *id_list_item;
233
234 id_list_item = ast_calloc(1, sizeof(*id_list_item));
235 if (!id_list_item) {
236 ast_log(LOG_ERROR, "Unable to add endpoint identifier. Out of memory.\n");
237 return -1;
238 }
239 id_list_item->identifier = identifier;
240 id_list_item->name = name;
241
242 ast_debug(1, "Register endpoint identifier %s(%p)\n", name ?: "", identifier);
243
244 if (ast_strlen_zero(name)) {
245 /* if an identifier has no name then place in front */
247 return 0;
248 }
249
250 /* see if the name of the identifier is in the global endpoint_identifier_order list */
251 identifier_order = prev = current = ast_sip_get_endpoint_identifier_order();
252
253 if (ast_strlen_zero(identifier_order)) {
254 id_list_item->priority = UINT_MAX;
256 ast_free(identifier_order);
257 return 0;
258 }
259
260 id_list_item->priority = 0;
261 while ((current = strchr(current, ','))) {
262 ++id_list_item->priority;
263 if (!strncmp(prev, name, current - prev)
264 && strlen(name) == current - prev) {
265 break;
266 }
267 prev = ++current;
268 }
269
270 if (!current) {
271 /* check to see if it is the only or last item */
272 if (!strcmp(prev, name)) {
273 ++id_list_item->priority;
274 } else {
275 id_list_item->priority = UINT_MAX;
276 }
277 }
278
279 if (id_list_item->priority == UINT_MAX || AST_RWLIST_EMPTY(&endpoint_identifiers)) {
280 /* if not in the endpoint_identifier_order list then consider it less in
281 priority and add it to the end */
283 ast_free(identifier_order);
284 return 0;
285 }
286
288 if (id_list_item->priority < iter->priority) {
290 break;
291 }
292
293 if (!AST_RWLIST_NEXT(iter, list)) {
295 break;
296 }
297 }
299
300 ast_free(identifier_order);
301 return 0;
302}
size_t current
#define AST_RWLIST_EMPTY
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_INSERT_AFTER
#define AST_RWLIST_NEXT
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_RWLIST_INSERT_HEAD
#define AST_RWLIST_INSERT_BEFORE_CURRENT
struct endpoint_identifier_list::@488 list

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, endpoint_identifier_list::list, lock, LOG_ERROR, name, endpoint_identifier_list::name, endpoint_identifier_list::priority, and SCOPED_LOCK.

Referenced by ast_sip_register_endpoint_identifier(), load_module(), load_module(), 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 185 of file res_pjsip.c.

186{
188 ast_log(LOG_WARNING, "Outbound authenticator %p is already registered. Cannot register a new one\n", registered_outbound_authenticator);
189 return -1;
190 }
192 ast_debug(1, "Registered SIP outbound authenticator module %p\n", auth);
193
194 return 0;
195}

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 111 of file res_pjsip.c.

112{
114}
#define ast_sip_push_task_wait_servant(serializer, sip_task, task_data)
Definition res_pjsip.h:2133
static int register_service(void *data)
Definition res_pjsip.c:96

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(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), load_module(), 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 1450 of file res_pjsip.c.

1451{
1452 struct ast_sip_supplement *iter;
1453 int inserted = 0;
1455
1457 if (iter->priority > supplement->priority) {
1459 inserted = 1;
1460 break;
1461 }
1462 }
1464
1465 if (!inserted) {
1467 }
1468}

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(), load_module(), 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}
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.

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(), register_aor_core(), 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 157 of file res_pjsip.c.

158{
160 && !pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, &pjsip_options_method)) {
161 ast_debug(3, "Skipping OPTIONS authentication due to endpoint configuration\n");
162 return 0;
163 }
164
166 ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is not required\n");
167 return 0;
168 }
169
170 return registered_authenticator->requires_authentication(endpoint, rdata);
171}

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 2602 of file pjsip_configuration.c.

2603{
2604 int i;
2605
2606 for (i = 0; i < AST_VECTOR_SIZE(auths); ++i) {
2607 /* Using AST_VECTOR_GET is safe since the vector is immutable */
2608 const char *name = AST_VECTOR_GET(auths, i);
2610 if (!out[i]) {
2611 ast_log(LOG_NOTICE, "Couldn't find auth '%s'. Cannot authenticate\n", name);
2612 return -1;
2613 }
2614 }
2615
2616 return 0;
2617}
#define LOG_NOTICE
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.

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 2627 of file pjsip_configuration.c.

2629{
2630 int i;
2631
2632 for (i = 0; i < AST_VECTOR_SIZE(auth_ids); ++i) {
2633 /* Using AST_VECTOR_GET is safe since the vector is immutable */
2634 const char *name = AST_VECTOR_GET(auth_ids, i);
2636 if (!auth_object) {
2637 ast_log(LOG_WARNING, "Auth object '%s' could not be found\n", name);
2638 } else {
2639 AST_VECTOR_APPEND(auth_objects, auth_object);
2640 }
2641 }
2642
2643 return AST_VECTOR_SIZE(auth_objects) == AST_VECTOR_SIZE(auth_ids) ? 0 : -1;
2644}

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 599 of file res_pjsip.c.

599 {
600 RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
601 RAII_VAR(struct ast_sip_transport_state *, transport_state, NULL, ao2_cleanup);
602 struct ast_sip_request_transport_details details = { 0, };
603 pjsip_sip_uri *tmp_uri;
604 pjsip_dialog *dlg;
605 struct ast_sockaddr addr = { { 0, } };
606
607 if ((tmp_uri = ast_sip_get_contact_sip_uri(tdata))) {
608 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
609 uri->port = tmp_uri->port;
610 } else if ((dlg = pjsip_tdata_get_dlg(tdata))
611 && (tmp_uri = pjsip_uri_get_uri(dlg->local.info->uri))
612 && (PJSIP_URI_SCHEME_IS_SIP(tmp_uri) || PJSIP_URI_SCHEME_IS_SIPS(tmp_uri))) {
613 pj_strdup(tdata->pool, &uri->host, &tmp_uri->host);
614 uri->port = tmp_uri->port;
615 }
616
617 if (ast_sip_set_request_transport_details(&details, tdata, 1)
618 || !(transport_state = ast_sip_find_transport_state_in_use(&details))
619 || !(transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_state->id))) {
620 return 0;
621 }
622
623 if (transport_state->localnet) {
624 ast_sockaddr_parse(&addr, tdata->tp_info.dst_name, PARSE_PORT_FORBID);
625 ast_sockaddr_set_port(&addr, tdata->tp_info.dst_port);
626 if (ast_sip_transport_is_local(transport_state, &addr)) {
627 return 0;
628 }
629 }
630
631 if (!ast_sockaddr_isnull(&transport_state->external_signaling_address)) {
632 pj_strdup2(tdata->pool, &uri->host, ast_sockaddr_stringify_host(&transport_state->external_signaling_address));
633 }
634
635 if (transport->external_signaling_port) {
636 uri->port = transport->external_signaling_port;
637 }
638
639 return 0;
640}
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:589
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:642
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:558
#define ast_sip_transport_is_local(transport_state, addr)
Definition res_pjsip.h:213

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 334 of file security_agreements.c.

335{
336 char *val = value ? ast_strdupa(value) : NULL;
337 struct ast_sip_security_mechanism *mech;
338 char *mechanism;
339
341 if (AST_VECTOR_INIT(security_mechanisms, 1)) {
342 return -1;
343 }
344
345 if (!val) {
346 return 0;
347 }
348
349 while ((mechanism = ast_strsep(&val, ',', AST_STRSEP_ALL))) {
350 if (!ast_sip_str_to_security_mechanism(&mech, mechanism)) {
351 AST_VECTOR_APPEND(security_mechanisms, mech);
352 }
353 }
354
355 return 0;
356}
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);
191 ast_free(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}
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(), and str.

Referenced by security_mechanism_to_str(), and 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:636

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 1932 of file res_pjsip.c.

1935{
1936 struct ast_sip_supplement *supplement;
1937 struct send_request_data *req_data;
1938 struct ast_sip_contact *contact;
1939
1940 req_data = send_request_data_alloc(endpoint, token, callback);
1941 if (!req_data) {
1942 pjsip_tx_data_dec_ref(tdata);
1943 return -1;
1944 }
1945
1946 if (endpoint) {
1948 }
1949
1950 contact = ast_sip_mod_data_get(tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT);
1951
1953 AST_LIST_TRAVERSE(&supplements, supplement, next) {
1954 if (supplement->outgoing_request
1955 && does_method_match(&tdata->msg->line.req.method.name, supplement->method)) {
1956 supplement->outgoing_request(endpoint, contact, tdata);
1957 }
1958 }
1960
1961 ast_sip_mod_data_set(tdata->pool, tdata->mod_data, supplement_module.id, MOD_DATA_CONTACT, NULL);
1962 ao2_cleanup(contact);
1963
1964 if (endpt_send_request(endpoint, tdata, timeout, req_data, send_request_cb)
1965 != PJ_SUCCESS) {
1966 ao2_cleanup(req_data);
1967 return -1;
1968 }
1969
1970 return 0;
1971}
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
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:1528
static void send_request_cb(void *token, pjsip_event *e)
Definition res_pjsip.c:1876
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:1690
static pj_bool_t does_method_match(const pj_str_t *message_method, const char *supplement_method)
Definition res_pjsip.c:1493
#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:3092
Structure to hold information about an outbound request.
Definition res_pjsip.c:1510

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, callback(), 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 1973 of file res_pjsip.c.

1976{
1977 ast_assert(tdata->msg->type == PJSIP_REQUEST_MSG);
1978
1979 if (dlg) {
1980 return send_in_dialog_request(tdata, dlg);
1981 } else {
1982 return ast_sip_send_out_of_dialog_request(tdata, endpoint, -1, token, callback);
1983 }
1984}
static int send_in_dialog_request(pjsip_tx_data *tdata, struct pjsip_dialog *dlg)
Definition res_pjsip.c:1484
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:1932

References ast_assert, ast_sip_send_out_of_dialog_request(), callback(), 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_message_to_uri(), 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 2367 of file res_pjsip.c.

2368{
2369 pj_status_t status;
2370
2371 supplement_outgoing_response(tdata, sip_endpoint);
2372 status = pjsip_endpt_send_response(ast_sip_get_pjsip_endpoint(), res_addr, tdata, NULL, NULL);
2373 if (status != PJ_SUCCESS) {
2374 pjsip_tx_data_dec_ref(tdata);
2375 }
2376
2377 return status == PJ_SUCCESS ? 0 : -1;
2378}
static void supplement_outgoing_response(pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
Definition res_pjsip.c:2345

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 2395 of file res_pjsip.c.

2396{
2397 pjsip_transaction *tsx;
2398 pj_grp_lock_t *tsx_glock;
2399 pj_pool_t *pool;
2400
2401 /* Create and initialize global lock pool */
2402 pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "stateful response", PJSIP_POOL_TSX_LEN, PJSIP_POOL_TSX_INC);
2403 if (!pool){
2404 /* ast_sip_create_response bumps the refcount of the contact and adds it to the tdata.
2405 * We'll leak that reference if we don't get rid of it here.
2406 */
2408 return -1;
2409 }
2410 /* Create with handler so that we can release the pool once the glock derefs out */
2411 if(pj_grp_lock_create_w_handler(pool, NULL, pool, &pool_destroy_callback, &tsx_glock) != PJ_SUCCESS) {
2413 pool_destroy_callback((void *) pool);
2414 return -1;
2415 }
2416 /* We need an additional reference as the qualify thread may destroy this out
2417 * from under us. Add it now before it gets added to the tsx. */
2418 pj_grp_lock_add_ref(tsx_glock);
2419
2420 if (pjsip_tsx_create_uas2(NULL, rdata, tsx_glock, &tsx) != PJ_SUCCESS) {
2422 pj_grp_lock_dec_ref(tsx_glock);
2423 return -1;
2424 }
2425
2426 pjsip_tsx_recv_msg(tsx, rdata);
2427 supplement_outgoing_response(tdata, sip_endpoint);
2428
2429 if (pjsip_tsx_send_msg(tsx, tdata) != PJ_SUCCESS) {
2430 pj_grp_lock_dec_ref(tsx_glock);
2431 pjsip_tx_data_dec_ref(tdata);
2432 return -1;
2433 }
2434
2435 pj_grp_lock_dec_ref(tsx_glock);
2436 return 0;
2437}
static void clean_contact_from_tdata(pjsip_tx_data *tdata)
Definition res_pjsip.c:2386
static void pool_destroy_callback(void *arg)
Definition res_pjsip.c:2380

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:873

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 2793 of file res_pjsip.c.

2794{
2795 return !set_id_from_pai(rdata, id) || !set_id_from_rpid(rdata, id) ? 0 : -1;
2796}
static int set_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
Definition res_pjsip.c:2681
static int set_id_from_rpid(pjsip_rx_data *rdata, struct ast_party_id *id)
Definition res_pjsip.c:2722

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 2798 of file res_pjsip.c.

2799{
2800 if (trust_inbound && (!set_id_from_pai(rdata, id) || !set_id_from_rpid(rdata, id))) {
2801 /* Trusted: Check PAI and RPID */
2802 ast_free(id->tag);
2803 id->tag = ast_strdup(default_id->tag);
2804 return 0;
2805 }
2806 /* Not trusted: check the endpoint config or use From. */
2807 ast_party_id_copy(id, default_id);
2808 if (!default_id->number.valid) {
2809 set_id_from_from(rdata, id);
2810 }
2811 return 0;
2812}
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:1751
static int set_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
Definition res_pjsip.c:2774
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 1986 of file res_pjsip.c.

1987{
1988 pjsip_route_hdr *route;
1989 static const pj_str_t ROUTE_HNAME = { "Route", 5 };
1990 pj_str_t tmp;
1991
1992 pj_strdup2_with_null(tdata->pool, &tmp, proxy);
1993 if (!(route = pjsip_parse_hdr(tdata->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
1994 return -1;
1995 }
1996
1997 pj_list_insert_nodes_before(&tdata->msg->hdr, (pjsip_hdr*)route);
1998
1999 return 0;
2000}

References NULL.

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 642 of file res_pjsip.c.

643 {
644 pjsip_sip_uri *uri;
645 pjsip_via_hdr *via;
646 long transport_type;
647
648 if (!details || !tdata) {
649 return -1;
650 }
651
652 /* If IPv6 should be considered, un-set Bit 7 to make TCP6 equal to TCP and TLS6 equal to TLS */
653 transport_type = use_ipv6 ? tdata->tp_info.transport->key.type & ~(PJSIP_TRANSPORT_IPV6)
654 : tdata->tp_info.transport->key.type;
655
656 if (tdata->tp_sel.type == PJSIP_TPSELECTOR_TRANSPORT) {
657 details->transport = tdata->tp_sel.u.transport;
658 } else if (tdata->tp_sel.type == PJSIP_TPSELECTOR_LISTENER) {
659 details->factory = tdata->tp_sel.u.listener;
660 } else if (transport_type == PJSIP_TRANSPORT_UDP || transport_type == PJSIP_TRANSPORT_UDP6) {
661 /* Connectionless uses the same transport for all requests */
662 details->type = AST_TRANSPORT_UDP;
663 details->transport = tdata->tp_info.transport;
664 } else {
665 if (transport_type == PJSIP_TRANSPORT_TCP) {
666 details->type = AST_TRANSPORT_TCP;
667 } else if (transport_type == PJSIP_TRANSPORT_TLS) {
668 details->type = AST_TRANSPORT_TLS;
669 } else {
670 /* Unknown transport type, we can't map. */
671 return -1;
672 }
673
674 if ((uri = ast_sip_get_contact_sip_uri(tdata))) {
675 details->local_address = uri->host;
676 details->local_port = uri->port;
677 } else if ((tdata->msg->type == PJSIP_REQUEST_MSG) &&
678 (via = pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL))) {
679 details->local_address = via->sent_by.host;
680 details->local_port = via->sent_by.port;
681 } else {
682 return -1;
683 }
684
685 if (!details->local_port) {
686 details->local_port = (details->type == AST_TRANSPORT_TLS) ? 5061 : 5060;
687 }
688 }
689 return 0;
690}
@ AST_TRANSPORT_UDP
Definition netsock2.h:60
@ AST_TRANSPORT_TLS
Definition netsock2.h:62
@ AST_TRANSPORT_TCP
Definition netsock2.h:61

References ast_sip_get_contact_sip_uri(), AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, ast_sip_request_transport_details::factory, 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(), and 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 905 of file res_pjsip.c.

907{
908 char transport_name[128];
909
910 if (ast_sip_get_transport_name(endpoint, sip_uri, transport_name, sizeof(transport_name))) {
911 return 0;
912 }
913
914 return ast_sip_set_tpselector_from_transport_name(transport_name, selector);
915}
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:692
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:887

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 837 of file res_pjsip.c.

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

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 887 of file res_pjsip.c.

888{
889 RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
890
891 if (ast_strlen_zero(transport_name)) {
892 return 0;
893 }
894
895 transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", transport_name);
896 if (!transport) {
897 ast_log(LOG_ERROR, "Unable to retrieve PJSIP transport '%s'\n",
898 transport_name);
899 return -1;
900 }
901
902 return ast_sip_set_tpselector_from_transport(transport, selector);
903}
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:837

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 1825 of file pjsip_configuration.c.

1826{
1829 struct ast_variable *i;
1830
1831 if (!objset) {
1832 return -1;
1833 }
1834
1836
1837 for (i = objset; i; i = i->next) {
1838 RAII_VAR(char *, camel, ast_to_camel_case(i->name), ast_free);
1839 ast_str_append(buf, 0, "%s: %s\r\n", camel, i->value);
1840 }
1841
1842 return 0;
1843}
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition extconf.c:1260
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:1575
#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
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 3704 of file res_pjsip.c.

3705{
3706 int i;
3707
3708 if (ast_strlen_zero(name)) {
3709 return -1;
3710 }
3711
3712 for (i = 0; i < ARRAY_LEN(rc_map); i++) {
3713 if (strcasecmp(rc_map[i].short_name, name) == 0 ||
3714 strcasecmp(rc_map[i].long_name, name) == 0) {
3715 return rc_map[i].code;
3716 }
3717 }
3718
3719 return -1;
3720}
static const struct response_code_map rc_map[]
Definition res_pjsip.c:3624

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 2504 of file res_pjsip.c.

2505{
2506 int result = -1;
2507
2508 if (!strcasecmp(dtmf_mode, "info")) {
2510 } else if (!strcasecmp(dtmf_mode, "rfc4733")) {
2512 } else if (!strcasecmp(dtmf_mode, "inband")) {
2514 } else if (!strcasecmp(dtmf_mode, "none")) {
2516 } else if (!strcasecmp(dtmf_mode, "auto")) {
2518 } else if (!strcasecmp(dtmf_mode, "auto_info")) {
2520 }
2521
2522 return result;
2523}
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 216 of file security_agreements.c.

216 {
217 struct ast_sip_security_mechanism *mech;
218 char *param;
219 char *tmp;
220 char *mechanism = ast_strdupa(value);
221 int err = 0;
222 int type = -1;
223
225 if (!mech) {
226 err = ENOMEM;
227 goto out;
228 }
229
230 tmp = ast_strsep(&mechanism, ';', AST_STRSEP_ALL);
232 if (type == -1) {
233 err = EINVAL;
234 goto out;
235 }
236
237 mech->type = type;
238 while ((param = ast_strsep(&mechanism, ';', AST_STRSEP_ALL))) {
239 if (!param) {
240 err = EINVAL;
241 goto out;
242 }
243 if (!strncmp(param, "q=", 2)) {
244 mech->qvalue = ast_sip_parse_qvalue(&param[2]);
245 if (mech->qvalue < 0.0) {
246 err = EINVAL;
247 goto out;
248 }
249 continue;
250 }
251 param = ast_strdup(param);
253 }
254
255 *security_mechanism = mech;
256
257out:
258 if (err && (mech != NULL)) {
260 }
261 return err;
262}
static struct ast_sip_security_mechanism * security_mechanisms_alloc(size_t n_params)
static int str_to_security_mechanism_type(const char *security_mechanism)

References ast_sip_parse_qvalue(), ast_strdup, ast_strdupa, ast_strsep(), AST_STRSEP_ALL, AST_VECTOR_APPEND, ast_sip_security_mechanism::mechanism_parameters, NULL, out, ast_sip_security_mechanism::qvalue, security_mechanism_destroy(), security_mechanisms_alloc(), str_to_security_mechanism_type(), 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_taskpool()

struct ast_taskpool * ast_sip_taskpool ( void  )

Retrieve the SIP taskpool object.

Definition at line 3433 of file res_pjsip.c.

3434{
3435 return sip_taskpool;
3436}
static struct ast_taskpool * sip_taskpool
Definition res_pjsip.c:70

References sip_taskpool.

Referenced by load_module().

◆ ast_sip_taskpool_queue_size()

long ast_sip_taskpool_queue_size ( void  )

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

Since
13.7.0

Definition at line 3428 of file res_pjsip.c.

3429{
3431}
long ast_taskpool_queue_size(struct ast_taskpool *pool)
Get the current number of queued tasks in the taskpool.
Definition taskpool.c:464

References ast_taskpool_queue_size(), and sip_taskpool.

◆ 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 917 of file res_pjsip.c.

918{
919 if (selector->type == PJSIP_TPSELECTOR_TRANSPORT && selector->u.transport) {
920 pjsip_transport_dec_ref(selector->u.transport);
921 }
922}

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:91
#define IP6ADDR_COLON_PORT_BUFLEN
Definition res_pjsip.h:83

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.

Referenced by register_aor_core().

◆ 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_data_matcher matches
ast_transport_monitor_shutdown_cb cb
Structure for transport to be monitored.
pjsip_transport * transport
The underlying PJSIP transport.
struct transport_monitor::@494 monitors
char key[IP6ADDR_COLON_PORT_BUFLEN]
Key <ipaddr>:<port>

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(), unload_module(), unload_module(), 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.
static struct @493 transport_state_list

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.

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 146 of file res_pjsip.c.

147{
148 if (registered_authenticator != auth) {
149 ast_log(LOG_WARNING, "Trying to unregister authenticator %p but authenticator %p registered\n",
151 return;
152 }
154 ast_debug(1, "Unregistered SIP authenticator %p\n", auth);
155}

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 309 of file res_pjsip.c.

310{
311 struct endpoint_identifier_list *iter;
314 if (iter->identifier == identifier) {
316 ast_free(iter);
317 ast_debug(1, "Unregistered endpoint identifier %p\n", identifier);
318 break;
319 }
320 }
322}

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, endpoint_identifier_list::list, lock, and SCOPED_LOCK.

Referenced by unload_module(), unload_module(), unload_module(), and 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 197 of file res_pjsip.c.

198{
200 ast_log(LOG_WARNING, "Trying to unregister outbound authenticator %p but outbound authenticator %p registered\n",
202 return;
203 }
205 ast_debug(1, "Unregistered SIP outbound authenticator %p\n", auth);
206}

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 127 of file res_pjsip.c.

128{
130}
static int unregister_service(void *data)
Definition res_pjsip.c:116

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(), load_module(), load_module(), load_module(), load_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_module(), unload_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 1470 of file res_pjsip.c.

1471{
1472 struct ast_sip_supplement *iter;
1474
1476 if (supplement == iter) {
1478 break;
1479 }
1480 }
1482}

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(), unload_module(), 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 3354 of file res_pjsip.c.

3355{
3356 pjsip_name_addr *name_addr;
3357 pjsip_sip_uri *uri;
3358 pjsip_name_addr *parsed_name_addr;
3359 pjsip_from_hdr *from_hdr;
3360
3361 if (ast_strlen_zero(from)) {
3362 return 0;
3363 }
3364
3365 from_hdr = PJSIP_MSG_FROM_HDR(tdata->msg);
3366 if (!from_hdr) {
3367 return -1;
3368 }
3369 name_addr = (pjsip_name_addr *) from_hdr->uri;
3370 uri = pjsip_uri_get_uri(name_addr);
3371
3372 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, from,
3373 strlen(from), PJSIP_PARSE_URI_AS_NAMEADDR);
3374 if (parsed_name_addr) {
3375 pjsip_sip_uri *parsed_uri;
3376
3377 if (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3378 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri)) {
3379 ast_log(LOG_WARNING, "From address '%s' is not a valid SIP/SIPS URI\n", from);
3380 return -1;
3381 }
3382
3383 parsed_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3384
3385 if (pj_strlen(&parsed_name_addr->display)) {
3386 pj_strdup(tdata->pool, &name_addr->display, &parsed_name_addr->display);
3387 }
3388
3389 /* Unlike the To header, we only want to replace the user, host and port */
3390 pj_strdup(tdata->pool, &uri->user, &parsed_uri->user);
3391 pj_strdup(tdata->pool, &uri->host, &parsed_uri->host);
3392 uri->port = parsed_uri->port;
3393
3394 return 0;
3395 } else {
3396 /* assume it is 'user[@domain]' format */
3397 char *domain = strchr(from, '@');
3398
3399 if (domain) {
3400 pj_str_t pj_from;
3401
3402 pj_strset3(&pj_from, from, domain);
3403 pj_strdup(tdata->pool, &uri->user, &pj_from);
3404
3405 pj_strdup2(tdata->pool, &uri->host, domain + 1);
3406 } else {
3407 pj_strdup2(tdata->pool, &uri->user, from);
3408 }
3409
3410 return 0;
3411 }
3412
3413 return -1;
3414}

References ast_log, ast_strlen_zero(), and LOG_WARNING.

Referenced by msg_send(), refer_send(), and send_message_to_uri().

◆ 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 3294 of file res_pjsip.c.

3295{
3296 pjsip_name_addr *parsed_name_addr;
3297 pjsip_sip_uri *sip_uri;
3298 pjsip_name_addr *tdata_name_addr;
3299 pjsip_sip_uri *tdata_sip_uri;
3300 pjsip_to_hdr *to_hdr;
3301 char *buf = NULL;
3302#define DEBUG_BUF_SIZE 256
3303
3304 parsed_name_addr = (pjsip_name_addr *) pjsip_parse_uri(tdata->pool, (char*)to, strlen(to),
3305 PJSIP_PARSE_URI_AS_NAMEADDR);
3306
3307 if (!parsed_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(parsed_name_addr->uri)
3308 && !PJSIP_URI_SCHEME_IS_SIPS(parsed_name_addr->uri))) {
3309 ast_log(LOG_WARNING, "To address '%s' is not a valid SIP/SIPS URI\n", to);
3310 return -1;
3311 }
3312
3313 sip_uri = pjsip_uri_get_uri(parsed_name_addr->uri);
3314 if (DEBUG_ATLEAST(3)) {
3316 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, sip_uri, buf, DEBUG_BUF_SIZE);
3317 ast_debug(3, "Parsed To: %.*s %s\n", (int)parsed_name_addr->display.slen,
3318 parsed_name_addr->display.ptr, buf);
3319 }
3320
3321 to_hdr = PJSIP_MSG_TO_HDR(tdata->msg);
3322 tdata_name_addr = to_hdr ? (pjsip_name_addr *) to_hdr->uri : NULL;
3323 if (!tdata_name_addr || (!PJSIP_URI_SCHEME_IS_SIP(tdata_name_addr->uri)
3324 && !PJSIP_URI_SCHEME_IS_SIPS(tdata_name_addr->uri))) {
3325 /* Highly unlikely but we have to check */
3326 ast_log(LOG_WARNING, "tdata To address '%s' is not a valid SIP/SIPS URI\n", to);
3327 return -1;
3328 }
3329
3330 tdata_sip_uri = pjsip_uri_get_uri(tdata_name_addr->uri);
3331 if (DEBUG_ATLEAST(3)) {
3332 buf[0] = '\0';
3333 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, tdata_sip_uri, buf, DEBUG_BUF_SIZE);
3334 ast_debug(3, "Original tdata To: %.*s %s\n", (int)tdata_name_addr->display.slen,
3335 tdata_name_addr->display.ptr, buf);
3336 }
3337
3338 /* Replace the uri */
3339 pjsip_sip_uri_assign(tdata->pool, tdata_sip_uri, sip_uri);
3340 /* The display name isn't part of the URI so we need to replace it separately */
3341 pj_strdup(tdata->pool, &tdata_name_addr->display, &parsed_name_addr->display);
3342
3343 if (DEBUG_ATLEAST(3)) {
3344 buf[0] = '\0';
3345 pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, tdata_sip_uri, buf, 256);
3346 ast_debug(3, "New tdata To: %.*s %s\n", (int)tdata_name_addr->display.slen,
3347 tdata_name_addr->display.ptr, buf);
3348 }
3349
3350 return 0;
3351#undef DEBUG_BUF_SIZE
3352}
#define DEBUG_ATLEAST(level)
#define DEBUG_BUF_SIZE

References ast_alloca, ast_debug, ast_log, buf, DEBUG_ATLEAST, DEBUG_BUF_SIZE, LOG_WARNING, and NULL.

Referenced by msg_send(), refer_send(), and send_message_to_uri().

Variable Documentation

◆ AST_PJ_STR_EMPTY

const pj_str_t AST_PJ_STR_EMPTY = { "", 0 }
static

Definition at line 112 of file res_pjsip.h.

112{ "", 0 };

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 3903 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 3899 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 3900 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 3901 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 3904 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 3906 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 3905 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 3902 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 3907 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 3909 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 3910 of file res_pjsip.c.

Referenced by load_module().