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 /** Address Resolution Protocol (ARP) */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 23 /**************************************************************************/ 24 /* */ 25 /* COMPONENT DEFINITION RELEASE */ 26 /* */ 27 /* nx_arp.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 Address Resolution Protocol component, */ 36 /* including all data types and external references. It is assumed */ 37 /* 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_ARP_H 53 #define NX_ARP_H 54 55 #include "nx_api.h" 56 57 58 #ifndef NX_DISABLE_IPV4 59 /* Define ARP 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 0x0806. 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_ARP_HARDWARE_TYPE ((ULONG)0x0001) 78 #define NX_ARP_PROTOCOL_TYPE ((ULONG)0x0800) 79 #define NX_ARP_HARDWARE_SIZE ((ULONG)0x06) 80 #define NX_ARP_PROTOCOL_SIZE ((ULONG)0x04) 81 #define NX_ARP_OPTION_REQUEST ((ULONG)0x0001) 82 #define NX_ARP_OPTION_RESPONSE ((ULONG)0x0002) 83 #define NX_ARP_MESSAGE_SIZE 28 84 85 86 /* Define the ARP defend interval. The default value is 10 seconds. */ 87 #ifndef NX_ARP_DEFEND_INTERVAL 88 89 #define NX_ARP_DEFEND_INTERVAL 10 90 91 #endif /* NX_ARP_DEFEND_INTERVAL */ 92 93 /* Define ARP internal function prototypes. */ 94 VOID _nx_arp_initialize(VOID); 95 UINT _nx_arp_dynamic_entry_delete(NX_IP *ip_ptr, NX_ARP *arp_ptr); 96 VOID _nx_arp_static_entry_delete_internal(NX_IP *ip_ptr, NX_ARP *arp_entry); 97 VOID _nx_arp_queue_process(NX_IP *ip_ptr); 98 VOID _nx_arp_queue_send(NX_IP *ip_ptr, NX_ARP *arp_ptr); 99 UINT _nx_arp_entry_allocate(NX_IP *ip_ptr, NX_ARP **arp_ptr, UINT is_static); 100 /*lint -sem(_nx_arp_packet_send, 3p) nx_interface must not be NULL. */ 101 VOID _nx_arp_packet_send(NX_IP *ip_ptr, ULONG destination_ip, NX_INTERFACE *nx_interface); 102 VOID _nx_arp_packet_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr); 103 VOID _nx_arp_packet_deferred_receive(NX_IP *ip_ptr, NX_PACKET *packet_ptr); 104 VOID _nx_arp_periodic_update(NX_IP *ip_ptr); 105 UINT _nx_arp_interface_entries_delete(NX_IP *ip_ptr, UINT index); 106 107 #endif /* NX_DISABLE_IPV4 */ 108 109 /* Define ARP function prototypes. */ 110 111 UINT _nx_arp_dynamic_entries_invalidate(NX_IP *ip_ptr); 112 UINT _nx_arp_dynamic_entry_set(NX_IP *ip_ptr, ULONG ip_address, ULONG physical_msw, ULONG physical_lsw); 113 UINT _nx_arp_enable(NX_IP *ip_ptr, VOID *arp_cache_memory, ULONG arp_cache_size); 114 UINT _nx_arp_entry_delete(NX_IP *ip_ptr, ULONG ip_address); 115 UINT _nx_arp_gratuitous_send(NX_IP *ip_ptr, VOID (*response_handler)(NX_IP *ip_ptr, NX_PACKET *packet_ptr)); 116 UINT _nx_arp_hardware_address_find(NX_IP *ip_ptr, ULONG ip_address, ULONG *physical_msw, ULONG *physical_lsw); 117 UINT _nx_arp_info_get(NX_IP *ip_ptr, ULONG *arp_requests_sent, ULONG *arp_requests_received, 118 ULONG *arp_responses_sent, ULONG *arp_responses_received, 119 ULONG *arp_dynamic_entries, ULONG *arp_static_entries, 120 ULONG *arp_aged_entries, ULONG *arp_invalid_messages); 121 UINT _nx_arp_ip_address_find(NX_IP *ip_ptr, ULONG *ip_address, ULONG physical_msw, ULONG physical_lsw); 122 UINT _nx_arp_static_entries_delete(NX_IP *ip_ptr); 123 UINT _nx_arp_static_entry_create(NX_IP *ip_ptr, ULONG ip_address, ULONG physical_msw, ULONG physical_lsw); 124 UINT _nx_arp_static_entry_delete(NX_IP *ip_ptr, ULONG ip_address, ULONG physical_msw, ULONG physical_lsw); 125 UINT _nx_arp_probe_send(NX_IP *ip_ptr, UINT interface_index, ULONG probe_address); 126 UINT _nx_arp_announce_send(NX_IP *ip_ptr, UINT interface_index); 127 128 /* Define error checking shells for ARP services. These are only referenced by the 129 application. */ 130 131 UINT _nxe_arp_dynamic_entries_invalidate(NX_IP *ip_ptr); 132 UINT _nxe_arp_dynamic_entry_set(NX_IP *ip_ptr, ULONG ip_address, ULONG physical_msw, ULONG physical_lsw); 133 UINT _nxe_arp_enable(NX_IP *ip_ptr, VOID *arp_cache_memory, ULONG arp_cache_size); 134 UINT _nxe_arp_entry_delete(NX_IP *ip_ptr, ULONG ip_address); 135 UINT _nxe_arp_gratuitous_send(NX_IP *ip_ptr, VOID (*response_handler)(NX_IP *ip_ptr, NX_PACKET *packet_ptr)); 136 UINT _nxe_arp_hardware_address_find(NX_IP *ip_ptr, ULONG ip_address, ULONG *physical_msw, ULONG *physical_lsw); 137 UINT _nxe_arp_info_get(NX_IP *ip_ptr, ULONG *arp_requests_sent, ULONG *arp_requests_received, 138 ULONG *arp_responses_sent, ULONG *arp_responses_received, 139 ULONG *arp_dynamic_entries, ULONG *arp_static_entries, 140 ULONG *arp_aged_entries, ULONG *arp_invalid_messages); 141 UINT _nxe_arp_ip_address_find(NX_IP *ip_ptr, ULONG *ip_address, ULONG physical_msw, ULONG physical_lsw); 142 UINT _nxe_arp_static_entries_delete(NX_IP *ip_ptr); 143 UINT _nxe_arp_static_entry_create(NX_IP *ip_ptr, ULONG ip_address, ULONG physical_msw, ULONG physical_lsw); 144 UINT _nxe_arp_static_entry_delete(NX_IP *ip_ptr, ULONG ip_address, ULONG physical_msw, ULONG physical_lsw); 145 #endif 146 147