36 #define MAX_POINTER_STRING 33 39 #define DEFAULT_STATE_BUCKETS 53 88 const char *right_key = arg;
93 right_key = object_right->
id;
96 cmp = strcmp(object_left->
id, right_key);
138 const char *right_key = arg;
143 right_key = object_right->
id;
146 cmp = strcmp(object_left->
id, right_key);
216 if (!transport_state) {
220 if (!transport_state->
flow) {
226 if (transport_state->
transport != transport) {
228 pjsip_transport_dec_ref(transport_state->
transport);
232 pjsip_transport_add_ref(transport_state->
transport);
251 if (!transport_state) {
255 if (!transport_state->
flow) {
280 if (!transport_state) {
285 if (!transport_state->
flow) {
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))) {
320 if (!transport_state) {
324 if (!transport_state->
flow) {
354 struct ast_sip_service_route_vector *service_routes;
356 service_routes =
ast_calloc(1,
sizeof(*service_routes));
357 if (!service_routes) {
363 return service_routes;
368 if (!service_routes) {
378 int tos_as_dscp = transport->
tos >> 2;
380 if (transport->
tos) {
381 qos->flags |= PJ_QOS_PARAM_HAS_DSCP;
382 qos->dscp_val = tos_as_dscp;
384 if (transport->
cos) {
385 qos->flags |= PJ_QOS_PARAM_HAS_SO_PRIO;
386 qos->so_prio = transport->
cos;
429 pjsip_transport_shutdown(transport_state->
transport);
494 if (state && *state) {
507 if (!internal_state) {
512 if (!internal_state->
id) {
519 if (!internal_state->
state) {
527 return internal_state;
544 if (!state || *state) {
555 pjsip_tls_setting_default(&new_state->
tls);
556 #ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO 558 new_state->
tls.proto = 0;
573 memcpy(&transport->
tls, &transport->
state->
tls,
sizeof(transport->
tls));
586 if (pj_sockaddr_cmp(&a->
host, &b->
host)) {
606 if (a->
tls.method != b->
tls.method
607 || a->
tls.ciphers_num != b->
tls.ciphers_num
609 || a->
tls.proto != b->
tls.proto
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) {
617 if (memcmp(a->
ciphers, b->
ciphers,
sizeof(pj_ssl_cipher) * fmax(a->
tls.ciphers_num, b->
tls.ciphers_num))) {
640 pj_status_t res = -1;
643 #define BIND_DELAY_US 100000 658 ast_log(
LOG_ERROR,
"Transport '%s' failed to allocate memory\n", transport_id);
667 transport->
state = perm_state->state;
675 memcpy(&temp_state->state->host, &perm_state->state->host,
sizeof(temp_state->state->host));
676 memcpy(&temp_state->state->tls, &perm_state->state->tls,
sizeof(temp_state->state->tls));
677 memcpy(&temp_state->state->ciphers, &perm_state->state->ciphers,
sizeof(temp_state->state->ciphers));
682 if (temp_state->state->host.addr.sa_family != PJ_AF_INET && temp_state->state->host.addr.sa_family != PJ_AF_INET6) {
683 ast_log(
LOG_ERROR,
"Transport '%s' could not be started as binding not specified\n", transport_id);
688 if (!pj_sockaddr_get_port(&temp_state->state->host)) {
689 pj_sockaddr_set_port(&temp_state->state->host, (transport->
type ==
AST_TRANSPORT_TLS) ? 5061 : 5060);
695 if (temp_state->state->host.addr.sa_family == pj_AF_INET()) {
696 temp_state->state->external_signaling_address.ss.ss_family = AF_INET;
697 }
else if (temp_state->state->host.addr.sa_family == pj_AF_INET6()) {
698 temp_state->state->external_signaling_address.ss.ss_family = AF_INET6;
700 ast_log(
LOG_ERROR,
"Unknown address family for transport '%s', could not get external signaling address\n",
706 ast_log(
LOG_ERROR,
"Could not create dnsmgr for external signaling address on '%s'\n", transport_id);
712 if (temp_state->state->host.addr.sa_family == pj_AF_INET()) {
713 temp_state->state->external_media_address.ss.ss_family = AF_INET;
714 }
else if (temp_state->state->host.addr.sa_family == pj_AF_INET6()) {
715 temp_state->state->external_media_address.ss.ss_family = AF_INET6;
717 ast_log(
LOG_ERROR,
"Unknown address family for transport '%s', could not get external media address\n",
723 ast_log(
LOG_ERROR,
"Could not create dnsmgr for external media address on '%s'\n", transport_id);
728 if (transport->
flow) {
731 ast_debug(1,
"Ignoring any bind configuration on transport '%s' as it is a child of another\n",
733 pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&address,
"0.0.0.0"), &temp_state->state->host);
735 temp_state->state->flow = 1;
739 ast_log(
LOG_WARNING,
"Transport '%s' is not fully reloadable, not reloading: protocol, bind, TLS, TCP, ToS, or CoS options.\n", transport_id);
740 temp_state->state->transport = perm_state->state->transport;
741 perm_state->state->transport =
NULL;
742 temp_state->state->factory = perm_state->state->factory;
743 perm_state->state->factory =
NULL;
747 for (i = 0; i <
BIND_TRIES && res != PJ_SUCCESS; i++) {
748 if (perm_state && perm_state->state && perm_state->state->transport) {
749 pjsip_udp_transport_pause(perm_state->state->transport,
750 PJSIP_UDP_TRANSPORT_DESTROY_SOCKET);
754 if (temp_state->state->host.addr.sa_family == pj_AF_INET()) {
757 &temp_state->state->transport);
758 }
else if (temp_state->state->host.addr.sa_family == pj_AF_INET6()) {
761 &temp_state->state->transport);
765 if (res == PJ_SUCCESS) {
766 temp_state->state->transport->info = pj_pool_alloc(temp_state->state->transport->pool,
769 sprintf(temp_state->state->transport->info,
"%s:%s",
AST_SIP_X_AST_TXP, transport_id);
771 if (transport->
tos || transport->
cos) {
773 pj_qos_params qos_params;
774 sock = pjsip_udp_transport_get_socket(temp_state->state->transport);
775 pj_sock_get_qos_params(sock, &qos_params);
776 set_qos(transport, &qos_params);
777 pj_sock_set_qos_params(sock, &qos_params);
781 pjsip_tcp_transport_cfg cfg;
782 static int option = 1;
784 pjsip_tcp_transport_cfg_default(&cfg, temp_state->state->host.addr.sa_family);
785 cfg.bind_addr = temp_state->state->host;
787 set_qos(transport, &cfg.qos_params);
789 cfg.sockopt_params.options[0].level = pj_SOL_TCP();
790 cfg.sockopt_params.options[0].optname = pj_TCP_NODELAY();
791 cfg.sockopt_params.options[0].optval = &option;
792 cfg.sockopt_params.options[0].optlen =
sizeof(option);
793 cfg.sockopt_params.cnt = 1;
795 for (i = 0; i <
BIND_TRIES && res != PJ_SUCCESS; i++) {
796 if (perm_state && perm_state->state && perm_state->state->factory
797 && perm_state->state->factory->destroy) {
798 perm_state->state->factory->destroy(perm_state->state->factory);
803 &temp_state->state->factory);
806 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 807 static int option = 1;
810 ast_log(
LOG_ERROR,
"Transport: %s: When protocol=tls and pjproject version < 2.5.0, async_operations can't be > 1\n",
815 temp_state->state->tls.password = pj_str((
char*)transport->
password);
819 temp_state->state->tls.sockopt_params.options[0].level = pj_SOL_TCP();
820 temp_state->state->tls.sockopt_params.options[0].optname = pj_TCP_NODELAY();
821 temp_state->state->tls.sockopt_params.options[0].optval = &option;
822 temp_state->state->tls.sockopt_params.options[0].optlen =
sizeof(option);
823 temp_state->state->tls.sockopt_params.cnt = 1;
825 for (i = 0; i <
BIND_TRIES && res != PJ_SUCCESS; i++) {
826 if (perm_state && perm_state->state && perm_state->state->factory
827 && perm_state->state->factory->destroy) {
828 perm_state->state->factory->destroy(perm_state->state->factory);
834 &temp_state->state->factory);
837 ast_log(
LOG_ERROR,
"Transport: %s: PJSIP has not been compiled with TLS transport support, ensure OpenSSL development packages are installed\n",
842 if (transport->
cos || transport->
tos) {
846 ast_log(
LOG_WARNING,
"TLS certificate values ignored for websocket transport as they are configured in http.conf\n");
851 if (res != PJ_SUCCESS) {
852 char msg[PJ_ERR_MSG_SIZE];
854 pj_strerror(res, msg,
sizeof(msg));
895 ast_log(
LOG_ERROR,
"Transport: %s: %s %s is either missing or not readable\n",
900 if (!strcasecmp(var->
name,
"ca_list_file")) {
901 state->tls.ca_list_file = pj_str((
char*)var->
value);
903 }
else if (!strcasecmp(var->
name,
"ca_list_path")) {
904 #ifdef HAVE_PJ_SSL_CERT_LOAD_FROM_FILES2 905 state->tls.ca_list_path = pj_str((
char*)var->
value);
908 ast_log(
LOG_WARNING,
"Asterisk has been built against a version of pjproject that does not " 909 "support the 'ca_list_path' option. Please upgrade to version 2.4 or later.\n");
911 }
else if (!strcasecmp(var->
name,
"cert_file")) {
912 state->tls.cert_file = pj_str((
char*)var->
value);
914 }
else if (!strcasecmp(var->
name,
"priv_key_file")) {
915 state->tls.privkey_file = pj_str((
char*)var->
value);
968 if (!strcasecmp(var->
value,
"flow")) {
971 if (!strcasecmp(var->
value,
"udp")) {
973 }
else if (!strcasecmp(var->
value,
"tcp")) {
975 }
else if (!strcasecmp(var->
value,
"tls")) {
977 }
else if (!strcasecmp(var->
value,
"ws")) {
979 }
else if (!strcasecmp(var->
value,
"wss")) {
1004 if (transport->
flow) {
1025 rc = pj_sockaddr_parse(pj_AF_UNSPEC(), 0, pj_cstr(&buf, var->
value), &
state->host);
1027 return rc != PJ_SUCCESS ? -1 : 0;
1059 if (!strcasecmp(var->
name,
"verify_server")) {
1061 }
else if (!strcasecmp(var->
name,
"verify_client")) {
1063 }
else if (!strcasecmp(var->
name,
"require_client_cert")) {
1125 state->tls.method = PJSIP_SSL_DEFAULT_METHOD;
1126 }
else if (!strcasecmp(var->
value,
"unspecified")) {
1127 state->tls.method = PJSIP_SSL_UNSPECIFIED_METHOD;
1128 }
else if (!strcasecmp(var->
value,
"tlsv1")) {
1129 state->tls.method = PJSIP_TLSV1_METHOD;
1130 #ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO 1131 }
else if (!strcasecmp(var->
value,
"tlsv1_1")) {
1132 state->tls.method = PJSIP_TLSV1_1_METHOD;
1133 }
else if (!strcasecmp(var->
value,
"tlsv1_2")) {
1134 state->tls.method = PJSIP_TLSV1_2_METHOD;
1136 }
else if (!strcasecmp(var->
value,
"sslv2")) {
1137 state->tls.method = PJSIP_SSLV2_METHOD;
1138 }
else if (!strcasecmp(var->
value,
"sslv3")) {
1139 state->tls.method = PJSIP_SSLV3_METHOD;
1140 }
else if (!strcasecmp(var->
value,
"sslv23")) {
1141 state->tls.method = PJSIP_SSLV23_METHOD;
1150 [PJSIP_SSL_UNSPECIFIED_METHOD] =
"unspecified",
1151 [PJSIP_TLSV1_METHOD] =
"tlsv1",
1152 #ifdef HAVE_PJSIP_TLS_TRANSPORT_PROTO 1153 [PJSIP_TLSV1_1_METHOD] =
"tlsv1_1",
1154 [PJSIP_TLSV1_2_METHOD] =
"tlsv1_2",
1156 [PJSIP_SSLV2_METHOD] =
"sslv2",
1157 [PJSIP_SSLV3_METHOD] =
"sslv3",
1158 [PJSIP_SSLV23_METHOD] =
"sslv23",
1178 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1179 static pj_ssl_cipher cipher_name_to_id(
const char *
name)
1181 pj_ssl_cipher
ciphers[PJ_SSL_SOCK_MAX_CIPHERS];
1182 unsigned int cipher_num = PJ_ARRAY_SIZE(ciphers);
1185 if (pj_ssl_cipher_get_availables(ciphers, &cipher_num)) {
1189 for (pos = 0; pos < cipher_num; ++pos) {
1190 const char *pos_name = pj_ssl_cipher_name(ciphers[pos]);
1191 if (pos_name && !strcmp(pos_name, name)) {
1192 return ciphers[pos];
1210 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1213 pj_ssl_cipher cipher;
1216 cipher = cipher_name_to_id(name);
1219 if (!strnicmp(name,
"0x", 2)) {
1220 pj_str_t cipher_st = pj_str((
char *) name + 2);
1221 cipher = pj_strtoul2(&cipher_st,
NULL, 16);
1223 cipher = atoi(name);
1227 if (pj_ssl_cipher_is_supported(cipher)) {
1228 for (idx = state->
tls.ciphers_num; idx--;) {
1229 if (state->
ciphers[idx] == cipher) {
1234 state->
ciphers[state->
tls.ciphers_num++] = cipher;
1244 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1267 res |= transport_cipher_add(state, name);
1269 return res ? -1 : 0;
1273 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1274 static void cipher_to_str(
char **
buf,
const pj_ssl_cipher *
ciphers,
unsigned int cipher_num)
1285 for (idx = 0; idx < cipher_num; ++idx) {
1287 if (idx < cipher_num - 1) {
1297 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1298 static int transport_tls_cipher_to_str(
const void *obj,
const intptr_t *
args,
char **
buf)
1307 cipher_to_str(buf, state->
ciphers, state->
tls.ciphers_num);
1308 return *buf ? 0 : -1;
1312 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1315 pj_ssl_cipher
ciphers[PJ_SSL_SOCK_MAX_CIPHERS];
1316 unsigned int cipher_num = PJ_ARRAY_SIZE(ciphers);
1321 e->
command =
"pjsip list ciphers";
1322 e->
usage =
"Usage: pjsip list ciphers\n" 1323 " List available OpenSSL cipher names.\n";
1329 if (pj_ssl_cipher_get_availables(ciphers, &cipher_num) || !cipher_num) {
1332 cipher_to_str(&buf, ciphers, cipher_num);
1336 ast_cli(a->
fd,
"Available ciphers: '%s'\n", buf);
1338 ast_cli(a->
fd,
"No available ciphers\n");
1426 "interpret 'tos' value '%s'\n",
1435 "transport '%s' - 'tos' value '%s' uses bits that are " 1436 "discarded when converted to DSCP. Using equivalent %u instead.\n",
1489 return callback(transport, args, 0);
1506 "%*s: <TransportId........> <Type> <cos> <tos> <BindAddress%*.*s>\n",
1516 char hoststr[PJ_INET6_ADDRSTRLEN];
1525 pj_sockaddr_print(&state->
host, hoststr,
sizeof(hoststr), 3);
1531 transport->
cos, transport->
tos, hoststr);
1543 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1544 AST_CLI_DEFINE(handle_pjsip_list_ciphers,
"List available OpenSSL cipher names"),
1547 .
command =
"pjsip list transports",
1548 .
usage =
"Usage: pjsip list transports [ like <pattern> ]\n" 1549 " List the configured PJSIP Transports\n" 1550 " Optional regular expression pattern is used to filter the list.\n"),
1552 .
command =
"pjsip show transports",
1553 .
usage =
"Usage: pjsip show transports [ like <pattern> ]\n" 1554 " Show the configured PJSIP Transport\n" 1555 " Optional regular expression pattern is used to filter the list.\n"),
1557 .
command =
"pjsip show transport",
1558 .
usage =
"Usage: pjsip show transport <id>\n" 1559 " Show the configured PJSIP Transport\n"),
1569 if (!transport_states) {
1582 if (trans_state->
flow) {
1585 pjsip_transport_dec_ref(trans_state->
transport);
1626 if (!transport_states) {
1657 #if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0 1670 if (!cli_formatter) {
1674 cli_formatter->
name =
"transport";
1699 ao2_ref(transport_states, -1);
1700 transport_states =
NULL;
static char * ast_sockaddr_stringify_addr(const struct ast_sockaddr *addr)
Wrapper around ast_sockaddr_stringify_fmt() to return an address only.
struct ast_str * output_buffer
struct ao2_container *(* get_container)(const char *regex)
#define ARRAY_IN_BOUNDS(v, a)
Checks to see if value is within the bounds of the given array.
int ast_sip_transport_state_set_transport(const char *transport_name, pjsip_transport *transport)
Sets the PJSIP transport on a child transport.
#define AST_CLI_DEFINE(fn, txt,...)
struct ast_dnsmgr_entry * external_address_refresher
static int format_ami_endpoint_transport(const struct ast_sip_endpoint *endpoint, struct ast_sip_ami *ami)
void astman_append(struct mansession *s, const char *fmt,...)
Asterisk main include file. File version handling, generic pbx functions.
static int transport_localnet_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Helper function which turns a cipher name into an identifier.
void * ast_threadstorage_get(struct ast_threadstorage *ts, size_t init_size)
Retrieve thread storage.
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
int ast_cli_unregister_multiple(struct ast_cli_entry *e, int len)
Unregister multiple commands.
static int transport_bind_to_str(const void *obj, const intptr_t *args, char **buf)
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.
struct ast_sip_transport_state * ast_sip_get_transport_state(const char *transport_id)
Retrieve transport state.
The arg parameter is a search key, but is not an object.
const ast_string_field transport
static int transport_state_cmp(void *obj, void *arg, int flags)
comparator function for state objects
static int transport_tls_method_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS method setting.
void ast_sip_service_route_vector_destroy(struct ast_sip_service_route_vector *service_routes)
Destroy a vector of service routes.
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 sip_transport_destroy(void *obj)
Destructor for transport.
struct ast_sip_transport_state * state
Transport state information.
descriptor for a cli entry.
int ast_file_is_readable(const char *filename)
Test that a file exists and is readable by the effective user.
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
#define ao2_callback(c, flags, cb_fn, arg)
const ast_string_field external_media_address
#define ao2_container_alloc_list(ao2_options, container_options, sort_fn, cmp_fn)
static int has_state_changed(struct ast_sip_transport_state *a, struct ast_sip_transport_state *b)
Structure for variables, used for configurations and for channel variables.
static int cli_print_header(void *obj, void *arg, int flags)
static struct ao2_container * transport_states
Perform no matching, return all objects.
int ast_sorcery_object_id_compare(void *obj, void *arg, int flags)
ao2 object comparator based on sorcery id.
static int cert_file_to_str(const void *obj, const intptr_t *args, char **buf)
Assume that the ao2_container is already locked.
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.
Full structure for sorcery.
int(* iterate)(void *container, ao2_callback_fn callback, void *args)
static struct internal_state * find_internal_state_by_transport(const struct ast_sip_transport *transport)
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
#define ast_cli_register_multiple(e, len)
Register multiple commands.
Return all matching objects.
static int sip_transport_to_ami(const struct ast_sip_transport *transport, struct ast_str **buf)
#define ao2_link_flags(container, obj, flags)
static int localnet_to_vl(const void *obj, struct ast_variable **fields)
#define ast_strdup(str)
A wrapper for strdup()
void ast_sip_unregister_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Unregister an endpoint formatter.
int ast_str2tos(const char *value, unsigned int *tos)
Convert a string to the appropriate TOS value.
int ast_sockaddr_cmp(const struct ast_sockaddr *a, const struct ast_sockaddr *b)
Compares two ast_sockaddr structures.
struct ast_sip_transport_state * state
void ast_cli(int fd, const char *fmt,...)
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.
static void set_qos(struct ast_sip_transport *transport, pj_qos_params *qos)
static struct ast_str * password
static int verify_client_to_str(const void *obj, const intptr_t *args, char **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)
void ast_ha_join(const struct ast_ha *ha, struct ast_str **buf)
Convert HAs to a comma separated string value.
static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
Apply handler for transports.
char * ast_sip_cli_traverse_objects(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
int ast_sip_add_header(pjsip_tx_data *tdata, const char *name, const char *value)
Add a header to an outbound SIP message.
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.
static int transport_state_hash(const void *obj, const int flags)
hashing function for state objects
#define ast_asprintf(ret, fmt,...)
A wrapper for asprintf()
struct ast_sockaddr external_address
#define ast_strlen_zero(foo)
void * ast_sorcery_retrieve_by_id(const struct ast_sorcery *sorcery, const char *type, const char *id)
Retrieve an object using its unique identifier.
int ast_sip_register_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Registers a CLI formatter.
internal representation of ACL entries In principle user applications would have no need for this...
const ast_string_field password
struct ast_sockaddr external_media_address
static struct ast_sip_transport_state * find_state_by_transport(const struct ast_sip_transport *transport)
static int internal_state_hash(const void *obj, const int flags)
hashing function for state objects
char * preferred_identity
static const char * transport_types[]
#define DEFAULT_STATE_BUCKETS
Default number of state container buckets.
void ast_sip_register_endpoint_formatter(struct ast_sip_endpoint_formatter *obj)
Register an endpoint formatter.
static struct ast_sip_transport_state * find_or_create_temporary_state(struct ast_sip_transport *transport)
#define ast_debug(level,...)
Log a DEBUG message.
int() ao2_callback_fn(void *obj, void *arg, int flags)
Type of a generic callback function.
#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.
const ast_string_field ca_list_path
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
#define FLDSET(type,...)
Convert a struct and list of fields to an argument list of field offsets.
static int require_client_cert_to_str(const void *obj, const intptr_t *args, char **buf)
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Structure for SIP transport information.
static void states_cleanup(void *states)
struct ast_sockaddr netmask
int ast_sip_initialize_sorcery_transport(void)
Initialize sorcery with transport support.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Type for default option handler for unsigned integers.
void ast_dnsmgr_release(struct ast_dnsmgr_entry *entry)
Free a DNS manager entry.
#define ast_string_field_init(x, size)
Initialize a field pool and fields.
#define CLI_INDENT_TO_SPACES(x)
struct pjsip_transport * transport
Transport itself.
static void localnet_to_vl_append(struct ast_variable **head, struct ast_ha *ha)
Access Control of various sorts.
static int tls_method_to_str(const void *obj, const intptr_t *args, char **buf)
char * ast_strip(char *s)
Strip leading/trailing whitespace from a string.
#define ao2_ref(o, delta)
static int transport_tls_bool_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS boolean settings.
static void * cli_retrieve_by_id(const char *id)
static void * sip_transport_alloc(const char *name)
Allocator for transport.
#define ast_strdupa(s)
duplicate a string in memory from the stack
int ast_sorcery_object_id_sort(const void *obj, const void *arg, int flags)
ao2 object sorter based on sorcery id.
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
void *(* retrieve_by_id)(const char *id)
static void copy_state_to_transport(struct ast_sip_transport *transport)
struct ao2_container * container
#define ast_variable_new(name, value, filename)
int ast_sip_unregister_cli_formatter(struct ast_sip_cli_formatter_entry *formatter)
Unregisters a CLI formatter.
An entity with which Asterisk communicates.
Support for WebSocket connections within the Asterisk HTTP server and client WebSocket connections to...
#define ast_sorcery_object_register(sorcery, type, alloc, transform, apply)
Register an object type.
static struct ast_threadstorage temp_state_store
static int destroy_sip_transport_state(void *data)
#define MAX_OBJECT_FIELD
Maximum length of an object field name.
static struct internal_state * internal_state_alloc(struct ast_sip_transport *transport)
static int populate_transport_states(void *obj, void *arg, int flags)
static int ca_list_path_to_str(const void *obj, const intptr_t *args, char **buf)
#define CLI_HEADER_FILLER
static int verify_server_to_str(const void *obj, const intptr_t *args, char **buf)
#define AST_SIP_X_AST_TXP_LEN
static int cli_iterate(void *container, ao2_callback_fn callback, void *args)
#define HAVE_PJSIP_TLS_TRANSPORT_PROTO
void ast_sip_message_apply_transport(const char *transport_name, pjsip_tx_data *tdata)
Apply the configuration for a transport to an outgoing message.
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
int attribute_pure ast_true(const char *val)
Make sure something is true. Determine if a string containing a boolean value is "true". This function checks to see whether a string passed to it is an indication of an "true" value. It checks to see if the string is "yes", "true", "y", "t", "on" or "1".
const ast_string_field external_signaling_address
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
static void internal_state_destroy(void *obj)
Destructor for ast_sip_transport state information.
static const char * tls_method_map[]
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.
Type for default option handler for bools (ast_true/ast_false)
struct ast_sip_endpoint_formatter endpoint_transport_formatter
#define ast_sorcery_apply_default(sorcery, type, name, data)
unsigned int async_operations
static int transport_tos_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TOS setting.
static int internal_state_cmp(void *obj, void *arg, int flags)
comparator function for state objects
struct ast_sip_service_route_vector * ast_sip_service_route_vector_alloc(void)
Allocate a vector of service routes.
#define ao2_alloc(data_size, destructor_fn)
static struct ao2_container * cli_get_container(const char *regex)
const ast_string_field ca_list_file
const ast_string_field privkey_file
static void parse(struct mgcp_request *req)
#define ast_calloc(num, len)
A wrapper for calloc()
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
static int localnet_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.
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.
#define STRFLDSET(type,...)
Convert a struct and a list of stringfield fields to an argument list of field offsets.
#define ao2_find(container, arg, flags)
const char *(* get_id)(const void *obj)
static int transport_tls_file_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
Custom handler for TLS method setting.
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.
Support for logging to various files, console and syslog Configuration in file logger.conf.
struct ast_sockaddr external_signaling_address
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.
#define AST_THREADSTORAGE_CUSTOM(a, b, c)
Define a thread storage variable, with custom initialization and cleanup.
#define ast_sorcery_object_field_register(sorcery, type, name, default_val, opt_type, flags,...)
Register a field within an object.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
static int ca_list_file_to_str(const void *obj, const intptr_t *args, char **buf)
void ast_free_ha(struct ast_ha *ha)
Free a list of HAs.
#define AST_YESNO(x)
return Yes or No depending on the argument.
static struct ast_sip_cli_formatter_entry * cli_formatter
static int remove_temporary_state(void)
The arg parameter is an object of the same type.
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
char * strsep(char **str, const char *delims)
#define ao2_replace(dst, src)
static struct ast_sorcery * sorcery
struct ast_sorcery * ast_sip_get_sorcery(void)
Get a pointer to the SIP sorcery structure.
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.
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
#define AST_SIP_X_AST_TXP
struct ao2_container * ast_sip_get_transport_states(void)
Retrieves all transport states.
static struct ast_sip_transport_state * find_temporary_state(struct ast_sip_transport *transport)
#define AST_DEFAULT_WEBSOCKET_WRITE_TIMEOUT_STR
Default websocket write timeout, in ms (as a string)
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
struct ast_sip_transport * transport
Transport configuration object.
int ast_sip_sorcery_object_to_ami(const void *obj, struct ast_str **buf)
Converts a sorcery object to a string of object properties.
#define ao2_unlink_flags(container, obj, flags)
Type for default option handler for stringfields.
static int tos_to_str(const void *obj, const intptr_t *args, char **buf)
ao2_callback_fn * print_header
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.
int error(const char *format,...)
static int privkey_file_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_compare_versions(const char *version1, const char *version2)
Compare 2 major.minor.patch.extra version strings.
struct ast_sip_service_route_vector * service_routes
static int transport_protocol_to_str(const void *obj, const intptr_t *args, char **buf)
int ast_sip_transport_state_set_preferred_identity(const char *transport_name, const char *identity)
Sets the P-Preferred-Identity on a child transport.
Search option field mask.
static char context[AST_MAX_CONTEXT]
int ast_sip_destroy_sorcery_transport(void)
void * ast_sorcery_generic_alloc(size_t size, ao2_destructor_fn destructor)
Allocate a generic sorcery capable object.
static int cli_print_body(void *obj, void *arg, int flags)
Type for default option handler for signed integers.
ao2_callback_fn * print_body
struct ast_dnsmgr_entry * external_media_address_refresher
int ast_sip_cli_print_sorcery_objectset(void *obj, void *arg, int flags)
Prints a sorcery object's ast_variable list.
static void temp_state_store_cleanup(void *data)
#define ast_string_field_free_memory(x)
free all memory - to be called before destroying the object
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
#define ast_variable_list_append(head, new_var)
static struct ast_cli_entry cli_commands[]
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
struct ast_dnsmgr_entry * external_signaling_address_refresher
const ast_string_field cert_file
#define ast_str_create(init_len)
Create a malloc'ed dynamic length string.
Sorcery Data Access Layer API.
pj_ssl_cipher ciphers[SIP_TLS_MAX_CIPHERS]
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
static void sip_transport_state_destroy(void *obj)
Destructor for ast_sip_transport state information.
#define ast_string_field_set(x, field, data)
Set a field to a simple string value.
unsigned show_details_only_level_0
#define ao2_link(container, obj)