1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-12-24 17:41:01 +03:00

Move WANT_READ/WANT_WRITE codes to SSL

This commit is contained in:
Manuel Pégourié-Gonnard
2015-05-06 16:19:31 +01:00
parent 1b511f93c6
commit 8836994f6b
19 changed files with 130 additions and 125 deletions

View File

@@ -334,11 +334,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 );
}
@@ -351,11 +351,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 );
}
@@ -1217,7 +1217,7 @@ int main( int argc, char *argv[] )
while( ( ret = mbedtls_ssl_handshake( &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_handshake returned -0x%x\n", -ret );
if( ret == MBEDTLS_ERR_X509_CERT_VERIFY_FAILED )
@@ -1303,8 +1303,8 @@ int main( int argc, char *argv[] )
fflush( stdout );
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 exit;
@@ -1355,8 +1355,8 @@ send_request:
while( ( ret = mbedtls_ssl_write( &ssl, buf + written, len - written ) )
<= 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_write returned -0x%x\n\n", -ret );
goto exit;
@@ -1367,8 +1367,8 @@ send_request:
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 )
{
@@ -1400,8 +1400,8 @@ send_request:
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 )
@@ -1445,14 +1445,14 @@ send_request:
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 )
{
switch( ret )
{
case MBEDTLS_ERR_NET_TIMEOUT:
case MBEDTLS_ERR_SSL_TIMEOUT:
mbedtls_printf( " timeout\n" );
if( retry_left-- > 0 )
goto send_request;
@@ -1489,7 +1489,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" );
@@ -1545,8 +1545,8 @@ reconnect:
while( ( ret = mbedtls_ssl_handshake( &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_handshake returned -0x%x\n\n", -ret );
goto exit;