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 #define NX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "nx_api.h" 28 #include "nx_ip.h" 29 #include "nx_arp.h" 30 31 32 /* Bring in externs for caller checking code. */ 33 34 NX_CALLER_CHECKING_EXTERNS 35 36 37 /**************************************************************************/ 38 /* */ 39 /* FUNCTION RELEASE */ 40 /* */ 41 /* _nxe_arp_gratuitous_send PORTABLE C */ 42 /* 6.1 */ 43 /* AUTHOR */ 44 /* */ 45 /* Yuxin Zhou, Microsoft Corporation */ 46 /* */ 47 /* DESCRIPTION */ 48 /* */ 49 /* This function checks for errors in the Gratuitous ARP send */ 50 /* function call. */ 51 /* */ 52 /* INPUT */ 53 /* */ 54 /* ip_ptr IP instance pointer */ 55 /* response_handler Pointer to function to handle */ 56 /* Gratuitous ARP response */ 57 /* */ 58 /* OUTPUT */ 59 /* */ 60 /* status Completion status */ 61 /* */ 62 /* CALLS */ 63 /* */ 64 /* _nx_arp_gratuitous_send Send Gratuitous ARP */ 65 /* */ 66 /* CALLED BY */ 67 /* */ 68 /* Application Code */ 69 /* */ 70 /* RELEASE HISTORY */ 71 /* */ 72 /* DATE NAME DESCRIPTION */ 73 /* */ 74 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 75 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 76 /* resulting in version 6.1 */ 77 /* */ 78 /**************************************************************************/ _nxe_arp_gratuitous_send(NX_IP * ip_ptr,VOID (* response_handler)(NX_IP * ip_ptr,NX_PACKET * packet_ptr))79UINT _nxe_arp_gratuitous_send(NX_IP *ip_ptr, VOID (*response_handler)(NX_IP *ip_ptr, NX_PACKET *packet_ptr)) 80 { 81 82 #ifndef NX_DISABLE_IPV4 83 UINT status; 84 UINT i; 85 86 87 /* Check for invalid input pointers. */ 88 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID)) 89 { 90 return(NX_PTR_ERROR); 91 } 92 93 /* Check for invalid IP address. */ 94 for (i = 0; i < NX_MAX_PHYSICAL_INTERFACES; i++) 95 { 96 if (ip_ptr -> nx_ip_interface[i].nx_interface_ip_address) 97 { 98 break; 99 } 100 } 101 102 if (i == NX_MAX_PHYSICAL_INTERFACES) 103 { 104 return(NX_IP_ADDRESS_ERROR); 105 } 106 107 /* Check to see if ARP is enabled. */ 108 if (!ip_ptr -> nx_ip_arp_allocate) 109 { 110 return(NX_NOT_ENABLED); 111 } 112 113 /* Check for appropriate caller. */ 114 NX_THREADS_ONLY_CALLER_CHECKING 115 116 /* Call actual Gratuitous ARP send function. */ 117 status = _nx_arp_gratuitous_send(ip_ptr, response_handler); 118 119 /* Return completion status. */ 120 return(status); 121 #else /* NX_DISABLE_IPV4 */ 122 NX_PARAMETER_NOT_USED(ip_ptr); 123 NX_PARAMETER_NOT_USED(response_handler); 124 125 return(NX_NOT_SUPPORTED); 126 #endif /* !NX_DISABLE_IPV4 */ 127 } 128 129