mirror of
https://github.com/yuzu-emu/mbedtls.git
synced 2024-12-23 18:25:35 +00:00
Preparation for timers
Currently directly using timing.c, plan to use callbacks later to loosen coupling, but first just get things working.
This commit is contained in:
parent
bd97fdb3a4
commit
db2858ce96
|
@ -76,6 +76,10 @@
|
|||
#include "zlib.h"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_TIMING_C)
|
||||
#include "timing.h"
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_HAVE_TIME)
|
||||
#include <time.h>
|
||||
#endif
|
||||
|
@ -814,6 +818,14 @@ struct _ssl_context
|
|||
ssl_transform *transform; /*!< negotiated transform params */
|
||||
ssl_transform *transform_negotiate; /*!< transform params in negotiation */
|
||||
|
||||
/*
|
||||
* Timers (WIP)
|
||||
*/
|
||||
#if defined(POLARSSL_TIMING_C)
|
||||
struct hr_time time_info;
|
||||
unsigned long time_limit;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Record layer (incoming data)
|
||||
*/
|
||||
|
|
|
@ -78,6 +78,37 @@ static inline size_t ssl_ep_len( const ssl_context *ssl )
|
|||
return( 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Timers (WIP)
|
||||
*/
|
||||
#if defined(POLARSSL_TIMING_C)
|
||||
/*
|
||||
* Start a timer.
|
||||
* Passing millisecs = 0 cancels a running timer.
|
||||
* The timer is already running iff time_limit != 0.
|
||||
*/
|
||||
void ssl_set_timer( ssl_context *ssl, unsigned long millisecs )
|
||||
{
|
||||
ssl->time_limit = millisecs;
|
||||
get_timer( &ssl->time_info, 1 );
|
||||
}
|
||||
|
||||
/*
|
||||
* Return -1 is timer is expired, 0 if it isn't.
|
||||
*/
|
||||
int ssl_check_timer( ssl_context *ssl )
|
||||
{
|
||||
if( ssl->time_limit != 0 &&
|
||||
get_timer( &ssl->time_info, 0 ) > ssl->time_limit )
|
||||
{
|
||||
return( -1 );
|
||||
}
|
||||
|
||||
return( 0 );
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(POLARSSL_SSL_MAX_FRAGMENT_LENGTH)
|
||||
/*
|
||||
* Convert max_fragment_length codes to length.
|
||||
|
|
Loading…
Reference in a new issue