programs/test: fix build without MBEDTLS_HAVE_TIME
Allow programs/test/udp_proxy.c to build when MBEDTLS_HAVE_TIME is
not defined. In this case, do not attempt to seed the pseudo-random
number generator used to sometimes produce corrupt packets and other
erroneous data.
Signed-off-by: David Horstmann <david.horstmann@arm.com>
diff --git a/programs/test/udp_proxy.c b/programs/test/udp_proxy.c
index 6546e8f..21a5173 100644
--- a/programs/test/udp_proxy.c
+++ b/programs/test/udp_proxy.c
@@ -32,9 +32,11 @@
#else
#include <stdio.h>
#include <stdlib.h>
+#if defined(MBEDTLS_HAVE_TIME)
#include <time.h>
#define mbedtls_time time
#define mbedtls_time_t time_t
+#endif
#define mbedtls_printf printf
#define mbedtls_calloc calloc
#define mbedtls_free free
@@ -821,6 +823,7 @@
get_options( argc, argv );
+#if defined(MBEDTLS_HAVE_TIME)
/*
* Decisions to drop/delay/duplicate packets are pseudo-random: dropping
* exactly 1 in N packets would lead to problems when a flight has exactly
@@ -831,11 +834,12 @@
*/
if( opt.seed == 0 )
{
- opt.seed = (unsigned int) time( NULL );
+ opt.seed = (unsigned int) mbedtls_time( NULL );
mbedtls_printf( " . Pseudo-random seed: %u\n", opt.seed );
}
srand( opt.seed );
+#endif /* MBEDTLS_HAVE_TIME */
/*
* 0. "Connect" to the server