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 /**   Reverse Address Resolution Protocol (RARP)                          */
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_rarp.h"
29 
30 #ifndef NX_DISABLE_IPV4
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _nx_rarp_queue_process                              PORTABLE C      */
36 /*                                                           6.1          */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Yuxin Zhou, Microsoft Corporation                                   */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function processes the received RARP messages on the RARP      */
44 /*    queue placed there by nx_rarp_deferred_receive.                     */
45 /*                                                                        */
46 /*  INPUT                                                                 */
47 /*                                                                        */
48 /*    ip_ptr                                Pointer to IP instance        */
49 /*                                                                        */
50 /*  OUTPUT                                                                */
51 /*                                                                        */
52 /*    None                                                                */
53 /*                                                                        */
54 /*  CALLS                                                                 */
55 /*                                                                        */
56 /*    _nx_rarp_packet_receive               Process received RARP packet  */
57 /*                                                                        */
58 /*  CALLED BY                                                             */
59 /*                                                                        */
60 /*    _nx_ip_thread_entry                   IP helper thread              */
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_rarp_queue_process(NX_IP * ip_ptr)71 VOID  _nx_rarp_queue_process(NX_IP *ip_ptr)
72 {
73 
74 TX_INTERRUPT_SAVE_AREA
75 
76 NX_PACKET *packet_ptr;
77 
78 
79     /* Loop to process all RARP deferred packet requests.  */
80     while (ip_ptr -> nx_ip_rarp_deferred_received_packet_head)
81     {
82 
83         /* Remove the first packet and process it!  */
84 
85         /* Disable interrupts.  */
86         TX_DISABLE
87 
88         /* Pickup the first packet.  */
89         packet_ptr =  ip_ptr -> nx_ip_rarp_deferred_received_packet_head;
90 
91         /* Move the head pointer to the next packet.  */
92         ip_ptr -> nx_ip_rarp_deferred_received_packet_head =  packet_ptr -> nx_packet_queue_next;
93 
94         /* Check for end of RARP deferred processing queue.  */
95         if (ip_ptr -> nx_ip_rarp_deferred_received_packet_head == NX_NULL)
96         {
97 
98             /* Yes, the RARP deferred queue is empty.  Set the tail pointer to NULL.  */
99             ip_ptr -> nx_ip_rarp_deferred_received_packet_tail =  NX_NULL;
100         }
101 
102         /* Restore interrupts.  */
103         TX_RESTORE
104 
105         /* Call the actual RARP packet receive function.  */
106         _nx_rarp_packet_receive(ip_ptr, packet_ptr);
107     }
108 }
109 #endif /* !NX_DISABLE_IPV4  */
110 
111