diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h index 7d68564f9..295562276 100644 --- a/include/mbedtls/compat-1.3.h +++ b/include/mbedtls/compat-1.3.h @@ -2157,7 +2157,7 @@ #define mpi_write_string mbedtls_mpi_write_string #define net_accept mbedtls_net_accept #define net_bind mbedtls_net_bind -#define net_close mbedtls_net_close +#define net_close mbedtls_net_free #define net_connect mbedtls_net_connect #define net_recv mbedtls_net_recv #define net_recv_timeout mbedtls_net_recv_timeout diff --git a/include/mbedtls/net.h b/include/mbedtls/net.h index d2cb8d48d..85c4977cf 100644 --- a/include/mbedtls/net.h +++ b/include/mbedtls/net.h @@ -216,11 +216,11 @@ int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len, uint32_t timeout ); /** - * \brief Gracefully shutdown the connection + * \brief Gracefully shutdown the connection and free associated data * - * \param ctx The socket to close + * \param ctx The context to free */ -void mbedtls_net_close( mbedtls_net_context *ctx ); +void mbedtls_net_free( mbedtls_net_context *ctx ); #ifdef __cplusplus } diff --git a/library/net.c b/library/net.c index 0576ed6b1..ed8ed7a7a 100644 --- a/library/net.c +++ b/library/net.c @@ -521,7 +521,7 @@ int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len ) /* * Gracefully close the connection */ -void mbedtls_net_close( mbedtls_net_context *ctx ) +void mbedtls_net_free( mbedtls_net_context *ctx ) { if( ctx->fd == -1 ) return; diff --git a/programs/pkey/dh_client.c b/programs/pkey/dh_client.c index 3ccfa6d9f..66fc471ef 100644 --- a/programs/pkey/dh_client.c +++ b/programs/pkey/dh_client.c @@ -281,7 +281,7 @@ int main( void ) exit: - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); mbedtls_aes_free( &aes ); mbedtls_rsa_free( &rsa ); diff --git a/programs/pkey/dh_server.c b/programs/pkey/dh_server.c index 71fa73704..7219c09f6 100644 --- a/programs/pkey/dh_server.c +++ b/programs/pkey/dh_server.c @@ -283,8 +283,8 @@ int main( void ) exit: - mbedtls_net_close( &client_fd ); - mbedtls_net_close( &listen_fd ); + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); mbedtls_aes_free( &aes ); mbedtls_rsa_free( &rsa ); diff --git a/programs/ssl/dtls_client.c b/programs/ssl/dtls_client.c index b3cfb310d..df68dbd73 100644 --- a/programs/ssl/dtls_client.c +++ b/programs/ssl/dtls_client.c @@ -326,7 +326,7 @@ exit: } #endif - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); mbedtls_x509_crt_free( &cacert ); mbedtls_ssl_free( &ssl ); diff --git a/programs/ssl/dtls_server.c b/programs/ssl/dtls_server.c index e1da0f74a..a3839c656 100644 --- a/programs/ssl/dtls_server.c +++ b/programs/ssl/dtls_server.c @@ -256,7 +256,7 @@ reset: } #endif - mbedtls_net_close( &client_fd ); + mbedtls_net_free( &client_fd ); mbedtls_ssl_session_reset( &ssl ); @@ -401,8 +401,8 @@ exit: } #endif - mbedtls_net_close( &client_fd ); - mbedtls_net_close( &listen_fd ); + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); mbedtls_x509_crt_free( &srvcert ); mbedtls_pk_free( &pkey ); diff --git a/programs/ssl/mini_client.c b/programs/ssl/mini_client.c index 95b0f9227..4a53340b9 100644 --- a/programs/ssl/mini_client.c +++ b/programs/ssl/mini_client.c @@ -280,7 +280,7 @@ int main( void ) mbedtls_ssl_close_notify( &ssl ); exit: - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); mbedtls_ssl_free( &ssl ); mbedtls_ssl_config_free( &conf ); diff --git a/programs/ssl/ssl_client1.c b/programs/ssl/ssl_client1.c index 61ead50ed..4b99a15d5 100644 --- a/programs/ssl/ssl_client1.c +++ b/programs/ssl/ssl_client1.c @@ -290,7 +290,7 @@ exit: } #endif - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); mbedtls_x509_crt_free( &cacert ); mbedtls_ssl_free( &ssl ); diff --git a/programs/ssl/ssl_client2.c b/programs/ssl/ssl_client2.c index 27bd8bf41..773bca6db 100644 --- a/programs/ssl/ssl_client2.c +++ b/programs/ssl/ssl_client2.c @@ -1503,7 +1503,7 @@ reconnect: { --opt.reconnect; - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); #if defined(MBEDTLS_TIMING_C) if( opt.reco_delay > 0 ) @@ -1572,7 +1572,7 @@ exit: } #endif - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); #if defined(MBEDTLS_X509_CRT_PARSE_C) mbedtls_x509_crt_free( &clicert ); diff --git a/programs/ssl/ssl_fork_server.c b/programs/ssl/ssl_fork_server.c index 9aab97585..235b4e90f 100644 --- a/programs/ssl/ssl_fork_server.c +++ b/programs/ssl/ssl_fork_server.c @@ -259,11 +259,11 @@ int main( void ) goto exit; } - mbedtls_net_close( &client_fd ); + mbedtls_net_free( &client_fd ); continue; } - mbedtls_net_close( &listen_fd ); + mbedtls_net_free( &listen_fd ); /* * 4. Setup stuff @@ -385,8 +385,8 @@ int main( void ) } exit: - mbedtls_net_close( &client_fd ); - mbedtls_net_close( &listen_fd ); + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); mbedtls_x509_crt_free( &srvcert ); mbedtls_pk_free( &pkey ); diff --git a/programs/ssl/ssl_mail_client.c b/programs/ssl/ssl_mail_client.c index 4ea5d4c1b..27e7d5aec 100644 --- a/programs/ssl/ssl_mail_client.c +++ b/programs/ssl/ssl_mail_client.c @@ -819,7 +819,7 @@ int main( int argc, char *argv[] ) exit: - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); mbedtls_x509_crt_free( &clicert ); mbedtls_x509_crt_free( &cacert ); mbedtls_pk_free( &pkey ); diff --git a/programs/ssl/ssl_pthread_server.c b/programs/ssl/ssl_pthread_server.c index 4bd3671d4..1fe098013 100644 --- a/programs/ssl/ssl_pthread_server.c +++ b/programs/ssl/ssl_pthread_server.c @@ -265,7 +265,7 @@ thread_exit: } #endif - mbedtls_net_close( client_fd ); + mbedtls_net_free( client_fd ); mbedtls_ssl_free( &ssl ); thread_info->thread_complete = 1; @@ -491,7 +491,7 @@ reset: if( ( ret = thread_create( &client_fd ) ) != 0 ) { mbedtls_printf( " [ main ] failed: thread_create returned %d\n", ret ); - mbedtls_net_close( &client_fd ); + mbedtls_net_free( &client_fd ); goto reset; } diff --git a/programs/ssl/ssl_server.c b/programs/ssl/ssl_server.c index 786ae5c3d..d556d43e2 100644 --- a/programs/ssl/ssl_server.c +++ b/programs/ssl/ssl_server.c @@ -237,7 +237,7 @@ reset: } #endif - mbedtls_net_close( &client_fd ); + mbedtls_net_free( &client_fd ); mbedtls_ssl_session_reset( &ssl ); @@ -373,8 +373,8 @@ exit: } #endif - mbedtls_net_close( &client_fd ); - mbedtls_net_close( &listen_fd ); + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); mbedtls_x509_crt_free( &srvcert ); mbedtls_pk_free( &pkey ); diff --git a/programs/ssl/ssl_server2.c b/programs/ssl/ssl_server2.c index 3b2c802b1..99d43c949 100644 --- a/programs/ssl/ssl_server2.c +++ b/programs/ssl/ssl_server2.c @@ -755,8 +755,8 @@ void term_handler( int sig ) { ((void) sig); received_sigterm = 1; - mbedtls_net_close( &listen_fd ); /* causes mbedtls_net_accept() to abort */ - mbedtls_net_close( &client_fd ); /* causes net_read() to abort */ + mbedtls_net_free( &listen_fd ); /* causes mbedtls_net_accept() to abort */ + mbedtls_net_free( &client_fd ); /* causes net_read() to abort */ } #endif @@ -1843,7 +1843,7 @@ reset: } #endif - mbedtls_net_close( &client_fd ); + mbedtls_net_free( &client_fd ); mbedtls_ssl_session_reset( &ssl ); @@ -2252,8 +2252,8 @@ exit: mbedtls_printf( " . Cleaning up..." ); fflush( stdout ); - mbedtls_net_close( &client_fd ); - mbedtls_net_close( &listen_fd ); + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &listen_fd ); #if defined(MBEDTLS_DHM_C) && defined(MBEDTLS_FS_IO) mbedtls_dhm_free( &dhm ); diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c index 9962445f9..7360d8a37 100644 --- a/programs/test/udp_proxy.c +++ b/programs/test/udp_proxy.c @@ -615,9 +615,9 @@ exit: } #endif - mbedtls_net_close( &client_fd ); - mbedtls_net_close( &server_fd ); - mbedtls_net_close( &listen_fd ); + mbedtls_net_free( &client_fd ); + mbedtls_net_free( &server_fd ); + mbedtls_net_free( &listen_fd ); #if defined(_WIN32) mbedtls_printf( " Press Enter to exit this program.\n" ); diff --git a/programs/x509/cert_app.c b/programs/x509/cert_app.c index dd5c508cc..e555bdb23 100644 --- a/programs/x509/cert_app.c +++ b/programs/x509/cert_app.c @@ -475,7 +475,7 @@ ssl_exit: exit: - mbedtls_net_close( &server_fd ); + mbedtls_net_free( &server_fd ); mbedtls_x509_crt_free( &cacert ); mbedtls_x509_crt_free( &clicert ); #if defined(MBEDTLS_X509_CRL_PARSE_C) diff --git a/scripts/data_files/rename-1.3-2.0.txt b/scripts/data_files/rename-1.3-2.0.txt index d70b9b169..571d249cd 100644 --- a/scripts/data_files/rename-1.3-2.0.txt +++ b/scripts/data_files/rename-1.3-2.0.txt @@ -1701,7 +1701,7 @@ mpi_write_file mbedtls_mpi_write_file mpi_write_string mbedtls_mpi_write_string net_accept mbedtls_net_accept net_bind mbedtls_net_bind -net_close mbedtls_net_close +net_close mbedtls_net_free net_connect mbedtls_net_connect net_recv mbedtls_net_recv net_recv_timeout mbedtls_net_recv_timeout