mirror of
https://github.com/yuzu-emu/mbedtls
synced 2024-11-25 00:48:28 +00:00
Start adapting ssl_client2 to datagram I/O
This commit is contained in:
parent
67427c07b2
commit
ae5050c212
1 changed files with 55 additions and 14 deletions
|
@ -1177,6 +1177,11 @@ send_request:
|
||||||
printf( " < Read from server:" );
|
printf( " < Read from server:" );
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* TLS and DTLS need different reading styles (stream vs datagram)
|
||||||
|
*/
|
||||||
|
if( opt.transport == SSL_TRANSPORT_STREAM )
|
||||||
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
len = sizeof( buf ) - 1;
|
len = sizeof( buf ) - 1;
|
||||||
|
@ -1221,6 +1226,42 @@ send_request:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( 1 );
|
while( 1 );
|
||||||
|
}
|
||||||
|
else /* Not stream, so datagram */
|
||||||
|
{
|
||||||
|
len = sizeof( buf ) - 1;
|
||||||
|
memset( buf, 0, sizeof( buf ) );
|
||||||
|
|
||||||
|
do ret = ssl_read( &ssl, buf, len );
|
||||||
|
while( ret == POLARSSL_ERR_NET_WANT_READ ||
|
||||||
|
ret == POLARSSL_ERR_NET_WANT_WRITE );
|
||||||
|
|
||||||
|
if( ret <= 0 )
|
||||||
|
{
|
||||||
|
switch( ret )
|
||||||
|
{
|
||||||
|
case POLARSSL_ERR_SSL_PEER_CLOSE_NOTIFY:
|
||||||
|
printf( " connection was closed gracefully\n" );
|
||||||
|
ret = 0;
|
||||||
|
goto close_notify;
|
||||||
|
|
||||||
|
case 0:
|
||||||
|
case POLARSSL_ERR_NET_CONN_RESET:
|
||||||
|
printf( " connection was reset by peer\n" );
|
||||||
|
ret = 0;
|
||||||
|
goto reconnect;
|
||||||
|
|
||||||
|
default:
|
||||||
|
printf( " ssl_read returned -0x%x\n", -ret );
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
len = ret;
|
||||||
|
buf[len] = '\0';
|
||||||
|
printf( " %d bytes read\n\n%s", len, (char *) buf );
|
||||||
|
ret = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* 7b. Continue doing data exchanges?
|
* 7b. Continue doing data exchanges?
|
||||||
|
|
Loading…
Reference in a new issue