1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** NetX Component */ 17 /** */ 18 /** Transmission Control Protocol (TCP) */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 #define NX_SOURCE_CODE 24 25 26 /* Include necessary system files. */ 27 28 #include "nx_api.h" 29 #include "nx_tcp.h" 30 31 32 /**************************************************************************/ 33 /* */ 34 /* FUNCTION RELEASE */ 35 /* */ 36 /* _nx_tcp_socket_queue_depth_notify_set PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Yuxin Zhou, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function sets the transmit queue depth update callback to the */ 45 /* function specified by the application, which is called whenever */ 46 /* the specified socket determines that it has released packets from */ 47 /* the transmit queue such that the queue depth is no longer exceeded. */ 48 /* */ 49 /* If a NULL pointer is supplied, the queue depth notify function is */ 50 /* disabled. */ 51 /* */ 52 /* INPUT */ 53 /* */ 54 /* socket_ptr Pointer to TCP socket */ 55 /* tcp_queue_depth_notify Routine to call when NetX */ 56 /* queue depth decreases below */ 57 /* the maximum transmit depth */ 58 /* */ 59 /* OUTPUT */ 60 /* */ 61 /* status Completion status */ 62 /* */ 63 /* CALLS */ 64 /* */ 65 /* None */ 66 /* */ 67 /* CALLED BY */ 68 /* */ 69 /* Application Code */ 70 /* */ 71 /* RELEASE HISTORY */ 72 /* */ 73 /* DATE NAME DESCRIPTION */ 74 /* */ 75 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 76 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 77 /* resulting in version 6.1 */ 78 /* */ 79 /**************************************************************************/ _nx_tcp_socket_queue_depth_notify_set(NX_TCP_SOCKET * socket_ptr,VOID (* tcp_socket_queue_depth_notify)(NX_TCP_SOCKET * socket_ptr))80UINT _nx_tcp_socket_queue_depth_notify_set(NX_TCP_SOCKET *socket_ptr, VOID (*tcp_socket_queue_depth_notify)(NX_TCP_SOCKET *socket_ptr)) 81 { 82 #ifdef NX_ENABLE_TCP_QUEUE_DEPTH_UPDATE_NOTIFY 83 TX_INTERRUPT_SAVE_AREA 84 85 /* Get mutex protection. */ 86 tx_mutex_get(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection), TX_WAIT_FOREVER); 87 88 /* Disable interrupts. */ 89 TX_DISABLE 90 91 /* Setup the receive notify function pointer. */ 92 socket_ptr -> nx_tcp_socket_queue_depth_notify = tcp_socket_queue_depth_notify; 93 94 /* Restore interrupts. */ 95 TX_RESTORE 96 97 /* Release protection. */ 98 tx_mutex_put(&(socket_ptr -> nx_tcp_socket_ip_ptr -> nx_ip_protection)); 99 100 /* Return successful completion. */ 101 return(NX_SUCCESS); 102 103 #else /* !NX_ENABLE_TCP_QUEUE_DEPTH_UPDATE_NOTIFY */ 104 NX_PARAMETER_NOT_USED(socket_ptr); 105 NX_PARAMETER_NOT_USED(tcp_socket_queue_depth_notify); 106 107 return(NX_NOT_SUPPORTED); 108 109 #endif /* NX_ENABLE_TCP_QUEUE_DEPTH_UPDATE_NOTIFY */ 110 } 111 112