Add ssl_set_client_transport_id()
diff --git a/library/ssl_srv.c b/library/ssl_srv.c
index 430f51a..eac553f 100644
--- a/library/ssl_srv.c
+++ b/library/ssl_srv.c
@@ -351,6 +351,26 @@
}
#endif /* POLARSSL_SSL_SESSION_TICKETS */
+#if defined(POLARSSL_SSL_PROTO_DTLS)
+int ssl_set_client_transport_id( ssl_context *ssl,
+ const unsigned char *info,
+ size_t ilen )
+{
+ if( ssl->endpoint != SSL_IS_SERVER )
+ return( POLARSSL_ERR_SSL_BAD_INPUT_DATA );
+
+ polarssl_free( ssl->cli_id );
+
+ if( ( ssl->cli_id = polarssl_malloc( ilen ) ) == NULL )
+ return( POLARSSL_ERR_SSL_MALLOC_FAILED );
+
+ memcpy( ssl->cli_id, info, ilen );
+ ssl->cli_id_len = ilen;
+
+ return( 0 );
+}
+#endif /* POLARSSL_SSL_PROTO_DTLS */
+
#if defined(POLARSSL_SSL_SERVER_NAME_INDICATION)
/*
* Wrapper around f_sni, allowing use of ssl_set_own_cert() but
diff --git a/library/ssl_tls.c b/library/ssl_tls.c
index 27ee058..d854199 100644
--- a/library/ssl_tls.c
+++ b/library/ssl_tls.c
@@ -3749,6 +3749,12 @@
ssl->alpn_chosen = NULL;
#endif
+#if defined(POLARSSL_SSL_PROTO_DTLS) && defined(POLARSSL_SSL_SRV_C)
+ polarssl_free( ssl->cli_id );
+ ssl->cli_id = NULL;
+ ssl->cli_id_len = 0;
+#endif
+
if( ( ret = ssl_handshake_init( ssl ) ) != 0 )
return( ret );
@@ -5033,6 +5039,10 @@
}
#endif
+#if defined(POLARSSL_SSL_PROTO_DTLS) && defined(POLARSSL_SSL_SRV_C)
+ polarssl_free( ssl->cli_id );
+#endif
+
SSL_DEBUG_MSG( 2, ( "<= free" ) );
/* Actually clear after last debug message */