Also compiles / runs without time-based functions in OS

Can now run without need of time() / localtime() and gettimeofday()
This commit is contained in:
Paul Bakker 2013-07-03 15:31:03 +02:00
parent ecd54fb897
commit fa9b10050b
13 changed files with 119 additions and 16 deletions

View file

@ -94,6 +94,15 @@
*
#define POLARSSL_HAVE_SSE2
*/
/**
* \def POLARSSL_HAVE_TIME
*
* System has time.h and time() / localtime() / gettimeofday()
*
* Comment if your system does not support time functions
*/
#define POLARSSL_HAVE_TIME
/* \} name */
/**

View file

@ -27,8 +27,6 @@
#ifndef POLARSSL_SSL_H
#define POLARSSL_SSL_H
#include <time.h>
#include "config.h"
#include "net.h"
#include "bignum.h"
@ -60,6 +58,10 @@
#include "zlib.h"
#endif
#if defined(POLARSSL_HAVE_TIME)
#include <time.h>
#endif
#if defined(_MSC_VER) && !defined(inline)
#define inline _inline
#else
@ -306,7 +308,9 @@ typedef struct _ssl_handshake_params ssl_handshake_params;
*/
struct _ssl_session
{
#if defined(POLARSSL_HAVE_TIME)
time_t start; /*!< starting time */
#endif
int ciphersuite; /*!< chosen ciphersuite */
int compression; /*!< chosen compression */
size_t length; /*!< session id length */

View file

@ -46,7 +46,9 @@ typedef struct _ssl_cache_entry ssl_cache_entry;
*/
struct _ssl_cache_entry
{
#if defined(POLARSSL_HAVE_TIME)
time_t timestamp; /*!< entry timestamp */
#endif
ssl_session session; /*!< entry session */
#if defined(POLARSSL_X509_PARSE_C)
x509_buf peer_cert; /*!< entry peer_cert */
@ -87,6 +89,7 @@ int ssl_cache_get( void *data, ssl_session *session );
*/
int ssl_cache_set( void *data, const ssl_session *session );
#if defined(POLARSSL_HAVE_TIME)
/**
* \brief Set the cache timeout
* (Default: SSL_CACHE_DEFAULT_TIMEOUT (1 day))
@ -97,6 +100,7 @@ int ssl_cache_set( void *data, const ssl_session *session );
* \param timeout cache entry timeout
*/
void ssl_cache_set_timeout( ssl_cache_context *cache, int timeout );
#endif /* POLARSSL_HAVE_TIME */
/**
* \brief Set the cache timeout