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 Component */ 16 /** */ 17 /** Transmission Control Protocol (TCP) */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define NX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "nx_api.h" 28 #include "nx_tcp.h" 29 30 31 /**************************************************************************/ 32 /* */ 33 /* FUNCTION RELEASE */ 34 /* */ 35 /* _nx_tcp_socket_timed_wait_callback PORTABLE C */ 36 /* 6.1 */ 37 /* AUTHOR */ 38 /* */ 39 /* Yuxin Zhou, Microsoft Corporation */ 40 /* */ 41 /* DESCRIPTION */ 42 /* */ 43 /* This function sets the timed wait callback function pointer */ 44 /* to the function specified by the application, which is called when */ 45 /* it is time to start the timed wait state before a socket can be set */ 46 /* to the closed or listen state. */ 47 /* */ 48 /* INPUT */ 49 /* */ 50 /* socket_ptr Pointer to TCP socket */ 51 /* tcp_timed_wait_callback Routine to call to start */ 52 /* timed wait before close */ 53 /* */ 54 /* OUTPUT */ 55 /* */ 56 /* status Completion status */ 57 /* */ 58 /* CALLS */ 59 /* */ 60 /* None */ 61 /* */ 62 /* CALLED BY */ 63 /* */ 64 /* Application Code */ 65 /* */ 66 /* RELEASE HISTORY */ 67 /* */ 68 /* DATE NAME DESCRIPTION */ 69 /* */ 70 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 71 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 72 /* resulting in version 6.1 */ 73 /* */ 74 /**************************************************************************/ _nx_tcp_socket_timed_wait_callback(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_timed_wait_callback)(NX_TCP_SOCKET * socket_ptr))75UINT _nx_tcp_socket_timed_wait_callback(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_timed_wait_callback)(NX_TCP_SOCKET *socket_ptr)) 76 { 77 #ifndef NX_DISABLE_EXTENDED_NOTIFY_SUPPORT 78 79 TX_INTERRUPT_SAVE_AREA 80 81 /* Get mutex protection. */ 82 tx_mutex_get(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER); 83 84 /* Disable interrupts. */ 85 TX_DISABLE 86 87 /* Setup the establish notify function pointer. */ 88 socket_ptr -> nx_tcp_timed_wait_callback = tcp_timed_wait_callback; 89 90 /* Restore interrupts. */ 91 TX_RESTORE 92 93 /* Release protection. */ 94 tx_mutex_put(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection)); 95 96 /* Return successful completion. */ 97 return(NX_SUCCESS); 98 99 #else /* !NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */ 100 NX_PARAMETER_NOT_USED(socket_ptr); 101 NX_PARAMETER_NOT_USED(tcp_timed_wait_callback); 102 103 return(NX_NOT_SUPPORTED); 104 105 #endif /* NX_DISABLE_EXTENDED_NOTIFY_SUPPORT */ 106 } 107 108