mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Adapt programs to the new NET API
This commit is contained in:
@ -92,8 +92,7 @@ static void my_debug( void *ctx, int level,
|
||||
int main( void )
|
||||
{
|
||||
int ret, len;
|
||||
int listen_fd;
|
||||
int client_fd = -1;
|
||||
mbedtls_net_context listen_fd, client_fd;
|
||||
unsigned char buf[1024];
|
||||
const char *pers = "dtls_server";
|
||||
unsigned char client_ip[16] = { 0 };
|
||||
@ -111,6 +110,8 @@ int main( void )
|
||||
mbedtls_ssl_cache_context cache;
|
||||
#endif
|
||||
|
||||
mbedtls_net_init( &listen_fd );
|
||||
mbedtls_net_init( &client_fd );
|
||||
mbedtls_ssl_init( &ssl );
|
||||
mbedtls_ssl_config_init( &conf );
|
||||
mbedtls_ssl_cookie_init( &cookie_ctx );
|
||||
@ -255,20 +256,17 @@ reset:
|
||||
}
|
||||
#endif
|
||||
|
||||
if( client_fd != -1 )
|
||||
mbedtls_net_close( client_fd );
|
||||
mbedtls_net_close( &client_fd );
|
||||
|
||||
mbedtls_ssl_session_reset( &ssl );
|
||||
|
||||
/*
|
||||
* 3. Wait until a client connects
|
||||
*/
|
||||
client_fd = -1;
|
||||
|
||||
printf( " . Waiting for a remote connection ..." );
|
||||
fflush( stdout );
|
||||
|
||||
if( ( ret = mbedtls_net_accept( listen_fd, &client_fd,
|
||||
if( ( ret = mbedtls_net_accept( &listen_fd, &client_fd,
|
||||
client_ip, sizeof( client_ip ), &cliip_len ) ) != 0 )
|
||||
{
|
||||
printf( " failed\n ! mbedtls_net_accept returned %d\n\n", ret );
|
||||
@ -403,8 +401,8 @@ exit:
|
||||
}
|
||||
#endif
|
||||
|
||||
if( client_fd != -1 )
|
||||
mbedtls_net_close( client_fd );
|
||||
mbedtls_net_close( &client_fd );
|
||||
mbedtls_net_close( &listen_fd );
|
||||
|
||||
mbedtls_x509_crt_free( &srvcert );
|
||||
mbedtls_pk_free( &pkey );
|
||||
|
Reference in New Issue
Block a user