Example apps: Don't use runtime IO config API if CBs are hardcoded

Multiple example applications still use mbedtls_ssl_set_bio() even
if the I/O callbacks are hardcoded. This commit fixes this.
This commit is contained in:
Hanno Becker 2019-07-19 17:07:30 +01:00 committed by Manuel Pégourié-Gonnard
parent 2a0cd5a031
commit 41e5a6871d
9 changed files with 73 additions and 11 deletions

View file

@ -305,8 +305,15 @@ reset:
goto exit; goto exit;
} }
#if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_ssl_set_bio( &ssl, &client_fd,
mbedtls_net_send, mbedtls_net_recv, mbedtls_net_recv_timeout ); mbedtls_net_send, mbedtls_net_recv,
mbedtls_net_recv_timeout );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &client_fd );
#endif
printf( " ok\n" ); printf( " ok\n" );

View file

@ -196,7 +196,14 @@ int main( void )
goto exit; goto exit;
} }
mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &server_fd,
mbedtls_net_send, mbedtls_net_recv, NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &server_fd );
#endif
/* /*
* 4. Handshake * 4. Handshake

View file

@ -2681,8 +2681,14 @@ send_request:
goto exit; goto exit;
} }
#if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &io_ctx, send_cb, recv_cb, mbedtls_ssl_set_bio( &ssl, &io_ctx, send_cb, recv_cb,
opt.nbio == 0 ? recv_timeout_cb : NULL ); opt.nbio == 0 ? recv_timeout_cb : NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &server_fd );
#endif
#if defined(MBEDTLS_TIMING_C) #if defined(MBEDTLS_TIMING_C)
#if !defined(MBEDTLS_SSL_CONF_SET_TIMER) && \ #if !defined(MBEDTLS_SSL_CONF_SET_TIMER) && \

View file

@ -300,7 +300,14 @@ int main( void )
goto exit; goto exit;
} }
mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &client_fd,
mbedtls_net_send, mbedtls_net_recv, NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &client_fd );
#endif
mbedtls_printf( "pid %d: SSL setup ok\n", pid ); mbedtls_printf( "pid %d: SSL setup ok\n", pid );

View file

@ -649,7 +649,14 @@ int main( int argc, char *argv[] )
goto exit; goto exit;
} }
mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &server_fd,
mbedtls_net_send, mbedtls_net_recv, NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &server_fd );
#endif
mbedtls_printf( " ok\n" ); mbedtls_printf( " ok\n" );

View file

@ -149,7 +149,14 @@ static void *handle_ssl_connection( void *data )
goto thread_exit; goto thread_exit;
} }
mbedtls_ssl_set_bio( &ssl, client_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &client_fd,
mbedtls_net_send, mbedtls_net_recv, NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &client_fd );
#endif
/* /*
* 5. Handshake * 5. Handshake

View file

@ -265,7 +265,14 @@ reset:
goto exit; goto exit;
} }
mbedtls_ssl_set_bio( &ssl, &client_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &client_fd,
mbedtls_net_send, mbedtls_net_recv, NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &client_fd );
#endif
mbedtls_printf( " ok\n" ); mbedtls_printf( " ok\n" );

View file

@ -3714,12 +3714,19 @@ data_exchange:
/* /*
* This illustrates the minimum amount of things you need to set * This illustrates the minimum amount of things you need to set
* up, however you could set up much more if desired, for example * up: I/O and timer callbacks/contexts; however you could set up
* if you want to share your set up code between the case of * much more if desired, for example if you want to share your set
* establishing a new connection and this case. * up code between the case of establishing a new connection and
* this case.
*/ */
#if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &io_ctx, send_cb, recv_cb, mbedtls_ssl_set_bio( &ssl, &io_ctx, send_cb, recv_cb,
opt.nbio == 0 ? recv_timeout_cb : NULL ); opt.nbio == 0 ? recv_timeout_cb : NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &client_fd );
#endif
#if defined(MBEDTLS_TIMING_C) #if defined(MBEDTLS_TIMING_C)
#if !defined(MBEDTLS_SSL_CONF_SET_TIMER) && \ #if !defined(MBEDTLS_SSL_CONF_SET_TIMER) && \

View file

@ -441,7 +441,14 @@ int main( int argc, char *argv[] )
goto ssl_exit; goto ssl_exit;
} }
mbedtls_ssl_set_bio( &ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL ); #if !defined(MBEDTLS_SSL_CONF_RECV) && \
!defined(MBEDTLS_SSL_CONF_SEND) && \
!defined(MBEDTLS_SSL_CONF_RECV_TIMEOUT)
mbedtls_ssl_set_bio( &ssl, &server_fd,
mbedtls_net_send, mbedtls_net_recv, NULL );
#else
mbedtls_ssl_set_bio_ctx( &ssl, &server_fd );
#endif
/* /*
* 4. Handshake * 4. Handshake