Asterisk - The Open Source Telephony Project  GIT-master-8beac82
Data Structures | Macros | Typedefs | Enumerations | Functions
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"

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_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_supplement
 A supplement to SIP message processing. More...
 
struct  ast_sip_t38_configuration
 
struct  ast_sip_timer_options
 Session timers options. More...
 
struct  ast_sip_tpmgr_state_callback
 
struct  ast_sip_transport
 Transport to bind to. More...
 
struct  ast_sip_transport_state
 Structure for SIP transport information. More...
 

Macros

#define ast_sip_cleanup_auth_objects_vector(auth_objects)   AST_VECTOR_RESET(auth_objects, ao2_cleanup)
 Clean up retrieved auth objects in vector. More...
 
#define ast_sip_mod_data_get(mod_data, id, key)   ast_sip_dict_get(mod_data[id], key)
 Using the dictionary stored in mod_data array at a given id, retrieve the value associated with the given key. More...
 
#define ast_sip_mod_data_set(pool, mod_data, id, key, val)   mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)
 Utilizing a mod_data array for a given id, set the value associated with the given key. More...
 
#define ast_sip_transport_is_local(transport_state, addr)   (transport_state->localnet && ast_apply_ha(transport_state->localnet, addr) != AST_SENSE_ALLOW)
 
#define ast_sip_transport_is_nonlocal(transport_state, addr)   (!transport_state->localnet || ast_apply_ha(transport_state->localnet, addr) == AST_SENSE_ALLOW)
 
#define AST_SIP_USER_OPTIONS_TRUNCATE_CHECK(str)
 Truncate the URI user field options string if enabled. More...
 
#define AST_SIP_X_AST_TXP   "x-ast-txp"
 
#define AST_SIP_X_AST_TXP_LEN   9
 
#define 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 SIP_SORCERY_DOMAIN_ALIAS_TYPE   "domain_alias"
 
#define SIP_TLS_MAX_CIPHERS   64
 Maximum number of ciphers supported for a TLS transport. More...
 

Typedefs

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

Enumerations

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

Functions

void ast_copy_pj_str (char *dest, const pj_str_t *src, size_t size)
 Copy a pj_str_t into a standard character buffer. More...
 
int ast_copy_pj_str2 (char **dest, const pj_str_t *src)
 Create and copy a pj_str_t into a standard character buffer. More...
 
struct ast_sip_endpointast_pjsip_rdata_get_endpoint (pjsip_rx_data *rdata)
 Get the looked-up endpoint on an out-of dialog request or response. More...
 
int ast_sip_add_body (pjsip_tx_data *tdata, const struct ast_sip_body *body)
 Add a body to an outbound SIP message. More...
 
int ast_sip_add_body_multipart (pjsip_tx_data *tdata, const struct ast_sip_body *bodies[], int num_bodies)
 Add a multipart body to an outbound SIP message. More...
 
void ast_sip_add_date_header (pjsip_tx_data *tdata)
 Adds a Date header to the tdata, formatted like: Date: Wed, 01 Jan 2021 14:53:01 GMT. More...
 
int ast_sip_add_global_request_header (const char *name, const char *value, int replace)
 
int ast_sip_add_global_response_header (const char *name, const char *value, int replace)
 
int ast_sip_add_header (pjsip_tx_data *tdata, const char *name, const char *value)
 Add a header to an outbound SIP message. More...
 
void ast_sip_add_usereqphone (const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
 Add 'user=phone' parameter to URI if enabled and user is a phone number. More...
 
int ast_sip_append_body (pjsip_tx_data *tdata, const char *body_text)
 Append body data to a SIP message. More...
 
const char * ast_sip_auth_type_to_str (enum ast_sip_auth_type type)
 Converts the given auth type to a string. More...
 
void ast_sip_auth_vector_destroy (struct ast_sip_auth_vector *vector)
 Free contents of an auth vector. More...
 
int ast_sip_auth_vector_init (struct ast_sip_auth_vector *vector, const char *auth_names)
 Initialize an auth vector with the configured values. More...
 
int ast_sip_auths_to_str (const struct ast_sip_auth_vector *auths, char **buf)
 Converts an auths array to a string of comma separated values. More...
 
const char * ast_sip_call_codec_pref_to_str (struct ast_flags pref)
 Convert the call codec preference flags to a string. More...
 
int ast_sip_call_codec_str_to_pref (struct ast_flags *pref, const char *pref_str, int is_outgoing)
 Convert a call codec preference string to preference flags. More...
 
enum ast_sip_check_auth_result ast_sip_check_authentication (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
 Method to determine authentication status of an incoming request. More...
 
void ast_sip_cleanup_auths (struct ast_sip_auth *auths[], size_t num_auths)
 Clean up retrieved auth structures from memory. More...
 
int ast_sip_contact_to_str (void *object, void *arg, int flags)
 Handler used to convert a contact to a string. More...
 
struct ast_strast_sip_create_ami_event (const char *event, struct ast_sip_ami *ami)
 Creates a string to store AMI event data in. More...
 
pjsip_dialog * ast_sip_create_dialog_uac (const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user)
 General purpose method for creating a UAC dialog with an endpoint. More...
 
pjsip_dialog * ast_sip_create_dialog_uas (const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
 General purpose method for creating a UAS dialog with an endpoint. More...
 
pjsip_dialog * ast_sip_create_dialog_uas_locked (const struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pj_status_t *status)
 General purpose method for creating a UAS dialog with an endpoint. More...
 
int ast_sip_create_rdata (pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port)
 General purpose method for creating an rdata structure using specific information. More...
 
int ast_sip_create_rdata_with_contact (pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port, char *transport_type, const char *local_name, int local_port, const char *contact_uri)
 General purpose method for creating an rdata structure using specific information. More...
 
int ast_sip_create_request (const char *method, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, const char *uri, struct ast_sip_contact *contact, pjsip_tx_data **tdata)
 General purpose method for creating a SIP request. More...
 
int ast_sip_create_request_with_auth (const struct ast_sip_auth_vector *auths, pjsip_rx_data *challenge, pjsip_tx_data *tdata, pjsip_tx_data **new_request)
 Create a response to an authentication challenge. More...
 
int ast_sip_create_response (const pjsip_rx_data *rdata, int st_code, struct ast_sip_contact *contact, pjsip_tx_data **p_tdata)
 General purpose method for creating a SIP response. More...
 
struct ast_taskprocessorast_sip_create_serializer (const char *name)
 Create a new serializer for SIP tasks. More...
 
struct ast_taskprocessorast_sip_create_serializer_group (const char *name, struct ast_serializer_shutdown_group *shutdown_group)
 Create a new serializer for SIP tasks. More...
 
struct ast_sip_endpointast_sip_default_outbound_endpoint (void)
 Retrieve the default outbound endpoint. More...
 
struct ast_sip_endpointast_sip_dialog_get_endpoint (pjsip_dialog *dlg)
 Get the endpoint associated with this dialog. More...
 
void ast_sip_dialog_set_endpoint (pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint)
 Set an endpoint on a SIP dialog so in-dialog requests do not undergo endpoint lookup. More...
 
void ast_sip_dialog_set_serializer (pjsip_dialog *dlg, struct ast_taskprocessor *serializer)
 Set a serializer on a SIP dialog so requests and responses are automatically serialized. More...
 
int ast_sip_dialog_setup_outbound_authentication (pjsip_dialog *dlg, const struct ast_sip_endpoint *endpoint, ast_sip_dialog_outbound_auth_cb cb, void *user_data)
 Set up outbound authentication on a SIP dialog. More...
 
void * ast_sip_dict_get (void *ht, const char *key)
 Retrieves the value associated with the given key. More...
 
void * ast_sip_dict_set (pj_pool_t *pool, void *ht, const char *key, void *val)
 Set the value for the given key. More...
 
int ast_sip_dlg_set_transport (const struct ast_sip_endpoint *endpoint, pjsip_dialog *dlg, pjsip_tpselector *selector)
 Set the transport on a dialog. More...
 
int ast_sip_dtmf_to_str (const enum ast_sip_dtmf_mode dtmf, char *buf, size_t buf_len)
 Convert the DTMF mode enum value into a string. More...
 
void * ast_sip_endpoint_alloc (const char *name)
 Allocate a new SIP endpoint. More...
 
int ast_sip_failover_request (pjsip_tx_data *tdata)
 Set a request to use the next value in the list of resolved addresses. More...
 
int ast_sip_for_each_aor (const char *aors, ao2_callback_fn on_aor, void *arg)
 For every aor in the comma separated aors string call the given 'on_aor' handler. More...
 
int ast_sip_for_each_auth (const struct ast_sip_auth_vector *array, ao2_callback_fn on_auth, void *arg)
 For every auth in the array call the given 'on_auth' handler. More...
 
int ast_sip_for_each_channel (const struct ast_sip_endpoint *endpoint, ao2_callback_fn on_channel_snapshot, void *arg)
 For every channel snapshot on an endpoint all the given 'on_channel_snapshot' handler. More...
 
int ast_sip_for_each_channel_snapshot (const struct ast_endpoint_snapshot *endpoint_snapshot, ao2_callback_fn on_channel_snapshot, void *arg)
 For every channel snapshot on an endpoint snapshot call the given 'on_channel_snapshot' handler. More...
 
int ast_sip_for_each_contact (const struct ast_sip_aor *aor, ao2_callback_fn on_contact, void *arg)
 For every contact on an AOR call the given 'on_contact' handler. More...
 
int ast_sip_format_auths_ami (const struct ast_sip_auth_vector *auths, struct ast_sip_ami *ami)
 Format auth details for AMI. More...
 
int ast_sip_format_contact_ami (void *obj, void *arg, int flags)
 Formats the contact and sends over AMI. More...
 
int ast_sip_format_endpoint_ami (struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami, int *count)
 Formats the endpoint and sends over AMI. More...
 
struct ast_sip_authast_sip_get_artificial_auth (void)
 Retrieves a reference to the artificial auth. More...
 
struct ast_sip_endpointast_sip_get_artificial_endpoint (void)
 Retrieves a reference to the artificial endpoint. More...
 
unsigned int ast_sip_get_contact_expiration_check_interval (void)
 Retrieve the system contact expiration check interval setting. More...
 
const char * ast_sip_get_contact_short_status_label (const enum ast_sip_contact_status_type status)
 
struct ast_sip_contact_statusast_sip_get_contact_status (const struct ast_sip_contact *contact)
 Retrieve the current status for a contact. More...
 
const char * ast_sip_get_contact_status_label (const enum ast_sip_contact_status_type status)
 translate ast_sip_contact_status_type to character string. More...
 
char * ast_sip_get_debug (void)
 Retrieve the system debug setting (yes|no|host). More...
 
void ast_sip_get_default_from_user (char *from_user, size_t size)
 Retrieve the global default from user. More...
 
void ast_sip_get_default_realm (char *realm, size_t size)
 Retrieve the global default realm. More...
 
char * ast_sip_get_default_voicemail_extension (void)
 Retrieve the default voicemail extension. More...
 
const char * ast_sip_get_device_state (const struct ast_sip_endpoint *endpoint)
 Retrieve the device state for an endpoint. More...
 
unsigned int ast_sip_get_disable_multi_domain (void)
 Retrieve the system setting 'disable multi domain'. More...
 
struct ast_taskprocessorast_sip_get_distributor_serializer (pjsip_rx_data *rdata)
 Determine the distributor serializer for the SIP message. More...
 
char * ast_sip_get_endpoint_identifier_order (void)
 Retrieve the global endpoint_identifier_order setting. More...
 
struct ast_endpoint_snapshotast_sip_get_endpoint_snapshot (const struct ast_sip_endpoint *endpoint)
 Retrieve the endpoint snapshot for an endpoint. More...
 
struct ao2_containerast_sip_get_endpoints (void)
 Retrieve any endpoints available to sorcery. More...
 
int ast_sip_get_host_ip (int af, pj_sockaddr *addr)
 Retrieve the local host address in IP form. More...
 
const char * ast_sip_get_host_ip_string (int af)
 Retrieve the local host address in string form. More...
 
unsigned int ast_sip_get_ignore_uri_user_options (void)
 Retrieve the global setting 'ignore_uri_user_options'. More...
 
unsigned int ast_sip_get_keep_alive_interval (void)
 Retrieve the system keep alive interval setting. More...
 
unsigned int ast_sip_get_max_initial_qualify_time (void)
 Retrieve the system max initial qualify time. More...
 
unsigned int ast_sip_get_mwi_disable_initial_unsolicited (void)
 Retrieve the global setting 'disable sending unsolicited mwi on startup'. More...
 
unsigned int ast_sip_get_mwi_tps_queue_high (void)
 Retrieve the global MWI taskprocessor high water alert trigger level. More...
 
int ast_sip_get_mwi_tps_queue_low (void)
 Retrieve the global MWI taskprocessor low water clear alert level. More...
 
unsigned int ast_sip_get_norefersub (void)
 Retrieve the global setting 'norefersub'. More...
 
pjsip_endpoint * ast_sip_get_pjsip_endpoint (void)
 Get a pointer to the PJSIP endpoint. More...
 
char * ast_sip_get_regcontext (void)
 Retrieve the global regcontext setting. More...
 
unsigned int ast_sip_get_send_contact_status_on_update_registration (void)
 Retrieve the global setting 'send_contact_status_on_update_registration'. More...
 
struct ast_sorceryast_sip_get_sorcery (void)
 Get a pointer to the SIP sorcery structure. More...
 
int ast_sip_get_transport_name (const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, char *buf, size_t buf_len)
 Get the transport name from an endpoint or request uri. More...
 
struct ast_sip_transport_stateast_sip_get_transport_state (const char *transport_id)
 Retrieve transport state. More...
 
struct ao2_containerast_sip_get_transport_states (void)
 Retrieves all transport states. More...
 
void ast_sip_get_unidentified_request_thresholds (unsigned int *count, unsigned int *period, unsigned int *prune_interval)
 Retrieve the unidentified request security event thresholds. More...
 
unsigned int ast_sip_get_use_callerid_contact (void)
 Retrieve the global setting 'use_callerid_contact'. More...
 
struct ast_sip_endpointast_sip_identify_endpoint (pjsip_rx_data *rdata)
 Determine the endpoint that has sent a SIP message. More...
 
int ast_sip_is_content_type (pjsip_media_type *content_type, char *type, char *subtype)
 Checks if the given content type matches type/subtype. More...
 
int ast_sip_location_add_contact (struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, struct ast_sip_endpoint *endpoint)
 Add a new contact to an AOR. More...
 
int ast_sip_location_add_contact_nolock (struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, struct ast_sip_endpoint *endpoint)
 Add a new contact to an AOR without locking the AOR. More...
 
struct ast_sip_contactast_sip_location_create_contact (struct ast_sip_aor *aor, const char *uri, struct timeval expiration_time, const char *path_info, const char *user_agent, const char *via_addr, int via_port, const char *call_id, int prune_on_boot, struct ast_sip_endpoint *endpoint)
 Create a new contact for an AOR without locking the AOR. More...
 
int ast_sip_location_delete_contact (struct ast_sip_contact *contact)
 Delete a contact. More...
 
void ast_sip_location_prune_boot_contacts (void)
 Prune the prune_on_boot contacts. More...
 
struct ast_sip_aorast_sip_location_retrieve_aor (const char *aor_name)
 Retrieve a named AOR. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts (const struct ast_sip_aor *aor)
 Retrieve all contacts currently available for an AOR. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts_filtered (const struct ast_sip_aor *aor, unsigned int flags)
 Retrieve all contacts currently available for an AOR and filter based on flags. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts_nolock (const struct ast_sip_aor *aor)
 Retrieve all contacts currently available for an AOR without locking the AOR. More...
 
struct ao2_containerast_sip_location_retrieve_aor_contacts_nolock_filtered (const struct ast_sip_aor *aor, unsigned int flags)
 Retrieve all contacts currently available for an AOR without locking the AOR and filter based on flags. More...
 
struct ast_sip_contactast_sip_location_retrieve_contact (const char *contact_name)
 Retrieve a named contact. More...
 
void ast_sip_location_retrieve_contact_and_aor_from_list (const char *aor_list, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
 Retrieve the first bound contact AND the AOR chosen from a list of AORs. More...
 
void ast_sip_location_retrieve_contact_and_aor_from_list_filtered (const char *aor_list, unsigned int flags, struct ast_sip_aor **aor, struct ast_sip_contact **contact)
 Retrieve the first bound contact AND the AOR chosen from a list of AORs and filter based on flags. More...
 
struct ast_sip_contactast_sip_location_retrieve_contact_from_aor_list (const char *aor_list)
 Retrieve the first bound contact from a list of AORs. More...
 
struct ao2_containerast_sip_location_retrieve_contacts_from_aor_list (const char *aor_list)
 Retrieve all contacts from a list of AORs. More...
 
struct ast_sip_contactast_sip_location_retrieve_first_aor_contact (const struct ast_sip_aor *aor)
 Retrieve the first bound contact for an AOR. More...
 
struct ast_sip_contactast_sip_location_retrieve_first_aor_contact_filtered (const struct ast_sip_aor *aor, unsigned int flags)
 Retrieve the first bound contact for an AOR and filter based on flags. More...
 
int ast_sip_location_update_contact (struct ast_sip_contact *contact)
 Update a contact. More...
 
void ast_sip_message_apply_transport (const char *transport_name, pjsip_tx_data *tdata)
 Apply the configuration for a transport to an outgoing message. More...
 
void ast_sip_modify_id_header (pj_pool_t *pool, pjsip_fromto_hdr *id_hdr, const struct ast_party_id *id)
 Set name and number information on an identity header. More...
 
void ast_sip_persistent_endpoint_publish_contact_state (const char *endpoint_name, const struct ast_sip_contact_status *contact_status)
 Publish the change of state for a contact. More...
 
int ast_sip_persistent_endpoint_update_state (const char *endpoint_name, enum ast_endpoint_state state)
 Change state of a persistent endpoint. More...
 
int ast_sip_push_task (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
 Pushes a task to SIP servants. More...
 
int ast_sip_push_task_synchronous (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
 Push a task to SIP servants and wait for it to complete. More...
 
int ast_sip_push_task_wait_serializer (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
 Push a task to the serializer and wait for it to complete. More...
 
int ast_sip_push_task_wait_servant (struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
 Push a task to SIP servants and wait for it to complete. More...
 
char * ast_sip_rdata_get_header_value (pjsip_rx_data *rdata, const pj_str_t str)
 Get a specific header value from rdata. More...
 
int ast_sip_register_authenticator (struct ast_sip_authenticator *auth)
 Register a SIP authenticator. More...
 
void ast_sip_register_endpoint_formatter (struct ast_sip_endpoint_formatter *obj)
 Register an endpoint formatter. More...
 
int ast_sip_register_endpoint_identifier (struct ast_sip_endpoint_identifier *identifier)
 Register a SIP endpoint identifier. More...
 
int ast_sip_register_endpoint_identifier_with_name (struct ast_sip_endpoint_identifier *identifier, const char *name)
 Register a SIP endpoint identifier with a name. More...
 
int ast_sip_register_outbound_authenticator (struct ast_sip_outbound_authenticator *outbound_auth)
 Register an outbound SIP authenticator. More...
 
int ast_sip_register_service (pjsip_module *module)
 Register a SIP service in Asterisk. More...
 
void ast_sip_register_supplement (struct ast_sip_supplement *supplement)
 Register a supplement to SIP out of dialog processing. More...
 
void ast_sip_report_auth_challenge_sent (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, pjsip_tx_data *tdata)
 Send a security event notification for when an authentication challenge is sent. More...
 
void ast_sip_report_auth_failed_challenge_response (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Send a security event notification for when a challenge response has failed. More...
 
void ast_sip_report_auth_success (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Send a security event notification for when authentication succeeds. More...
 
void ast_sip_report_failed_acl (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *name)
 Send a security event notification for when an ACL check fails. More...
 
void ast_sip_report_invalid_endpoint (const char *name, pjsip_rx_data *rdata)
 Send a security event notification for when an invalid endpoint is requested. More...
 
void ast_sip_report_mem_limit (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Send a security event notification for when a memory limit is hit. More...
 
void ast_sip_report_req_no_support (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata, const char *req_type)
 Send a security event notification for when a request is not supported. More...
 
int ast_sip_requires_authentication (struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
 Determine if an incoming request requires authentication. More...
 
int ast_sip_retrieve_auths (const struct ast_sip_auth_vector *auths, struct ast_sip_auth **out)
 Retrieve relevant SIP auth structures from sorcery. More...
 
int ast_sip_retrieve_auths_vector (const struct ast_sip_auth_vector *auth_ids, struct ast_sip_auth_objects_vector *auth_objects)
 
int ast_sip_sched_is_task_running (struct ast_sip_sched_task *schtd)
 Checks if the task is currently running. More...
 
int ast_sip_sched_is_task_running_by_name (const char *name)
 Checks if the task is currently running. More...
 
int ast_sip_sched_task_cancel (struct ast_sip_sched_task *schtd)
 Cancels the next invocation of a task. More...
 
int ast_sip_sched_task_cancel_by_name (const char *name)
 Cancels the next invocation of a task by name. More...
 
int ast_sip_sched_task_get_name (struct ast_sip_sched_task *schtd, char *name, size_t maxlen)
 Gets the task name. More...
 
int ast_sip_sched_task_get_next_run (struct ast_sip_sched_task *schtd)
 Gets the number of milliseconds until the next invocation. More...
 
int ast_sip_sched_task_get_next_run_by_name (const char *name)
 Gets the number of milliseconds until the next invocation. More...
 
int ast_sip_sched_task_get_times (struct ast_sip_sched_task *schtd, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end)
 Gets the last start and end times of the task. More...
 
int ast_sip_sched_task_get_times2 (struct ast_sip_sched_task *schtd, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end, int *interval, int *time_left, struct timeval *next_start)
 Gets the queued, last start, last_end, time left, interval, next run. More...
 
int ast_sip_sched_task_get_times_by_name (const char *name, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end)
 Gets the last start and end times of the task by name. More...
 
int ast_sip_sched_task_get_times_by_name2 (const char *name, struct timeval *when_queued, struct timeval *last_start, struct timeval *last_end, int *interval, int *time_left, struct timeval *next_start)
 Gets the queued, last start, last_end, time left, interval, next run by task name. More...
 
struct ast_sip_sched_taskast_sip_schedule_task (struct ast_taskprocessor *serializer, int interval, ast_sip_task sip_task, const char *name, void *task_data, enum ast_sip_scheduler_task_flags flags)
 Schedule a task to run in the res_pjsip thread pool. More...
 
int ast_sip_send_out_of_dialog_request (pjsip_tx_data *tdata, struct ast_sip_endpoint *endpoint, int timeout, void *token, void(*callback)(void *token, pjsip_event *e))
 General purpose method for sending an Out-Of-Dialog SIP request. More...
 
int ast_sip_send_request (pjsip_tx_data *tdata, struct pjsip_dialog *dlg, struct ast_sip_endpoint *endpoint, void *token, void(*callback)(void *token, pjsip_event *e))
 General purpose method for sending a SIP request. More...
 
int ast_sip_send_response (pjsip_response_addr *res_addr, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
 Send a response to an out of dialog request. More...
 
int ast_sip_send_stateful_response (pjsip_rx_data *rdata, pjsip_tx_data *tdata, struct ast_sip_endpoint *sip_endpoint)
 Send a stateful response to an out of dialog request. More...
 
struct ast_sip_service_route_vector * ast_sip_service_route_vector_alloc (void)
 Allocate a vector of service routes. More...
 
void ast_sip_service_route_vector_destroy (struct ast_sip_service_route_vector *service_routes)
 Destroy a vector of service routes. More...
 
int ast_sip_set_outbound_proxy (pjsip_tx_data *tdata, const char *proxy)
 Set the outbound proxy for an outbound SIP message. More...
 
int ast_sip_set_tpselector_from_ep_or_uri (const struct ast_sip_endpoint *endpoint, pjsip_sip_uri *sip_uri, pjsip_tpselector *selector)
 Sets pjsip_tpselector from an endpoint or uri. More...
 
int ast_sip_set_tpselector_from_transport (const struct ast_sip_transport *transport, pjsip_tpselector *selector)
 Sets pjsip_tpselector from ast_sip_transport. More...
 
int ast_sip_set_tpselector_from_transport_name (const char *transport_name, pjsip_tpselector *selector)
 Sets pjsip_tpselector from ast_sip_transport. More...
 
int ast_sip_sorcery_object_to_ami (const void *obj, struct ast_str **buf)
 Converts a sorcery object to a string of object properties. More...
 
int ast_sip_str_to_dtmf (const char *dtmf_mode)
 Convert the DTMF mode name into an enum. More...
 
int ast_sip_thread_is_servant (void)
 Determine if the current thread is a SIP servant thread. More...
 
struct ast_threadpoolast_sip_threadpool (void)
 Retrieve the SIP threadpool object. More...
 
long ast_sip_threadpool_queue_size (void)
 Return the size of the SIP threadpool's task queue. More...
 
void ast_sip_tpselector_unref (pjsip_tpselector *selector)
 Unreference a pjsip_tpselector. More...
 
enum ast_transport_monitor_reg ast_sip_transport_monitor_register (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data)
 Register a reliable transport shutdown monitor callback. More...
 
enum ast_transport_monitor_reg ast_sip_transport_monitor_register_replace (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *ao2_data, ast_transport_monitor_data_matcher matches)
 Register a reliable transport shutdown monitor callback replacing any duplicate. More...
 
void ast_sip_transport_monitor_unregister (pjsip_transport *transport, ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
 Unregister a reliable transport shutdown monitor. More...
 
void ast_sip_transport_monitor_unregister_all (ast_transport_monitor_shutdown_cb cb, void *data, ast_transport_monitor_data_matcher matches)
 Unregister a transport shutdown monitor from all reliable transports. More...
 
void ast_sip_transport_state_register (struct ast_sip_tpmgr_state_callback *element)
 Register a transport state notification callback element. More...
 
int ast_sip_transport_state_set_preferred_identity (const char *transport_name, const char *identity)
 Sets the P-Preferred-Identity on a child transport. More...
 
int ast_sip_transport_state_set_service_routes (const char *transport_name, struct ast_sip_service_route_vector *service_routes)
 Sets the service routes on a child transport. More...
 
int ast_sip_transport_state_set_transport (const char *transport_name, pjsip_transport *transport)
 Sets the PJSIP transport on a child transport. More...
 
void ast_sip_transport_state_unregister (struct ast_sip_tpmgr_state_callback *element)
 Unregister a transport state notification callback element. More...
 
void ast_sip_unregister_authenticator (struct ast_sip_authenticator *auth)
 Unregister a SIP authenticator. More...
 
void ast_sip_unregister_endpoint_formatter (struct ast_sip_endpoint_formatter *obj)
 Unregister an endpoint formatter. More...
 
void ast_sip_unregister_endpoint_identifier (struct ast_sip_endpoint_identifier *identifier)
 Unregister a SIP endpoint identifier. More...
 
void ast_sip_unregister_outbound_authenticator (struct ast_sip_outbound_authenticator *auth)
 Unregister an outbound SIP authenticator. More...
 
void ast_sip_unregister_service (pjsip_module *module)
 
void ast_sip_unregister_supplement (struct ast_sip_supplement *supplement)
 Unregister a an supplement to SIP out of dialog processing. More...
 
 AST_VECTOR (ast_sip_service_route_vector, char *)
 
 AST_VECTOR (ast_sip_auth_objects_vector, struct ast_sip_auth *)
 Retrieve relevant SIP auth structures from sorcery as a vector. More...
 

Macro Definition Documentation

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

Referenced by digest_create_request_with_auth().

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

Referenced by ast_sip_send_out_of_dialog_request(), ast_sip_send_stateful_response(), ast_sip_subscription_get_header(), create_subscription_tree(), filter_on_tx_message(), get_restrictions(), session_inv_on_tsx_state_changed(), session_outgoing_nat_hook(), sip_subscription_accept(), and supplement_outgoing_response().

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

Referenced by ast_sip_create_response(), ast_sip_send_out_of_dialog_request(), ast_sip_send_stateful_response(), ast_sip_session_send_request_with_cb(), create_out_of_dialog_request(), create_subscription_tree(), get_restrictions(), session_outgoing_nat_hook(), sub_persistence_recreate(), and supplement_outgoing_response().

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

Referenced by process_nat(), and session_outgoing_nat_hook().

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

Referenced by change_outgoing_sdp_stream_media_address().

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

Referenced by find_aor(), get_destination(), handle_atsign(), options_on_rx_request(), publish_request_initial(), pubsub_on_rx_subscribe_request(), refer_incoming_blind_request(), rx_data_to_ast_msg(), session_inv_on_redirected(), sub_persistence_recreate(), and username_identify().

◆ AST_SIP_X_AST_TXP

#define AST_SIP_X_AST_TXP   "x-ast-txp"

URI parameter for symmetric transport

Definition at line 913 of file res_pjsip.h.

Referenced by ast_sip_get_transport_name(), on_rx_process_symmetric_transport(), sanitize_tdata(), and transport_apply().

◆ AST_SIP_X_AST_TXP_LEN

#define AST_SIP_X_AST_TXP_LEN   9

◆ MAX_RX_CHALLENGES

#define MAX_RX_CHALLENGES   10

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

Definition at line 80 of file res_pjsip.h.

Referenced by check_request_status(), outbound_invite_auth(), and session_inv_on_tsx_state_changed().

◆ PJSIP_EXPIRES_NOT_SPECIFIED

#define PJSIP_EXPIRES_NOT_SPECIFIED   ((pj_uint32_t)-1)

◆ PJSIP_MINVERSION

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

Definition at line 54 of file res_pjsip.h.

◆ SIP_SORCERY_DOMAIN_ALIAS_TYPE

#define SIP_SORCERY_DOMAIN_ALIAS_TYPE   "domain_alias"

Definition at line 254 of file res_pjsip.h.

Referenced by ast_sip_initialize_sorcery_domain_alias(), and domain_alias_apply().

◆ SIP_TLS_MAX_CIPHERS

#define SIP_TLS_MAX_CIPHERS   64

Maximum number of ciphers supported for a TLS transport.

Definition at line 77 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 1472 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 3461 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.
Returns
Nothing

Definition at line 3449 of file res_pjsip.h.

Enumeration Type Documentation

◆ ast_sip_auth_type

Methods of storing SIP digest authentication credentials.

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

Enumerator
AST_SIP_AUTH_TYPE_USER_PASS 

Credentials stored as a username and password combination

AST_SIP_AUTH_TYPE_MD5 

Credentials stored as an MD5 sum

AST_SIP_AUTH_TYPE_GOOGLE_OAUTH 

Google Oauth

AST_SIP_AUTH_TYPE_ARTIFICIAL 

Credentials not stored this is a fake auth

Definition at line 433 of file res_pjsip.h.

435  {
436  /*! Credentials stored as a username and password combination */
438  /*! Credentials stored as an MD5 sum */
440  /*! Google Oauth */
442  /*! Credentials not stored this is a fake auth */

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

535  {
536  /*! Two bits for merge */
537  /*! Intersection of local and remote */
539  /*! Union of local and remote */
541 
542  /*! Two bits for filter */
543  /*! No filter */
545  /*! Only the first */
547 
548  /*! Two bits for preference and sort */
549  /*! Prefer, and order by local values */

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

950  {

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

1011  {
1012  /*!
1013  * \brief Callback used to identify the source of a message.
1014  * See ast_sip_identify_endpoint for more details

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

323  {
324  /*! Frequency > 0, but no response from remote uri */
325  UNAVAILABLE,
326  /*! Frequency > 0, and got response from remote uri */
327  AVAILABLE,
328  /*! Default last status, and when a contact status object is not found */
329  UNKNOWN,
330  /*! Frequency == 0, has a contact, but don't know status (non-qualified) */
331  CREATED,
332  REMOVED,
333 };

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

497  {
498  /*! Take no special action to mitigate reinvite glare */
500  /*! Do not send an initial direct media session refresh on outgoing call legs
501  * Subsequent session refreshes will be sent no matter the session direction
502  */
504  /*! Do not send an initial direct media session refresh on incoming call legs

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

412  {
413  /*! No DTMF to be used */
415  /* XXX Should this be 2833 instead? */
416  /*! Use RFC 4733 events for DTMF */
418  /*! Use DTMF in the audio stream */
420  /*! Use SIP INFO DTMF (blech) */
422  /*! Use SIP 4733 if supported by the other side or INBAND if not */
424  /*! Use SIP 4733 if supported by the other side or INFO DTMF (blech) if not */

◆ 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

Definition at line 474 of file res_pjsip.h.

478  {
479  /*! Identify based on user name in From header */
481  /*! Identify based on user name in Auth header first, then From header */
483  /*! Identify based on source IP address */

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

510  {
511  /*! Invalid media encryption configuration */
513  /*! Do not allow any encryption of session media */
515  /*! Offer SDES-encrypted session media */

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

521  {
522  /*! User portion of the target URI should be used as the target in the dialplan */
524  /*! Target URI should be used as the target in the dialplan */

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

490  {
491  /*! Use reinvite to negotiate direct media */

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

2887  {

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

3477  {

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

References MIN.

Referenced by add_identity_header(), apply_dtls_attrib(), apply_negotiated_sdp_stream(), assign_uuid(), ast_sip_get_transport_name(), ast_sip_report_auth_challenge_sent(), ast_sip_report_auth_failed_challenge_response(), chan_pjsip_get_uniqueid(), change_outgoing_sdp_stream_media_address(), channel_read_pjsip(), cli_complete_subscription_common(), cli_list_subscriptions_detail(), cli_show_subscriptions_detail(), determine_sip_publish_type(), dialog_info_generate_body_content(), endpoint_lookup(), evaluate_like(), extract_contact_addr(), find_aor(), find_aor_name(), find_challenge(), get_auth_header(), get_codecs(), get_destination(), get_endpoint_details(), get_from_header(), get_mid_bundle_group(), get_user_agent(), handle_incoming_sdp(), handle_negotiated_sdp_session_media(), handle_registration_response(), headers_to_vars(), incoming_in_dialog_request(), log_failed_request(), negotiate_incoming_sdp_stream(), options_on_rx_request(), parse_uri_cb(), process_extmap_attributes(), process_ice_attributes(), process_ice_auth_attrb(), process_ssrc_attributes(), publish_request_initial(), pubsub_on_rx_publish_request(), pubsub_on_rx_subscribe_request(), refer_blind_callback(), refer_incoming_blind_request(), refer_incoming_refer_request(), register_aor_core(), rfc3326_use_reason_header(), rx_data_to_ast_msg(), save_response_fields_to_transport(), sdp_requires_deferral(), security_event_populate(), session_inv_on_redirected(), session_outgoing_nat_hook(), set_id_from_hdr(), set_id_from_oli(), set_mid_and_bundle_group(), set_redirecting_value(), set_remote_mslabel_and_stream_group(), set_sipdomain_variable(), sip_subscription_to_ami(), sub_persistence_recreate(), subscription_get_generator_from_rdata(), subscription_get_handler_from_rdata(), subscription_persistence_create(), subscription_persistence_update(), and transfer_refer().

5278 {
5279  size_t chars_to_copy = MIN(size - 1, pj_strlen(src));
5280  memcpy(dest, pj_strbuf(src), chars_to_copy);
5281  dest[chars_to_copy] = '\0';
5282 }
#define MIN(a, b)
Definition: utils.h:226

◆ 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
dest[out] The destination buffer
srcThe pj_str_t to copy
Return values
Numberof characters copied or negative value on error

Definition at line 5284 of file res_pjsip.c.

References ast_asprintf, and NULL.

5285 {
5286  int res = ast_asprintf(dest, "%.*s", (int)pj_strlen(src), pj_strbuf(src));
5287 
5288  if (res < 0) {
5289  *dest = NULL;
5290  }
5291 
5292  return res;
5293 }
#define NULL
Definition: resample.c:96
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:269

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

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_subscribe_request(), registrar_on_rx_request(), rx_data_to_ast_msg(), send_options_response(), send_response(), and supplement_on_rx_request().

970 {
971  struct ast_sip_endpoint *endpoint = rdata->endpt_info.mod_data[endpoint_mod.id];
972  if (endpoint) {
973  ao2_ref(endpoint, +1);
974  }
975  return endpoint;
976 }
static pjsip_module endpoint_mod
#define ao2_ref(o, delta)
Definition: astobj2.h:464
An entity with which Asterisk communicates.
Definition: res_pjsip.h:816

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

References ast_body_to_pjsip_body().

Referenced by build_notify_body(), msg_send(), send_unsolicited_mwi_notify_to_contact(), sendtext(), sip_publisher_service_queue(), transmit_info_dtmf(), and transmit_info_with_vidupdate().

5129 {
5130  pjsip_msg_body *pjsip_body = ast_body_to_pjsip_body(tdata->pool, body);
5131  tdata->msg->body = pjsip_body;
5132  return 0;
5133 }
static pjsip_msg_body * ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
Definition: res_pjsip.c:5115

◆ 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 parts of the body to add
Return values
0Success
-1Failure

Definition at line 5135 of file res_pjsip.c.

References ast_body_to_pjsip_body(), and NULL.

5136 {
5137  int i;
5138  /* NULL for type and subtype automatically creates "multipart/mixed" */
5139  pjsip_msg_body *body = pjsip_multipart_create(tdata->pool, NULL, NULL);
5140 
5141  for (i = 0; i < num_bodies; ++i) {
5142  pjsip_multipart_part *part = pjsip_multipart_create_part(tdata->pool);
5143  part->body = ast_body_to_pjsip_body(tdata->pool, bodies[i]);
5144  pjsip_multipart_add_part(tdata->pool, body, part);
5145  }
5146 
5147  tdata->msg->body = body;
5148  return 0;
5149 }
#define NULL
Definition: resample.c:96
static pjsip_msg_body * ast_body_to_pjsip_body(pj_pool_t *pool, const struct ast_sip_body *body)
Definition: res_pjsip.c:5115

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

References ast_sip_add_header(), and NULL.

Referenced by add_date_header(), and register_aor_core().

3326 {
3327  char date[256];
3328  struct tm tm;
3329  time_t t = time(NULL);
3330 
3331  gmtime_r(&t, &tm);
3332  strftime(date, sizeof(date), "%a, %d %b %Y %T GMT", &tm);
3333 
3334  ast_sip_add_header(tdata, "Date", date);
3335 }
#define NULL
Definition: resample.c:96
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:5100

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

References add_header(), and request_headers.

Referenced by global_apply().

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

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

References add_header(), and response_headers.

Referenced by global_apply().

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

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

Referenced by add_header_from_channel_var(), add_headers_to_message(), ast_sip_add_date_header(), ast_sip_message_apply_transport(), build_notify(), notify_channel(), notify_contact(), notify_uri(), options_incoming_request(), rfc3326_add_reason_header(), send_options_response(), sip_publication_respond(), transfer_refer(), and vars_to_headers().

5101 {
5102  pj_str_t hdr_name;
5103  pj_str_t hdr_value;
5104  pjsip_generic_string_hdr *hdr;
5105 
5106  pj_cstr(&hdr_name, name);
5107  pj_cstr(&hdr_value, value);
5108 
5109  hdr = pjsip_generic_string_hdr_create(tdata->pool, &hdr_name, &hdr_value);
5110 
5111  pjsip_msg_add_hdr(tdata->msg, (pjsip_hdr *) hdr);
5112  return 0;
5113 }
static const char name[]
Definition: format_mp3.c:68
int value
Definition: syslog.c:37

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

References AST_DIGIT_ANY, and ast_sip_endpoint::usereqphone.

Referenced by ast_sip_create_dialog_uac(), create_out_of_dialog_request(), and set_from_header().

4032 {
4033  pjsip_sip_uri *sip_uri;
4034  int i = 0;
4035  static const pj_str_t STR_PHONE = { "phone", 5 };
4036 
4037  if (!endpoint || !endpoint->usereqphone || (!PJSIP_URI_SCHEME_IS_SIP(uri) && !PJSIP_URI_SCHEME_IS_SIPS(uri))) {
4038  return;
4039  }
4040 
4041  sip_uri = pjsip_uri_get_uri(uri);
4042 
4043  if (!pj_strlen(&sip_uri->user)) {
4044  return;
4045  }
4046 
4047  if (pj_strbuf(&sip_uri->user)[0] == '+') {
4048  i = 1;
4049  }
4050 
4051  /* Test URI user against allowed characters in AST_DIGIT_ANY */
4052  for (; i < pj_strlen(&sip_uri->user); i++) {
4053  if (!strchr(AST_DIGIT_ANY, pj_strbuf(&sip_uri->user)[i])) {
4054  break;
4055  }
4056  }
4057 
4058  if (i < pj_strlen(&sip_uri->user)) {
4059  return;
4060  }
4061 
4062  sip_uri->user_param = STR_PHONE;
4063 }
#define AST_DIGIT_ANY
Definition: file.h:48
unsigned int usereqphone
Definition: res_pjsip.h:881

◆ 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
bodyThe string to append to the end of the current body
Return values
0Success
-1Failure

Definition at line 5151 of file res_pjsip.c.

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

5152 {
5153  size_t combined_size = strlen(body_text) + tdata->msg->body->len;
5154  struct ast_str *body_buffer = ast_str_alloca(combined_size);
5155 
5156  ast_str_set(&body_buffer, 0, "%.*s%s", (int) tdata->msg->body->len, (char *) tdata->msg->body->data, body_text);
5157 
5158  tdata->msg->body->data = pj_pool_alloc(tdata->pool, combined_size);
5159  pj_memcpy(tdata->msg->body->data, ast_str_buffer(body_buffer), combined_size);
5160  tdata->msg->body->len = combined_size;
5161 
5162  return 0;
5163 }
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
#define ast_str_alloca(init_len)
Definition: strings.h:800
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:1065
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584

◆ ast_sip_auth_type_to_str()

const char* ast_sip_auth_type_to_str ( enum ast_sip_auth_type  type)

Converts the given auth type to a string.

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

Definition at line 80 of file config_auth.c.

References ARRAY_IN_BOUNDS, auth_types_map, and type.

Referenced by auth_type_to_str().

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

◆ ast_sip_auth_vector_destroy()

void ast_sip_auth_vector_destroy ( struct ast_sip_auth_vector vector)

Free contents of an auth vector.

Parameters
arrayVector whose contents are to be freed

Definition at line 249 of file pjsip_configuration.c.

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

250 {
251  int i;
252  size_t size;
253 
254  if (!auths) {
255  return;
256  }
257 
258  size = AST_VECTOR_SIZE(auths);
259 
260  for (i = 0; i < size; ++i) {
261  const char *name = AST_VECTOR_REMOVE_UNORDERED(auths, 0);
262  ast_free((char *) name);
263  }
264  AST_VECTOR_FREE(auths);
265 }
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
static const char name[]
Definition: format_mp3.c:68
#define AST_VECTOR_REMOVE_UNORDERED(vec, idx)
Remove an element from an unordered vector by index.
Definition: vector.h:438
#define ast_free(a)
Definition: astmm.h:182
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

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

Referenced by inbound_auth_handler(), and outbound_auth_handler().

268 {
269  char *auth_names = ast_strdupa(value);
270  char *val;
271 
272  ast_assert(auths != NULL);
273 
274  if (AST_VECTOR_SIZE(auths)) {
276  }
277  if (AST_VECTOR_INIT(auths, 1)) {
278  return -1;
279  }
280 
281  while ((val = ast_strip(strsep(&auth_names, ",")))) {
282  if (ast_strlen_zero(val)) {
283  continue;
284  }
285 
286  val = ast_strdup(val);
287  if (!val) {
288  goto failure;
289  }
290  if (AST_VECTOR_APPEND(auths, val)) {
291  ast_free(val);
292 
293  goto failure;
294  }
295  }
296  return 0;
297 
298 failure:
300  return -1;
301 }
Definition: ast_expr2.c:325
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256
void ast_sip_auth_vector_destroy(struct ast_sip_auth_vector *auths)
Free contents of an auth vector.
#define ast_assert(a)
Definition: utils.h:710
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
int value
Definition: syslog.c:37
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
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:219
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#define ast_free(a)
Definition: astmm.h:182
char * strsep(char **str, const char *delims)
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

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

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

318 {
319  if (!auths || !AST_VECTOR_SIZE(auths)) {
320  return 0;
321  }
322 
323  if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
324  return -1;
325  }
326 
327  /* I feel like accessing the vector's elem array directly is cheating...*/
328  ast_join_delim(*buf, MAX_OBJECT_FIELD, auths->elems, AST_VECTOR_SIZE(auths), ',');
329  return 0;
330 }
const char ** elems
Definition: res_pjsip.h:469
void ast_join_delim(char *s, size_t len, const char *const w[], unsigned int size, char delim)
Definition: main/utils.c:2130
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
Definition: sorcery.h:110
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

References value.

Referenced by incoming_call_offer_pref_to_str(), log_caps(), and outgoing_call_offer_pref_to_str().

5572 {
5573  const char *value;
5574 
5575  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)) {
5576  value = "local";
5577  } 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)) {
5578  value = "local_merge";
5579  } 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)) {
5580  value = "local_first";
5581  } 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)) {
5582  value = "remote";
5583  } 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)) {
5584  value = "remote_merge";
5585  } 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)) {
5586  value = "remote_first";
5587  } else {
5588  value = "unknown";
5589  }
5590 
5591  return value;
5592 }
int value
Definition: syslog.c:37

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

References ast_set_flag, AST_SIP_CALL_CODEC_PREF_ALL, AST_SIP_CALL_CODEC_PREF_FIRST, AST_SIP_CALL_CODEC_PREF_INTERSECT, AST_SIP_CALL_CODEC_PREF_LOCAL, AST_SIP_CALL_CODEC_PREF_REMOTE, AST_SIP_CALL_CODEC_PREF_UNION, and ast_flags::flags.

Referenced by call_offer_pref_handler(), and test_create_joint().

5595 {
5596  pref->flags = 0;
5597 
5598  if (strcmp(pref_str, "local") == 0) {
5600  } else if (is_outgoing && strcmp(pref_str, "local_merge") == 0) {
5602  } else if (strcmp(pref_str, "local_first") == 0) {
5604  } else if (strcmp(pref_str, "remote") == 0) {
5606  } else if (is_outgoing && strcmp(pref_str, "remote_merge") == 0) {
5608  } else if (strcmp(pref_str, "remote_first") == 0) {
5610  } else {
5611  return -1;
5612  }
5613 
5614  return 0;
5615 }
#define ast_set_flag(p, flag)
Definition: utils.h:70
unsigned int flags
Definition: utils.h:200

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

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

Referenced by authenticate().

3416 {
3417  if (!registered_authenticator) {
3418  ast_log(LOG_WARNING, "No SIP authenticator registered. Assuming authentication is successful\n");
3420  }
3421  return registered_authenticator->check_authentication(endpoint, rdata, tdata);
3422 }
static struct ast_sip_authenticator * registered_authenticator
Definition: res_pjsip.c:3373
#define LOG_WARNING
Definition: logger.h:274
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:969
#define ast_log
Definition: astobj2.c:42

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

References ao2_cleanup.

Referenced by digest_check_auth(), and set_outbound_initial_authentication_credentials().

2379 {
2380  int i;
2381  for (i = 0; i < num_auths; ++i) {
2382  ao2_cleanup(auths[i]);
2383  }
2384 }
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

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

768 {
769  struct ast_sip_contact_wrapper *wrapper = object;
770  struct ast_str **buf = arg;
771 
772  ast_str_append(buf, 0, "%s,", wrapper->contact_id);
773 
774  return 0;
775 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
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:1091
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:398
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584

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

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

1585 {
1587 
1588  if (!(buf)) {
1589  astman_send_error_va(ami->s, ami->m, "Unable create event "
1590  "for %s\n", event);
1591  return NULL;
1592  }
1593 
1594  ast_str_set(&buf, 0, "Event: %s\r\n", event);
1595  if (!ast_strlen_zero(ami->action_id)) {
1596  ast_str_append(&buf, 0, "ActionID: %s\r\n", ami->action_id);
1597  }
1598  return buf;
1599 }
const struct message * m
Definition: res_pjsip.h:2745
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
Definition: astman.c:222
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:1091
#define NULL
Definition: resample.c:96
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:3164
#define AMI_DEFAULT_STR_SIZE
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:1065
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
struct mansession * s
Definition: res_pjsip.h:2743
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
const char * action_id
Definition: res_pjsip.h:2747
#define ast_str_create(init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:620

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

References ast_log, ast_sip_add_usereqphone(), ast_sip_dlg_set_transport(), ast_sip_tpselector_unref(), ast_sorcery_object_get_id(), ast_strlen_zero(), ast_sip_endpoint::contact_user, ast_sip_endpoint::fromdomain, ast_sip_endpoint::fromuser, ast_sip_endpoint::info, LOG_ERROR, NULL, ast_sip_endpoint::outbound_proxy, sip_dialog_create_from(), and tmp().

Referenced by ast_sip_create_subscription(), and ast_sip_session_create_outgoing().

4067 {
4068  char enclosed_uri[PJSIP_MAX_URL_SIZE];
4069  pj_str_t local_uri = { "sip:temp@temp", 13 }, remote_uri, target_uri;
4070  pj_status_t res;
4071  pjsip_dialog *dlg = NULL;
4072  const char *outbound_proxy = endpoint->outbound_proxy;
4073  pjsip_tpselector selector = { .type = PJSIP_TPSELECTOR_NONE, };
4074  static const pj_str_t HCONTACT = { "Contact", 7 };
4075 
4076  snprintf(enclosed_uri, sizeof(enclosed_uri), "<%s>", uri);
4077  pj_cstr(&remote_uri, enclosed_uri);
4078 
4079  pj_cstr(&target_uri, uri);
4080 
4081  res = pjsip_dlg_create_uac(pjsip_ua_instance(), &local_uri, NULL, &remote_uri, &target_uri, &dlg);
4082  if (res == PJ_SUCCESS && !(PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target))) {
4083  /* dlg->target is a pjsip_other_uri, but it's assumed to be a
4084  * pjsip_sip_uri below. Fail fast. */
4085  res = PJSIP_EINVALIDURI;
4086  pjsip_dlg_terminate(dlg);
4087  }
4088  if (res != PJ_SUCCESS) {
4089  if (res == PJSIP_EINVALIDURI) {
4091  "Endpoint '%s': Could not create dialog to invalid URI '%s'. Is endpoint registered and reachable?\n",
4092  ast_sorcery_object_get_id(endpoint), uri);
4093  }
4094  return NULL;
4095  }
4096 
4097  /* We have to temporarily bump up the sess_count here so the dialog is not prematurely destroyed */
4098  dlg->sess_count++;
4099 
4100  ast_sip_dlg_set_transport(endpoint, dlg, &selector);
4101 
4102  if (sip_dialog_create_from(dlg->pool, &local_uri, endpoint->fromuser, endpoint->fromdomain, &remote_uri, &selector)) {
4103  dlg->sess_count--;
4104  pjsip_dlg_terminate(dlg);
4105  ast_sip_tpselector_unref(&selector);
4106  return NULL;
4107  }
4108 
4109  ast_sip_tpselector_unref(&selector);
4110 
4111  /* Update the dialog with the new local URI, we do it afterwards so we can use the dialog pool for construction */
4112  pj_strdup_with_null(dlg->pool, &dlg->local.info_str, &local_uri);
4113  dlg->local.info->uri = pjsip_parse_uri(dlg->pool, dlg->local.info_str.ptr, dlg->local.info_str.slen, 0);
4114  if (!dlg->local.info->uri) {
4116  "Could not parse URI '%s' for endpoint '%s'\n",
4117  dlg->local.info_str.ptr, ast_sorcery_object_get_id(endpoint));
4118  dlg->sess_count--;
4119  pjsip_dlg_terminate(dlg);
4120  return NULL;
4121  }
4122 
4123  dlg->local.contact = pjsip_parse_hdr(dlg->pool, &HCONTACT, local_uri.ptr, local_uri.slen, NULL);
4124 
4125  if (!ast_strlen_zero(endpoint->contact_user)) {
4126  pjsip_sip_uri *sip_uri;
4127 
4128  sip_uri = pjsip_uri_get_uri(dlg->local.contact->uri);
4129  pj_strdup2(dlg->pool, &sip_uri->user, endpoint->contact_user);
4130  }
4131 
4132  /* If a request user has been specified and we are permitted to change it, do so */
4133  if (!ast_strlen_zero(request_user)) {
4134  pjsip_sip_uri *sip_uri;
4135 
4136  if (PJSIP_URI_SCHEME_IS_SIP(dlg->target) || PJSIP_URI_SCHEME_IS_SIPS(dlg->target)) {
4137  sip_uri = pjsip_uri_get_uri(dlg->target);
4138  pj_strdup2(dlg->pool, &sip_uri->user, request_user);
4139  }
4140  if (PJSIP_URI_SCHEME_IS_SIP(dlg->remote.info->uri) || PJSIP_URI_SCHEME_IS_SIPS(dlg->remote.info->uri)) {
4141  sip_uri = pjsip_uri_get_uri(dlg->remote.info->uri);
4142  pj_strdup2(dlg->pool, &sip_uri->user, request_user);
4143  }
4144  }
4145 
4146  /* Add the user=phone parameter if applicable */
4147  ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->target);
4148  ast_sip_add_usereqphone(endpoint, dlg->pool, dlg->remote.info->uri);
4149 
4150  if (!ast_strlen_zero(outbound_proxy)) {
4151  pjsip_route_hdr route_set, *route;
4152  static const pj_str_t ROUTE_HNAME = { "Route", 5 };
4153  pj_str_t tmp;
4154 
4155  pj_list_init(&route_set);
4156 
4157  pj_strdup2_with_null(dlg->pool, &tmp, outbound_proxy);
4158  if (!(route = pjsip_parse_hdr(dlg->pool, &ROUTE_HNAME, tmp.ptr, tmp.slen, NULL))) {
4159  ast_log(LOG_ERROR, "Could not create dialog to endpoint '%s' as outbound proxy URI '%s' is not valid\n",
4160  ast_sorcery_object_get_id(endpoint), outbound_proxy);
4161  dlg->sess_count--;
4162  pjsip_dlg_terminate(dlg);
4163  return NULL;
4164  }
4165  pj_list_insert_nodes_before(&route_set, route);
4166 
4167  pjsip_dlg_set_route_set(dlg, &route_set);
4168  }
4169 
4170  dlg->sess_count--;
4171 
4172  return dlg;
4173 }
void ast_sip_add_usereqphone(const struct ast_sip_endpoint *endpoint, pj_pool_t *pool, pjsip_uri *uri)
Add &#39;user=phone&#39; parameter to URI if enabled and user is a phone number.
Definition: res_pjsip.c:4031
const ast_string_field fromuser
Definition: res_pjsip.h:833
char * contact_user
Definition: res_pjsip.h:891
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
const ast_string_field outbound_proxy
Definition: res_pjsip.h:823
struct ast_sip_endpoint_info_configuration info
Definition: res_pjsip.h:853
#define LOG_ERROR
Definition: logger.h:285
void ast_sip_tpselector_unref(pjsip_tpselector *selector)
Unreference a pjsip_tpselector.
Definition: res_pjsip.c:4024
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:3828
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:3850
const ast_string_field fromdomain
Definition: res_pjsip.h:835

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

References create_dialog_uas().

4271 {
4272 #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
4273  pjsip_dialog *dlg;
4274 
4275  dlg = create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas_and_inc_lock);
4276  if (dlg) {
4277  pjsip_dlg_dec_lock(dlg);
4278  }
4279 
4280  return dlg;
4281 #else
4282  return create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas);
4283 #endif
4284 }
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:4214
jack_status_t status
Definition: app_jack.c:146

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

References create_dialog_uas().

Referenced by create_subscription_tree(), and pre_session_setup().

4288 {
4289 #ifdef HAVE_PJSIP_DLG_CREATE_UAS_AND_INC_LOCK
4290  return create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas_and_inc_lock);
4291 #else
4292  /*
4293  * This is put here in order to be compatible with older versions of pjproject.
4294  * Best we can do in this case is immediately lock after getting the dialog.
4295  * However, that does leave a "gap" between creating and locking.
4296  */
4297  pjsip_dialog *dlg;
4298 
4299  dlg = create_dialog_uas(endpoint, rdata, status, pjsip_dlg_create_uas);
4300  if (dlg) {
4301  pjsip_dlg_inc_lock(dlg);
4302  }
4303 
4304  return dlg;
4305 #endif
4306  }
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:4214
jack_status_t status
Definition: app_jack.c:146

◆ 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
rdata[out]The 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 4360 of file res_pjsip.c.

References ast_sip_create_rdata_with_contact(), and NULL.

4362 {
4363  return ast_sip_create_rdata_with_contact(rdata, packet, src_name, src_port, transport_type,
4364  local_name, local_port, NULL);
4365 }
#define NULL
Definition: resample.c:96
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:4308

◆ 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
rdata[out]The 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 4308 of file res_pjsip.c.

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

Referenced by ast_sip_create_rdata(), and subscription_persistence_recreate().

4310 {
4311  pj_str_t tmp;
4312 
4313  /*
4314  * Initialize the error list in case there is a parse error
4315  * in the given packet.
4316  */
4317  pj_list_init(&rdata->msg_info.parse_err);
4318 
4319  rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
4320  if (!rdata->tp_info.transport) {
4321  return -1;
4322  }
4323 
4324  ast_copy_string(rdata->pkt_info.packet, packet, sizeof(rdata->pkt_info.packet));
4325  ast_copy_string(rdata->pkt_info.src_name, src_name, sizeof(rdata->pkt_info.src_name));
4326  rdata->pkt_info.src_port = src_port;
4327  pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&tmp, src_name), &rdata->pkt_info.src_addr);
4328  pj_sockaddr_set_port(&rdata->pkt_info.src_addr, src_port);
4329 
4330  pjsip_parse_rdata(packet, strlen(packet), rdata);
4331  if (!rdata->msg_info.msg || !pj_list_empty(&rdata->msg_info.parse_err)) {
4332  return -1;
4333  }
4334 
4335  if (!ast_strlen_zero(contact)) {
4336  pjsip_contact_hdr *contact_hdr;
4337 
4338  contact_hdr = pjsip_msg_find_hdr(rdata->msg_info.msg, PJSIP_H_CONTACT, NULL);
4339  if (contact_hdr) {
4340  contact_hdr->uri = pjsip_parse_uri(rdata->tp_info.pool, (char *)contact,
4341  strlen(contact), PJSIP_PARSE_URI_AS_NAMEADDR);
4342  if (!contact_hdr->uri) {
4343  ast_log(LOG_WARNING, "Unable to parse contact URI from '%s'.\n", contact);
4344  return -1;
4345  }
4346  }
4347  }
4348 
4349  pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
4350  rdata->msg_info.via->rport_param = -1;
4351 
4352  rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
4353  rdata->tp_info.transport->type_name = transport_type;
4354  pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
4355  rdata->tp_info.transport->local_name.port = local_port;
4356 
4357  return 0;
4358 }
#define LOG_WARNING
Definition: logger.h:274
static int tmp()
Definition: bt_open.c:389
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

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

References ast_assert, ast_log, create_in_dialog_request(), create_out_of_dialog_request(), get_pjsip_method(), LOG_WARNING, NULL, and pmethod.

Referenced by msg_send(), notify_channel(), notify_contact(), notify_uri(), send_unsolicited_mwi_notify_to_contact(), sendtext(), sip_options_qualify_contact(), transmit_info_dtmf(), and transmit_info_with_vidupdate().

4530 {
4531  const pjsip_method *pmethod = get_pjsip_method(method);
4532 
4533  if (!pmethod) {
4534  ast_log(LOG_WARNING, "Unknown method '%s'. Cannot send request\n", method);
4535  return -1;
4536  }
4537 
4538  if (dlg) {
4539  return create_in_dialog_request(pmethod, dlg, tdata);
4540  } else {
4541  ast_assert(endpoint != NULL);
4542  return create_out_of_dialog_request(pmethod, endpoint, uri, contact, tdata);
4543  }
4544 }
static const pjsip_method * get_pjsip_method(const char *method)
Definition: res_pjsip.c:4388
static int create_in_dialog_request(const pjsip_method *method, struct pjsip_dialog *dlg, pjsip_tx_data **tdata)
Definition: res_pjsip.c:4399
#define LOG_WARNING
Definition: logger.h:274
const pjsip_method * pmethod
Definition: res_pjsip.c:4373
#define ast_assert(a)
Definition: utils.h:710
#define NULL
Definition: resample.c:96
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:4417
#define ast_log
Definition: astobj2.c:42
const char * method
Definition: res_pjsip.c:4372

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

References ast_log, ast_sip_outbound_authenticator::create_request_with_auth, and LOG_WARNING.

Referenced by check_request_status(), handle_registration_response(), outbound_invite_auth(), session_inv_on_tsx_state_changed(), and sip_outbound_publish_callback().

3451 {
3453  ast_log(LOG_WARNING, "No SIP outbound authenticator registered. Cannot respond to authentication challenge\n");
3454  return -1;
3455  }
3456  return registered_outbound_authenticator->create_request_with_auth(auths, challenge, old_request, new_request);
3457 }
#define LOG_WARNING
Definition: logger.h:274
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:990
static struct ast_sip_outbound_authenticator * registered_outbound_authenticator
Definition: res_pjsip.c:3424
#define ast_log
Definition: astobj2.c:42
static void challenge(const char *realm, pjsip_tx_data *tdata, const pjsip_rx_data *rdata, int is_stale)
astobj2 callback for adding digest challenges to responses

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

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

Referenced by register_aor_core(), send_options_response(), and send_response().

5487 {
5488  int res = pjsip_endpt_create_response(ast_sip_get_pjsip_endpoint(), rdata, st_code, NULL, tdata);
5489 
5490  if (!res) {
5491  ast_sip_mod_data_set((*tdata)->pool, (*tdata)->mod_data, supplement_module.id, MOD_DATA_CONTACT, ao2_bump(contact));
5492  }
5493 
5494  return res;
5495 }
#define NULL
Definition: resample.c:96
#define ao2_bump(obj)
Definition: astobj2.h:491
static pjsip_module supplement_module
Definition: res_pjsip.c:4410
#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:2674
#define MOD_DATA_CONTACT
Definition: res_pjsip.c:3301
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:3755

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

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

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

2355 {
2358  sip_sorcery, "endpoint", name);
2359 }
static const char name[]
Definition: format_mp3.c:68
#define NULL
Definition: resample.c:96
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
char * ast_sip_global_default_outbound_endpoint(void)
static struct ast_sorcery * sip_sorcery
#define ast_free(a)
Definition: astmm.h:182

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

References NULL.

5376 {
5377  unsigned int hval = 0;
5378 
5379  if (!ht) {
5380  return NULL;
5381  }
5382 
5383  return pj_hash_get(ht, key, PJ_HASH_KEY_STRING, &hval);
5384 }
#define NULL
Definition: resample.c:96

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

5388 {
5389  if (!ht) {
5390  ht = pj_hash_create(pool, 11);
5391  }
5392 
5393  pj_hash_set(pool, ht, key, PJ_HASH_KEY_STRING, 0, val);
5394 
5395  return ht;
5396 }
Definition: ast_expr2.c:325

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

References ast_sip_set_tpselector_from_ep_or_uri(), and ast_sip_tpselector_unref().

Referenced by ast_sip_create_dialog_uac().

3830 {
3831  pjsip_sip_uri *uri;
3832  pjsip_tpselector sel = { .type = PJSIP_TPSELECTOR_NONE, };
3833 
3834  uri = pjsip_uri_get_uri(dlg->target);
3835  if (!selector) {
3836  selector = &sel;
3837  }
3838 
3839  ast_sip_set_tpselector_from_ep_or_uri(endpoint, uri, selector);
3840 
3841  pjsip_dlg_set_transport(dlg, selector);
3842 
3843  if (selector == &sel) {
3845  }
3846 
3847  return 0;
3848 }
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:4012
void ast_sip_tpselector_unref(pjsip_tpselector *selector)
Unreference a pjsip_tpselector.
Definition: res_pjsip.c:4024

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

References ast_copy_string(), AST_SIP_DTMF_AUTO, AST_SIP_DTMF_AUTO_INFO, AST_SIP_DTMF_INBAND, AST_SIP_DTMF_INFO, AST_SIP_DTMF_NONE, and AST_SIP_DTMF_RFC_4733.

Referenced by dtmf_to_str(), and pjsip_acf_dtmf_mode_read().

5523 {
5524  switch (dtmf) {
5525  case AST_SIP_DTMF_NONE:
5526  ast_copy_string(buf, "none", buf_len);
5527  break;
5528  case AST_SIP_DTMF_RFC_4733:
5529  ast_copy_string(buf, "rfc4733", buf_len);
5530  break;
5531  case AST_SIP_DTMF_INBAND:
5532  ast_copy_string(buf, "inband", buf_len);
5533  break;
5534  case AST_SIP_DTMF_INFO:
5535  ast_copy_string(buf, "info", buf_len);
5536  break;
5537  case AST_SIP_DTMF_AUTO:
5538  ast_copy_string(buf, "auto", buf_len);
5539  break;
5541  ast_copy_string(buf, "auto_info", buf_len);
5542  break;
5543  default:
5544  buf[0] = '\0';
5545  return -1;
5546  }
5547  return 0;
5548 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401

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

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_VECTOR_INIT, ast_sip_endpoint_media_configuration::codecs, sip_persistent_endpoint::endpoint, 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().

2308 {
2309  struct ast_sip_endpoint *endpoint = ast_sorcery_generic_alloc(sizeof(*endpoint), endpoint_destructor);
2310  if (!endpoint) {
2311  return NULL;
2312  }
2313  if (ast_string_field_init(endpoint, 64)) {
2314  ao2_cleanup(endpoint);
2315  return NULL;
2316  }
2317 
2319  ao2_cleanup(endpoint);
2320  return NULL;
2321  }
2323  ao2_cleanup(endpoint);
2324  return NULL;
2325  }
2326  if (init_info_configuration(&endpoint->info)) {
2327  ao2_cleanup(endpoint);
2328  return NULL;
2329  }
2330  if (init_media_configuration(&endpoint->media)) {
2331  ao2_cleanup(endpoint);
2332  return NULL;
2333  }
2334 
2335  ast_party_id_init(&endpoint->id.self);
2336  endpoint->id.self.tag = ast_strdup("");
2337 
2338  if (AST_VECTOR_INIT(&endpoint->ident_method_order, 1)) {
2339  return NULL;
2340  }
2341 
2342  return endpoint;
2343 }
static int init_info_configuration(struct ast_sip_endpoint_info_configuration *info)
static int init_subscription_configuration(struct ast_sip_endpoint_subscription_configuration *subscription)
static int init_media_configuration(struct ast_sip_endpoint_media_configuration *media)
struct ast_format_cap * codecs
Definition: res_pjsip.h:774
struct ast_sip_endpoint_subscription_configuration subscription
Definition: res_pjsip.h:847
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
struct ast_sip_endpoint_media_configuration media
Definition: res_pjsip.h:845
struct ast_sip_identify_by_vector ident_method_order
Definition: res_pjsip.h:865
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:353
An entity with which Asterisk communicates.
Definition: res_pjsip.h:816
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
struct ast_sip_endpoint_id_configuration id
Definition: res_pjsip.h:851
static void endpoint_destructor(void *obj)
struct ast_sip_endpoint_info_configuration info
Definition: res_pjsip.h:853
void ast_party_id_init(struct ast_party_id *init)
Initialize the given party id structure.
Definition: channel.c:1753
char * tag
User-set "tag".
Definition: channel.h:355
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
struct ast_party_id self
Definition: res_pjsip.h:631
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728

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

References NULL, and send_request_cb().

Referenced by check_request_status(), and handle_registration_response().

4909 {
4910  pjsip_via_hdr *via;
4911 
4912  if (!tdata || !tdata->dest_info.addr.count
4913  || (tdata->dest_info.cur_addr == tdata->dest_info.addr.count - 1)) {
4914  /* No more addresses to try */
4915  return 0;
4916  }
4917 
4918  /* Try next address */
4919  ++tdata->dest_info.cur_addr;
4920 
4921  via = (pjsip_via_hdr*)pjsip_msg_find_hdr(tdata->msg, PJSIP_H_VIA, NULL);
4922  via->branch_param.slen = 0;
4923 
4924  pjsip_tx_data_invalidate_msg(tdata);
4925 
4926  return 1;
4927 }
#define NULL
Definition: resample.c:96

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

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

685 {
686  char *copy;
687  char *name;
688  int res;
689 
690  if (!on_aor || ast_strlen_zero(aors)) {
691  return 0;
692  }
693 
694  copy = ast_strdupa(aors);
695  while ((name = ast_strip(strsep(&copy, ",")))) {
696  struct ast_sip_aor *aor;
697 
698  aor = ast_sip_location_retrieve_aor(name);
699  if (aor) {
700  res = on_aor(aor, arg, 0);
701  ao2_ref(aor, -1);
702  if (res) {
703  return -1;
704  }
705  }
706  }
707  return 0;
708 }
static const char name[]
Definition: format_mp3.c:68
A SIP address of record.
Definition: res_pjsip.h:361
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition: location.c:147
static int copy(char *infile, char *outfile)
Utility function to copy a file.
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:219
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
char * strsep(char **str, const char *delims)
const ast_string_field aors
Definition: res_pjsip.h:825

◆ ast_sip_for_each_auth()

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

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

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

Definition at line 135 of file config_auth.c.

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

Referenced by ast_sip_format_auths_ami(), and cli_iterator().

137 {
138  int i;
139 
140  if (!vector || !AST_VECTOR_SIZE(vector)) {
141  return 0;
142  }
143 
144  for (i = 0; i < AST_VECTOR_SIZE(vector); ++i) {
145  /* AST_VECTOR_GET is safe to use since the vector is immutable */
147  ast_sip_get_sorcery(), SIP_SORCERY_AUTH_TYPE,
148  AST_VECTOR_GET(vector,i)), ao2_cleanup);
149 
150  if (!auth) {
151  continue;
152  }
153 
154  if (on_auth(auth, arg, 0)) {
155  return -1;
156  }
157  }
158 
159  return 0;
160 }
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

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

1553 {
1554  RAII_VAR(struct ast_endpoint_snapshot *, endpoint_snapshot, ast_sip_get_endpoint_snapshot(endpoint), ao2_cleanup);
1555  return ast_sip_for_each_channel_snapshot(endpoint_snapshot, on_channel_snapshot, arg);
1556 }
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 &#39;on_channel_snapshot&#39; handler...
#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:911
A snapshot of an endpoint&#39;s state.
struct ast_endpoint_snapshot * ast_sip_get_endpoint_snapshot(const struct ast_sip_endpoint *endpoint)
Retrieve the endpoint snapshot for an endpoint.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

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

Referenced by active_channels_to_str(), and ast_sip_for_each_channel().

1526 {
1527  int num, num_channels = endpoint_snapshot->num_channels;
1528 
1529  if (!on_channel_snapshot || !num_channels) {
1530  return 0;
1531  }
1532 
1533  for (num = 0; num < num_channels; ++num) {
1534  RAII_VAR(struct ast_channel_snapshot *, snapshot, NULL, ao2_cleanup);
1535  int res;
1536 
1537  snapshot = ast_channel_snapshot_get_latest(endpoint_snapshot->channel_ids[num]);
1538  if (!snapshot) {
1539  continue;
1540  }
1541 
1542  res = on_channel_snapshot(snapshot, arg, 0);
1543  if (res) {
1544  return -1;
1545  }
1546  }
1547  return 0;
1548 }
Structure representing a snapshot of channel state.
#define NULL
Definition: resample.c:96
#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:911
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...
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

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

721 {
722  struct ao2_container *contacts;
723  struct ao2_iterator i;
724  int res = 0;
725  void *object = NULL;
726 
727  if (!on_contact ||
728  !(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
729  return 0;
730  }
731 
732  i = ao2_iterator_init(contacts, 0);
733  while ((object = ao2_iterator_next(&i))) {
734  RAII_VAR(struct ast_sip_contact *, contact, object, ao2_cleanup);
735  RAII_VAR(struct ast_sip_contact_wrapper *, wrapper, NULL, ao2_cleanup);
736  const char *aor_id = ast_sorcery_object_get_id(aor);
737 
738  wrapper = ao2_alloc_options(sizeof(struct ast_sip_contact_wrapper),
740  if (!wrapper) {
741  res = -1;
742  break;
743  }
744  wrapper->contact_id = ast_malloc(strlen(aor_id) + strlen(contact->uri) + 2);
745  if (!wrapper->contact_id) {
746  res = -1;
747  break;
748  }
749  sprintf(wrapper->contact_id, "%s/%s", aor_id, contact->uri);
750  wrapper->aor_id = ast_strdup(aor_id);
751  if (!wrapper->aor_id) {
752  res = -1;
753  break;
754  }
755  wrapper->contact = contact;
756  ao2_bump(wrapper->contact);
757 
758  if ((res = on_contact(wrapper, arg, 0))) {
759  break;
760  }
761  }
763  ao2_ref(contacts, -1);
764  return res;
765 }
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define NULL
Definition: resample.c:96
#define ao2_bump(obj)
Definition: astobj2.h:491
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
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:398
#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:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
static void contact_wrapper_destroy(void *obj)
Definition: location.c:710
Contact associated with an address of record.
Definition: res_pjsip.h:281
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Generic container type.
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.

◆ ast_sip_format_auths_ami()

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

Format auth details for AMI.

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

Definition at line 195 of file config_auth.c.

References ast_sip_for_each_auth(), and format_ami_auth_handler().

Referenced by ami_outbound_registration_task(), and format_ami_endpoint_auth().

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

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

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(), astman_append(), ast_sip_contact::authenticate_qualify, AVAILABLE, buf, ast_sip_contact::call_id, ast_sip_contact_wrapper::contact, ast_sip_ami::count, ast_sip_contact::endpoint_name, ast_sip_contact::expiration_time, ast_sip_contact::outbound_proxy, ast_sip_contact::path, ast_sip_contact::qualify_frequency, ast_sip_contact::qualify_timeout, ast_sip_contact_status::rtt, ast_sip_ami::s, S_OR, status, ast_sip_contact_status::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().

2718 {
2719  struct ast_sip_contact_wrapper *wrapper = obj;
2720  struct ast_sip_contact *contact = wrapper->contact;
2721  struct ast_sip_ami *ami = arg;
2723  struct ast_str *buf;
2724  const struct ast_sip_endpoint *endpoint = ami->arg;
2725 
2726  buf = ast_sip_create_ami_event("ContactStatusDetail", ami);
2727  if (!buf) {
2728  return -1;
2729  }
2730 
2731  status = ast_sip_get_contact_status(contact);
2732 
2733  ast_str_append(&buf, 0, "AOR: %s\r\n", wrapper->aor_id);
2734  ast_str_append(&buf, 0, "URI: %s\r\n", contact->uri);
2735  ast_str_append(&buf, 0, "UserAgent: %s\r\n", contact->user_agent);
2736  ast_str_append(&buf, 0, "RegExpire: %ld\r\n", contact->expiration_time.tv_sec);
2737  if (!ast_strlen_zero(contact->via_addr)) {
2738  ast_str_append(&buf, 0, "ViaAddress: %s", contact->via_addr);
2739  if (contact->via_port) {
2740  ast_str_append(&buf, 0, ":%d", contact->via_port);
2741  }
2742  ast_str_append(&buf, 0, "\r\n");
2743  }
2744  if (!ast_strlen_zero(contact->call_id)) {
2745  ast_str_append(&buf, 0, "CallID: %s\r\n", contact->call_id);
2746  }
2747  ast_str_append(&buf, 0, "Status: %s\r\n",
2748  ast_sip_get_contact_status_label(status ? status->status : UNKNOWN));
2749  if (!status || status->status != AVAILABLE) {
2750  ast_str_append(&buf, 0, "RoundtripUsec: N/A\r\n");
2751  } else {
2752  ast_str_append(&buf, 0, "RoundtripUsec: %" PRId64 "\r\n", status->rtt);
2753  }
2754  ast_str_append(&buf, 0, "EndpointName: %s\r\n",
2755  endpoint ? ast_sorcery_object_get_id(endpoint) : S_OR(contact->endpoint_name, ""));
2756 
2757  ast_str_append(&buf, 0, "ID: %s\r\n", ast_sorcery_object_get_id(contact));
2758  ast_str_append(&buf, 0, "AuthenticateQualify: %d\r\n", contact->authenticate_qualify);
2759  ast_str_append(&buf, 0, "OutboundProxy: %s\r\n", contact->outbound_proxy);
2760  ast_str_append(&buf, 0, "Path: %s\r\n", contact->path);
2761  ast_str_append(&buf, 0, "QualifyFrequency: %u\r\n", contact->qualify_frequency);
2762  ast_str_append(&buf, 0, "QualifyTimeout: %.3f\r\n", contact->qualify_timeout);
2763 
2764  astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
2765  ami->count++;
2766 
2767  ast_free(buf);
2768  ao2_cleanup(status);
2769  return 0;
2770 }
int authenticate_qualify
Definition: res_pjsip.h:309
A contact&#39;s status.
Definition: res_pjsip.h:341
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3080
const ast_string_field outbound_proxy
Definition: res_pjsip.h:303
const ast_string_field call_id
Definition: res_pjsip.h:303
const ast_string_field user_agent
Definition: res_pjsip.h:303
const ast_string_field path
Definition: res_pjsip.h:303
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
const ast_string_field via_addr
Definition: res_pjsip.h:303
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
void * arg
Definition: res_pjsip.h:2749
AMI variable container.
Definition: res_pjsip.h:2741
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:1091
unsigned int qualify_frequency
Definition: res_pjsip.h:307
const ast_string_field endpoint_name
Definition: res_pjsip.h:303
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:398
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
struct mansession * s
Definition: res_pjsip.h:2743
double qualify_timeout
Definition: res_pjsip.h:311
An entity with which Asterisk communicates.
Definition: res_pjsip.h:816
enum ast_sip_contact_status_type status
Definition: res_pjsip.h:351
struct ast_sip_contact * contact
Definition: res_pjsip.h:404
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
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.
Contact associated with an address of record.
Definition: res_pjsip.h:281
struct ast_sip_contact_status * ast_sip_get_contact_status(const struct ast_sip_contact *contact)
Retrieve the current status for a contact.
struct timeval expiration_time
Definition: res_pjsip.h:305
#define ast_free(a)
Definition: astmm.h:182
struct ast_str * ast_sip_create_ami_event(const char *event, struct ast_sip_ami *ami)
Creates a string to store AMI event data in.
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
const ast_string_field uri
Definition: res_pjsip.h:303
jack_status_t status
Definition: app_jack.c:146

◆ 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
endpointami AMI variable container
countthe number of formatters operated on
Return values
0Success, otherwise non-zero on error

Definition at line 3736 of file res_pjsip.c.

References AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sip_endpoint_formatter::format_ami, lock, and SCOPED_LOCK.

Referenced by ami_show_endpoint().

3738 {
3739  int res = 0;
3740  struct ast_sip_endpoint_formatter *i;
3742  *count = 0;
3744  if (i->format_ami && ((res = i->format_ami(endpoint, ami)) < 0)) {
3745  return res;
3746  }
3747 
3748  if (!res) {
3749  (*count)++;
3750  }
3751  }
3752  return 0;
3753 }
An entity responsible formatting endpoint information.
Definition: res_pjsip.h:2767
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
ast_mutex_t lock
Definition: app_meetme.c:1093
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:581
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:2771

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

References ao2_global_obj_ref.

Referenced by digest_check_auth(), and global_loaded().

632 {
633  return ao2_global_obj_ref(artificial_auth);
634 }
#define ao2_global_obj_ref(holder)
Definition: astobj2.h:925

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

References ao2_ref, and artificial_endpoint.

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

655 {
657  return artificial_endpoint;
658 }
static struct ast_sip_endpoint * artificial_endpoint
#define ao2_ref(o, delta)
Definition: astobj2.h:464

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

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

Referenced by expiration_global_loaded().

310 {
311  unsigned int interval;
312  struct global_config *cfg;
313 
314  cfg = get_global_cfg();
315  if (!cfg) {
317  }
318 
319  interval = cfg->contact_expiration_check_interval;
320  ao2_ref(cfg, -1);
321  return interval;
322 }
unsigned int contact_expiration_check_interval
Definition: config_global.c:92
#define DEFAULT_CONTACT_EXPIRATION_CHECK_INTERVAL
Definition: config_global.c:42
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

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

References ARRAY_LEN, ast_assert, short_status_map, and status.

Referenced by cli_contact_print_body().

343 {
345  return short_status_map[status];
346 }
static const char * short_status_map[]
#define ast_assert(a)
Definition: utils.h:710
#define ARRAY_LEN(a)
Definition: utils.h:639
jack_status_t status
Definition: app_jack.c:146

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

References ao2_find, AO2_STRING_FIELD_CMP_FN(), AO2_STRING_FIELD_HASH_FN(), ast_sorcery_object_get_id(), sip_options_endpoint_aor_status::name, and OBJ_SEARCH_KEY.

Referenced by ast_sip_format_contact_ami(), cli_contact_print_body(), contact_remove_unreachable(), format_ami_contactlist_handler(), pjsip_contact_function_read(), registrar_add_unreachable(), sip_options_contact_update_task(), and vec_contact_cmp().

524 {
527 }
static struct ao2_container * sip_options_contact_statuses
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1105
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756

◆ ast_sip_get_contact_status_label()

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.

Return values
thecharacter string equivalent.

Definition at line 336 of file pjsip_options.c.

References ARRAY_LEN, ast_assert, status, and status_map.

Referenced by ast_res_pjsip_find_or_create_contact_status(), ast_sip_format_contact_ami(), ast_sip_initialize_sorcery_location(), ast_sip_persistent_endpoint_publish_contact_state(), format_ami_contactlist_handler(), pjsip_contact_function_read(), sip_options_contact_status_notify_task(), sip_options_remove_contact_status(), and sip_options_set_contact_status().

337 {
339  return status_map[status];
340 }
static const char * status_map[]
#define ast_assert(a)
Definition: utils.h:710
#define ARRAY_LEN(a)
Definition: utils.h:639
jack_status_t status
Definition: app_jack.c:146

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

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

Referenced by check_debug().

233 {
234  char *res;
235  struct global_config *cfg;
236 
237  cfg = get_global_cfg();
238  if (!cfg) {
239  return ast_strdup(DEFAULT_DEBUG);
240  }
241 
242  res = ast_strdup(cfg->debug);
243  ao2_ref(cfg, -1);
244  return res;
245 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
const ast_string_field debug
Definition: config_global.c:84
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_DEBUG
Definition: config_global.c:36
static struct global_config * get_global_cfg(void)

◆ 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
Returns
nothing

Definition at line 388 of file config_global.c.

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

Referenced by sip_dialog_create_from().

389 {
390  struct global_config *cfg;
391 
392  cfg = get_global_cfg();
393  if (!cfg) {
394  ast_copy_string(from_user, DEFAULT_FROM_USER, size);
395  } else {
396  ast_copy_string(from_user, cfg->default_from_user, size);
397  ao2_ref(cfg, -1);
398  }
399 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_FROM_USER
Definition: config_global.c:39
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static struct global_config * get_global_cfg(void)
const ast_string_field default_from_user
Definition: config_global.c:84

◆ 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
Returns
nothing

Definition at line 375 of file config_global.c.

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

Referenced by create_artificial_auth(), and global_loaded().

376 {
377  struct global_config *cfg;
378 
379  cfg = get_global_cfg();
380  if (!cfg) {
381  ast_copy_string(realm, DEFAULT_REALM, size);
382  } else {
383  ast_copy_string(realm, cfg->default_realm, size);
384  ao2_ref(cfg, -1);
385  }
386 }
#define DEFAULT_REALM
Definition: config_global.c:40
const ast_string_field default_realm
Definition: config_global.c:84
#define ao2_ref(o, delta)
Definition: astobj2.h:464
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
static struct global_config * get_global_cfg(void)

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

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

Referenced by global_loaded().

264 {
265  char *res;
266  struct global_config *cfg;
267 
268  cfg = get_global_cfg();
269  if (!cfg) {
271  }
272 
274  ao2_ref(cfg, -1);
275 
276  return res;
277 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
const ast_string_field default_voicemail_extension
Definition: config_global.c:84
#define DEFAULT_VOICEMAIL_EXTENSION
Definition: config_global.c:44
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

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

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

1508 {
1509  char device[MAX_OBJECT_FIELD];
1510 
1511  snprintf(device, MAX_OBJECT_FIELD, "PJSIP/%s", ast_sorcery_object_get_id(endpoint));
1512  return ast_devstate2str(ast_device_state(device));
1513 }
const char * ast_devstate2str(enum ast_device_state devstate) attribute_pure
Convert device state to text string for output.
Definition: devicestate.c:237
ast_device_state
Device States.
Definition: devicestate.h:52
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
Definition: sorcery.h:110

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

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

325 {
326  unsigned int disable_multi_domain;
327  struct global_config *cfg;
328 
329  cfg = get_global_cfg();
330  if (!cfg) {
332  }
333 
334  disable_multi_domain = cfg->disable_multi_domain;
335  ao2_ref(cfg, -1);
336  return disable_multi_domain;
337 }
unsigned int disable_multi_domain
Definition: config_global.c:94
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_DISABLE_MULTI_DOMAIN
Definition: config_global.c:43
static struct global_config * get_global_cfg(void)

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

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

280 {
281  char *res;
282  struct global_config *cfg;
283 
284  cfg = get_global_cfg();
285  if (!cfg) {
287  }
288 
290  ao2_ref(cfg, -1);
291  return res;
292 }
#define DEFAULT_ENDPOINT_IDENTIFIER_ORDER
Definition: config_global.c:37
const ast_string_field endpoint_identifier_order
Definition: config_global.c:84
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

◆ 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 retreieved.
Return values
Theendpoint snapshot

Definition at line 1515 of file pjsip_configuration.c.

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

1517 {
1519  ast_endpoint_get_tech(endpoint->persistent),
1521 }
const char * ast_endpoint_get_tech(const struct ast_endpoint *endpoint)
Gets the technology 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.
const char * ast_endpoint_get_resource(const struct ast_endpoint *endpoint)
Gets the resource name of the given endpoint.
struct ast_endpoint * persistent
Definition: res_pjsip.h:869

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

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

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

2346 {
2347  struct ao2_container *endpoints;
2348 
2350 
2351  return endpoints;
2352 }
Perform no matching, return all objects.
Definition: sorcery.h:123
Return all matching objects.
Definition: sorcery.h:120
#define NULL
Definition: resample.c:96
static struct ao2_container * endpoints
static struct ast_sorcery * sip_sorcery
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
Definition: sorcery.c:1897
Generic container type.

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

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

5498 {
5499  if (af == pj_AF_INET() && !ast_strlen_zero(host_ip_ipv4_string)) {
5500  pj_sockaddr_copy_addr(addr, &host_ip_ipv4);
5501  return 0;
5502  } else if (af == pj_AF_INET6() && !ast_strlen_zero(host_ip_ipv6_string)) {
5503  pj_sockaddr_copy_addr(addr, &host_ip_ipv6);
5504  return 0;
5505  }
5506 
5507  return -1;
5508 }
static pj_sockaddr host_ip_ipv6
Definition: res_pjsip.c:3320
static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN]
Definition: res_pjsip.c:3323
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
static char host_ip_ipv4_string[PJ_INET6_ADDRSTRLEN]
Definition: res_pjsip.c:3317
static pj_sockaddr host_ip_ipv4
Definition: res_pjsip.c:3314

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

References host_ip_ipv4_string, host_ip_ipv6_string, and NULL.

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

5511 {
5512  if (af == pj_AF_INET()) {
5513  return host_ip_ipv4_string;
5514  } else if (af == pj_AF_INET6()) {
5515  return host_ip_ipv6_string;
5516  }
5517 
5518  return NULL;
5519 }
static char host_ip_ipv6_string[PJ_INET6_ADDRSTRLEN]
Definition: res_pjsip.c:3323
#define NULL
Definition: resample.c:96
static char host_ip_ipv4_string[PJ_INET6_ADDRSTRLEN]
Definition: res_pjsip.c:3317

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

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

Referenced by find_registrar_aor().

448 {
449  unsigned int ignore_uri_user_options;
450  struct global_config *cfg;
451 
452  cfg = get_global_cfg();
453  if (!cfg) {
455  }
456 
457  ignore_uri_user_options = cfg->ignore_uri_user_options;
458  ao2_ref(cfg, -1);
460 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_IGNORE_URI_USER_OPTIONS
Definition: config_global.c:51
unsigned int ignore_uri_user_options
static struct global_config * get_global_cfg(void)

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

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

Referenced by keepalive_global_loaded().

295 {
296  unsigned int interval;
297  struct global_config *cfg;
298 
299  cfg = get_global_cfg();
300  if (!cfg) {
302  }
303 
304  interval = cfg->keep_alive_interval;
305  ao2_ref(cfg, -1);
306  return interval;
307 }
unsigned int keep_alive_interval
Definition: config_global.c:88
#define DEFAULT_KEEPALIVE_INTERVAL
Definition: config_global.c:33
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

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

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

340 {
341  unsigned int time;
342  struct global_config *cfg;
343 
344  cfg = get_global_cfg();
345  if (!cfg) {
347  }
348 
349  time = cfg->max_initial_qualify_time;
350  ao2_ref(cfg, -1);
351  return time;
352 }
#define DEFAULT_MAX_INITIAL_QUALIFY_TIME
Definition: config_global.c:38
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
unsigned int max_initial_qualify_time
Definition: config_global.c:90

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

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

433 {
434  unsigned int disable_initial_unsolicited;
435  struct global_config *cfg;
436 
437  cfg = get_global_cfg();
438  if (!cfg) {
440  }
441 
442  disable_initial_unsolicited = cfg->mwi.disable_initial_unsolicited;
443  ao2_ref(cfg, -1);
445 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_MWI_DISABLE_INITIAL_UNSOLICITED
Definition: config_global.c:50
unsigned int disable_initial_unsolicited
static struct global_config * get_global_cfg(void)
struct global_config::@460 mwi

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

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

Referenced by global_loaded().

403 {
404  unsigned int tps_queue_high;
405  struct global_config *cfg;
406 
407  cfg = get_global_cfg();
408  if (!cfg) {
410  }
411 
412  tps_queue_high = cfg->mwi.tps_queue_high;
413  ao2_ref(cfg, -1);
414  return tps_queue_high;
415 }
#define DEFAULT_MWI_TPS_QUEUE_HIGH
Definition: config_global.c:48
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
struct global_config::@460 mwi
unsigned int tps_queue_high

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

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

Referenced by global_loaded().

418 {
419  int tps_queue_low;
420  struct global_config *cfg;
421 
422  cfg = get_global_cfg();
423  if (!cfg) {
425  }
426 
427  tps_queue_low = cfg->mwi.tps_queue_low;
428  ao2_ref(cfg, -1);
429  return tps_queue_low;
430 }
#define DEFAULT_MWI_TPS_QUEUE_LOW
Definition: config_global.c:49
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
struct global_config::@460 mwi

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

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

Referenced by load_module().

508 {
509  unsigned int norefersub;
510  struct global_config *cfg;
511 
512  cfg = get_global_cfg();
513  if (!cfg) {
514  return DEFAULT_NOREFERSUB;
515  }
516 
517  norefersub = cfg->norefersub;
518  ao2_ref(cfg, -1);
519  return norefersub;
520 }
#define DEFAULT_NOREFERSUB
Definition: config_global.c:55
unsigned int norefersub
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)

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

References ast_pjsip_endpoint.

Referenced by acl_on_rx_msg(), 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_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(), keepalive_transport_send_keepalive(), load_module(), logging_on_rx_msg(), logging_on_tx_msg(), notify_task(), on_rx_process_uris(), options_incoming_request(), parse_uri_cb(), 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().

3756 {
3757  return ast_pjsip_endpoint;
3758 }
static pjsip_endpoint * ast_pjsip_endpoint
Definition: res_pjsip.c:3309

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

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

Referenced by ast_sip_persistent_endpoint_update_state().

248 {
249  char *res;
250  struct global_config *cfg;
251 
252  cfg = get_global_cfg();
253  if (!cfg) {
255  }
256 
257  res = ast_strdup(cfg->regcontext);
258  ao2_ref(cfg, -1);
259 
260  return res;
261 }
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
#define DEFAULT_REGCONTEXT
Definition: config_global.c:41
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const ast_string_field regcontext
Definition: config_global.c:84
static struct global_config * get_global_cfg(void)

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

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

478 {
480  struct global_config *cfg;
481 
482  cfg = get_global_cfg();
483  if (!cfg) {
485  }
486 
487  send_contact_status_on_update_registration = cfg->send_contact_status_on_update_registration;
488  ao2_ref(cfg, -1);
490 }
unsigned int send_contact_status_on_update_registration
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct global_config * get_global_cfg(void)
#define DEFAULT_SEND_CONTACT_STATUS_ON_UPDATE_REGISTRATION
Definition: config_global.c:53

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

References sip_sorcery.

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

2406 {
2407  return sip_sorcery;
2408 }
static struct ast_sorcery * sip_sorcery

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

References ast_alloca, ast_copy_pj_str(), ast_copy_string(), AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN, ast_sockaddr_parse(), ast_strlen_zero(), NULL, PARSE_PORT_FORBID, and ast_sip_endpoint::transport.

Referenced by ast_sip_set_tpselector_from_ep_or_uri().

3801 {
3802  char *host = NULL;
3803  static const pj_str_t x_name = { AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN };
3804  pjsip_param *x_transport;
3805 
3806  if (!ast_strlen_zero(endpoint->transport)) {
3807  ast_copy_string(buf, endpoint->transport, buf_len);
3808  return 0;
3809  }
3810 
3811  x_transport = pjsip_param_find(&sip_uri->other_param, &x_name);
3812  if (!x_transport) {
3813  return -1;
3814  }
3815 
3816  /* Only use x_transport if the uri host is an ip (4 or 6) address */
3817  host = ast_alloca(sip_uri->host.slen + 1);
3818  ast_copy_pj_str(host, &sip_uri->host, sip_uri->host.slen + 1);
3819  if (!ast_sockaddr_parse(NULL, host, PARSE_PORT_FORBID)) {
3820  return -1;
3821  }
3822 
3823  ast_copy_pj_str(buf, &x_transport->value, buf_len);
3824 
3825  return 0;
3826 }
int ast_sockaddr_parse(struct ast_sockaddr *addr, const char *str, int flags)
Parse an IPv4 or IPv6 address string.
Definition: netsock2.c:230
const ast_string_field transport
Definition: res_pjsip.h:821
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
#define NULL
Definition: resample.c:96
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:5277
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
#define AST_SIP_X_AST_TXP_LEN
Definition: res_pjsip.h:914
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define AST_SIP_X_AST_TXP
Definition: res_pjsip.h:913

◆ 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
Returns
transport_state
Note
ao2_cleanup(...) or ao2_ref(..., -1) must be called on the returned object

Definition at line 1564 of file config_transport.c.

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

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

1565 {
1566  struct internal_state *state = NULL;
1567  struct ast_sip_transport_state *trans_state;
1568 
1569  if (!transport_states) {
1570  return NULL;
1571  }
1572 
1573  state = ao2_find(transport_states, transport_id, OBJ_SEARCH_KEY);
1574  if (!state) {
1575  return NULL;
1576  }
1577 
1578  trans_state = ao2_bump(state->state);
1579  ao2_ref(state, -1);
1580 
1581  /* If this is a child transport see if the transport is actually dead */
1582  if (trans_state->flow) {
1583  ao2_lock(trans_state);
1584  if (trans_state->transport && trans_state->transport->is_shutdown == PJ_TRUE) {
1585  pjsip_transport_dec_ref(trans_state->transport);
1586  trans_state->transport = NULL;
1587  }
1588  ao2_unlock(trans_state);
1589  }
1590 
1591  return trans_state;
1592 }
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1105
struct ast_sip_transport_state * state
Transport state information.
static struct ao2_container * transport_states
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
#define ao2_bump(obj)
Definition: astobj2.h:491
Structure for SIP transport information.
Definition: res_pjsip.h:87
struct pjsip_transport * transport
Transport itself.
Definition: res_pjsip.h:89
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_lock(a)
Definition: astobj2.h:718
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756

◆ ast_sip_get_transport_states()

struct ao2_container* ast_sip_get_transport_states ( void  )

Retrieves all transport states.

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

Definition at line 1604 of file config_transport.c.

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

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

1605 {
1608 
1609  if (!states) {
1610  return NULL;
1611  }
1612 
1614  return states;
1615 }
static int transport_state_cmp(void *obj, void *arg, int flags)
comparator function for state objects
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
static struct ao2_container * transport_states
#define NULL
Definition: resample.c:96
static int transport_state_hash(const void *obj, const int flags)
hashing 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)
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
Generic container type.

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

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

356 {
357  struct global_config *cfg;
358 
359  cfg = get_global_cfg();
360  if (!cfg) {
364  return;
365  }
366 
367  *count = cfg->unidentified_request_count;
368  *period = cfg->unidentified_request_period;
369  *prune_interval = cfg->unidentified_request_prune_interval;
370 
371  ao2_ref(cfg, -1);
372  return;
373 }
#define DEFAULT_UNIDENTIFIED_REQUEST_PRUNE_INTERVAL
Definition: config_global.c:47
unsigned int unidentified_request_prune_interval
unsigned int unidentified_request_count
Definition: config_global.c:96
#define DEFAULT_UNIDENTIFIED_REQUEST_COUNT
Definition: config_global.c:45
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_UNIDENTIFIED_REQUEST_PERIOD
Definition: config_global.c:46
static struct global_config * get_global_cfg(void)
unsigned int unidentified_request_period
Definition: config_global.c:98

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

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

Referenced by set_from_header().

463 {
464  unsigned int use_callerid_contact;
465  struct global_config *cfg;
466 
467  cfg = get_global_cfg();
468  if (!cfg) {
470  }
471 
472  use_callerid_contact = cfg->use_callerid_contact;
473  ao2_ref(cfg, -1);
474  return use_callerid_contact;
475 }
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define DEFAULT_USE_CALLERID_CONTACT
Definition: config_global.c:52
unsigned int use_callerid_contact
static struct global_config * get_global_cfg(void)

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

References ast_assert, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, endpoint_identifier_list::identifier, ast_sip_endpoint_identifier::identify_endpoint, lock, NULL, and SCOPED_LOCK.

Referenced by endpoint_lookup().

3566 {
3567  struct endpoint_identifier_list *iter;
3568  struct ast_sip_endpoint *endpoint = NULL;
3572  endpoint = iter->identifier->identify_endpoint(rdata);
3573  if (endpoint) {
3574  break;
3575  }
3576  }
3577  return endpoint;
3578 }
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:150
#define ast_assert(a)
Definition: utils.h:710
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:1002
#define NULL
Definition: resample.c:96
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:77
ast_mutex_t lock
Definition: app_meetme.c:1093
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:493
#define SCOPED_LOCK(varname, lock, lockfunc, unlockfunc)
Scoped Locks.
Definition: lock.h:581
An entity with which Asterisk communicates.
Definition: res_pjsip.h:816
struct ast_sip_endpoint_identifier * identifier
Definition: res_pjsip.c:3462

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

References compare().

Referenced by asterisk_publication_devicestate_state_change(), asterisk_publication_mwi_state_change(), check_content_type(), filter_on_tx_message(), pubsub_on_rx_notify_request(), session_outgoing_nat_hook(), and video_info_incoming_request().

5297 {
5298  pjsip_media_type compare;
5299 
5300  if (!content_type) {
5301  return 0;
5302  }
5303 
5304  pjsip_media_type_init2(&compare, type, subtype);
5305 
5306  return pjsip_media_type_cmp(content_type, &compare, 0) ? 0 : -1;
5307 }
static const char type[]
Definition: chan_ooh323.c:109
static int compare(const char *text, const char *template)

◆ ast_sip_location_add_contact()

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

Add a new contact to an AOR.

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

Definition at line 429 of file location.c.

References ao2_lock, ao2_unlock, and ast_sip_location_add_contact_nolock().

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

◆ ast_sip_location_add_contact_nolock()

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

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

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

Definition at line 416 of file location.c.

References ao2_cleanup, and ast_sip_location_create_contact().

Referenced by ast_sip_location_add_contact().

420 {
421  struct ast_sip_contact *contact;
422 
423  contact = ast_sip_location_create_contact(aor, uri, expiration_time, path_info,
424  user_agent, via_addr, via_port, call_id, 0, endpoint);
425  ao2_cleanup(contact);
426  return contact ? 0 : -1;
427 }
const ast_string_field call_id
Definition: res_pjsip.h:303
const ast_string_field user_agent
Definition: res_pjsip.h:303
const ast_string_field via_addr
Definition: res_pjsip.h:303
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
Contact associated with an address of record.
Definition: res_pjsip.h:281
struct timeval expiration_time
Definition: res_pjsip.h:305
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
const ast_string_field uri
Definition: res_pjsip.h:303

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

References ao2_bump, ao2_ref, 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_aor::authenticate_qualify, 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_aor::outbound_proxy, ast_sip_contact::path, ast_sip_contact::prune_on_boot, ast_sip_contact::qualify_frequency, ast_sip_aor::qualify_frequency, ast_sip_contact::qualify_timeout, ast_sip_aor::qualify_timeout, ast_sip_contact::reg_server, ast_sip_aor::support_path, and ast_sip_contact::via_port.

Referenced by ast_sip_location_add_contact_nolock(), and register_aor_core().

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);
373  contact->expiration_time = expiration_time;
374  contact->qualify_frequency = aor->qualify_frequency;
375  contact->qualify_timeout = aor->qualify_timeout;
377  if (path_info && aor->support_path) {
378  ast_string_field_set(contact, path, path_info);
379  }
380 
381  if (!ast_strlen_zero(aor->outbound_proxy)) {
383  }
384 
385  if (!ast_strlen_zero(user_agent)) {
387  }
388 
391  }
392 
393  if (!ast_strlen_zero(via_addr)) {
395  }
396  contact->via_port = via_port;
397 
398  if (!ast_strlen_zero(call_id)) {
400  }
401 
402  contact->endpoint = ao2_bump(endpoint);
403  if (endpoint) {
405  }
406 
407  contact->prune_on_boot = prune_on_boot;
408 
409  if (ast_sorcery_create(ast_sip_get_sorcery(), contact)) {
410  ao2_ref(contact, -1);
411  return NULL;
412  }
413  return contact;
414 }
double qualify_timeout
Definition: res_pjsip.h:387
int authenticate_qualify
Definition: res_pjsip.h:309
static const char name[]
Definition: format_mp3.c:68
const ast_string_field outbound_proxy
Definition: res_pjsip.h:303
const ast_string_field call_id
Definition: res_pjsip.h:303
const ast_string_field user_agent
Definition: res_pjsip.h:303
const ast_string_field path
Definition: res_pjsip.h:303
const ast_string_field via_addr
Definition: res_pjsip.h:303
unsigned int qualify_frequency
Definition: res_pjsip.h:307
const ast_string_field outbound_proxy
Definition: res_pjsip.h:367
const ast_string_field reg_server
Definition: res_pjsip.h:303
#define NULL
Definition: resample.c:96
const char * ast_config_AST_SYSTEM_NAME
Definition: options.c:170
struct ast_sip_endpoint * endpoint
Definition: res_pjsip.h:313
#define ao2_bump(obj)
Definition: astobj2.h:491
unsigned int qualify_frequency
Definition: res_pjsip.h:375
int ast_sorcery_create(const struct ast_sorcery *sorcery, void *object)
Create and potentially persist an object using an available wizard.
Definition: sorcery.c:2057
const ast_string_field endpoint_name
Definition: res_pjsip.h:303
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
double qualify_timeout
Definition: res_pjsip.h:311
unsigned int support_path
Definition: res_pjsip.h:385
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
Definition: sorcery.h:110
Contact associated with an address of record.
Definition: res_pjsip.h:281
void * ast_sorcery_alloc(const struct ast_sorcery *sorcery, const char *type, const char *id)
Allocate an object.
Definition: sorcery.c:1744
struct timeval expiration_time
Definition: res_pjsip.h:305
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
int authenticate_qualify
Definition: res_pjsip.h:377
void ast_md5_hash(char *output, const char *input)
Produces MD5 hash based on input string.
Definition: main/utils.c:248
const ast_string_field uri
Definition: res_pjsip.h:303
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:514

◆ ast_sip_location_delete_contact()

int ast_sip_location_delete_contact ( struct ast_sip_contact contact)

Delete a contact.

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

Definition at line 450 of file location.c.

References ast_sip_get_sorcery(), and ast_sorcery_delete().

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

451 {
452  return ast_sorcery_delete(ast_sip_get_sorcery(), contact);
453 }
int ast_sorcery_delete(const struct ast_sorcery *sorcery, void *object)
Delete an object.
Definition: sorcery.c:2233
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.

◆ ast_sip_location_prune_boot_contacts()

void ast_sip_location_prune_boot_contacts ( void  )

Prune the prune_on_boot contacts.

Since
13.18.0

Definition at line 469 of file location.c.

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

470 {
471  struct ao2_container *contacts;
472 
473  contacts = ast_sorcery_retrieve_by_fields(ast_sip_get_sorcery(), "contact",
475  if (contacts) {
477  ao2_ref(contacts, -1);
478  }
479 }
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
static int prune_boot_contacts_cb(void *obj, void *arg, int flags)
Definition: location.c:455
Perform no matching, return all objects.
Definition: sorcery.h:123
Return all matching objects.
Definition: sorcery.h:120
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
void * ast_sorcery_retrieve_by_fields(const struct ast_sorcery *sorcery, const char *type, unsigned int flags, struct ast_variable *fields)
Retrieve an object or multiple objects using specific fields.
Definition: sorcery.c:1897
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
Generic container type.

◆ ast_sip_location_retrieve_aor()

struct ast_sip_aor* ast_sip_location_retrieve_aor ( const char *  aor_name)

Retrieve a named AOR.

Parameters
aor_nameName of the AOR
Return values
NULLif not found
non-NULLif found

Definition at line 147 of file location.c.

References ast_sip_get_sorcery(), and ast_sorcery_retrieve_by_id().

Referenced by ast_sip_for_each_aor(), ast_sip_location_retrieve_contact_and_aor_from_list_filtered(), find_aor(), find_aor_for_resource(), find_registrar_aor(), handle_slash(), notify_endpoint(), pjsip_acf_dial_contacts_read(), register_contact_transport_remove_cb(), send_unsolicited_mwi_notify(), and vec_contact_cmp().

148 {
149  return ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "aor", aor_name);
150 }
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.

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

References AST_SIP_CONTACT_FILTER_DEFAULT, and ast_sip_location_retrieve_aor_contacts_filtered().

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

248 {
250 }
Default filter flags.
Definition: res_pjsip.h:1010
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

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

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

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 }
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_lock(a)
Definition: astobj2.h:718
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
Generic container type.

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

215 {
217 }
Default filter flags.
Definition: res_pjsip.h:1010
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

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

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

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 
240  if (flags & AST_SIP_CONTACT_FILTER_REACHABLE) {
242  }
243 
244  return contacts;
245 }
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
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
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
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:1984
#define NULL
Definition: resample.c:96
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
struct ao2_container * permanent_contacts
Definition: res_pjsip.h:383
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
Return only reachable or unknown contacts.
Definition: res_pjsip.h:1013
Generic container type.
static char prefix[MAX_PREFIX]
Definition: http.c:141

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

References ast_sip_get_sorcery(), and ast_sorcery_retrieve_by_id().

Referenced by register_contact_transport_remove_cb().

351 {
352  return ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "contact", contact_name);
353 }
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
Definition: sorcery.c:1853
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.

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

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

268 {
270 }
Default filter flags.
Definition: res_pjsip.h:1010
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

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

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

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 }
#define LOG_WARNING
Definition: logger.h:274
struct ast_sip_aor * ast_sip_location_retrieve_aor(const char *aor_name)
Retrieve a named AOR.
Definition: location.c:147
#define NULL
Definition: resample.c:96
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
#define ast_log
Definition: astobj2.c:42
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:219
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
char * strsep(char **str, const char *delims)

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

References ao2_cleanup, ast_sip_location_retrieve_contact_and_aor_from_list(), cli_contact_populate_container(), and permanent_uri_sort_fn().

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

305 {
306  struct ast_sip_aor *aor;
307  struct ast_sip_contact *contact;
308 
309  ast_sip_location_retrieve_contact_and_aor_from_list(aor_list, &aor, &contact);
310 
311  ao2_cleanup(aor);
312 
313  return contact;
314 }
A SIP address of record.
Definition: res_pjsip.h:361
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
Contact associated with an address of record.
Definition: res_pjsip.h:281
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

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

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

336 {
337  struct ao2_container *contacts;
338 
341  if (!contacts) {
342  return NULL;
343  }
344 
345  ast_sip_for_each_aor(aor_list, gather_contacts_for_aor, contacts);
346 
347  return contacts;
348 }
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 &#39;on_aor&#39; handler. ...
Definition: location.c:684
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Definition: astobj2.h:1335
#define NULL
Definition: resample.c:96
static int gather_contacts_for_aor(void *obj, void *arg, int flags)
Definition: location.c:319
static int permanent_uri_sort_fn(const void *obj_left, const void *obj_right, int flags)
Definition: location.c:495
Reject objects with duplicate keys in container.
Definition: astobj2.h:1192
Generic container type.

◆ 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_FILTER_DEFAULT, and ast_sip_location_retrieve_first_aor_contact_filtered().

Referenced by handle_slash().

195 {
197 }
Default filter flags.
Definition: res_pjsip.h:1010
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

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

References ao2_callback, ao2_cleanup, ao2_container_count(), 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().

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.
#define ao2_callback(c, flags, cb_fn, arg)
Definition: astobj2.h:1716
#define NULL
Definition: resample.c:96
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
Contact associated with an address of record.
Definition: res_pjsip.h:281
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
Generic container type.

◆ ast_sip_location_update_contact()

int ast_sip_location_update_contact ( struct ast_sip_contact contact)

Update a contact.

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

Definition at line 445 of file location.c.

References ast_sip_get_sorcery(), and ast_sorcery_update().

Referenced by register_aor_core().

446 {
447  return ast_sorcery_update(ast_sip_get_sorcery(), contact);
448 }
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
int ast_sorcery_update(const struct ast_sorcery *sorcery, void *object)
Update an object.
Definition: sorcery.c:2145

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

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

302 {
303  struct ast_sip_transport_state *transport_state;
304 
305  if (