1 /*************************************************************************** 2 * Copyright (c) 2024 Microsoft Corporation 3 * 4 * This program and the accompanying materials are made available under the 5 * terms of the MIT License which is available at 6 * https://opensource.org/licenses/MIT. 7 * 8 * SPDX-License-Identifier: MIT 9 **************************************************************************/ 10 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** NetX Secure Component */ 16 /** */ 17 /** Datagram Transport Layer Security (DTLS) */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define NX_SECURE_SOURCE_CODE 23 24 #include "nx_secure_dtls.h" 25 26 /**************************************************************************/ 27 /* */ 28 /* FUNCTION RELEASE */ 29 /* */ 30 /* _nxe_secure_dtls_server_delete PORTABLE C */ 31 /* 6.1 */ 32 /* AUTHOR */ 33 /* */ 34 /* Timothy Stapko, Microsoft Corporation */ 35 /* */ 36 /* DESCRIPTION */ 37 /* */ 38 /* This function checks for errors when deleting a DTLS server. */ 39 /* */ 40 /* INPUT */ 41 /* */ 42 /* server_ptr DTLS server control block */ 43 /* */ 44 /* OUTPUT */ 45 /* */ 46 /* status Completion status */ 47 /* */ 48 /* CALLS */ 49 /* */ 50 /* _nx_secure_dtls_server_delete Actual function call */ 51 /* */ 52 /* CALLED BY */ 53 /* */ 54 /* Application Code */ 55 /* */ 56 /* RELEASE HISTORY */ 57 /* */ 58 /* DATE NAME DESCRIPTION */ 59 /* */ 60 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 61 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 62 /* resulting in version 6.1 */ 63 /* */ 64 /**************************************************************************/ _nxe_secure_dtls_server_delete(NX_SECURE_DTLS_SERVER * server_ptr)65UINT _nxe_secure_dtls_server_delete(NX_SECURE_DTLS_SERVER *server_ptr) 66 { 67 #ifdef NX_SECURE_ENABLE_DTLS 68 UINT status = NX_SUCCESS; 69 NX_SECURE_DTLS_SERVER *temp_server; 70 71 /* Check pointer */ 72 if(server_ptr == NX_NULL) 73 { 74 return(NX_PTR_ERROR); 75 } 76 77 temp_server = _nx_secure_dtls_server_created_ptr; 78 for (;;) 79 { 80 if (temp_server == NX_NULL) 81 { 82 83 /* No session created. */ 84 return(NX_PTR_ERROR); 85 } 86 87 if (temp_server == server_ptr) 88 { 89 90 /* Found the server to delete. */ 91 break; 92 } 93 94 temp_server = temp_server -> nx_dtls_server_created_next; 95 96 if (temp_server == _nx_secure_dtls_server_created_ptr) 97 { 98 99 /* This server is not created. */ 100 return(NX_PTR_ERROR); 101 } 102 } 103 104 /* Call actual function. */ 105 status = _nx_secure_dtls_server_delete(server_ptr); 106 107 return(status); 108 #else 109 NX_PARAMETER_NOT_USED(server_ptr); 110 111 return(NX_NOT_SUPPORTED); 112 #endif /* NX_SECURE_ENABLE_DTLS */ 113 } 114 115