mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-11-23 10:05:40 +01:00
Adapt ssl_{client,server}2.c to datagram write
This commit is contained in:
parent
a6fcffe516
commit
2d87e419e0
@ -1211,17 +1211,37 @@ send_request:
|
||||
if( len >= 1 ) buf[len - 1] = '\n';
|
||||
}
|
||||
|
||||
if( opt.transport == SSL_TRANSPORT_STREAM )
|
||||
{
|
||||
for( written = 0, frags = 0; written < len; written += ret, frags++ )
|
||||
{
|
||||
while( ( ret = ssl_write( &ssl, buf + written, len - written ) ) <= 0 )
|
||||
while( ( ret = ssl_write( &ssl, buf + written, len - written ) )
|
||||
<= 0 )
|
||||
{
|
||||
if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
|
||||
if( ret != POLARSSL_ERR_NET_WANT_READ &&
|
||||
ret != POLARSSL_ERR_NET_WANT_WRITE )
|
||||
{
|
||||
printf( " failed\n ! ssl_write returned -0x%x\n\n", -ret );
|
||||
goto exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Not stream, so datagram */
|
||||
{
|
||||
do ret = ssl_write( &ssl, buf, len );
|
||||
while( ret == POLARSSL_ERR_NET_WANT_READ ||
|
||||
ret == POLARSSL_ERR_NET_WANT_WRITE );
|
||||
|
||||
if( ret < 0 )
|
||||
{
|
||||
printf( " failed\n ! ssl_write returned %d\n\n", ret );
|
||||
goto exit;
|
||||
}
|
||||
|
||||
frags = 1;
|
||||
written = ret;
|
||||
}
|
||||
|
||||
buf[written] = '\0';
|
||||
printf( " %d bytes written in %d fragments\n\n%s\n", written, frags, (char *) buf );
|
||||
|
@ -1915,9 +1915,12 @@ data_exchange:
|
||||
len = sprintf( (char *) buf, HTTP_RESPONSE,
|
||||
ssl_get_ciphersuite( &ssl ) );
|
||||
|
||||
if( opt.transport == SSL_TRANSPORT_STREAM )
|
||||
{
|
||||
for( written = 0, frags = 0; written < len; written += ret, frags++ )
|
||||
{
|
||||
while( ( ret = ssl_write( &ssl, buf + written, len - written ) ) <= 0 )
|
||||
while( ( ret = ssl_write( &ssl, buf + written, len - written ) )
|
||||
<= 0 )
|
||||
{
|
||||
if( ret == POLARSSL_ERR_NET_CONN_RESET )
|
||||
{
|
||||
@ -1925,13 +1928,30 @@ data_exchange:
|
||||
goto reset;
|
||||
}
|
||||
|
||||
if( ret != POLARSSL_ERR_NET_WANT_READ && ret != POLARSSL_ERR_NET_WANT_WRITE )
|
||||
if( ret != POLARSSL_ERR_NET_WANT_READ &&
|
||||
ret != POLARSSL_ERR_NET_WANT_WRITE )
|
||||
{
|
||||
printf( " failed\n ! ssl_write returned %d\n\n", ret );
|
||||
goto reset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else /* Not stream, so datagram */
|
||||
{
|
||||
do ret = ssl_write( &ssl, buf, len );
|
||||
while( ret == POLARSSL_ERR_NET_WANT_READ ||
|
||||
ret == POLARSSL_ERR_NET_WANT_WRITE );
|
||||
|
||||
if( ret < 0 )
|
||||
{
|
||||
printf( " failed\n ! ssl_write returned %d\n\n", ret );
|
||||
goto reset;
|
||||
}
|
||||
|
||||
frags = 1;
|
||||
written = ret;
|
||||
}
|
||||
|
||||
buf[written] = '\0';
|
||||
printf( " %d bytes written in %d fragments\n\n%s\n", written, frags, (char *) buf );
|
||||
|
Loading…
Reference in New Issue
Block a user