[Asterisk-code-review] res_pjsip/config_transport: Load and run without OpenSSL. (asterisk[16])

Friendly Automation asteriskteam at digium.com
Mon Nov 9 08:51:16 CST 2020


Friendly Automation has submitted this change. ( https://gerrit.asterisk.org/c/asterisk/+/15118 )

Change subject: res_pjsip/config_transport: Load and run without OpenSSL.
......................................................................

res_pjsip/config_transport: Load and run without OpenSSL.

ASTERISK-28933
Reported-by: Walter Doekes

Change-Id: I65eac49e5b0a79261ea80e2b9b38a836886ed59f
---
M res/res_pjsip/config_transport.c
1 file changed, 18 insertions(+), 0 deletions(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/res/res_pjsip/config_transport.c b/res/res_pjsip/config_transport.c
index d299340..f3a8d97 100644
--- a/res/res_pjsip/config_transport.c
+++ b/res/res_pjsip/config_transport.c
@@ -618,6 +618,7 @@
 			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 @@
 				&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 @@
 }
 
 /*! \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 @@
 
 	return 0;
 }
+#endif
 
 /*!
  * \internal
@@ -1008,6 +1012,7 @@
  * \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 @@
 		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 @@
 	}
 	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 @@
 	*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 @@
 	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 @@
 	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 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"
@@ -1433,7 +1449,9 @@
 	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));

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15118
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: I65eac49e5b0a79261ea80e2b9b38a836886ed59f
Gerrit-Change-Number: 15118
Gerrit-PatchSet: 2
Gerrit-Owner: Alexander Traud <pabstraud at compuserve.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20201109/842c9c66/attachment.html>


More information about the asterisk-code-review mailing list