util.h
1 /* util.h
2  *
3  * Copyright (C) 2006-2020 wolfSSL Inc.
4  *
5  * This file is part of wolfSSL.
6  *
7  * wolfSSL is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * wolfSSL is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1335, USA
20  */
21 
22 #ifndef _UTIL_H_
23 #define _UTIL_H_
24 #include "common/user_settings.h"
25 #include <wolfssl/ssl.h>
26 #include "FreeRTOS_IP.h"
27 #include <stdio.h>
28 
29 static void util_Cleanup(xSocket_t xSock, WOLFSSL_CTX *ctx, WOLFSSL *ssl) {
30  printf("Cleaning up socket and wolfSSL objects.\n");
31  if (xSock != NULL)
32  FreeRTOS_closesocket(xSock);
33  if (ssl != NULL)
34  wolfSSL_free(ssl);
35  if (ctx != NULL)
36  wolfSSL_CTX_free(ctx);
38 }
39 
40 static inline void util_inf_loop(xSocket_t xClientSocket, WOLFSSL_CTX *ctx,
41  WOLFSSL *ssl) {
42  util_Cleanup(xClientSocket, ctx, ssl);
43  printf("Reached infinite loop.\n");
44  while (1)
45  ;
46 }
47 
48 #endif /* _UTIL_H */
Header file containing key wolfSSL API.
Definition: internal.h:2595
WOLFSSL_API void wolfSSL_free(WOLFSSL *)
This function frees an allocated wolfSSL object.
Definition: ssl.c:557
WOLFSSL_API int wolfSSL_Cleanup(void)
Un-initializes the wolfSSL library from further use. Doesn’t have to be called, though it will free ...
Definition: ssl.c:12129
WOLFSSL_API void wolfSSL_CTX_free(WOLFSSL_CTX *)
This function frees an allocated WOLFSSL_CTX object. This function decrements the CTX reference count...
Definition: ssl.c:446
Definition: internal.h:3849