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_ip.h" 30 #include "nx_packet.h" 31 #include "nx_tcp.h" 32 33 34 /**************************************************************************/ 35 /* */ 36 /* FUNCTION RELEASE */ 37 /* */ 38 /* _nx_tcp_socket_receive_queue_flush PORTABLE C */ 39 /* 6.1 */ 40 /* AUTHOR */ 41 /* */ 42 /* Yuxin Zhou, Microsoft Corporation */ 43 /* */ 44 /* DESCRIPTION */ 45 /* */ 46 /* This function releases all packets in the specified socket's */ 47 /* receive queue. */ 48 /* */ 49 /* INPUT */ 50 /* */ 51 /* socket_ptr Pointer to socket */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* None */ 56 /* */ 57 /* CALLS */ 58 /* */ 59 /* _nx_packet_release Release a packet */ 60 /* */ 61 /* CALLED BY */ 62 /* */ 63 /* _nx_tcp_socket_connection_reset Socket connection reset */ 64 /* processing */ 65 /* _nx_tcp_server_socket_unaccept Server socket unaccept */ 66 /* processing */ 67 /* */ 68 /* RELEASE HISTORY */ 69 /* */ 70 /* DATE NAME DESCRIPTION */ 71 /* */ 72 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 73 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 74 /* resulting in version 6.1 */ 75 /* */ 76 /**************************************************************************/ _nx_tcp_socket_receive_queue_flush(NX_TCP_SOCKET * socket_ptr)77VOID _nx_tcp_socket_receive_queue_flush(NX_TCP_SOCKET *socket_ptr) 78 { 79 80 NX_PACKET *packet_ptr; 81 NX_PACKET *next_packet_ptr; 82 83 84 /* Setup packet pointer. */ 85 packet_ptr = socket_ptr -> nx_tcp_socket_receive_queue_head; 86 87 /* Clear the head and the tail pointers. */ 88 socket_ptr -> nx_tcp_socket_receive_queue_head = NX_NULL; 89 socket_ptr -> nx_tcp_socket_receive_queue_tail = NX_NULL; 90 91 /* Loop to clear all the packets out. */ 92 while (socket_ptr -> nx_tcp_socket_receive_queue_count) 93 { 94 95 /* Pickup the next queued packet. */ 96 next_packet_ptr = packet_ptr -> nx_packet_union_next.nx_packet_tcp_queue_next; 97 98 /* Mark it as allocated so it will be released. */ 99 /*lint -e{923} suppress cast of ULONT to pointer. */ 100 packet_ptr -> nx_packet_union_next.nx_packet_tcp_queue_next = (NX_PACKET *)NX_PACKET_ALLOCATED; 101 102 /* Release the packet. */ 103 _nx_packet_release(packet_ptr); 104 105 /* Move to the next packet. */ 106 packet_ptr = next_packet_ptr; 107 108 /* Decrease the queued packet count. */ 109 socket_ptr -> nx_tcp_socket_receive_queue_count--; 110 } 111 } 112 113