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 /* _nx_secure_dtls_server_stop PORTABLE C */ 31 /* 6.1 */ 32 /* AUTHOR */ 33 /* */ 34 /* Timothy Stapko, Microsoft Corporation */ 35 /* */ 36 /* DESCRIPTION */ 37 /* */ 38 /* This function stops a DTLS server from processing incoming UDP */ 39 /* datagrams and resets the state of all associated DTLS sessions. To */ 40 /* free up resources, see nx_secure_dtls_server_delete. */ 41 /* */ 42 /* INPUT */ 43 /* */ 44 /* server_ptr DTLS server control block */ 45 /* */ 46 /* OUTPUT */ 47 /* */ 48 /* status Completion status */ 49 /* */ 50 /* CALLS */ 51 /* */ 52 /* nx_udp_socket_receive_notify Reset receive notify function */ 53 /* _nx_secure_dtls_session_reset Reset internal DTLS sessions */ 54 /* */ 55 /* CALLED BY */ 56 /* */ 57 /* Application Code */ 58 /* */ 59 /* RELEASE HISTORY */ 60 /* */ 61 /* DATE NAME DESCRIPTION */ 62 /* */ 63 /* 05-19-2020 Timothy Stapko Initial Version 6.0 */ 64 /* 09-30-2020 Timothy Stapko Modified comment(s), */ 65 /* resulting in version 6.1 */ 66 /* */ 67 /**************************************************************************/ _nx_secure_dtls_server_stop(NX_SECURE_DTLS_SERVER * server_ptr)68UINT _nx_secure_dtls_server_stop(NX_SECURE_DTLS_SERVER *server_ptr) 69 { 70 #ifdef NX_SECURE_ENABLE_DTLS 71 UINT i; 72 UINT status; 73 74 /* Setup the UDP socket with our internal receive callback. */ 75 nx_udp_socket_receive_notify(&(server_ptr->nx_dtls_server_udp_socket), NX_NULL); 76 77 /* Reset all DTLS sessions. This clears any active sessions and allows the 78 server to be re-used. */ 79 for(i = 0; i < server_ptr->nx_dtls_server_sessions_count; ++i) 80 { 81 _nx_secure_dtls_session_reset(&(server_ptr->nx_dtls_server_sessions[i])); 82 } 83 84 /* Unbind the UDP socket. */ 85 status = nx_udp_socket_unbind(&(server_ptr -> nx_dtls_server_udp_socket)); 86 if (status) 87 { 88 return(status); 89 } 90 91 return(NX_SUCCESS); 92 #else 93 NX_PARAMETER_NOT_USED(server_ptr); 94 95 return(NX_NOT_SUPPORTED); 96 #endif /* NX_SECURE_ENABLE_DTLS */ 97 } 98 99