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_queue_process PORTABLE C */ 37 /* 6.1 */ 38 /* AUTHOR */ 39 /* */ 40 /* Yuxin Zhou, Microsoft Corporation */ 41 /* */ 42 /* DESCRIPTION */ 43 /* */ 44 /* This function processes the TCP receive packet queue. */ 45 /* */ 46 /* INPUT */ 47 /* */ 48 /* ip_ptr Pointer to IP control block */ 49 /* */ 50 /* OUTPUT */ 51 /* */ 52 /* None */ 53 /* */ 54 /* CALLS */ 55 /* */ 56 /* _nx_tcp_packet_process Process TCP packet */ 57 /* */ 58 /* CALLED BY */ 59 /* */ 60 /* _nx_ip_thread_entry IP helper thread processing */ 61 /* */ 62 /* RELEASE HISTORY */ 63 /* */ 64 /* DATE NAME DESCRIPTION */ 65 /* */ 66 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 67 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 68 /* resulting in version 6.1 */ 69 /* */ 70 /**************************************************************************/ _nx_tcp_queue_process(NX_IP * ip_ptr)71VOID _nx_tcp_queue_process(NX_IP *ip_ptr) 72 { 73 74 TX_INTERRUPT_SAVE_AREA 75 76 NX_PACKET *queue_head; 77 NX_PACKET *packet_ptr; 78 79 80 /* Disable interrupts. */ 81 TX_DISABLE 82 83 /* Remove the TCP message queue from the IP structure. */ 84 queue_head = ip_ptr -> nx_ip_tcp_queue_head; 85 ip_ptr -> nx_ip_tcp_queue_head = NX_NULL; 86 ip_ptr -> nx_ip_tcp_queue_tail = NX_NULL; 87 ip_ptr -> nx_ip_tcp_received_packet_count = 0; 88 89 /* Restore interrupts. */ 90 TX_RESTORE 91 92 /* Walk through the entire TCP message queue and process packets 93 one by one. */ 94 while (queue_head) 95 { 96 97 /* Pickup the first queue TCP message and remove it from the 98 TCP queue. */ 99 packet_ptr = queue_head; 100 queue_head = queue_head -> nx_packet_queue_next; 101 packet_ptr -> nx_packet_queue_next = NX_NULL; 102 103 /* Add debug information. */ 104 NX_PACKET_DEBUG(__FILE__, __LINE__, packet_ptr); 105 106 /* Process the packet. */ 107 _nx_tcp_packet_process(ip_ptr, packet_ptr); 108 } 109 } 110 111