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 
23 /**************************************************************************/
24 /*                                                                        */
25 /*  COMPONENT DEFINITION                                   RELEASE        */
26 /*                                                                        */
27 /*    nx_rarp.h                                           PORTABLE C      */
28 /*                                                           6.1.9        */
29 /*  AUTHOR                                                                */
30 /*                                                                        */
31 /*    Yuxin Zhou, Microsoft Corporation                                   */
32 /*                                                                        */
33 /*  DESCRIPTION                                                           */
34 /*                                                                        */
35 /*    This file defines the NetX Reverse Address Resolution Protocol      */
36 /*    component, including all data types and external references.  It    */
37 /*    is assumed that nx_api.h and nx_port.h have already been included.  */
38 /*                                                                        */
39 /*  RELEASE HISTORY                                                       */
40 /*                                                                        */
41 /*    DATE              NAME                      DESCRIPTION             */
42 /*                                                                        */
43 /*  05-19-2020     Yuxin Zhou               Initial Version 6.0           */
44 /*  09-30-2020     Yuxin Zhou               Modified comment(s),          */
45 /*                                            resulting in version 6.1    */
46 /*  10-15-2021     Yuxin Zhou               Modified comment(s), included */
47 /*                                            necessary header file,      */
48 /*                                            resulting in version 6.1.9  */
49 /*                                                                        */
50 /**************************************************************************/
51 
52 #ifndef NX_RARP_H
53 #define NX_RARP_H
54 
55 #include "nx_api.h"
56 
57 
58 #ifndef NX_DISABLE_IPV4
59 /* Define RARP Message format.  This will get encapsulated by an Ethernet frame
60    as well.  The Ethernet frame will typically have a 6-byte Ethernet destination
61    address, a 6-byte Ethernet source address, and a 2-byte Ethernet Frame type,
62    which is 0x8035.  Regular IP frames have a frame type of 0x0800.
63 
64     Byte offset     Size            Meaning
65 
66         0           2           Hardware type (1 for Ethernet)
67         2           2           Protocol type (0x0800 for IP)
68         4           1           Number of bytes for hardware address (6 for Ethernet)
69         5           1           Number of bytes for IP address (4 for IP)
70         6           2           Operation, ARP request is 1, ARP reply is 2
71         8           6           Sender's Ethernet Address
72         14          4           Sender's IP Address
73         18          6           Target Ethernet Address
74         24          4           Target IP Address
75  */
76 
77 #define NX_RARP_HARDWARE_TYPE   ((ULONG)0x0001)
78 #define NX_RARP_PROTOCOL_TYPE   ((ULONG)0x0800)
79 #define NX_RARP_HARDWARE_SIZE   ((ULONG)0x06)
80 #define NX_RARP_PROTOCOL_SIZE   ((ULONG)0x04)
81 #define NX_RARP_OPTION_REQUEST  ((ULONG)0x0003)
82 #define NX_RARP_OPTION_RESPONSE ((ULONG)0x0004)
83 #define NX_RARP_MESSAGE_SIZE    28
84 
85 /* Define RARP internal function prototypes.  */
86 VOID _nx_rarp_packet_send(NX_IP *ip_ptr);
87 VOID _nx_rarp_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr);
88 VOID _nx_rarp_packet_deferred_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr);
89 VOID _nx_rarp_periodic_update(NX_IP *ip_ptr);
90 VOID _nx_rarp_queue_process(NX_IP *ip_ptr);
91 #endif /* NX_DISABLE_IPV4 */
92 
93 /* Define RARP function prototypes.  */
94 UINT _nx_rarp_enable(NX_IP *ip_ptr);
95 UINT _nx_rarp_disable(NX_IP *ip_ptr);
96 UINT _nx_rarp_info_get(NX_IP *ip_ptr, ULONG *rarp_requests_sent, ULONG *rarp_responses_received,
97                        ULONG *rarp_invalid_messages);
98 
99 /* Define error checking shells for RARP services.  These are only referenced by the
100    application.  */
101 
102 UINT _nxe_rarp_enable(NX_IP *ip_ptr);
103 UINT _nxe_rarp_disable(NX_IP *ip_ptr);
104 UINT _nxe_rarp_info_get(NX_IP *ip_ptr, ULONG *rarp_requests_sent, ULONG *rarp_responses_received,
105                         ULONG *rarp_invalid_messages);
106 #endif
107 
108