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 /* Bring in externs for caller checking code. */ 32 33 NX_CALLER_CHECKING_EXTERNS 34 35 36 /**************************************************************************/ 37 /* */ 38 /* FUNCTION RELEASE */ 39 /* */ 40 /* _nxe_arp_enable PORTABLE C */ 41 /* 6.1 */ 42 /* AUTHOR */ 43 /* */ 44 /* Yuxin Zhou, Microsoft Corporation */ 45 /* */ 46 /* DESCRIPTION */ 47 /* */ 48 /* This function checks for errors in the ARP enable function */ 49 /* call. */ 50 /* */ 51 /* INPUT */ 52 /* */ 53 /* ip_ptr IP instance pointer */ 54 /* arp_cache_memory Start of ARP cache memory */ 55 /* arp_cache_size Size in bytes of cache memory */ 56 /* */ 57 /* OUTPUT */ 58 /* */ 59 /* status Completion status */ 60 /* */ 61 /* CALLS */ 62 /* */ 63 /* _nx_arp_enable Actual ARP enable function */ 64 /* */ 65 /* CALLED BY */ 66 /* */ 67 /* Application Code */ 68 /* */ 69 /* RELEASE HISTORY */ 70 /* */ 71 /* DATE NAME DESCRIPTION */ 72 /* */ 73 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 74 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 75 /* resulting in version 6.1 */ 76 /* */ 77 /**************************************************************************/ _nxe_arp_enable(NX_IP * ip_ptr,VOID * arp_cache_memory,ULONG arp_cache_size)78UINT _nxe_arp_enable(NX_IP *ip_ptr, VOID *arp_cache_memory, ULONG arp_cache_size) 79 { 80 81 #ifndef NX_DISABLE_IPV4 82 UINT status; 83 84 85 /* Check for invalid input pointers. */ 86 if ((ip_ptr == NX_NULL) || (ip_ptr -> nx_ip_id != NX_IP_ID) || (arp_cache_memory == NX_NULL)) 87 { 88 return(NX_PTR_ERROR); 89 } 90 91 /* Check to see if ARP is already enabled. */ 92 if (ip_ptr -> nx_ip_arp_allocate) 93 { 94 return(NX_ALREADY_ENABLED); 95 } 96 97 /* Check for invalid ARP cache size. */ 98 if (arp_cache_size < sizeof(NX_ARP)) 99 { 100 return(NX_SIZE_ERROR); 101 } 102 103 /* Check for appropriate caller. */ 104 NX_INIT_AND_THREADS_CALLER_CHECKING 105 106 /* Call actual ARP enable function. */ 107 status = _nx_arp_enable(ip_ptr, arp_cache_memory, arp_cache_size); 108 109 /* Return completion status. */ 110 return(status); 111 #else /* NX_DISABLE_IPV4 */ 112 NX_PARAMETER_NOT_USED(ip_ptr); 113 NX_PARAMETER_NOT_USED(arp_cache_memory); 114 NX_PARAMETER_NOT_USED(arp_cache_size); 115 116 return(NX_NOT_SUPPORTED); 117 #endif /* !NX_DISABLE_IPV4 */ 118 } 119 120