From: Alexander Traud Date: Fri, 30 Oct 2020 16:43:59 +0000 (+0100) Subject: res_pjsip/config_transport: Load and run without OpenSSL. X-Git-Tag: 16.15.0-rc1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ddfb76a864fd8e0d29fe7c14db5b8f760e3662f5;p=thirdparty%2Fasterisk.git res_pjsip/config_transport: Load and run without OpenSSL. ASTERISK-28933 Reported-by: Walter Doekes Change-Id: I65eac49e5b0a79261ea80e2b9b38a836886ed59f --- diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c index d2993401fc..f3a8d97d9b 100644 --- a/res/res_pjsip/config_transport.c +++ b/res/res_pjsip/config_transport.c @@ -618,6 +618,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; @@ -648,6 +649,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"); @@ -978,6 +980,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]; @@ -997,6 +1000,7 @@ static pj_ssl_cipher cipher_name_to_id(const char *name) return 0; } +#endif /*! * \internal @@ -1008,6 +1012,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; @@ -1038,8 +1043,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; @@ -1066,7 +1073,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; @@ -1088,7 +1097,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; @@ -1101,7 +1112,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]; @@ -1132,6 +1145,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) @@ -1331,7 +1345,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 ]\n" @@ -1433,7 +1449,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));