From d4f04dba4285ffe97599b252cb13c075234891de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 14 May 2015 18:58:17 +0200 Subject: [PATCH] net.c now depends on select() unconditionally --- ChangeLog | 2 +- include/mbedtls/net.h | 4 ---- library/net.c | 8 -------- library/timing.c | 4 ++-- programs/ssl/ssl_client2.c | 7 +------ programs/ssl/ssl_server2.c | 7 +------ 6 files changed, 5 insertions(+), 27 deletions(-) diff --git a/ChangeLog b/ChangeLog index a1b5e8af5..e28d166b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -115,7 +115,7 @@ Default behavior changes Requirement changes * The minimum MSVC version required is now 2010 (better C99 support). - * The NET layer now unconditionnaly relies on getaddrinfo(). + * The NET layer now unconditionnaly relies on getaddrinfo() and select(). * Compiler is required to support C99 types such as long long and uint32_t. API changes from the 1.4 preview branch diff --git a/include/mbedtls/net.h b/include/mbedtls/net.h index 077fa3d5d..586ee0b36 100644 --- a/include/mbedtls/net.h +++ b/include/mbedtls/net.h @@ -126,7 +126,6 @@ int mbedtls_net_set_block( int fd ); */ int mbedtls_net_set_nonblock( int fd ); -#if defined(MBEDTLS_HAVE_TIME) /** * \brief Portable usleep helper * @@ -136,7 +135,6 @@ int mbedtls_net_set_nonblock( int fd ); * select()'s timeout granularity (typically, 10ms). */ void mbedtls_net_usleep( unsigned long usec ); -#endif /** * \brief Read at most 'len' characters. If no error occurs, @@ -168,7 +166,6 @@ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ); */ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ); -#if defined(MBEDTLS_HAVE_TIME) /** * \brief Read at most 'len' characters, blocking for at most * 'timeout' seconds. If no error occurs, the actual amount @@ -191,7 +188,6 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ); */ int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, uint32_t timeout ); -#endif /* MBEDTLS_HAVE_TIME */ /** * \brief Gracefully shutdown the connection diff --git a/library/net.c b/library/net.c index a37213446..568a244e9 100644 --- a/library/net.c +++ b/library/net.c @@ -65,9 +65,7 @@ static int wsa_init_done = 0; #include #include #include -#if defined(MBEDTLS_HAVE_TIME) #include -#endif #include #include #include @@ -84,9 +82,7 @@ static int wsa_init_done = 0; #define snprintf _snprintf #endif -#if defined(MBEDTLS_HAVE_TIME) #include -#endif #if defined(_MSC_VER) && !defined(EFIX64) && !defined(EFI32) #include @@ -396,7 +392,6 @@ int mbedtls_net_set_nonblock( int fd ) #endif } -#if defined(MBEDTLS_HAVE_TIME) /* * Portable usleep helper */ @@ -412,7 +407,6 @@ void mbedtls_net_usleep( unsigned long usec ) #endif select( 0, NULL, NULL, NULL, &tv ); } -#endif /* MBEDTLS_HAVE_TIME */ /* * Read at most 'len' characters @@ -445,7 +439,6 @@ int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len ) return( ret ); } -#if defined(MBEDTLS_HAVE_TIME) /* * Read at most 'len' characters, blocking for at most 'timeout' ms */ @@ -486,7 +479,6 @@ int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, /* This call will not block */ return( mbedtls_net_recv( ctx, buf, len ) ); } -#endif /* MBEDTLS_HAVE_TIME */ /* * Write at most 'len' characters diff --git a/library/timing.c b/library/timing.c index e83b74e75..4ff11e79e 100644 --- a/library/timing.c +++ b/library/timing.c @@ -352,7 +352,7 @@ int mbedtls_timing_get_delay( void *data ) #if defined(MBEDTLS_SELF_TEST) /* To test mbedtls_net_usleep against our functions */ -#if defined(MBEDTLS_NET_C) && defined(MBEDTLS_HAVE_TIME) +#if defined(MBEDTLS_NET_C) #include "mbedtls/net.h" #endif @@ -507,7 +507,7 @@ hard_test: if( verbose != 0 ) mbedtls_printf( "passed\n" ); -#if defined(MBEDTLS_NET_C) && defined(MBEDTLS_HAVE_TIME) +#if defined(MBEDTLS_NET_C) if( verbose != 0 ) mbedtls_printf( " TIMING test #4 (net_usleep/ get_timer): " ); diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index b14026361..f5cf74603 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1183,12 +1183,7 @@ int main( int argc, char *argv[] ) mbedtls_ssl_set_bio( &ssl, &server_fd, my_send, my_recv, NULL ); else mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, -#if defined(MBEDTLS_HAVE_TIME) - opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL -#else - NULL -#endif - ); + opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL ); #if defined(MBEDTLS_TIMING_C) mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay, diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 1d2132e02..7dbf414b8 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -1746,12 +1746,7 @@ int main( int argc, char *argv[] ) mbedtls_ssl_set_bio( &ssl, &client_fd, my_send, my_recv, NULL ); else mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, -#if defined(MBEDTLS_HAVE_TIME) - opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL -#else - NULL -#endif - ); + opt.nbio == 0 ? mbedtls_net_recv_timeout : NULL ); #if defined(MBEDTLS_TIMING_C) mbedtls_ssl_set_timer_cb( &ssl, &timer, mbedtls_timing_set_delay,