|
|
|
@ -799,6 +799,7 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
|
|
|
|
|
res = pjsip_tcp_transport_start3(ast_sip_get_pjsip_endpoint(), &cfg,
|
|
|
|
|
&temp_state->state->factory);
|
|
|
|
|
}
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
} else if (transport->type == AST_TRANSPORT_TLS) {
|
|
|
|
|
static int option = 1;
|
|
|
|
|
|
|
|
|
@ -829,6 +830,7 @@ static int transport_apply(const struct ast_sorcery *sorcery, void *obj)
|
|
|
|
|
&temp_state->state->host, NULL, transport->async_operations,
|
|
|
|
|
&temp_state->state->factory);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
} else if ((transport->type == AST_TRANSPORT_WS) || (transport->type == AST_TRANSPORT_WSS)) {
|
|
|
|
|
if (transport->cos || transport->tos) {
|
|
|
|
|
ast_log(LOG_WARNING, "TOS and COS values ignored for websocket transport\n");
|
|
|
|
@ -1166,6 +1168,7 @@ static int tls_method_to_str(const void *obj, const intptr_t *args, char **buf)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*! \brief Helper function which turns a cipher name into an identifier */
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
static pj_ssl_cipher cipher_name_to_id(const char *name)
|
|
|
|
|
{
|
|
|
|
|
pj_ssl_cipher ciphers[PJ_SSL_SOCK_MAX_CIPHERS];
|
|
|
|
@ -1185,6 +1188,7 @@ static pj_ssl_cipher cipher_name_to_id(const char *name)
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \internal
|
|
|
|
@ -1196,6 +1200,7 @@ static pj_ssl_cipher cipher_name_to_id(const char *name)
|
|
|
|
|
* \retval 0 on success.
|
|
|
|
|
* \retval -1 on error.
|
|
|
|
|
*/
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
static int transport_cipher_add(struct ast_sip_transport_state *state, const char *name)
|
|
|
|
|
{
|
|
|
|
|
pj_ssl_cipher cipher;
|
|
|
|
@ -1226,8 +1231,10 @@ static int transport_cipher_add(struct ast_sip_transport_state *state, const cha
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*! \brief Custom handler for TLS cipher setting */
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
|
|
|
|
|
{
|
|
|
|
|
struct ast_sip_transport *transport = obj;
|
|
|
|
@ -1254,7 +1261,9 @@ static int transport_tls_cipher_handler(const struct aco_option *opt, struct ast
|
|
|
|
|
}
|
|
|
|
|
return res ? -1 : 0;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
static void cipher_to_str(char **buf, const pj_ssl_cipher *ciphers, unsigned int cipher_num)
|
|
|
|
|
{
|
|
|
|
|
struct ast_str *str;
|
|
|
|
@ -1276,7 +1285,9 @@ static void cipher_to_str(char **buf, const pj_ssl_cipher *ciphers, unsigned int
|
|
|
|
|
*buf = ast_strdup(ast_str_buffer(str));
|
|
|
|
|
ast_free(str);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
static int transport_tls_cipher_to_str(const void *obj, const intptr_t *args, char **buf)
|
|
|
|
|
{
|
|
|
|
|
const struct ast_sip_transport *transport = obj;
|
|
|
|
@ -1289,7 +1300,9 @@ static int transport_tls_cipher_to_str(const void *obj, const intptr_t *args, ch
|
|
|
|
|
cipher_to_str(buf, state->ciphers, state->tls.ciphers_num);
|
|
|
|
|
return *buf ? 0 : -1;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
static char *handle_pjsip_list_ciphers(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
|
|
|
|
|
{
|
|
|
|
|
pj_ssl_cipher ciphers[PJ_SSL_SOCK_MAX_CIPHERS];
|
|
|
|
@ -1320,6 +1333,7 @@ static char *handle_pjsip_list_ciphers(struct ast_cli_entry *e, int cmd, struct
|
|
|
|
|
ast_free(buf);
|
|
|
|
|
return CLI_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*! \brief Custom handler for localnet setting */
|
|
|
|
|
static int transport_localnet_handler(const struct aco_option *opt, struct ast_variable *var, void *obj)
|
|
|
|
@ -1519,7 +1533,9 @@ static int cli_print_body(void *obj, void *arg, int flags)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static struct ast_cli_entry cli_commands[] = {
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
AST_CLI_DEFINE(handle_pjsip_list_ciphers, "List available OpenSSL cipher names"),
|
|
|
|
|
#endif
|
|
|
|
|
AST_CLI_DEFINE(ast_sip_cli_traverse_objects, "List PJSIP Transports",
|
|
|
|
|
.command = "pjsip list transports",
|
|
|
|
|
.usage = "Usage: pjsip list transports [ like <pattern> ]\n"
|
|
|
|
@ -1631,7 +1647,9 @@ int ast_sip_initialize_sorcery_transport(void)
|
|
|
|
|
ast_sorcery_object_field_register_custom(sorcery, "transport", "verify_client", "", transport_tls_bool_handler, verify_client_to_str, NULL, 0, 0);
|
|
|
|
|
ast_sorcery_object_field_register_custom(sorcery, "transport", "require_client_cert", "", transport_tls_bool_handler, require_client_cert_to_str, NULL, 0, 0);
|
|
|
|
|
ast_sorcery_object_field_register_custom(sorcery, "transport", "method", "", transport_tls_method_handler, tls_method_to_str, NULL, 0, 0);
|
|
|
|
|
#if defined(PJ_HAS_SSL_SOCK) && PJ_HAS_SSL_SOCK != 0
|
|
|
|
|
ast_sorcery_object_field_register_custom(sorcery, "transport", "cipher", "", transport_tls_cipher_handler, transport_tls_cipher_to_str, NULL, 0, 0);
|
|
|
|
|
#endif
|
|
|
|
|
ast_sorcery_object_field_register_custom(sorcery, "transport", "local_net", "", transport_localnet_handler, localnet_to_str, localnet_to_vl, 0, 0);
|
|
|
|
|
ast_sorcery_object_field_register_custom(sorcery, "transport", "tos", "0", transport_tos_handler, tos_to_str, NULL, 0, 0);
|
|
|
|
|
ast_sorcery_object_field_register(sorcery, "transport", "cos", "0", OPT_UINT_T, 0, FLDSET(struct ast_sip_transport, cos));
|
|
|
|
|