1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 13 /**************************************************************************/ 14 /**************************************************************************/ 15 /** */ 16 /** NetX Component */ 17 /** */ 18 /** AutoIP (AutoIP) */ 19 /** */ 20 /**************************************************************************/ 21 /**************************************************************************/ 22 23 24 /**************************************************************************/ 25 /* */ 26 /* APPLICATION INTERFACE DEFINITION RELEASE */ 27 /* */ 28 /* nx_auto_ip.h PORTABLE C */ 29 /* 6.1.9 */ 30 /* AUTHOR */ 31 /* */ 32 /* Yuxin Zhou, Microsoft Corporation */ 33 /* */ 34 /* DESCRIPTION */ 35 /* */ 36 /* This file defines the NetX AutoIP Protocol (AutoIP) component, */ 37 /* including all data types and external references. It is assumed */ 38 /* that nx_api.h and nx_port.h have already been included. */ 39 /* */ 40 /* RELEASE HISTORY */ 41 /* */ 42 /* DATE NAME DESCRIPTION */ 43 /* */ 44 /* 05-19-2020 Yuxin Zhou Initial Version 6.0 */ 45 /* 09-30-2020 Yuxin Zhou Modified comment(s), */ 46 /* resulting in version 6.1 */ 47 /* 10-15-2021 Yuxin Zhou Modified comment(s), included */ 48 /* necessary header file, */ 49 /* resulting in version 6.1.9 */ 50 /* */ 51 /**************************************************************************/ 52 53 #ifndef NX_AUTO_IP_H 54 #define NX_AUTO_IP_H 55 56 /* Determine if a C++ compiler is being used. If so, ensure that standard 57 C is used to process the API information. */ 58 59 #ifdef __cplusplus 60 61 /* Yes, C++ compiler is present. Use standard C. */ 62 extern "C" { 63 64 #endif 65 66 #include "nx_api.h" 67 68 69 /* Define the AutoIP ID that is used to mark the AutoIP structure as created. */ 70 71 #define NX_AUTO_IP_ID 0x4155544FUL 72 73 74 /* Define the timing and retry constants for AutoIP. */ 75 76 #ifndef NX_AUTO_IP_PROBE_WAIT 77 #define NX_AUTO_IP_PROBE_WAIT 1 78 #endif 79 80 #ifndef NX_AUTO_IP_PROBE_NUM 81 #define NX_AUTO_IP_PROBE_NUM 3 82 #endif 83 84 #ifndef NX_AUTO_IP_PROBE_MIN 85 #define NX_AUTO_IP_PROBE_MIN 1 86 #endif 87 88 #ifndef NX_AUTO_IP_PROBE_MAX 89 #define NX_AUTO_IP_PROBE_MAX 2 90 #endif 91 92 #ifndef NX_AUTO_IP_MAX_CONFLICTS 93 #define NX_AUTO_IP_MAX_CONFLICTS 10 94 #endif 95 96 #ifndef NX_AUTO_IP_RATE_LIMIT_INTERVAL 97 #define NX_AUTO_IP_RATE_LIMIT_INTERVAL 60 98 #endif 99 100 #ifndef NX_AUTO_IP_ANNOUNCE_WAIT 101 #define NX_AUTO_IP_ANNOUNCE_WAIT 2 102 #endif 103 104 #ifndef NX_AUTO_IP_ANNOUNCE_NUM 105 #define NX_AUTO_IP_ANNOUNCE_NUM 2 106 #endif 107 108 #ifndef NX_AUTO_IP_ANNOUNCE_INTERVAL 109 #define NX_AUTO_IP_ANNOUNCE_INTERVAL 2 110 #endif 111 112 #ifndef NX_AUTO_IP_DEFEND_INTERVAL 113 #define NX_AUTO_IP_DEFEND_INTERVAL 10 114 #endif 115 116 117 /* Define the starting and ending local IP addresses. */ 118 119 #define NX_AUTO_IP_START_ADDRESS IP_ADDRESS(169,254,1,0) 120 #define NX_AUTO_IP_END_ADDRESS IP_ADDRESS(169,254,254,255) 121 122 123 /* Define error codes from AutoIP API. */ 124 125 #define NX_AUTO_IP_ERROR 0xA00 126 #define NX_AUTO_IP_NO_LOCAL 0xA01 127 #define NX_AUTO_IP_BAD_INTERFACE_INDEX 0xA02 128 129 130 /* Define the AutoIP structure that holds all the information necessary for this AutoIP 131 instance. */ 132 133 typedef struct NX_AUTO_IP_STRUCT 134 { 135 ULONG nx_auto_ip_id; 136 CHAR *nx_auto_ip_name; 137 NX_IP *nx_auto_ip_ip_ptr; 138 UINT nx_ip_interface_index; 139 ULONG nx_auto_ip_current_local_address; 140 ULONG nx_auto_ip_restart_flag; 141 ULONG nx_auto_ip_conflict_count; 142 ULONG nx_auto_ip_probe_count; 143 ULONG nx_auto_ip_announce_count; 144 ULONG nx_auto_ip_defend_count; 145 TX_EVENT_FLAGS_GROUP nx_auto_ip_conflict_event; 146 TX_THREAD nx_auto_ip_thread; 147 } NX_AUTO_IP; 148 149 150 #ifndef NX_AUTO_IP_SOURCE_CODE 151 152 /* Application caller is present, perform API mapping. */ 153 154 /* Determine if error checking is desired. If so, map AutoIP API functions 155 to the appropriate error checking front-ends. Otherwise, map API 156 functions to the core functions that actually perform the work. 157 Note: error checking is enabled by default. */ 158 159 #ifdef NX_DISABLE_ERROR_CHECKING 160 161 /* Services without error checking. */ 162 163 #define nx_auto_ip_create _nx_auto_ip_create 164 #define nx_auto_ip_get_address _nx_auto_ip_get_address 165 #define nx_auto_ip_set_interface _nx_auto_ip_set_interface 166 #define nx_auto_ip_start _nx_auto_ip_start 167 #define nx_auto_ip_stop _nx_auto_ip_stop 168 #define nx_auto_ip_delete _nx_auto_ip_delete 169 170 #else 171 172 /* Services with error checking. */ 173 174 #define nx_auto_ip_create _nxe_auto_ip_create 175 #define nx_auto_ip_get_address _nxe_auto_ip_get_address 176 #define nx_auto_ip_set_interface _nxe_auto_ip_set_interface 177 #define nx_auto_ip_start _nxe_auto_ip_start 178 #define nx_auto_ip_stop _nxe_auto_ip_stop 179 #define nx_auto_ip_delete _nxe_auto_ip_delete 180 181 #endif 182 183 /* Define the prototypes accessible to the application software. */ 184 185 UINT nx_auto_ip_create(NX_AUTO_IP *auto_ip_ptr, CHAR *name, NX_IP *ip_ptr, VOID *stack_ptr, ULONG stack_size, UINT priority); 186 UINT nx_auto_ip_get_address(NX_AUTO_IP *auto_ip_ptr, ULONG *local_ip_address); 187 UINT nx_auto_ip_set_interface(NX_AUTO_IP *auto_ip_ptr, UINT interface_index); 188 UINT nx_auto_ip_start(NX_AUTO_IP *auto_ip_ptr, ULONG starting_local_address); 189 UINT nx_auto_ip_stop(NX_AUTO_IP *auto_ip_ptr); 190 UINT nx_auto_ip_delete(NX_AUTO_IP *auto_ip_ptr); 191 192 193 #else 194 195 /* AutoIP source code is being compiled, do not perform any API mapping. */ 196 197 UINT _nxe_auto_ip_create(NX_AUTO_IP *auto_ip_ptr, CHAR *name, NX_IP *ip_ptr, VOID *stack_ptr, ULONG stack_size, UINT priority); 198 UINT _nx_auto_ip_create(NX_AUTO_IP *auto_ip_ptr, CHAR *name, NX_IP *ip_ptr, VOID *stack_ptr, ULONG stack_size, UINT priority); 199 UINT _nxe_auto_ip_get_address(NX_AUTO_IP *auto_ip_ptr, ULONG *local_ip_address); 200 UINT _nx_auto_ip_get_address(NX_AUTO_IP *auto_ip_ptr, ULONG *local_ip_address); 201 UINT _nxe_auto_ip_set_interface(NX_AUTO_IP *auto_ip_ptr, UINT interface_index); 202 UINT _nx_auto_ip_set_interface(NX_AUTO_IP *auto_ip_ptr, UINT interface_index); 203 UINT _nxe_auto_ip_start(NX_AUTO_IP *auto_ip_ptr, ULONG starting_local_address); 204 UINT _nx_auto_ip_start(NX_AUTO_IP *auto_ip_ptr, ULONG starting_local_address); 205 UINT _nxe_auto_ip_stop(NX_AUTO_IP *auto_ip_ptr); 206 UINT _nx_auto_ip_stop(NX_AUTO_IP *auto_ip_ptr); 207 UINT _nxe_auto_ip_delete(NX_AUTO_IP *auto_ip_ptr); 208 UINT _nx_auto_ip_delete(NX_AUTO_IP *auto_ip_ptr); 209 VOID _nx_auto_ip_thread_entry(ULONG auto_ip_address); 210 VOID _nx_auto_ip_conflict(NX_IP *ip_ptr, UINT interface_index, ULONG ip_address, ULONG physical_msw, ULONG physical_lsw); 211 212 #endif 213 214 215 /* Determine if a C++ compiler is being used. If so, complete the standard 216 C conditional started above. */ 217 #ifdef __cplusplus 218 } 219 #endif 220 221 #endif /* NX_AUTO_IP_H */ 222 223