Introduce typedef for SSL session cache callbacks
Signed-off-by: Hanno Becker <hanno.becker@arm.com>
diff --git a/include/mbedtls/ssl.h b/include/mbedtls/ssl.h
index 41973b7..b2d5574 100644
--- a/include/mbedtls/ssl.h
+++ b/include/mbedtls/ssl.h
@@ -501,6 +501,7 @@
MBEDTLS_SSL_TLS_PRF_SHA256
}
mbedtls_tls_prf_types;
+
/**
* \brief Callback type: send data on the network.
*
@@ -626,6 +627,11 @@
typedef struct mbedtls_ssl_flight_item mbedtls_ssl_flight_item;
#endif
+/* TODO: Document */
+typedef int mbedtls_ssl_cache_get_t( void *data, mbedtls_ssl_session *session );
+/* TODO: Document */
+typedef int mbedtls_ssl_cache_set_t( void *data, const mbedtls_ssl_session *session );
+
#if defined(MBEDTLS_SSL_ASYNC_PRIVATE)
#if defined(MBEDTLS_X509_CRT_PARSE_C)
/**
@@ -968,9 +974,9 @@
void *p_rng; /*!< context for the RNG function */
/** Callback to retrieve a session from the cache */
- int (*f_get_cache)(void *, mbedtls_ssl_session *);
+ mbedtls_ssl_cache_get_t *f_get_cache;
/** Callback to store a session into the cache */
- int (*f_set_cache)(void *, const mbedtls_ssl_session *);
+ mbedtls_ssl_cache_set_t *f_set_cache;
void *p_cache; /*!< context for cache callbacks */
#if defined(MBEDTLS_SSL_SERVER_NAME_INDICATION)
@@ -2428,9 +2434,9 @@
* \param f_set_cache session set callback
*/
void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf,
- void *p_cache,
- int (*f_get_cache)(void *, mbedtls_ssl_session *),
- int (*f_set_cache)(void *, const mbedtls_ssl_session *) );
+ void *p_cache,
+ mbedtls_ssl_cache_get_t *f_get_cache,
+ mbedtls_ssl_cache_set_t *f_set_cache );
#endif /* MBEDTLS_SSL_SRV_C */
#if defined(MBEDTLS_SSL_CLI_C)
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 1a04f6cb..67fcebf 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -4167,9 +4167,9 @@
#if defined(MBEDTLS_SSL_SRV_C)
void mbedtls_ssl_conf_session_cache( mbedtls_ssl_config *conf,
- void *p_cache,
- int (*f_get_cache)(void *, mbedtls_ssl_session *),
- int (*f_set_cache)(void *, const mbedtls_ssl_session *) )
+ void *p_cache,
+ mbedtls_ssl_cache_get_t *f_get_cache,
+ mbedtls_ssl_cache_set_t *f_set_cache )
{
conf->p_cache = p_cache;
conf->f_get_cache = f_get_cache;