Add MBEDTLS_SSL_CONF_TRANSPORT

Follow the model of `MBEDTLS_SSL_CONF_ENDPOINT`. This saves a small
amount - most of the saving was already acheived via`
MBEDTLS_SSL_TRANSPORT_IS_TLS` but we can scrape out a little more by
totally eliminating `ssl->conf->transport` references.

Signed-off-by: Kevin Bracey <kevin.bracey@arm.com>
This commit is contained in:
Kevin Bracey 2020-11-03 12:22:27 +02:00
parent d859db833c
commit 585e9e0922
8 changed files with 58 additions and 12 deletions

View file

@ -3860,6 +3860,9 @@
/* Endpoint (Client/Server) */
//#define MBEDTLS_SSL_CONF_ENDPOINT MBEDTLS_SSL_IS_CLIENT
/* Transport (Stream/Datagram) */
//#define MBEDTLS_SSL_CONF_TRANSPORT MBEDTLS_SSL_TRANSPORT_STREAM
//#define MBEDTLS_SSL_CONF_CERT_REQ_CA_LIST MBEDTLS_SSL_CERT_REQ_CA_LIST_ENABLED
/* DTLS-specific settings */

View file

@ -1200,7 +1200,9 @@ struct mbedtls_ssl_config
#if !defined(MBEDTLS_SSL_CONF_ENDPOINT)
unsigned int endpoint : 1; /*!< 0: client, 1: server */
#endif /* !MBEDTLS_SSL_CONF_ENDPOINT */
#if !defined(MBEDTLS_SSL_CONF_TRANSPORT)
unsigned int transport : 1; /*!< stream (TLS) or datagram (DTLS) */
#endif /* !MBEDTLS_SSL_CONF_TRANSPORT */
#if !defined(MBEDTLS_SSL_CONF_AUTHMODE)
unsigned int authmode : 6; /*!< MBEDTLS_SSL_VERIFY_XXX */
#endif /* !MBEDTLS_SSL_CONF_AUTHMODE */
@ -1569,6 +1571,7 @@ int mbedtls_ssl_session_reset( mbedtls_ssl_context *ssl );
void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint );
#endif /* !MBEDTLS_SSL_CONF_ENDPOINT */
#if !defined(MBEDTLS_SSL_CONF_TRANSPORT)
/**
* \brief Set the transport type (TLS or DTLS).
* Default: TLS unless #MBEDTLS_SSL_PROTO_NO_TLS is defined,
@ -1579,12 +1582,16 @@ void mbedtls_ssl_conf_endpoint( mbedtls_ssl_config *conf, int endpoint );
* \c mbedtls_ssl_set_bio(). You also need to provide timer
* callbacks with \c mbedtls_ssl_set_timer_cb().
*
* \note On constrained systems, this can also be configured
* at compile-time via MBEDTLS_SSL_CONF_TRANSPORT.
*
* \param conf SSL configuration
* \param transport transport type:
* MBEDTLS_SSL_TRANSPORT_STREAM for TLS,
* MBEDTLS_SSL_TRANSPORT_DATAGRAM for DTLS.
*/
void mbedtls_ssl_conf_transport( mbedtls_ssl_config *conf, int transport );
#endif /* !MBEDTLS_SSL_CONF_TRANSPORT */
/**
* \brief Set the certificate verification mode

View file

@ -1454,6 +1454,21 @@ static inline unsigned int mbedtls_ssl_conf_get_endpoint(
}
#endif /* MBEDTLS_SSL_CONF_ENDPOINT */
#if !defined(MBEDTLS_SSL_CONF_TRANSPORT)
static inline unsigned int mbedtls_ssl_conf_get_transport(
mbedtls_ssl_config const *conf )
{
return( conf->transport );
}
#else /* !MBEDTLS_SSL_CONF_TRANSPORT */
static inline unsigned int mbedtls_ssl_conf_get_transport(
mbedtls_ssl_config const *conf )
{
((void) conf);
return( MBEDTLS_SSL_CONF_TRANSPORT );
}
#endif /* MBEDTLS_SSL_CONF_TRANSPORT */
#if !defined(MBEDTLS_SSL_CONF_READ_TIMEOUT)
static inline uint32_t mbedtls_ssl_conf_get_read_timeout(
mbedtls_ssl_config const *conf )