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