Asterisk - The Open Source Telephony Project  GIT-master-a24979a
Data Structures | Macros | Functions | Variables
config_transport.c File Reference
#include "asterisk.h"
#include <math.h>
#include <pjsip.h>
#include <pjlib.h>
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_cli.h"
#include "asterisk/logger.h"
#include "asterisk/astobj2.h"
#include "asterisk/sorcery.h"
#include "asterisk/acl.h"
#include "asterisk/utils.h"
#include "include/res_pjsip_private.h"
#include "asterisk/http_websocket.h"
Include dependency graph for config_transport.c:

Go to the source code of this file.

Data Structures

struct  internal_state
 

Macros

#define BIND_DELAY_US   100000
 
#define BIND_TRIES   3
 
#define DEFAULT_STATE_BUCKETS   53
 Default number of state container buckets. More...
 
#define MAX_POINTER_STRING   33
 

Functions

static void __init_temp_state_store (void)
 
int ast_sip_destroy_sorcery_transport (void)
 
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...
 
int ast_sip_initialize_sorcery_transport (void)
 Initialize sorcery with transport support. 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...
 
struct ast_sip_service_route_vectorast_sip_service_route_vector_alloc (void)
 Allocate a vector of service routes. More...
 
void ast_sip_service_route_vector_destroy (struct ast_sip_service_route_vector *service_routes)
 Destroy a vector of service routes. More...
 
int ast_sip_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...
 
static int ca_list_file_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int ca_list_path_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int cert_file_to_str (const void *obj, const intptr_t *args, char **buf)
 
static struct ao2_containercli_get_container (const char *regex)
 
static int cli_iterate (void *container, ao2_callback_fn callback, void *args)
 
static int cli_print_body (void *obj, void *arg, int flags)
 
static int cli_print_header (void *obj, void *arg, int flags)
 
static void * cli_retrieve_by_id (const char *id)
 
static void copy_state_to_transport (struct ast_sip_transport *transport)
 
static int destroy_sip_transport_state (void *data)
 
static struct internal_statefind_internal_state_by_transport (const struct ast_sip_transport *transport)
 
static struct ast_sip_transport_statefind_or_create_temporary_state (struct ast_sip_transport *transport)
 
static struct ast_sip_transport_statefind_state_by_transport (const struct ast_sip_transport *transport)
 
static struct ast_sip_transport_statefind_temporary_state (struct ast_sip_transport *transport)
 
static int format_ami_endpoint_transport (const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami)
 
static int has_state_changed (struct ast_sip_transport_state *a, struct ast_sip_transport_state *b)
 
static struct internal_stateinternal_state_alloc (struct ast_sip_transport *transport)
 
static int internal_state_cmp (void *obj, void *arg, int flags)
 comparator function for state objects More...
 
static void internal_state_destroy (void *obj)
 Destructor for ast_sip_transport state information. More...
 
static int internal_state_hash (const void *obj, const int flags)
 hashing function for state objects More...
 
static int localnet_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int localnet_to_vl (const void *obj, struct ast_variable **fields)
 
static void localnet_to_vl_append (struct ast_variable **head, struct ast_ha *ha)
 
static int populate_transport_states (void *obj, void *arg, int flags)
 
static int privkey_file_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int remove_temporary_state (void)
 
static int require_client_cert_to_str (const void *obj, const intptr_t *args, char **buf)
 
static void set_qos (struct ast_sip_transport *transport, pj_qos_params *qos)
 
static void * sip_transport_alloc (const char *name)
 Allocator for transport. More...
 
static void sip_transport_destroy (void *obj)
 Destructor for transport. More...
 
static void sip_transport_state_destroy (void *obj)
 Destructor for ast_sip_transport state information. More...
 
static int sip_transport_to_ami (const struct ast_sip_transport *transport, struct ast_str **buf)
 
static void states_cleanup (void *states)
 
static void temp_state_store_cleanup (void *data)
 
static int tls_method_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int tos_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int transport_apply (const struct ast_sorcery *sorcery, void *obj)
 Apply handler for transports. More...
 
static int transport_bind_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for turning a string bind into a pj_sockaddr. More...
 
static int transport_bind_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int transport_localnet_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for localnet setting. More...
 
static int transport_protocol_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for turning a string protocol into an enum. More...
 
static int transport_protocol_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int transport_state_cmp (void *obj, void *arg, int flags)
 comparator function for state objects More...
 
static int transport_state_hash (const void *obj, const int flags)
 hashing function for state objects More...
 
static int transport_state_init (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for type just makes sure the state is created. More...
 
static int transport_tls_bool_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for TLS boolean settings. More...
 
static int transport_tls_file_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for TLS method setting. More...
 
static int transport_tls_method_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for TLS method setting. More...
 
static int transport_tos_handler (const struct aco_option *opt, struct ast_variable *var, void *obj)
 Custom handler for TOS setting. More...
 
static int verify_client_to_str (const void *obj, const intptr_t *args, char **buf)
 
static int verify_server_to_str (const void *obj, const intptr_t *args, char **buf)
 

Variables

static struct ast_cli_entry cli_commands []
 
static struct ast_sip_cli_formatter_entrycli_formatter
 
struct ast_sip_endpoint_formatter endpoint_transport_formatter
 
static struct ast_threadstorage temp_state_store = { .once = PTHREAD_ONCE_INIT , .key_init = __init_temp_state_store , .custom_init = NULL , }
 
static const char * tls_method_map []
 
static struct ao2_containertransport_states
 
static const char * transport_types []
 

Macro Definition Documentation

◆ BIND_DELAY_US

#define BIND_DELAY_US   100000

◆ BIND_TRIES

#define BIND_TRIES   3

◆ DEFAULT_STATE_BUCKETS

#define DEFAULT_STATE_BUCKETS   53

Default number of state container buckets.

Definition at line 39 of file config_transport.c.

◆ MAX_POINTER_STRING

#define MAX_POINTER_STRING   33

Definition at line 36 of file config_transport.c.

Function Documentation

◆ __init_temp_state_store()

static void __init_temp_state_store ( void  )
static

Definition at line 60 of file config_transport.c.

64 {

◆ ast_sip_destroy_sorcery_transport()

int ast_sip_destroy_sorcery_transport ( void  )

Definition at line 1698 of file config_transport.c.

1699 {
1702 
1704 
1707 
1708  return 0;
1709 }
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
Definition: clicompat.c:30
static struct ast_cli_entry cli_commands[]
struct ast_sip_endpoint_formatter endpoint_transport_formatter
static struct ast_sip_cli_formatter_entry * cli_formatter
static struct ao2_container * transport_states
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
Definition: res_pjsip.c:480
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
Definition: pjsip_cli.c:326
#define NULL
Definition: resample.c:96
#define ARRAY_LEN(a)
Definition: utils.h:661

References ao2_ref, ARRAY_LEN, ast_cli_unregister_multiple(), ast_sip_unregister_cli_formatter(), ast_sip_unregister_endpoint_formatter(), cli_commands, cli_formatter, endpoint_transport_formatter, NULL, and transport_states.

Referenced by ast_res_pjsip_destroy_configuration().

◆ 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 1570 of file config_transport.c.

1571 {
1572  struct internal_state *state = NULL;
1573  struct ast_sip_transport_state *trans_state;
1574 
1575  if (!transport_states) {
1576  return NULL;
1577  }
1578 
1579  state = ao2_find(transport_states, transport_id, OBJ_SEARCH_KEY);
1580  if (!state) {
1581  return NULL;
1582  }
1583 
1584  trans_state = ao2_bump(state->state);
1585  ao2_ref(state, -1);
1586 
1587  /* If this is a child transport see if the transport is actually dead */
1588  if (trans_state->flow) {
1589  ao2_lock(trans_state);
1590  if (trans_state->transport && trans_state->transport->is_shutdown == PJ_TRUE) {
1591  pjsip_transport_dec_ref(trans_state->transport);
1592  trans_state->transport = NULL;
1593  }
1594  ao2_unlock(trans_state);
1595  }
1596 
1597  return trans_state;
1598 }
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
@ OBJ_SEARCH_KEY
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1101
Structure for SIP transport information.
Definition: res_pjsip.h:103
struct pjsip_transport * transport
Transport itself.
Definition: res_pjsip.h:105

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

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

◆ 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 1610 of file config_transport.c.

1611 {
1614 
1615  if (!states) {
1616  return NULL;
1617  }
1618 
1620  return states;
1621 }
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
#define ao2_callback(c, flags, cb_fn, arg)
ao2_callback() is a generic function that applies cb_fn() to all objects in a container,...
Definition: astobj2.h:1693
@ OBJ_NODATA
Definition: astobj2.h:1044
@ OBJ_MULTIPLE
Definition: astobj2.h:1049
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
static int transport_state_hash(const void *obj, const int flags)
hashing function for state objects
static int transport_state_cmp(void *obj, void *arg, int flags)
comparator function for state objects
#define DEFAULT_STATE_BUCKETS
Default number of state container buckets.
static int populate_transport_states(void *obj, void *arg, int flags)
Generic container type.

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

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

◆ ast_sip_initialize_sorcery_transport()

int ast_sip_initialize_sorcery_transport ( void  )

Initialize sorcery with transport support.

Definition at line 1624 of file config_transport.c.

1625 {
1627  struct ao2_container *transports = NULL;
1628 
1629  /* Create outbound registration states container. */
1632  if (!transport_states) {
1633  ast_log(LOG_ERROR, "Unable to allocate transport states container\n");
1634  return -1;
1635  }
1636 
1637  ast_sorcery_apply_default(sorcery, "transport", "config", "pjsip.conf,criteria=type=transport");
1638 
1640  return -1;
1641  }
1642 
1643  /* Normally type is a OPT_NOOP_T but we're using it to make sure that state is created */
1647  ast_sorcery_object_field_register(sorcery, "transport", "async_operations", "1", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, async_operations));
1648 
1653 
1654  ast_sorcery_object_field_register(sorcery, "transport", "password", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, password));
1655  ast_sorcery_object_field_register(sorcery, "transport", "external_signaling_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, external_signaling_address));
1656  ast_sorcery_object_field_register(sorcery, "transport", "external_signaling_port", "0", OPT_UINT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_transport, external_signaling_port), 0, 65535);
1657  ast_sorcery_object_field_register(sorcery, "transport", "external_media_address", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct ast_sip_transport, external_media_address));
1663 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
1664  ast_sorcery_object_field_register_custom(sorcery, "transport", "cipher", "", transport_tls_cipher_handler, transport_tls_cipher_to_str, NULL, 0, 0);
1665 #endif
1668  ast_sorcery_object_field_register(sorcery, "transport", "cos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, cos));
1669  ast_sorcery_object_field_register(sorcery, "transport", "websocket_write_timeout", AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR, OPT_INT_T, PARSE_IN_RANGE, FLDSET(struct ast_sip_transport, write_timeout), 1, INT_MAX);
1670  ast_sorcery_object_field_register(sorcery, "transport", "allow_reload", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, allow_reload));
1671  ast_sorcery_object_field_register(sorcery, "transport", "symmetric_transport", "no", OPT_BOOL_T, 1, FLDSET(struct ast_sip_transport, symmetric_transport));
1672 
1674 
1676  if (!cli_formatter) {
1677  ast_log(LOG_ERROR, "Unable to allocate memory for cli formatter\n");
1678  return -1;
1679  }
1680  cli_formatter->name = "transport";
1687 
1690 
1691  /* trigger load of transports from realtime by trying to revrieve them all */
1693  ao2_cleanup(transports);
1694 
1695  return 0;
1696 }
#define ast_log
Definition: astobj2.c:42
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
unsigned int cos
Definition: chan_iax2.c:349
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Definition: cli.h:265
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
@ OPT_UINT_T
Type for default option handler for unsigned integers.
@ OPT_BOOL_T
Type for default option handler for bools (ast_true/ast_false)
@ OPT_INT_T
Type for default option handler for signed integers.
@ OPT_STRINGFIELD_T
Type for default option handler for stringfields.
static int require_client_cert_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_state_init(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for type just makes sure the state is created.
static void * cli_retrieve_by_id(const char *id)
static int verify_server_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_tls_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS method setting.
static int cli_print_header(void *obj, void *arg, int flags)
static int transport_bind_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for turning a string bind into a pj_sockaddr.
static int tls_method_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_protocol_to_str(const void *obj, const intptr_t *args, char **buf)
static int internal_state_hash(const void *obj, const int flags)
hashing function for state objects
static int verify_client_to_str(const void *obj, const intptr_t *args, char **buf)
static int cert_file_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_tls_bool_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS boolean settings.
static int transport_bind_to_str(const void *obj, const intptr_t *args, char **buf)
static int internal_state_cmp(void *obj, void *arg, int flags)
comparator function for state objects
static int localnet_to_str(const void *obj, const intptr_t *args, char **buf)
static int privkey_file_to_str(const void *obj, const intptr_t *args, char **buf)
static int cli_iterate(void *container, ao2_callback_fn callback, void *args)
static int transport_localnet_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for localnet setting.
static int tos_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
Apply handler for transports.
static struct ao2_container * cli_get_container(const char *regex)
static int cli_print_body(void *obj, void *arg, int flags)
static int localnet_to_vl(const void *obj, struct ast_variable **fields)
static int transport_tls_file_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS method setting.
static int transport_tos_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TOS setting.
static int ca_list_file_to_str(const void *obj, const intptr_t *args, char **buf)
static int ca_list_path_to_str(const void *obj, const intptr_t *args, char **buf)
static int transport_protocol_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for turning a string protocol into an enum.
static void * sip_transport_alloc(const char *name)
Allocator for transport.
#define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR
Default websocket write timeout, in ms (as a string)
#define LOG_ERROR
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
Definition: res_pjsip.c:474
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
Definition: pjsip_cli.c:310
static struct ast_sorcery * sorcery
@ AST_RETRIEVE_FLAG_MULTIPLE
Return all matching objects.
Definition: sorcery.h:120
@ AST_RETRIEVE_FLAG_ALL
Perform no matching, return all objects.
Definition: sorcery.h:123
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
Definition: sorcery.h:837
#define ast_sorcery_object_field_register_custom(sorcery, type, name, default_val, config_handler, sorcery_handler, multiple_handler, flags,...)
Register a field within an object with custom handlers.
Definition: sorcery.h:1005
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
Definition: sorcery.h:955
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
#define ast_sorcery_apply_default(sorcery, type, name, data)
Definition: sorcery.h:476
CLI Formatter Registry Entry.
Definition: res_pjsip_cli.h:52
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
Definition: res_pjsip_cli.h:66
ao2_callback_fn * print_header
Definition: res_pjsip_cli.h:60
const char *(* get_id)(const void *obj)
Definition: res_pjsip_cli.h:70
struct ao2_container *(* get_container)(const char *regex)
Definition: res_pjsip_cli.h:64
void *(* retrieve_by_id)(const char *id)
Definition: res_pjsip_cli.h:68
const char * name
Definition: res_pjsip_cli.h:58
ao2_callback_fn * print_body
Definition: res_pjsip_cli.h:62
Transport to bind to.
Definition: res_pjsip.h:187
Full structure for sorcery.
Definition: sorcery.c:230
Domain data structure.
Definition: sip.h:887

References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_cleanup, ao2_container_alloc_hash, ARRAY_LEN, ast_cli_register_multiple, AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR, ast_log, AST_RETRIEVE_FLAG_ALL, AST_RETRIEVE_FLAG_MULTIPLE, ast_sip_get_sorcery(), ast_sip_register_cli_formatter(), ast_sip_register_endpoint_formatter(), ast_sorcery_apply_default, ast_sorcery_object_field_register, ast_sorcery_object_field_register_custom, ast_sorcery_object_get_id(), ast_sorcery_object_register, ast_sorcery_retrieve_by_fields(), ca_list_file_to_str(), ca_list_path_to_str(), cert_file_to_str(), cli_commands, cli_formatter, cli_get_container(), cli_iterate(), cli_print_body(), cli_print_header(), cli_retrieve_by_id(), cos, DEFAULT_STATE_BUCKETS, endpoint_transport_formatter, FLDSET, ast_sip_cli_formatter_entry::get_container, ast_sip_cli_formatter_entry::get_id, internal_state_cmp(), internal_state_hash(), ast_sip_cli_formatter_entry::iterate, localnet_to_str(), localnet_to_vl(), LOG_ERROR, ast_sip_cli_formatter_entry::name, NULL, OPT_BOOL_T, OPT_INT_T, OPT_STRINGFIELD_T, OPT_UINT_T, PARSE_IN_RANGE, ast_sip_cli_formatter_entry::print_body, ast_sip_cli_formatter_entry::print_header, privkey_file_to_str(), require_client_cert_to_str(), ast_sip_cli_formatter_entry::retrieve_by_id, sip_transport_alloc(), sorcery, STRFLDSET, tls_method_to_str(), tos_to_str(), transport_apply(), transport_bind_handler(), transport_bind_to_str(), transport_localnet_handler(), transport_protocol_handler(), transport_protocol_to_str(), transport_state_init(), transport_states, transport_tls_bool_handler(), transport_tls_file_handler(), transport_tls_method_handler(), transport_tos_handler(), verify_client_to_str(), and verify_server_to_str().

Referenced by ast_res_pjsip_initialize_configuration().

◆ ast_sip_message_apply_transport()

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

Apply the configuration for a transport to an outgoing message.

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

Definition at line 301 of file config_transport.c.

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

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

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

◆ ast_sip_service_route_vector_alloc()

struct ast_sip_service_route_vector* ast_sip_service_route_vector_alloc ( void  )

Allocate a vector of service routes.

Since
17.0.0
Return values
non-NULLsuccess
NULLfailure

Definition at line 352 of file config_transport.c.

353 {
354  struct ast_sip_service_route_vector *service_routes;
355 
356  service_routes = ast_calloc(1, sizeof(*service_routes));
357  if (!service_routes) {
358  return NULL;
359  }
360 
361  AST_VECTOR_INIT(service_routes, 0);
362 
363  return service_routes;
364 }
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:202
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113

References ast_calloc, AST_VECTOR_INIT, and NULL.

Referenced by save_response_fields_to_transport().

◆ ast_sip_service_route_vector_destroy()

void ast_sip_service_route_vector_destroy ( struct ast_sip_service_route_vector service_routes)

Destroy a vector of service routes.

Since
17.0.0
Parameters
service_routesA vector of service routes

Definition at line 366 of file config_transport.c.

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

References ast_free, and AST_VECTOR_CALLBACK_VOID.

Referenced by ast_sip_transport_state_set_service_routes(), and save_response_fields_to_transport().

◆ ast_sip_transport_state_set_preferred_identity()

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

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

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

Definition at line 242 of file config_transport.c.

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

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

Referenced by save_response_fields_to_transport().

◆ ast_sip_transport_state_set_service_routes()

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

Sets the service routes on a child transport.

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

Definition at line 270 of file config_transport.c.

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

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

Referenced by save_response_fields_to_transport().

◆ ast_sip_transport_state_set_transport()

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

Sets the PJSIP transport on a child transport.

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

Definition at line 206 of file config_transport.c.

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

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

Referenced by save_response_fields_to_transport().

◆ ca_list_file_to_str()

static int ca_list_file_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 928 of file config_transport.c.

929 {
930  const struct ast_sip_transport *transport = obj;
931 
932  *buf = ast_strdup(transport->ca_list_file);
933 
934  return 0;
935 }
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
const ast_string_field ca_list_file
Definition: res_pjsip.h:207

References ast_strdup, buf, and ast_sip_transport::ca_list_file.

Referenced by ast_sip_initialize_sorcery_transport().

◆ ca_list_path_to_str()

static int ca_list_path_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 937 of file config_transport.c.

938 {
939  const struct ast_sip_transport *transport = obj;
940 
941  *buf = ast_strdup(transport->ca_list_path);
942 
943  return 0;
944 }
const ast_string_field ca_list_path
Definition: res_pjsip.h:207

References ast_strdup, buf, and ast_sip_transport::ca_list_path.

Referenced by ast_sip_initialize_sorcery_transport().

◆ cert_file_to_str()

static int cert_file_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 946 of file config_transport.c.

947 {
948  const struct ast_sip_transport *transport = obj;
949 
950  *buf = ast_strdup(transport->cert_file);
951 
952  return 0;
953 }
const ast_string_field cert_file
Definition: res_pjsip.h:207

References ast_strdup, buf, and ast_sip_transport::cert_file.

Referenced by ast_sip_initialize_sorcery_transport().

◆ cli_get_container()

static struct ao2_container* cli_get_container ( const char *  regex)
static

Definition at line 1460 of file config_transport.c.

1461 {
1463  struct ao2_container *s_container;
1464 
1466  regex);
1467  if (!container) {
1468  return NULL;
1469  }
1470 
1473  if (!s_container) {
1474  return NULL;
1475  }
1476 
1477  if (ao2_container_dup(s_container, container, 0)) {
1478  ao2_ref(s_container, -1);
1479  return NULL;
1480  }
1481 
1482  return s_container;
1483 }
int ao2_container_dup(struct ao2_container *dest, struct ao2_container *src, enum search_flags flags)
Copy all object references in the src container into the dest container.
@ AO2_ALLOC_OPT_LOCK_NOLOCK
Definition: astobj2.h:367
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
Allocate and initialize a list container.
Definition: astobj2.h:1327
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
struct ao2_container * container
Definition: res_fax.c:501
struct ao2_container * ast_sorcery_retrieve_by_regex(const struct ast_sorcery *sorcery, const char *type, const char *regex)
Retrieve multiple objects using a regular expression on their id.
Definition: sorcery.c:1949
int ast_sorcery_object_id_compare(void *obj, void *arg, int flags)
ao2 object comparator based on sorcery id.
Definition: sorcery.c:2459
int ast_sorcery_object_id_sort(const void *obj, const void *arg, int flags)
ao2 object sorter based on sorcery id.
Definition: sorcery.c:2435
#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:936

References AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_container_alloc_list, ao2_container_dup(), ao2_ref, ast_sip_get_sorcery(), ast_sorcery_object_id_compare(), ast_sorcery_object_id_sort(), ast_sorcery_retrieve_by_regex(), container, NULL, RAII_VAR, and regex().

Referenced by ast_sip_initialize_sorcery_transport().

◆ cli_iterate()

static int cli_iterate ( void *  container,
ao2_callback_fn  callback,
void *  args 
)
static

Definition at line 1485 of file config_transport.c.

1486 {
1487  const struct ast_sip_endpoint *endpoint = container;
1489  "transport", endpoint->transport);
1490 
1491  if (!transport) {
1492  return -1;
1493  }
1494 
1495  return callback(transport, args, 0);
1496 }
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
An entity with which Asterisk communicates.
Definition: res_pjsip.h:854
const ast_string_field transport
Definition: res_pjsip.h:883
const char * args

References args, ast_sip_get_sorcery(), ast_sorcery_retrieve_by_id(), container, and ast_sip_endpoint::transport.

Referenced by ast_sip_initialize_sorcery_transport().

◆ cli_print_body()

static int cli_print_body ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1518 of file config_transport.c.

1519 {
1520  struct ast_sip_transport *transport = obj;
1521  struct ast_sip_cli_context *context = arg;
1522  char hoststr[PJ_INET6_ADDRSTRLEN];
1524 
1525  if (!state) {
1526  return -1;
1527  }
1528 
1529  ast_assert(context->output_buffer != NULL);
1530 
1531  pj_sockaddr_print(&state->host, hoststr, sizeof(hoststr), 3);
1532 
1533  ast_str_append(&context->output_buffer, 0, "%*s: %-21s %6s %5u %5u %s\n",
1534  CLI_INDENT_TO_SPACES(context->indent_level), "Transport",
1535  ast_sorcery_object_get_id(transport),
1536  ARRAY_IN_BOUNDS(transport->type, transport_types) ? transport_types[transport->type] : "Unknown",
1537  transport->cos, transport->tos, hoststr);
1538 
1539  if (context->show_details
1540  || (context->show_details_only_level_0 && context->indent_level == 0)) {
1541  ast_str_append(&context->output_buffer, 0, "\n");
1543  }
1544 
1545  return 0;
1546 }
static char context[AST_MAX_CONTEXT]
Definition: chan_alsa.c:120
static struct ast_sip_transport_state * find_state_by_transport(const struct ast_sip_transport *transport)
static const char * transport_types[]
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
Definition: pjsip_cli.c:36
#define CLI_INDENT_TO_SPACES(x)
Definition: res_pjsip_cli.h:29
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:1117
CLI Formatter Context passed to all formatters.
Definition: res_pjsip_cli.h:34
unsigned int tos
Definition: res_pjsip.h:257
enum ast_transport type
Definition: res_pjsip.h:209
unsigned int cos
Definition: res_pjsip.h:259
#define ast_assert(a)
Definition: utils.h:734
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
Definition: utils.h:682

Referenced by ast_sip_initialize_sorcery_transport().

◆ cli_print_header()

static int cli_print_header ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1503 of file config_transport.c.

1504 {
1505  struct ast_sip_cli_context *context = arg;
1506  int indent = CLI_INDENT_TO_SPACES(context->indent_level);
1507  int filler = CLI_MAX_WIDTH - indent - 61;
1508 
1509  ast_assert(context->output_buffer != NULL);
1510 
1511  ast_str_append(&context->output_buffer, 0,
1512  "%*s: <TransportId........> <Type> <cos> <tos> <BindAddress%*.*s>\n",
1513  indent, "Transport", filler, filler, CLI_HEADER_FILLER);
1514 
1515  return 0;
1516 }
#define CLI_HEADER_FILLER
Definition: res_pjsip_cli.h:24
#define CLI_MAX_WIDTH
Definition: res_pjsip_cli.h:26

References ast_assert, ast_str_append(), CLI_HEADER_FILLER, CLI_INDENT_TO_SPACES, CLI_MAX_WIDTH, context, and NULL.

Referenced by ast_sip_initialize_sorcery_transport().

◆ cli_retrieve_by_id()

static void* cli_retrieve_by_id ( const char *  id)
static

Definition at line 1498 of file config_transport.c.

1499 {
1500  return ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport", id);
1501 }

References ast_sip_get_sorcery(), and ast_sorcery_retrieve_by_id().

Referenced by ast_sip_initialize_sorcery_transport().

◆ copy_state_to_transport()

static void copy_state_to_transport ( struct ast_sip_transport transport)
static

Definition at line 568 of file config_transport.c.

569 {
570  ast_assert(transport && transport->state);
571 
572  memcpy(&transport->host, &transport->state->host, sizeof(transport->host));
573  memcpy(&transport->tls, &transport->state->tls, sizeof(transport->tls));
574  memcpy(&transport->ciphers, &transport->state->ciphers, sizeof(transport->ciphers));
575  transport->localnet = transport->state->localnet;
577  memcpy(&transport->external_address, &transport->state->external_signaling_address, sizeof(transport->external_signaling_address));
578 }
pjsip_tls_setting tls
Definition: res_pjsip.h:127
struct ast_ha * localnet
Definition: res_pjsip.h:140
struct ast_dnsmgr_entry * external_signaling_address_refresher
Definition: res_pjsip.h:145
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
Definition: res_pjsip.h:132
struct ast_sockaddr external_signaling_address
Definition: res_pjsip.h:150
pjsip_tls_setting tls
Definition: res_pjsip.h:225
struct ast_sockaddr external_address
Definition: res_pjsip.h:249
const ast_string_field external_signaling_address
Definition: res_pjsip.h:207
struct ast_sip_transport_state * state
Definition: res_pjsip.h:255
struct ast_ha * localnet
Definition: res_pjsip.h:237
pj_sockaddr host
Definition: res_pjsip.h:215
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
Definition: res_pjsip.h:231
struct ast_dnsmgr_entry * external_address_refresher
Definition: res_pjsip.h:243

References ast_assert, and ast_sip_transport_state::transport.

Referenced by transport_apply().

◆ destroy_sip_transport_state()

static int destroy_sip_transport_state ( void *  data)
static

Definition at line 415 of file config_transport.c.

416 {
417  struct ast_sip_transport_state *transport_state = data;
418 
419  ast_free(transport_state->id);
420  ast_free_ha(transport_state->localnet);
421 
422  if (transport_state->external_signaling_address_refresher) {
424  }
425  if (transport_state->external_media_address_refresher) {
427  }
428  if (transport_state->transport) {
429  pjsip_transport_shutdown(transport_state->transport);
430  }
431 
432  return 0;
433 }
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
Definition: acl.c:222
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
Definition: dnsmgr.c:136
struct ast_dnsmgr_entry * external_media_address_refresher
Definition: res_pjsip.h:155

References ast_dnsmgr_release(), ast_free, ast_free_ha(), ast_sip_transport_state::external_media_address_refresher, ast_sip_transport_state::external_signaling_address_refresher, ast_sip_transport_state::id, ast_sip_transport_state::localnet, and ast_sip_transport_state::transport.

Referenced by sip_transport_state_destroy().

◆ find_internal_state_by_transport()

static struct internal_state* find_internal_state_by_transport ( const struct ast_sip_transport transport)
static

Definition at line 453 of file config_transport.c.

454 {
455  const char *key = ast_sorcery_object_get_id(transport);
456 
458 }
@ OBJ_NOLOCK
Assume that the ao2_container is already locked.
Definition: astobj2.h:1063

References ao2_find, ast_sorcery_object_get_id(), OBJ_NOLOCK, OBJ_SEARCH_KEY, internal_state::transport, and transport_states.

Referenced by find_state_by_transport(), and transport_apply().

◆ find_or_create_temporary_state()

static struct ast_sip_transport_state* find_or_create_temporary_state ( struct ast_sip_transport transport)
static

Definition at line 534 of file config_transport.c.

535 {
537  struct ast_sip_transport_state *new_state;
538 
539  if ((new_state = find_temporary_state(transport))) {
540  return new_state;
541  }
542 
544  if (!state || *state) {
545  return NULL;
546  }
547 
548  new_state = ao2_alloc(sizeof(**state), sip_transport_state_destroy);
549  if (!new_state) {
550  return NULL;
551  }
553  new_state->type = transport->type;
554 
555  pjsip_tls_setting_default(&new_state->tls);
556 #ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO
557  /* proto must be forced to 0 to enable all protocols otherwise only TLS will work */
558  new_state->tls.proto = 0;
559 #endif
560  new_state->tls.ciphers = new_state->ciphers;
561 
562  ao2_ref(new_state, +1);
563  *state = new_state;
564 
565  return new_state;
566 }
enum sip_cc_notify_state state
Definition: chan_sip.c:966
static void sip_transport_state_destroy(void *obj)
Destructor for ast_sip_transport state information.
static struct ast_sip_transport_state * find_temporary_state(struct ast_sip_transport *transport)
static struct ast_threadstorage temp_state_store
enum ast_transport type
Definition: res_pjsip.h:117
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.

References ao2_alloc, ao2_ref, ast_sorcery_object_get_id(), ast_strdup, ast_threadstorage_get(), ast_sip_transport_state::ciphers, find_temporary_state(), ast_sip_transport_state::id, NULL, sip_transport_state_destroy(), state, temp_state_store, ast_sip_transport_state::tls, ast_sip_transport_state::transport, and ast_sip_transport_state::type.

Referenced by transport_bind_handler(), transport_localnet_handler(), transport_protocol_handler(), transport_state_init(), transport_tls_bool_handler(), transport_tls_file_handler(), and transport_tls_method_handler().

◆ find_state_by_transport()

static struct ast_sip_transport_state* find_state_by_transport ( const struct ast_sip_transport transport)
static

Definition at line 460 of file config_transport.c.

461 {
462  struct internal_state *state;
463  struct ast_sip_transport_state *trans_state;
464 
466  if (!state) {
467  return NULL;
468  }
469  trans_state = ao2_bump(state->state);
470  ao2_ref(state, -1);
471 
472  return trans_state;
473 }
static struct internal_state * find_internal_state_by_transport(const struct ast_sip_transport *transport)

References ao2_bump, ao2_ref, find_internal_state_by_transport(), NULL, state, and ast_sip_transport_state::transport.

Referenced by localnet_to_str(), localnet_to_vl(), require_client_cert_to_str(), tls_method_to_str(), transport_bind_to_str(), verify_client_to_str(), and verify_server_to_str().

◆ find_temporary_state()

static struct ast_sip_transport_state* find_temporary_state ( struct ast_sip_transport transport)
static

Definition at line 489 of file config_transport.c.

490 {
492 
494  if (state && *state) {
495  ao2_ref(*state, +1);
496  return *state;
497  }
498 
499  return NULL;
500 }

References ao2_ref, ast_threadstorage_get(), NULL, state, and temp_state_store.

Referenced by find_or_create_temporary_state(), and internal_state_alloc().

◆ format_ami_endpoint_transport()

static int format_ami_endpoint_transport ( const struct ast_sip_endpoint endpoint,
struct ast_sip_ami ami 
)
static

Definition at line 168 of file config_transport.c.

170 {
171  RAII_VAR(struct ast_str *, buf, NULL, ast_free);
172  RAII_VAR(struct ast_sip_transport *, transport, NULL, ao2_cleanup);
173 
174  if (ast_strlen_zero(endpoint->transport)) {
175  return 0;
176  }
177 
178  buf = ast_sip_create_ami_event("TransportDetail", ami);
179  if (!buf) {
180  return -1;
181  }
182 
183  transport = ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "transport",
184  endpoint->transport);
185  if (!transport) {
186  astman_send_error_va(ami->s, ami->m, "Unable to retrieve "
187  "transport %s\n", endpoint->transport);
188  return -1;
189  }
190 
191  sip_transport_to_ami(transport, &buf);
192 
193  ast_str_append(&buf, 0, "EndpointName: %s\r\n",
194  ast_sorcery_object_get_id(endpoint));
195 
196  astman_append(ami->s, "%s\r\n", ast_str_buffer(buf));
197  ami->count++;
198 
199  return 0;
200 }
static int sip_transport_to_ami(const struct ast_sip_transport *transport, struct ast_str **buf)
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:3171
void astman_append(struct mansession *s, const char *fmt,...)
Definition: manager.c:3087
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.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:739
struct mansession * s
Definition: res_pjsip.h:2821
const struct message * m
Definition: res_pjsip.h:2823
Support for dynamic strings.
Definition: strings.h:604

◆ has_state_changed()

static int has_state_changed ( struct ast_sip_transport_state a,
struct ast_sip_transport_state b 
)
static

Definition at line 580 of file config_transport.c.

581 {
582  if (a->type != b->type) {
583  return -1;
584  }
585 
586  if (pj_sockaddr_cmp(&a->host, &b->host)) {
587  return -1;
588  }
589 
590  if ((a->localnet || b->localnet)
591  && ((!a->localnet != !b->localnet)
592  || ast_sockaddr_cmp(&a->localnet->addr, &b->localnet->addr)
593  || ast_sockaddr_cmp(&a->localnet->netmask, &b->localnet->netmask)))
594  {
595  return -1;
596  }
597 
598  if (ast_sockaddr_cmp(&a->external_signaling_address, &b->external_signaling_address)) {
599  return -1;
600  }
601 
602  if (ast_sockaddr_cmp(&a->external_media_address, &b->external_media_address)) {
603  return -1;
604  }
605 
606  if (a->tls.method != b->tls.method
607  || a->tls.ciphers_num != b->tls.ciphers_num
608 #ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO
609  || a->tls.proto != b->tls.proto
610 #endif
611  || a->tls.verify_client != b->tls.verify_client
612  || a->tls.verify_server != b->tls.verify_server
613  || a->tls.require_client_cert != b->tls.require_client_cert) {
614  return -1;
615  }
616 
617  if (memcmp(a->ciphers, b->ciphers, sizeof(pj_ssl_cipher) * fmax(a->tls.ciphers_num, b->tls.ciphers_num))) {
618  return -1;
619  }
620 
621  return 0;
622 }
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
Definition: netsock2.c:388
static struct test_val b
static struct test_val a

References a, ast_sockaddr_cmp(), and b.

Referenced by transport_apply().

◆ internal_state_alloc()

static struct internal_state* internal_state_alloc ( struct ast_sip_transport transport)
static

Definition at line 502 of file config_transport.c.

503 {
505 
507  if (!internal_state) {
508  return NULL;
509  }
510 
512  if (!internal_state->id) {
514  return NULL;
515  }
516 
517  /* We're transferring the reference from find_temporary_state */
519  if (!internal_state->state) {
521  return NULL;
522  }
526 
527  return internal_state;
528 }
static int remove_temporary_state(void)
static void internal_state_destroy(void *obj)
Destructor for ast_sip_transport state information.
struct ast_sip_transport_state * state
Transport state information.
struct ast_sip_transport * transport
Transport configuration object.

References ao2_alloc, ao2_bump, ao2_cleanup, ast_sorcery_object_get_id(), ast_strdup, find_temporary_state(), internal_state::id, internal_state_destroy(), NULL, remove_temporary_state(), ast_sip_transport::state, internal_state::state, and internal_state::transport.

Referenced by transport_apply().

◆ internal_state_cmp()

static int internal_state_cmp ( void *  obj,
void *  arg,
int  flags 
)
static

comparator function for state objects

Definition at line 84 of file config_transport.c.

85 {
86  const struct internal_state *object_left = obj;
87  const struct internal_state *object_right = arg;
88  const char *right_key = arg;
89  int cmp;
90 
91  switch (flags & OBJ_SEARCH_MASK) {
92  case OBJ_SEARCH_OBJECT:
93  right_key = object_right->id;
94  /* Fall through */
95  case OBJ_SEARCH_KEY:
96  cmp = strcmp(object_left->id, right_key);
97  break;
99  /* Not supported by container. */
100  ast_assert(0);
101  return 0;
102  default:
103  cmp = 0;
104  break;
105  }
106  if (cmp) {
107  return 0;
108  }
109  return CMP_MATCH;
110 }
@ CMP_MATCH
Definition: astobj2.h:1027
@ OBJ_SEARCH_PARTIAL_KEY
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
Definition: astobj2.h:1116
@ OBJ_SEARCH_OBJECT
The arg parameter is an object of the same type.
Definition: astobj2.h:1087
@ OBJ_SEARCH_MASK
Search option field mask.
Definition: astobj2.h:1072

References ast_assert, CMP_MATCH, internal_state::id, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.

Referenced by ast_sip_initialize_sorcery_transport().

◆ internal_state_destroy()

static void internal_state_destroy ( void *  obj)
static

Destructor for ast_sip_transport state information.

Definition at line 444 of file config_transport.c.

445 {
446  struct internal_state *state = obj;
447 
448  ast_free(state->id);
449  ao2_cleanup(state->transport);
450  ao2_cleanup(state->state);
451 }

References ao2_cleanup, and ast_free.

Referenced by internal_state_alloc().

◆ internal_state_hash()

static int internal_state_hash ( const void *  obj,
const int  flags 
)
static

hashing function for state objects

Definition at line 63 of file config_transport.c.

64 {
65  const struct internal_state *object;
66  const char *key;
67 
68  switch (flags & OBJ_SEARCH_MASK) {
69  case OBJ_SEARCH_KEY:
70  key = obj;
71  break;
72  case OBJ_SEARCH_OBJECT:
73  object = obj;
74  key = object->id;
75  break;
76  default:
77  ast_assert(0);
78  return 0;
79  }
80  return ast_str_hash(key);
81 }
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1237

References ast_assert, ast_str_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.

Referenced by ast_sip_initialize_sorcery_transport().

◆ localnet_to_str()

static int localnet_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1409 of file config_transport.c.

1410 {
1412  const struct ast_sip_transport *transport = obj;
1414 
1415  if (!state) {
1416  return -1;
1417  }
1418 
1419  ast_ha_join(state->localnet, &str);
1421  return 0;
1422 }
void ast_ha_join(const struct ast_ha *ha, struct ast_str **buf)
Convert HAs to a comma separated string value.
Definition: acl.c:723
const char * str
Definition: app_jack.c:147
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
Definition: sorcery.h:110
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Definition: strings.h:640

References ao2_cleanup, ast_free, ast_ha_join(), ast_str_buffer(), ast_str_create, ast_strdup, buf, find_state_by_transport(), MAX_OBJECT_FIELD, RAII_VAR, and str.

Referenced by ast_sip_initialize_sorcery_transport().

◆ localnet_to_vl()

static int localnet_to_vl ( const void *  obj,
struct ast_variable **  fields 
)
static

Definition at line 1387 of file config_transport.c.

1388 {
1389  const struct ast_sip_transport *transport = obj;
1390  struct ast_variable *head = NULL;
1391  struct ast_ha *ha;
1393 
1394  if (!state) {
1395  return -1;
1396  }
1397 
1398  for (ha = state->localnet; ha; ha = ha->next) {
1399  localnet_to_vl_append(&head, ha);
1400  }
1401 
1402  if (head) {
1403  *fields = head;
1404  }
1405 
1406  return 0;
1407 }
static void localnet_to_vl_append(struct ast_variable **head, struct ast_ha *ha)
internal representation of ACL entries In principle user applications would have no need for this,...
Definition: acl.h:51
struct ast_ha * next
Definition: acl.h:56
Structure for variables, used for configurations and for channel variables.

References ao2_cleanup, find_state_by_transport(), localnet_to_vl_append(), ast_ha::next, NULL, and RAII_VAR.

Referenced by ast_sip_initialize_sorcery_transport().

◆ localnet_to_vl_append()

static void localnet_to_vl_append ( struct ast_variable **  head,
struct ast_ha ha 
)
static

Definition at line 1377 of file config_transport.c.

1378 {
1379  char str[MAX_OBJECT_FIELD];
1380  const char *addr = ast_strdupa(ast_sockaddr_stringify_addr(&ha->addr));
1381  snprintf(str, MAX_OBJECT_FIELD, "%s%s/%s", ha->sense == AST_SENSE_ALLOW ? "!" : "",
1382  addr, ast_sockaddr_stringify_addr(&ha->netmask));
1383 
1384  ast_variable_list_append(head, ast_variable_new("local_net", str, ""));
1385 }
@ AST_SENSE_ALLOW
Definition: acl.h:38
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ast_variable_new(name, value, filename)
#define ast_variable_list_append(head, new_var)
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
Definition: netsock2.h:286
struct ast_sockaddr addr
Definition: acl.h:53
struct ast_sockaddr netmask
Definition: acl.h:54
enum ast_acl_sense sense
Definition: acl.h:55

References ast_ha::addr, AST_SENSE_ALLOW, ast_sockaddr_stringify_addr(), ast_strdupa, ast_variable_list_append, ast_variable_new, MAX_OBJECT_FIELD, ast_ha::netmask, ast_ha::sense, and str.

Referenced by localnet_to_vl().

◆ populate_transport_states()

static int populate_transport_states ( void *  obj,
void *  arg,
int  flags 
)
static

Definition at line 1600 of file config_transport.c.

1601 {
1602  struct internal_state *state = obj;
1603  struct ao2_container *container = arg;
1604 
1605  ao2_link(container, state->state);
1606 
1607  return CMP_MATCH;
1608 }
#define ao2_link(container, obj)
Add an object to a container.
Definition: astobj2.h:1532

References ao2_link, CMP_MATCH, and container.

Referenced by ast_sip_get_transport_states().

◆ privkey_file_to_str()

static int privkey_file_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 955 of file config_transport.c.

956 {
957  const struct ast_sip_transport *transport = obj;
958 
959  *buf = ast_strdup(transport->privkey_file);
960 
961  return 0;
962 }
const ast_string_field privkey_file
Definition: res_pjsip.h:207

References ast_strdup, buf, and ast_sip_transport::privkey_file.

Referenced by ast_sip_initialize_sorcery_transport().

◆ remove_temporary_state()

static int remove_temporary_state ( void  )
static

Definition at line 475 of file config_transport.c.

476 {
478 
480  if (!state) {
481  return -1;
482  }
483 
484  ao2_cleanup(*state);
485  *state = NULL;
486  return 0;
487 }

References ao2_cleanup, ast_threadstorage_get(), NULL, state, and temp_state_store.

Referenced by internal_state_alloc().

◆ require_client_cert_to_str()

static int require_client_cert_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1106 of file config_transport.c.

1107 {
1108  const struct ast_sip_transport *transport = obj;
1110 
1111  if (!state) {
1112  return -1;
1113  }
1114 
1115  *buf = ast_strdup(AST_YESNO(state->tls.require_client_cert));
1116 
1117  return 0;
1118 }
#define AST_YESNO(x)
return Yes or No depending on the argument.
Definition: strings.h:143

References ao2_cleanup, ast_strdup, AST_YESNO, buf, find_state_by_transport(), and RAII_VAR.

Referenced by ast_sip_initialize_sorcery_transport().

◆ set_qos()

static void set_qos ( struct ast_sip_transport transport,
pj_qos_params *  qos 
)
static

Definition at line 376 of file config_transport.c.

377 {
378  int tos_as_dscp = transport->tos >> 2;
379 
380  if (transport->tos) {
381  qos->flags |= PJ_QOS_PARAM_HAS_DSCP;
382  qos->dscp_val = tos_as_dscp;
383  }
384  if (transport->cos) {
385  qos->flags |= PJ_QOS_PARAM_HAS_SO_PRIO;
386  qos->so_prio = transport->cos;
387  }
388 }
static struct @107 qos

References ast_sip_transport::cos, qos, and ast_sip_transport::tos.

Referenced by transport_apply().

◆ sip_transport_alloc()

static void* sip_transport_alloc ( const char *  name)
static

Allocator for transport.

Definition at line 399 of file config_transport.c.

400 {
401  struct ast_sip_transport *transport = ast_sorcery_generic_alloc(sizeof(*transport), sip_transport_destroy);
402 
403  if (!transport) {
404  return NULL;
405  }
406 
407  if (ast_string_field_init(transport, 256)) {
408  ao2_cleanup(transport);
409  return NULL;
410  }
411 
412  return transport;
413 }
static void sip_transport_destroy(void *obj)
Destructor for transport.
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
Definition: sorcery.c:1728
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
Definition: stringfields.h:359

References ao2_cleanup, ast_sorcery_generic_alloc(), ast_string_field_init, NULL, and sip_transport_destroy().

Referenced by ast_sip_initialize_sorcery_transport().

◆ sip_transport_destroy()

static void sip_transport_destroy ( void *  obj)
static

Destructor for transport.

Definition at line 391 of file config_transport.c.

392 {
393  struct ast_sip_transport *transport = obj;
394 
395  ast_string_field_free_memory(transport);
396 }
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
Definition: stringfields.h:374

References ast_string_field_free_memory.

Referenced by sip_transport_alloc().

◆ sip_transport_state_destroy()

static void sip_transport_state_destroy ( void *  obj)
static

Destructor for ast_sip_transport state information.

Definition at line 436 of file config_transport.c.

437 {
438  struct ast_sip_transport_state *state = obj;
439 
441 }
static int destroy_sip_transport_state(void *data)
int ast_sip_push_task_wait_servant(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Push a task to SIP servants and wait for it to complete.
Definition: res_pjsip.c:1999

References ast_sip_push_task_wait_servant(), destroy_sip_transport_state(), and NULL.

Referenced by find_or_create_temporary_state().

◆ sip_transport_to_ami()

static int sip_transport_to_ami ( const struct ast_sip_transport transport,
struct ast_str **  buf 
)
static

Definition at line 162 of file config_transport.c.

164 {
165  return ast_sip_sorcery_object_to_ami(transport, buf);
166 }
int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
Converts a sorcery object to a string of object properties.

References ast_sip_sorcery_object_to_ami(), buf, and ast_sip_transport_state::transport.

◆ states_cleanup()

static void states_cleanup ( void *  states)
static

Definition at line 624 of file config_transport.c.

625 {
626  if (states) {
627  ao2_unlock(states);
628  }
629 }

References ao2_unlock.

Referenced by transport_apply().

◆ temp_state_store_cleanup()

static void temp_state_store_cleanup ( void *  data)
static

Definition at line 52 of file config_transport.c.

53 {
54  struct ast_sip_transport_state **temp_state = data;
55 
56  ao2_cleanup(*temp_state);
57  ast_free(data);
58 }

References ao2_cleanup, and ast_free.

◆ tls_method_to_str()

static int tls_method_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1167 of file config_transport.c.

1168 {
1169  const struct ast_sip_transport *transport = obj;
1171 
1172  if (!state) {
1173  return -1;
1174  }
1175 
1176  if (ARRAY_IN_BOUNDS(state->tls.method, tls_method_map)) {
1177  *buf = ast_strdup(tls_method_map[state->tls.method]);
1178  }
1179 
1180  return 0;
1181 }
static const char * tls_method_map[]

References ao2_cleanup, ARRAY_IN_BOUNDS, ast_strdup, buf, find_state_by_transport(), RAII_VAR, and tls_method_map.

Referenced by ast_sip_initialize_sorcery_transport().

◆ tos_to_str()

static int tos_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1450 of file config_transport.c.

1451 {
1452  const struct ast_sip_transport *transport = obj;
1453 
1454  if (ast_asprintf(buf, "%u", transport->tos) == -1) {
1455  return -1;
1456  }
1457  return 0;
1458 }
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
Definition: astmm.h:267

References ast_asprintf, buf, and ast_sip_transport::tos.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_apply()

static int transport_apply ( const struct ast_sorcery sorcery,
void *  obj 
)
static

Apply handler for transports.

Definition at line 632 of file config_transport.c.

633 {
634  struct ast_sip_transport *transport = obj;
635  const char *transport_id = ast_sorcery_object_get_id(obj);
637  RAII_VAR(struct internal_state *, temp_state, NULL, ao2_cleanup);
638  RAII_VAR(struct internal_state *, perm_state, NULL, ao2_cleanup);
639  RAII_VAR(struct ast_variable *, changes, NULL, ast_variables_destroy);
640  pj_status_t res = -1;
641  int i;
642 #define BIND_TRIES 3
643 #define BIND_DELAY_US 100000
644 
645  if (!states) {
646  return -1;
647  }
648 
649  /*
650  * transport_apply gets called for EVERY retrieval of a transport when using realtime.
651  * We need to prevent multiple threads from trying to mess with underlying transports
652  * at the same time. The container is the only thing we have to lock on.
653  */
654  ao2_wrlock(states);
655 
656  temp_state = internal_state_alloc(transport);
657  if (!temp_state) {
658  ast_log(LOG_ERROR, "Transport '%s' failed to allocate memory\n", transport_id);
659  return -1;
660  }
661 
662  if (transport->async_operations != 1) {
663  ast_log(LOG_WARNING, "The async_operations setting on transport '%s' has been set to '%d'. The setting can no longer be set and is always 1.\n",
664  transport_id, transport->async_operations);
665  transport->async_operations = 1;
666  }
667 
668  perm_state = find_internal_state_by_transport(transport);
669  if (perm_state) {
670  ast_sorcery_diff(sorcery, perm_state->transport, transport, &changes);
671  if (!changes && !has_state_changed(perm_state->state, temp_state->state)) {
672  /* In case someone is using the deprecated fields, reset them */
673  transport->state = perm_state->state;
674  copy_state_to_transport(transport);
675  ao2_replace(perm_state->transport, transport);
676  return 0;
677  }
678 
679  /* If we aren't allowed to reload then we copy values that can't be changed from perm_state */
680  if (!transport->allow_reload) {
681  memcpy(&temp_state->state->host, &perm_state->state->host, sizeof(temp_state->state->host));
682  memcpy(&temp_state->state->tls, &perm_state->state->tls, sizeof(temp_state->state->tls));
683  memcpy(&temp_state->state->ciphers, &perm_state->state->ciphers, sizeof(temp_state->state->ciphers));
684  }
685  }
686 
687  if (!transport->flow && (!perm_state || transport->allow_reload)) {
688  if (temp_state->state->host.addr.sa_family != PJ_AF_INET && temp_state->state->host.addr.sa_family != PJ_AF_INET6) {
689  ast_log(LOG_ERROR, "Transport '%s' could not be started as binding not specified\n", transport_id);
690  return -1;
691  }
692 
693  /* Set default port if not present */
694  if (!pj_sockaddr_get_port(&temp_state->state->host)) {
695  pj_sockaddr_set_port(&temp_state->state->host, (transport->type == AST_TRANSPORT_TLS) ? 5061 : 5060);
696  }
697  }
698 
699  /* Now that we know what address family we can set up a dnsmgr refresh for the external addresses if present */
700  if (!ast_strlen_zero(transport->external_signaling_address)) {
701  if (temp_state->state->host.addr.sa_family == pj_AF_INET()) {
702  temp_state->state->external_signaling_address.ss.ss_family = AF_INET;
703  } else if (temp_state->state->host.addr.sa_family == pj_AF_INET6()) {
704  temp_state->state->external_signaling_address.ss.ss_family = AF_INET6;
705  } else {
706  ast_log(LOG_ERROR, "Unknown address family for transport '%s', could not get external signaling address\n",
707  transport_id);
708  return -1;
709  }
710 
711  if (ast_dnsmgr_lookup(transport->external_signaling_address, &temp_state->state->external_signaling_address, &temp_state->state->external_signaling_address_refresher, NULL) < 0) {
712  ast_log(LOG_ERROR, "Could not create dnsmgr for external signaling address on '%s'\n", transport_id);
713  return -1;
714  }
715  }
716 
717  if (!ast_strlen_zero(transport->external_media_address)) {
718  if (temp_state->state->host.addr.sa_family == pj_AF_INET()) {
719  temp_state->state->external_media_address.ss.ss_family = AF_INET;
720  } else if (temp_state->state->host.addr.sa_family == pj_AF_INET6()) {
721  temp_state->state->external_media_address.ss.ss_family = AF_INET6;
722  } else {
723  ast_log(LOG_ERROR, "Unknown address family for transport '%s', could not get external media address\n",
724  transport_id);
725  return -1;
726  }
727 
728  if (ast_dnsmgr_lookup(transport->external_media_address, &temp_state->state->external_media_address, &temp_state->state->external_media_address_refresher, NULL) < 0) {
729  ast_log(LOG_ERROR, "Could not create dnsmgr for external media address on '%s'\n", transport_id);
730  return -1;
731  }
732  }
733 
734  if (transport->flow) {
735  pj_str_t address;
736 
737  ast_debug(1, "Ignoring any bind configuration on transport '%s' as it is a child of another\n",
738  transport_id);
739  pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&address, "0.0.0.0"), &temp_state->state->host);
740 
741  temp_state->state->flow = 1;
742  res = PJ_SUCCESS;
743  } else if (!transport->allow_reload && perm_state) {
744  /* We inherit the transport from perm state, untouched */
745  ast_log(LOG_WARNING, "Transport '%s' is not fully reloadable, not reloading: protocol, bind, TLS, TCP, ToS, or CoS options.\n", transport_id);
746  temp_state->state->transport = perm_state->state->transport;
747  perm_state->state->transport = NULL;
748  temp_state->state->factory = perm_state->state->factory;
749  perm_state->state->factory = NULL;
750  res = PJ_SUCCESS;
751  } else if (transport->type == AST_TRANSPORT_UDP) {
752 
753  for (i = 0; i < BIND_TRIES && res != PJ_SUCCESS; i++) {
754  if (perm_state && perm_state->state && perm_state->state->transport) {
755  pjsip_udp_transport_pause(perm_state->state->transport,
756  PJSIP_UDP_TRANSPORT_DESTROY_SOCKET);
757  usleep(BIND_DELAY_US);
758  }
759 
760  if (temp_state->state->host.addr.sa_family == pj_AF_INET()) {
761  res = pjsip_udp_transport_start(ast_sip_get_pjsip_endpoint(),
762  &temp_state->state->host.ipv4, NULL, transport->async_operations,
763  &temp_state->state->transport);
764  } else if (temp_state->state->host.addr.sa_family == pj_AF_INET6()) {
765  res = pjsip_udp_transport_start6(ast_sip_get_pjsip_endpoint(),
766  &temp_state->state->host.ipv6, NULL, transport->async_operations,
767  &temp_state->state->transport);
768  }
769  }
770 
771  if (res == PJ_SUCCESS) {
772  temp_state->state->transport->info = pj_pool_alloc(temp_state->state->transport->pool,
773  (AST_SIP_X_AST_TXP_LEN + strlen(transport_id) + 2));
774 
775  sprintf(temp_state->state->transport->info, "%s:%s", AST_SIP_X_AST_TXP, transport_id);
776 
777  if (transport->tos || transport->cos) {
778  pj_sock_t sock;
779  pj_qos_params qos_params;
780  sock = pjsip_udp_transport_get_socket(temp_state->state->transport);
781  pj_sock_get_qos_params(sock, &qos_params);
782  set_qos(transport, &qos_params);
783  pj_sock_set_qos_params(sock, &qos_params);
784  }
785  }
786  } else if (transport->type == AST_TRANSPORT_TCP) {
787  pjsip_tcp_transport_cfg cfg;
788  static int option = 1;
789 
790  pjsip_tcp_transport_cfg_default(&cfg, temp_state->state->host.addr.sa_family);
791  cfg.bind_addr = temp_state->state->host;
792  cfg.async_cnt = transport->async_operations;
793  set_qos(transport, &cfg.qos_params);
794  /* sockopt_params.options is copied to each newly connected socket */
795  cfg.sockopt_params.options[0].level = pj_SOL_TCP();
796  cfg.sockopt_params.options[0].optname = pj_TCP_NODELAY();
797  cfg.sockopt_params.options[0].optval = &option;
798  cfg.sockopt_params.options[0].optlen = sizeof(option);
799  cfg.sockopt_params.cnt = 1;
800 
801  for (i = 0; i < BIND_TRIES && res != PJ_SUCCESS; i++) {
802  if (perm_state && perm_state->state && perm_state->state->factory
803  && perm_state->state->factory->destroy) {
804  perm_state->state->factory->destroy(perm_state->state->factory);
805  usleep(BIND_DELAY_US);
806  }
807 
808  res = pjsip_tcp_transport_start3(ast_sip_get_pjsip_endpoint(), &cfg,
809  &temp_state->state->factory);
810  }
811  } else if (transport->type == AST_TRANSPORT_TLS) {
812 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
813  static int option = 1;
814 
815  if (transport->async_operations > 1 && ast_compare_versions(pj_get_version(), "2.5.0") < 0) {
816  ast_log(LOG_ERROR, "Transport: %s: When protocol=tls and pjproject version < 2.5.0, async_operations can't be > 1\n",
818  return -1;
819  }
820 
821  temp_state->state->tls.password = pj_str((char*)transport->password);
822  set_qos(transport, &temp_state->state->tls.qos_params);
823 
824  /* sockopt_params.options is copied to each newly connected socket */
825  temp_state->state->tls.sockopt_params.options[0].level = pj_SOL_TCP();
826  temp_state->state->tls.sockopt_params.options[0].optname = pj_TCP_NODELAY();
827  temp_state->state->tls.sockopt_params.options[0].optval = &option;
828  temp_state->state->tls.sockopt_params.options[0].optlen = sizeof(option);
829  temp_state->state->tls.sockopt_params.cnt = 1;
830 
831  for (i = 0; i < BIND_TRIES && res != PJ_SUCCESS; i++) {
832  if (perm_state && perm_state->state && perm_state->state->factory
833  && perm_state->state->factory->destroy) {
834  perm_state->state->factory->destroy(perm_state->state->factory);
835  usleep(BIND_DELAY_US);
836  }
837 
838  res = pjsip_tls_transport_start2(ast_sip_get_pjsip_endpoint(), &temp_state->state->tls,
839  &temp_state->state->host, NULL, transport->async_operations,
840  &temp_state->state->factory);
841  }
842 #else
843  ast_log(LOG_ERROR, "Transport: %s: PJSIP has not been compiled with TLS transport support, ensure OpenSSL development packages are installed\n",
845  return -1;
846 #endif
847  } else if ((transport->type == AST_TRANSPORT_WS) || (transport->type == AST_TRANSPORT_WSS)) {
848  if (transport->cos || transport->tos) {
849  ast_log(LOG_WARNING, "TOS and COS values ignored for websocket transport\n");
850  } else if (!ast_strlen_zero(transport->ca_list_file) || !ast_strlen_zero(transport->ca_list_path) ||
851  !ast_strlen_zero(transport->cert_file) || !ast_strlen_zero(transport->privkey_file)) {
852  ast_log(LOG_WARNING, "TLS certificate values ignored for websocket transport as they are configured in http.conf\n");
853  }
854  res = PJ_SUCCESS;
855  }
856 
857  if (res != PJ_SUCCESS) {
858  char msg[PJ_ERR_MSG_SIZE];
859 
860  pj_strerror(res, msg, sizeof(msg));
861  ast_log(LOG_ERROR, "Transport '%s' could not be started: %s\n", ast_sorcery_object_get_id(obj), msg);
862  return -1;
863  }
864 
865  copy_state_to_transport(transport);
866  if (perm_state) {
867  ao2_unlink_flags(states, perm_state, OBJ_NOLOCK);
868  }
869  ao2_link_flags(states, temp_state, OBJ_NOLOCK);
870 
871  return 0;
872 }
#define ao2_wrlock(a)
Definition: astobj2.h:719
#define ao2_unlink_flags(container, obj, flags)
Remove an object from a container.
Definition: astobj2.h:1600
#define ao2_link_flags(container, obj, flags)
Add an object to a container.
Definition: astobj2.h:1554
#define ao2_replace(dst, src)
Replace one object reference with another cleaning up the original.
Definition: astobj2.h:501
#define BIND_TRIES
static void copy_state_to_transport(struct ast_sip_transport *transport)
static void set_qos(struct ast_sip_transport *transport, pj_qos_params *qos)
static struct internal_state * internal_state_alloc(struct ast_sip_transport *transport)
#define BIND_DELAY_US
static int has_state_changed(struct ast_sip_transport_state *a, struct ast_sip_transport_state *b)
static void states_cleanup(void *states)
int ast_dnsmgr_lookup(const char *name, struct ast_sockaddr *result, struct ast_dnsmgr_entry **dnsmgr, const char *service)
Allocate and initialize a DNS manager entry.
Definition: dnsmgr.c:191
char * address
Definition: f2c.h:59
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
#define ast_debug(level,...)
Log a DEBUG message.
#define LOG_WARNING
@ AST_TRANSPORT_WSS
Definition: netsock2.h:64
@ AST_TRANSPORT_WS
Definition: netsock2.h:63
@ AST_TRANSPORT_UDP
Definition: netsock2.h:60
@ AST_TRANSPORT_TLS
Definition: netsock2.h:62
@ AST_TRANSPORT_TCP
Definition: netsock2.h:61
#define AST_SIP_X_AST_TXP
Definition: res_pjsip.h:955
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:513
#define AST_SIP_X_AST_TXP_LEN
Definition: res_pjsip.h:956
int ast_sorcery_diff(const struct ast_sorcery *sorcery, const void *original, const void *modified, struct ast_variable **changes)
Create a changeset of two objects.
Definition: sorcery.c:1805
const ast_string_field password
Definition: res_pjsip.h:207
unsigned int async_operations
Definition: res_pjsip.h:217
const ast_string_field external_media_address
Definition: res_pjsip.h:207
int ast_compare_versions(const char *version1, const char *version2)
Compare 2 major.minor.patch.extra version strings.
Definition: main/utils.c:3020

References ast_sip_transport::allow_reload, ao2_cleanup, ao2_link_flags, ao2_replace, ao2_unlink_flags, ao2_wrlock, ast_compare_versions(), ast_debug, ast_dnsmgr_lookup(), ast_log, ast_sip_get_pjsip_endpoint(), AST_SIP_X_AST_TXP, AST_SIP_X_AST_TXP_LEN, ast_sorcery_diff(), ast_sorcery_object_get_id(), ast_strlen_zero(), AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, AST_TRANSPORT_WS, AST_TRANSPORT_WSS, ast_variables_destroy(), ast_sip_transport::async_operations, BIND_DELAY_US, BIND_TRIES, ast_sip_transport::ca_list_file, ast_sip_transport::ca_list_path, ast_sip_transport::cert_file, copy_state_to_transport(), ast_sip_transport::cos, ast_sip_transport::external_media_address, ast_sip_transport::external_signaling_address, find_internal_state_by_transport(), ast_sip_transport::flow, has_state_changed(), internal_state_alloc(), LOG_ERROR, LOG_WARNING, NULL, OBJ_NOLOCK, ast_sip_transport::password, ast_sip_transport::privkey_file, RAII_VAR, set_qos(), sorcery, ast_sip_transport::state, states_cleanup(), ast_sip_transport_state::tls, ast_sip_transport::tos, transport_states, and ast_sip_transport::type.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_bind_handler()

static int transport_bind_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for turning a string bind into a pj_sockaddr.

Definition at line 1020 of file config_transport.c.

1021 {
1022  struct ast_sip_transport *transport = obj;
1023  pj_str_t buf;
1024  int rc;
1026 
1027  if (!state) {
1028  return -1;
1029  }
1030 
1031  rc = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&buf, var->value), &state->host);
1032 
1033  return rc != PJ_SUCCESS ? -1 : 0;
1034 }
#define var
Definition: ast_expr2f.c:614
static struct ast_sip_transport_state * find_or_create_temporary_state(struct ast_sip_transport *transport)

References ao2_cleanup, buf, find_or_create_temporary_state(), RAII_VAR, and var.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_bind_to_str()

static int transport_bind_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1036 of file config_transport.c.

1037 {
1038  const struct ast_sip_transport *transport = obj;
1040 
1041  if (!state) {
1042  return -1;
1043  }
1044 
1045  if (!(*buf = ast_calloc(MAX_OBJECT_FIELD, sizeof(char)))) {
1046  return -1;
1047  }
1048 
1049  /* include port as well as brackets if IPv6 */
1050  pj_sockaddr_print(&state->host, *buf, MAX_OBJECT_FIELD, 1 | 2);
1051 
1052  return 0;
1053 }

References ao2_cleanup, ast_calloc, buf, find_state_by_transport(), MAX_OBJECT_FIELD, and RAII_VAR.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_localnet_handler()

static int transport_localnet_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for localnet setting.

Definition at line 1352 of file config_transport.c.

1353 {
1354  struct ast_sip_transport *transport = obj;
1355  int error = 0;
1357 
1358  if (!state) {
1359  return -1;
1360  }
1361 
1362  if (ast_strlen_zero(var->value)) {
1363  ast_free_ha(state->localnet);
1364  state->localnet = NULL;
1365  return 0;
1366  }
1367 
1368  /* We use only the ast_apply_ha() which defaults to ALLOW
1369  * ("permit"), so we add DENY rules. */
1370  if (!(state->localnet = ast_append_ha("deny", var->value, state->localnet, &error))) {
1371  return -1;
1372  }
1373 
1374  return error;
1375 }
struct ast_ha * ast_append_ha(const char *sense, const char *stuff, struct ast_ha *path, int *error)
Add a new rule to a list of HAs.
Definition: acl.c:713
int error(const char *format,...)
Definition: utils/frame.c:999

References ao2_cleanup, ast_append_ha(), ast_free_ha(), ast_strlen_zero(), error(), find_or_create_temporary_state(), NULL, RAII_VAR, and var.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_protocol_handler()

static int transport_protocol_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for turning a string protocol into an enum.

Definition at line 965 of file config_transport.c.

966 {
967  struct ast_sip_transport *transport = obj;
969 
970  if (!state) {
971  return -1;
972  }
973 
974  if (!strcasecmp(var->value, "flow")) {
975  transport->flow = 1;
976  } else {
977  if (!strcasecmp(var->value, "udp")) {
978  transport->type = AST_TRANSPORT_UDP;
979  } else if (!strcasecmp(var->value, "tcp")) {
980  transport->type = AST_TRANSPORT_TCP;
981  } else if (!strcasecmp(var->value, "tls")) {
982  transport->type = AST_TRANSPORT_TLS;
983  } else if (!strcasecmp(var->value, "ws")) {
984  transport->type = AST_TRANSPORT_WS;
985  } else if (!strcasecmp(var->value, "wss")) {
986  transport->type = AST_TRANSPORT_WSS;
987  } else {
988  return -1;
989  }
990  transport->flow = 0;
991  }
992 
993  state->type = transport->type;
994 
995  return 0;
996 }

References ao2_cleanup, AST_TRANSPORT_TCP, AST_TRANSPORT_TLS, AST_TRANSPORT_UDP, AST_TRANSPORT_WS, AST_TRANSPORT_WSS, find_or_create_temporary_state(), ast_sip_transport::flow, RAII_VAR, ast_sip_transport::type, and var.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_protocol_to_str()

static int transport_protocol_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1006 of file config_transport.c.

1007 {
1008  const struct ast_sip_transport *transport = obj;
1009 
1010  if (transport->flow) {
1011  *buf = ast_strdup("flow");
1012  } else if (ARRAY_IN_BOUNDS(transport->type, transport_types)) {
1013  *buf = ast_strdup(transport_types[transport->type]);
1014  }
1015 
1016  return 0;
1017 }

References ARRAY_IN_BOUNDS, ast_strdup, buf, ast_sip_transport::flow, transport_types, and ast_sip_transport::type.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_state_cmp()

static int transport_state_cmp ( void *  obj,
void *  arg,
int  flags 
)
static

comparator function for state objects

Definition at line 134 of file config_transport.c.

135 {
136  const struct ast_sip_transport_state *object_left = obj;
137  const struct ast_sip_transport_state *object_right = arg;
138  const char *right_key = arg;
139  int cmp;
140 
141  switch (flags & OBJ_SEARCH_MASK) {
142  case OBJ_SEARCH_OBJECT:
143  right_key = object_right->id;
144  /* Fall through */
145  case OBJ_SEARCH_KEY:
146  cmp = strcmp(object_left->id, right_key);
147  break;
149  /* Not supported by container. */
150  ast_assert(0);
151  return 0;
152  default:
153  cmp = 0;
154  break;
155  }
156  if (cmp) {
157  return 0;
158  }
159  return CMP_MATCH;
160 }

References ast_assert, CMP_MATCH, ast_sip_transport_state::id, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.

Referenced by ast_sip_get_transport_states().

◆ transport_state_hash()

static int transport_state_hash ( const void *  obj,
const int  flags 
)
static

hashing function for state objects

Definition at line 113 of file config_transport.c.

114 {
115  const struct ast_sip_transport_state *object;
116  const char *key;
117 
118  switch (flags & OBJ_SEARCH_MASK) {
119  case OBJ_SEARCH_KEY:
120  key = obj;
121  break;
122  case OBJ_SEARCH_OBJECT:
123  object = obj;
124  key = object->id;
125  break;
126  default:
127  ast_assert(0);
128  return 0;
129  }
130  return ast_str_hash(key);
131 }

References ast_assert, ast_str_hash(), OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.

Referenced by ast_sip_get_transport_states().

◆ transport_state_init()

static int transport_state_init ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for type just makes sure the state is created.

Definition at line 875 of file config_transport.c.

876 {
877  struct ast_sip_transport *transport = obj;
879 
881 
882  return 0;
883 }

References ao2_cleanup, find_or_create_temporary_state(), and ast_sip_transport_state::transport.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_tls_bool_handler()

static int transport_tls_bool_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for TLS boolean settings.

Definition at line 1056 of file config_transport.c.

1057 {
1058  struct ast_sip_transport *transport = obj;
1060 
1061  if (!state) {
1062  return -1;
1063  }
1064 
1065  if (!strcasecmp(var->name, "verify_server")) {
1066  state->tls.verify_server = ast_true(var->value) ? PJ_TRUE : PJ_FALSE;
1067  } else if (!strcasecmp(var->name, "verify_client")) {
1068  state->tls.verify_client = ast_true(var->value) ? PJ_TRUE : PJ_FALSE;
1069  } else if (!strcasecmp(var->name, "require_client_cert")) {
1070  state->tls.require_client_cert = ast_true(var->value) ? PJ_TRUE : PJ_FALSE;
1071  } else {
1072  return -1;
1073  }
1074 
1075  return 0;
1076 }
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true"....
Definition: main/utils.c:2097

References ao2_cleanup, ast_true(), find_or_create_temporary_state(), RAII_VAR, and var.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_tls_file_handler()

static int transport_tls_file_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for TLS method setting.

Definition at line 886 of file config_transport.c.

887 {
888  struct ast_sip_transport *transport = obj;
890 
891  if (!state) {
892  return -1;
893  }
894 
895  if (ast_strlen_zero(var->value)) {
896  /* Ignore empty options */
897  return 0;
898  }
899 
900  if (!ast_file_is_readable(var->value)) {
901  ast_log(LOG_ERROR, "Transport: %s: %s %s is either missing or not readable\n",
902  ast_sorcery_object_get_id(obj), var->name, var->value);
903  return -1;
904  }
905 
906  if (!strcasecmp(var->name, "ca_list_file")) {
907  state->tls.ca_list_file = pj_str((char*)var->value);
908  ast_string_field_set(transport, ca_list_file, var->value);
909  } else if (!strcasecmp(var->name, "ca_list_path")) {
910 #ifdef HAVE_PJ_SSL_CERT_LOAD_FROM_FILES2
911  state->tls.ca_list_path = pj_str((char*)var->value);
912  ast_string_field_set(transport, ca_list_path, var->value);
913 #else
914  ast_log(LOG_WARNING, "Asterisk has been built against a version of pjproject that does not "
915  "support the 'ca_list_path' option. Please upgrade to version 2.4 or later.\n");
916 #endif
917  } else if (!strcasecmp(var->name, "cert_file")) {
918  state->tls.cert_file = pj_str((char*)var->value);
919  ast_string_field_set(transport, cert_file, var->value);
920  } else if (!strcasecmp(var->name, "priv_key_file")) {
921  state->tls.privkey_file = pj_str((char*)var->value);
922  ast_string_field_set(transport, privkey_file, var->value);
923  }
924 
925  return 0;
926 }
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
Definition: stringfields.h:521
int ast_file_is_readable(const char *filename)
Test that a file exists and is readable by the effective user.
Definition: main/utils.c:3003

References ao2_cleanup, ast_file_is_readable(), ast_log, ast_sorcery_object_get_id(), ast_string_field_set, ast_strlen_zero(), ast_sip_transport::ca_list_file, ast_sip_transport::ca_list_path, ast_sip_transport::cert_file, find_or_create_temporary_state(), LOG_ERROR, LOG_WARNING, ast_sip_transport::privkey_file, RAII_VAR, and var.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_tls_method_handler()

static int transport_tls_method_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for TLS method setting.

Definition at line 1121 of file config_transport.c.

1122 {
1123  struct ast_sip_transport *transport = obj;
1125 
1126  if (!state) {
1127  return -1;
1128  }
1129 
1130  if (ast_strlen_zero(var->value) || !strcasecmp(var->value, "default")) {
1131  state->tls.method = PJSIP_SSL_DEFAULT_METHOD;
1132  } else if (!strcasecmp(var->value, "unspecified")) {
1133  state->tls.method = PJSIP_SSL_UNSPECIFIED_METHOD;
1134  } else if (!strcasecmp(var->value, "tlsv1")) {
1135  state->tls.method = PJSIP_TLSV1_METHOD;
1136 #ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO
1137  } else if (!strcasecmp(var->value, "tlsv1_1")) {
1138  state->tls.method = PJSIP_TLSV1_1_METHOD;
1139  } else if (!strcasecmp(var->value, "tlsv1_2")) {
1140  state->tls.method = PJSIP_TLSV1_2_METHOD;
1141 #endif
1142  } else if (!strcasecmp(var->value, "sslv2")) {
1143  state->tls.method = PJSIP_SSLV2_METHOD;
1144  } else if (!strcasecmp(var->value, "sslv3")) {
1145  state->tls.method = PJSIP_SSLV3_METHOD;
1146  } else if (!strcasecmp(var->value, "sslv23")) {
1147  state->tls.method = PJSIP_SSLV23_METHOD;
1148  } else {
1149  return -1;
1150  }
1151 
1152  return 0;
1153 }

References ao2_cleanup, ast_strlen_zero(), find_or_create_temporary_state(), RAII_VAR, and var.

Referenced by ast_sip_initialize_sorcery_transport().

◆ transport_tos_handler()

static int transport_tos_handler ( const struct aco_option opt,
struct ast_variable var,
void *  obj 
)
static

Custom handler for TOS setting.

Definition at line 1425 of file config_transport.c.

1426 {
1427  struct ast_sip_transport *transport = obj;
1428  unsigned int value;
1429 
1430  if (ast_str2tos(var->value, &value)) {
1431  ast_log(LOG_ERROR, "Error configuring transport '%s' - Could not "
1432  "interpret 'tos' value '%s'\n",
1433  ast_sorcery_object_get_id(transport), var->value);
1434  return -1;
1435  }
1436 
1437  if (value % 4) {
1438  value = value >> 2;
1439  value = value << 2;
1441  "transport '%s' - 'tos' value '%s' uses bits that are "
1442  "discarded when converted to DSCP. Using equivalent %u instead.\n",
1443  ast_sorcery_object_get_id(transport), var->value, value);
1444  }
1445 
1446  transport->tos = value;
1447  return 0;
1448 }
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
Definition: acl.c:967
int value
Definition: syslog.c:37

References ast_log, ast_sorcery_object_get_id(), ast_str2tos(), LOG_ERROR, LOG_WARNING, ast_sip_transport::tos, value, and var.

Referenced by ast_sip_initialize_sorcery_transport().

◆ verify_client_to_str()

static int verify_client_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1092 of file config_transport.c.

1093 {
1094  const struct ast_sip_transport *transport = obj;
1096 
1097  if (!state) {
1098  return -1;
1099  }
1100 
1101  *buf = ast_strdup(AST_YESNO(state->tls.verify_client));
1102 
1103  return 0;
1104 }

References ao2_cleanup, ast_strdup, AST_YESNO, buf, find_state_by_transport(), and RAII_VAR.

Referenced by ast_sip_initialize_sorcery_transport().

◆ verify_server_to_str()

static int verify_server_to_str ( const void *  obj,
const intptr_t *  args,
char **  buf 
)
static

Definition at line 1078 of file config_transport.c.

1079 {
1080  const struct ast_sip_transport *transport = obj;
1082 
1083  if (!state) {
1084  return -1;
1085  }
1086 
1087  *buf = ast_strdup(AST_YESNO(state->tls.verify_server));
1088 
1089  return 0;
1090 }

References ao2_cleanup, ast_strdup, AST_YESNO, buf, find_state_by_transport(), and RAII_VAR.

Referenced by ast_sip_initialize_sorcery_transport().

Variable Documentation

◆ cli_commands

struct ast_cli_entry cli_commands[]
static

◆ cli_formatter

struct ast_sip_cli_formatter_entry* cli_formatter
static

◆ endpoint_transport_formatter

struct ast_sip_endpoint_formatter endpoint_transport_formatter
Initial value:
= {
}
static int format_ami_endpoint_transport(const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami)

Definition at line 168 of file config_transport.c.

Referenced by ast_sip_destroy_sorcery_transport(), and ast_sip_initialize_sorcery_transport().

◆ temp_state_store

struct ast_threadstorage temp_state_store = { .once = PTHREAD_ONCE_INIT , .key_init = __init_temp_state_store , .custom_init = NULL , }
static

◆ tls_method_map

const char* tls_method_map[]
static

Definition at line 1155 of file config_transport.c.

Referenced by tls_method_to_str().

◆ transport_states

struct ao2_container* transport_states
static

◆ transport_types

const char* transport_types[]
static

Definition at line 998 of file config_transport.c.

Referenced by transport_protocol_to_str().