From 7a254a8ecfc146f78571cd96f3c78bd8dd8cc703 Mon Sep 17 00:00:00 2001 From: J Harper Date: Tue, 24 May 2016 17:03:12 -0700 Subject: [PATCH] compile stub main if USE_DTLS not defined --- apps/dtls/dtlsClient.c | 10 +++++----- apps/dtls/dtlsCommon.c | 4 ++++ apps/dtls/dtlsCommon.h | 6 ++---- apps/dtls/dtlsServer.c | 18 ++++++++++++++++++ 4 files changed, 29 insertions(+), 9 deletions(-) diff --git a/apps/dtls/dtlsClient.c b/apps/dtls/dtlsClient.c index 2574a9d..2e8a921 100644 --- a/apps/dtls/dtlsClient.c +++ b/apps/dtls/dtlsClient.c @@ -34,7 +34,7 @@ #include "dtlsCommon.h" -#ifdef USE_CLIENT_SIDE_SSL +#if defined(USE_DTLS) && defined(USE_CLIENT_SIDE_SSL) static int packet_loss_prob = 0; /* Reciprocal of packet loss probability (i.e. P(packet loss) = 1/x). @@ -1087,15 +1087,15 @@ static int32 certCb(ssl_t *ssl, psX509Cert_t *cert, int32 alert) #else /******************************************************************************/ /* - Stub main for compiling without client enabled + Stub main for compiling without dtls and client enabled */ int32 main(int32 argc, char **argv) { - printf("USE_CLIENT_SIDE_SSL must be enabled in matrixsslConfig.h at build" \ - " time to run this application\n"); + printf("USE_DTLS and USE_CLIENT_SIDE_SSL must be enabled in " \ + "matrixsslConfig.h at build time to run this application\n"); return -1; } -#endif /* USE_CLIENT_SIDE_SSL */ +#endif /* USE_DTLS && USE_CLIENT_SIDE_SSL */ /******************************************************************************/ diff --git a/apps/dtls/dtlsCommon.c b/apps/dtls/dtlsCommon.c index 966a323..06d424e 100644 --- a/apps/dtls/dtlsCommon.c +++ b/apps/dtls/dtlsCommon.c @@ -31,6 +31,8 @@ #include "dtlsCommon.h" +#ifdef USE_DTLS + #ifdef DTLS_PACKET_LOSS_TEST static int num_dropped = 0; #endif /* DTLS_PACKET_LOSS_TEST */ @@ -121,3 +123,5 @@ int32 udpSend(SOCKET s, unsigned char *buf, int len, #endif /* DTLS_PACKET_LOSS_TEST */ return len; } + +#endif /* USE_DTLS */ diff --git a/apps/dtls/dtlsCommon.h b/apps/dtls/dtlsCommon.h index 3cbbb54..5a4e57c 100644 --- a/apps/dtls/dtlsCommon.h +++ b/apps/dtls/dtlsCommon.h @@ -34,9 +34,7 @@ #include "matrixssl/matrixsslApi.h" -#ifndef USE_DTLS - #error USE_DTLS must be defined in matrixsslConfig.h -#endif +#ifdef USE_DTLS #include #include @@ -60,7 +58,6 @@ #define MSG_DONTWAIT 0 #endif /* WIN32 */ - #ifdef __cplusplus extern "C" { #endif @@ -116,6 +113,7 @@ extern int32 udpSend(SOCKET s, unsigned char *buf, int len, } #endif +#endif /* USE_DTLS */ #endif /* _h_DTLSCOMMON */ /******************************************************************************/ diff --git a/apps/dtls/dtlsServer.c b/apps/dtls/dtlsServer.c index 0e7ba90..5f39788 100644 --- a/apps/dtls/dtlsServer.c +++ b/apps/dtls/dtlsServer.c @@ -39,6 +39,9 @@ #endif #include "dtlsCommon.h" + +#ifdef USE_DTLS + #include "../../crypto/cryptoApi.h" /* #define USE_CERT_VALIDATOR */ @@ -1265,3 +1268,18 @@ static void closeClientList() psFree(clientTable, NULL); tableSize = 0; } + +#else +/******************************************************************************/ +/* + Stub main for compiling without dtls enabled +*/ +int32 main(int32 argc, char **argv) +{ + printf("USE_DTLS must be enabled in " \ + "matrixsslConfig.h at build time to run this application\n"); + return -1; +} +#endif /* USE_DTLS */ + +/******************************************************************************/