From 418c508eba59de0adf55943b1b3d8f7152fcafbd Mon Sep 17 00:00:00 2001 From: David Garske Date: Wed, 19 Feb 2020 12:28:49 -0800 Subject: [PATCH] Fixes for SCTP example to check build options. --- examples/sctp/sctp-client-dtls.c | 17 +++++++++++------ examples/sctp/sctp-client.c | 10 +++++++++- examples/sctp/sctp-server-dtls.c | 16 ++++++++++------ examples/sctp/sctp-server.c | 9 ++++++++- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/examples/sctp/sctp-client-dtls.c b/examples/sctp/sctp-client-dtls.c index 11e7ee841..c0a222463 100644 --- a/examples/sctp/sctp-client-dtls.c +++ b/examples/sctp/sctp-client-dtls.c @@ -20,6 +20,14 @@ */ +/* wolfssl */ +#ifndef WOLFSSL_USER_SETTINGS + #include +#endif +#include +#include + +#if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS) /* sctp */ #include #include @@ -32,12 +40,6 @@ #include #include -/* wolfssl */ -#include -#include - - - #define cacert "./certs/ca-cert.pem" static int err_sys(const char* msg) @@ -45,9 +47,11 @@ static int err_sys(const char* msg) perror(msg); exit(EXIT_FAILURE); } +#endif /* WOLFSSL_SCTP && WOLFSSL_DTLS */ int main() { +#if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS) int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); if (sd < 0) @@ -120,6 +124,7 @@ int main() wolfSSL_CTX_free(ctx); close(sd); +#endif /* WOLFSSL_SCTP && WOLFSSL_DTLS */ return 0; } diff --git a/examples/sctp/sctp-client.c b/examples/sctp/sctp-client.c index 21d12714b..cb01354d8 100644 --- a/examples/sctp/sctp-client.c +++ b/examples/sctp/sctp-client.c @@ -19,6 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +#ifndef WOLFSSL_USER_SETTINGS + #include +#endif +#include + +#ifdef WOLFSSL_SCTP /* sctp */ #include @@ -30,9 +36,11 @@ #include #include #include +#endif /* WOLFSSL_SCTP */ int main() { +#ifdef WOLFSSL_SCTP int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); if (sd < 0) @@ -59,6 +67,6 @@ int main() } close(sd); - +#endif /* WOLFSSL_SCTP */ return 0; } diff --git a/examples/sctp/sctp-server-dtls.c b/examples/sctp/sctp-server-dtls.c index 1a486a9a3..50a20f241 100644 --- a/examples/sctp/sctp-server-dtls.c +++ b/examples/sctp/sctp-server-dtls.c @@ -19,7 +19,14 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +/* wolfssl */ +#ifndef WOLFSSL_USER_SETTINGS + #include +#endif +#include +#include +#if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS) /* sctp */ #include #include @@ -31,11 +38,6 @@ #include #include -/* wolfssl */ -#include -#include - - #define key "./certs/server-key.pem" #define cert "./certs/server-cert.pem" @@ -45,9 +47,11 @@ static int err_sys(const char* msg) perror(msg); exit(EXIT_FAILURE); } +#endif /* WOLFSSL_SCTP && WOLFSSL_DTLS */ int main() { +#if defined(WOLFSSL_SCTP) && defined(WOLFSSL_DTLS) int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); if (sd < 0) @@ -119,6 +123,6 @@ int main() wolfSSL_CTX_free(ctx); close(sd); - +#endif /* WOLFSSL_SCTP && WOLFSSL_DTLS */ return 0; } diff --git a/examples/sctp/sctp-server.c b/examples/sctp/sctp-server.c index ac372f1d7..34b02c9ce 100644 --- a/examples/sctp/sctp-server.c +++ b/examples/sctp/sctp-server.c @@ -19,7 +19,12 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA */ +#ifndef WOLFSSL_USER_SETTINGS + #include +#endif +#include +#ifdef WOLFSSL_SCTP /* sctp */ #include #include @@ -29,9 +34,11 @@ #include #include #include +#endif /* WOLFSSL_SCTP */ int main() { +#ifdef WOLFSSL_SCTP int sd = socket(PF_INET, SOCK_STREAM, IPPROTO_SCTP); if (sd < 0) @@ -65,6 +72,6 @@ int main() close(sd); - +#endif /* WOLFSSL_SCTP */ return 0; }