mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Move WANT_READ/WANT_WRITE codes to SSL
This commit is contained in:
@ -409,11 +409,11 @@ static int my_recv( void *ctx, unsigned char *buf, size_t len )
|
||||
if( first_try )
|
||||
{
|
||||
first_try = 0;
|
||||
return( MBEDTLS_ERR_NET_WANT_READ );
|
||||
return( MBEDTLS_ERR_SSL_WANT_READ );
|
||||
}
|
||||
|
||||
ret = mbedtls_net_recv( ctx, buf, len );
|
||||
if( ret != MBEDTLS_ERR_NET_WANT_READ )
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_READ )
|
||||
first_try = 1; /* Next call will be a new operation */
|
||||
return( ret );
|
||||
}
|
||||
@ -426,11 +426,11 @@ static int my_send( void *ctx, const unsigned char *buf, size_t len )
|
||||
if( first_try )
|
||||
{
|
||||
first_try = 0;
|
||||
return( MBEDTLS_ERR_NET_WANT_WRITE );
|
||||
return( MBEDTLS_ERR_SSL_WANT_WRITE );
|
||||
}
|
||||
|
||||
ret = mbedtls_net_send( ctx, buf, len );
|
||||
if( ret != MBEDTLS_ERR_NET_WANT_WRITE )
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||
first_try = 1; /* Next call will be a new operation */
|
||||
return( ret );
|
||||
}
|
||||
@ -1874,8 +1874,8 @@ reset:
|
||||
fflush( stdout );
|
||||
|
||||
do ret = mbedtls_ssl_handshake( &ssl );
|
||||
while( ret == MBEDTLS_ERR_NET_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_NET_WANT_WRITE );
|
||||
while( ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE );
|
||||
|
||||
if( ret == MBEDTLS_ERR_SSL_HELLO_VERIFY_REQUIRED )
|
||||
{
|
||||
@ -1959,8 +1959,8 @@ data_exchange:
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
ret = mbedtls_ssl_read( &ssl, buf, len );
|
||||
|
||||
if( ret == MBEDTLS_ERR_NET_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_NET_WANT_WRITE )
|
||||
if( ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||
continue;
|
||||
|
||||
if( ret <= 0 )
|
||||
@ -2050,8 +2050,8 @@ data_exchange:
|
||||
memset( buf, 0, sizeof( buf ) );
|
||||
|
||||
do ret = mbedtls_ssl_read( &ssl, buf, len );
|
||||
while( ret == MBEDTLS_ERR_NET_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_NET_WANT_WRITE );
|
||||
while( ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE );
|
||||
|
||||
if( ret <= 0 )
|
||||
{
|
||||
@ -2086,8 +2086,8 @@ data_exchange:
|
||||
|
||||
while( ( ret = mbedtls_ssl_renegotiate( &ssl ) ) != 0 )
|
||||
{
|
||||
if( ret != MBEDTLS_ERR_NET_WANT_READ &&
|
||||
ret != MBEDTLS_ERR_NET_WANT_WRITE )
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_READ &&
|
||||
ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_renegotiate returned %d\n\n", ret );
|
||||
goto reset;
|
||||
@ -2120,8 +2120,8 @@ data_exchange:
|
||||
goto reset;
|
||||
}
|
||||
|
||||
if( ret != MBEDTLS_ERR_NET_WANT_READ &&
|
||||
ret != MBEDTLS_ERR_NET_WANT_WRITE )
|
||||
if( ret != MBEDTLS_ERR_SSL_WANT_READ &&
|
||||
ret != MBEDTLS_ERR_SSL_WANT_WRITE )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_ssl_write returned %d\n\n", ret );
|
||||
goto reset;
|
||||
@ -2132,8 +2132,8 @@ data_exchange:
|
||||
else /* Not stream, so datagram */
|
||||
{
|
||||
do ret = mbedtls_ssl_write( &ssl, buf, len );
|
||||
while( ret == MBEDTLS_ERR_NET_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_NET_WANT_WRITE );
|
||||
while( ret == MBEDTLS_ERR_SSL_WANT_READ ||
|
||||
ret == MBEDTLS_ERR_SSL_WANT_WRITE );
|
||||
|
||||
if( ret < 0 )
|
||||
{
|
||||
@ -2163,7 +2163,7 @@ close_notify:
|
||||
|
||||
/* No error checking, the connection might be closed already */
|
||||
do ret = mbedtls_ssl_close_notify( &ssl );
|
||||
while( ret == MBEDTLS_ERR_NET_WANT_WRITE );
|
||||
while( ret == MBEDTLS_ERR_SSL_WANT_WRITE );
|
||||
ret = 0;
|
||||
|
||||
mbedtls_printf( " done\n" );
|
||||
|
Reference in New Issue
Block a user