Rename mbedtls_net_close() to mbedtls_net_free()
close() may be more meaningful, but free() is symmetric with _init(), and more
consistent with all other modules
diff --git a/include/mbedtls/compat-1.3.h b/include/mbedtls/compat-1.3.h
index 7d68564..2955622 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 d2cb8d4..85c4977 100644
--- a/include/mbedtls/net.h
+++ b/include/mbedtls/net.h
@@ -216,11 +216,11 @@
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 0576ed6..ed8ed7a 100644
--- a/library/net.c
+++ b/library/net.c
@@ -521,7 +521,7 @@
/*
* 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 3ccfa6d..66fc471 100644
--- a/programs/pkey/dh_client.c
+++ b/programs/pkey/dh_client.c
@@ -281,7 +281,7 @@
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 71fa737..7219c09 100644
--- a/programs/pkey/dh_server.c
+++ b/programs/pkey/dh_server.c
@@ -283,8 +283,8 @@
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 b3cfb31..df68dbd 100644
--- a/programs/ssl/dtls_client.c
+++ b/programs/ssl/dtls_client.c
@@ -326,7 +326,7 @@
}
#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 e1da0f7..a3839c6 100644
--- a/programs/ssl/dtls_server.c
+++ b/programs/ssl/dtls_server.c
@@ -256,7 +256,7 @@
}
#endif
- mbedtls_net_close( &client_fd );
+ mbedtls_net_free( &client_fd );
mbedtls_ssl_session_reset( &ssl );
@@ -401,8 +401,8 @@
}
#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 95b0f92..4a53340 100644
--- a/programs/ssl/mini_client.c
+++ b/programs/ssl/mini_client.c
@@ -280,7 +280,7 @@
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 61ead50..4b99a15 100644
--- a/programs/ssl/ssl_client1.c
+++ b/programs/ssl/ssl_client1.c
@@ -290,7 +290,7 @@
}
#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 27bd8bf..773bca6 100644
--- a/programs/ssl/ssl_client2.c
+++ b/programs/ssl/ssl_client2.c
@@ -1503,7 +1503,7 @@
{
--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 @@
}
#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 9aab975..235b4e9 100644
--- a/programs/ssl/ssl_fork_server.c
+++ b/programs/ssl/ssl_fork_server.c
@@ -259,11 +259,11 @@
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 @@
}
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 4ea5d4c..27e7d5a 100644
--- a/programs/ssl/ssl_mail_client.c
+++ b/programs/ssl/ssl_mail_client.c
@@ -819,7 +819,7 @@
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 4bd3671..1fe0980 100644
--- a/programs/ssl/ssl_pthread_server.c
+++ b/programs/ssl/ssl_pthread_server.c
@@ -265,7 +265,7 @@
}
#endif
- mbedtls_net_close( client_fd );
+ mbedtls_net_free( client_fd );
mbedtls_ssl_free( &ssl );
thread_info->thread_complete = 1;
@@ -491,7 +491,7 @@
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 786ae5c..d556d43 100644
--- a/programs/ssl/ssl_server.c
+++ b/programs/ssl/ssl_server.c
@@ -237,7 +237,7 @@
}
#endif
- mbedtls_net_close( &client_fd );
+ mbedtls_net_free( &client_fd );
mbedtls_ssl_session_reset( &ssl );
@@ -373,8 +373,8 @@
}
#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 3b2c802..99d43c9 100644
--- a/programs/ssl/ssl_server2.c
+++ b/programs/ssl/ssl_server2.c
@@ -755,8 +755,8 @@
{
((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 @@
}
#endif
- mbedtls_net_close( &client_fd );
+ mbedtls_net_free( &client_fd );
mbedtls_ssl_session_reset( &ssl );
@@ -2252,8 +2252,8 @@
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 9962445..7360d8a 100644
--- a/programs/test/udp_proxy.c
+++ b/programs/test/udp_proxy.c
@@ -615,9 +615,9 @@
}
#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 dd5c508..e555bdb 100644
--- a/programs/x509/cert_app.c
+++ b/programs/x509/cert_app.c
@@ -475,7 +475,7 @@
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 d70b9b1..571d249 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_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