From 8e704f0f74e77dbcd74d0031a094bb5f5bfaa189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 14 Oct 2014 20:03:35 +0200 Subject: [PATCH] DTLS depends on TIMING_C for now --- include/polarssl/check_config.h | 5 +++-- include/polarssl/config.h | 5 +++++ include/polarssl/ssl.h | 11 ++++------- library/ssl_tls.c | 11 +++-------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/include/polarssl/check_config.h b/include/polarssl/check_config.h index c532db0d6..5e21f3ee8 100644 --- a/include/polarssl/check_config.h +++ b/include/polarssl/check_config.h @@ -223,8 +223,9 @@ #endif #if defined(POLARSSL_SSL_PROTO_DTLS) && ( \ - !defined(POLARSSL_SSL_PROTO_TLS1_1) && \ - !defined(POLARSSL_SSL_PROTO_TLS1_2) ) + ( !defined(POLARSSL_SSL_PROTO_TLS1_1) && \ + !defined(POLARSSL_SSL_PROTO_TLS1_2) ) || \ + !defined(POLARSSL_TIMING_C) ) #error "POLARSSL_SSL_PROTO_DTLS defined, but not all prerequisites" #endif diff --git a/include/polarssl/config.h b/include/polarssl/config.h index abc266823..6e9050ae5 100644 --- a/include/polarssl/config.h +++ b/include/polarssl/config.h @@ -908,6 +908,11 @@ * * Requires: POLARSSL_SSL_PROTO_TLS1_1 * or POLARSSL_SSL_PROTO_TLS1_2 + * POLARSSL_TIMING_C + * + * \note Dependency on TIMING_C may be replaced by something more flexible + * (callbacks or abstraction layer in the next major version). Please contact + * us if you're having issues with this dependency. * * Comment this macro to disable support for DTLS */ diff --git a/include/polarssl/ssl.h b/include/polarssl/ssl.h index ac6f03fdb..c5087348a 100644 --- a/include/polarssl/ssl.h +++ b/include/polarssl/ssl.h @@ -76,7 +76,7 @@ #include "zlib.h" #endif -#if defined(POLARSSL_TIMING_C) +#if defined(POLARSSL_SSL_PROTO_DTLS) #include "timing.h" #endif @@ -830,14 +830,11 @@ struct _ssl_context ssl_transform *transform_negotiate; /*!< transform params in negotiation */ /* - * Timers (WIP) + * Timers */ -#if defined(POLARSSL_TIMING_C) - struct hr_time time_info; - unsigned long time_limit; -#endif - #if defined(POLARSSL_SSL_PROTO_DTLS) + struct hr_time time_info; /*!< timer context */ + unsigned long time_limit; /*!< limit for the running timer */ uint32_t hs_timeout_min; /*!< initial value of the handshake retransmission timeout */ uint32_t hs_timeout_max; /*!< maximum value of the handshake diff --git a/library/ssl_tls.c b/library/ssl_tls.c index 7cb14424d..bfaefd46d 100644 --- a/library/ssl_tls.c +++ b/library/ssl_tls.c @@ -79,10 +79,7 @@ static inline size_t ssl_ep_len( const ssl_context *ssl ) } -/* - * Timers (WIP) - */ -#if defined(POLARSSL_TIMING_C) +#if defined(POLARSSL_SSL_PROTO_DTLS) /* * Start a timer. * Passing millisecs = 0 cancels a running timer. @@ -107,9 +104,7 @@ static int ssl_check_timer( ssl_context *ssl ) return( 0 ); } -#endif -#if defined(POLARSSL_SSL_PROTO_DTLS) /* * Double the retransmit timeout value, within the allowed range, * returning -1 if the maximum value has already been reached. @@ -5755,7 +5750,7 @@ int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ) if( ssl->in_offt == NULL ) { -#if defined(POLARSSL_TIMING_C) +#if defined(POLARSSL_SSL_PROTO_DTLS) /* Start timer if not already running */ if( ssl->time_limit == 0 ) ssl_set_timer( ssl, ssl->read_timeout ); @@ -5912,7 +5907,7 @@ int ssl_read( ssl_context *ssl, unsigned char *buf, size_t len ) ssl->in_offt = ssl->in_msg; -#if defined(POLARSSL_TIMING_C) +#if defined(POLARSSL_SSL_PROTO_DTLS) /* We're going to return something now, cancel timer, * except if handshake (renegotiation) is in progress */ if( ssl->state == SSL_HANDSHAKE_OVER )