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 /** USBX Component                                                        */
16 /**                                                                       */
17 /**   RNDIS Class                                                         */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 /**************************************************************************/
23 /*                                                                        */
24 /*  COMPONENT DEFINITION                                   RELEASE        */
25 /*                                                                        */
26 /*    ux_device_class_rndis.h                             PORTABLE C      */
27 /*                                                           6.2.0        */
28 /*  AUTHOR                                                                */
29 /*                                                                        */
30 /*    Chaoqiong Xiao, Microsoft Corporation                               */
31 /*                                                                        */
32 /*  DESCRIPTION                                                           */
33 /*                                                                        */
34 /*    This file defines the equivalences for the USBX Device Class RNDIS  */
35 /*    component.                                                          */
36 /*                                                                        */
37 /*  RELEASE HISTORY                                                       */
38 /*                                                                        */
39 /*    DATE              NAME                      DESCRIPTION             */
40 /*                                                                        */
41 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
42 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
43 /*                                            used UX prefix to refer to  */
44 /*                                            TX symbols instead of using */
45 /*                                            them directly,              */
46 /*                                            resulting in version 6.1    */
47 /*  08-02-2021     Wen Wang                 Modified comment(s),          */
48 /*                                            fixed spelling error,       */
49 /*                                            added extern "C" keyword    */
50 /*                                            for compatibility with C++, */
51 /*                                            resulting in version 6.1.8  */
52 /*  04-25-2022     Chaoqiong Xiao           Modified comment(s),          */
53 /*                                            fixed standalone compile,   */
54 /*                                            resulting in version 6.1.11 */
55 /*  10-31-2022     Chaoqiong Xiao           Modified comment(s),          */
56 /*                                            added wait and length DEFs, */
57 /*                                            resulting in version 6.2.0  */
58 /*                                                                        */
59 /**************************************************************************/
60 
61 #ifndef UX_DEVICE_CLASS_RNDIS_H
62 #define UX_DEVICE_CLASS_RNDIS_H
63 
64 /* Determine if a C++ compiler is being used.  If so, ensure that standard
65    C is used to process the API information.  */
66 
67 #ifdef   __cplusplus
68 
69 /* Yes, C++ compiler is present.  Use standard C.  */
70 extern   "C" {
71 
72 #endif
73 
74 #if !defined(UX_DEVICE_STANDALONE)
75 #include "nx_api.h"
76 #include "ux_network_driver.h"
77 #else
78 
79 /* Assume NX definitions for compiling.  */
80 #define NX_PACKET                                               VOID*
81 #define NX_IP                                                   VOID*
82 /*
83 UINT  _ux_network_driver_deactivate(VOID *ux_instance, VOID *ux_network_handle);
84 VOID  _ux_network_driver_link_up(VOID *ux_network_handle);
85 VOID  _ux_network_driver_link_down(VOID *ux_network_handle);
86 */
87 #ifndef _ux_network_driver_deactivate
88 #define _ux_network_driver_deactivate(a,b)                      do {} while(0)
89 #endif
90 #ifndef _ux_network_driver_link_up
91 #define _ux_network_driver_link_up(a)                           do {} while(0)
92 #endif
93 #ifndef _ux_network_driver_link_down
94 #define _ux_network_driver_link_down(a)                         do {} while(0)
95 #endif
96 #endif
97 
98 /* Define generic RNDIS equivalences.  */
99 #define UX_DEVICE_CLASS_RNDIS_CLASS_COMMUNICATION_CONTROL                       0x02
100 #define UX_DEVICE_CLASS_RNDIS_CLASS_COMMUNICATION_DATA                          0x0A
101 #define UX_DEVICE_CLASS_RNDIS_NEW_INTERRUPT_EVENT                               1
102 #define UX_DEVICE_CLASS_RNDIS_NEW_BULKOUT_EVENT                                 2
103 #define UX_DEVICE_CLASS_RNDIS_NEW_BULKIN_EVENT                                  4
104 #define UX_DEVICE_CLASS_RNDIS_NEW_DEVICE_STATE_CHANGE_EVENT                     8
105 #define UX_DEVICE_CLASS_RNDIS_INTERRUPT_RESPONSE_LENGTH                         8
106 #define UX_DEVICE_CLASS_RNDIS_INTERRUPT_RESPONSE_AVAILABLE_FLAG                 1
107 #define UX_DEVICE_CLASS_RNDIS_BASE_IP_ADDRESS                                   0xC0A80001
108 #define UX_DEVICE_CLASS_RNDIS_BASE_IP_MASK                                      0xFFFFFF00
109 #define UX_DEVICE_CLASS_RNDIS_MAX_MTU                                           1518
110 #define UX_DEVICE_CLASS_RNDIS_ETHERNET_IP                                       0x0800
111 #define UX_DEVICE_CLASS_RNDIS_ETHERNET_ARP                                      0x0806
112 #define UX_DEVICE_CLASS_RNDIS_ETHERNET_RARP                                     0x8035
113 #define UX_DEVICE_CLASS_RNDIS_ETHERNET_PACKET_SIZE                              1536
114 #define UX_DEVICE_CLASS_RNDIS_NX_ALIGN_PADDING                                  2
115 #define UX_DEVICE_CLASS_RNDIS_NX_PKPOOL_ENTRIES                                 8
116 
117 #define UX_DEVICE_CLASS_RNDIS_NX_PACKET_SIZE                                    sizeof(NX_PACKET)
118 
119 #define UX_DEVICE_CLASS_RNDIS_NX_PAYLOAD_SIZE_ASSERT                            UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_ADD_ULONG(UX_DEVICE_CLASS_RNDIS_ETHERNET_PACKET_SIZE, UX_DEVICE_CLASS_RNDIS_NX_ALIGN_PADDING), UX_DEVICE_CLASS_RNDIS_NX_PAYLOAD_SIZE_calc_ovf)
120 #define UX_DEVICE_CLASS_RNDIS_NX_PAYLOAD_SIZE                                   (UX_DEVICE_CLASS_RNDIS_ETHERNET_PACKET_SIZE + UX_DEVICE_CLASS_RNDIS_NX_ALIGN_PADDING)
121 
122 #define UX_DEVICE_CLASS_RNDIS_NX_BUFF_SIZE_ASSERT                           \
123     UX_DEVICE_CLASS_RNDIS_NX_PAYLOAD_SIZE_ASSERT                            \
124     UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_ADD_ULONG(                    \
125         UX_DEVICE_CLASS_RNDIS_NX_PAYLOAD_SIZE,                              \
126         UX_DEVICE_CLASS_RNDIS_NX_PACKET_SIZE),                              \
127         UX_DEVICE_CLASS_RNDIS_NX_BUFF_SIZE_calc_ovf)
128 #define UX_DEVICE_CLASS_RNDIS_NX_BUFF_SIZE                                      (UX_DEVICE_CLASS_RNDIS_NX_PAYLOAD_SIZE + UX_DEVICE_CLASS_RNDIS_NX_PACKET_SIZE)
129 
130 #define UX_DEVICE_CLASS_RNDIS_NX_ETHERNET_POOL_ALLOCSIZE_ASSERT             \
131     UX_DEVICE_CLASS_RNDIS_NX_BUFF_SIZE_ASSERT                               \
132     UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_MULC_ULONG(                   \
133         UX_DEVICE_CLASS_RNDIS_NX_PKPOOL_ENTRIES,                            \
134         UX_DEVICE_CLASS_RNDIS_NX_BUFF_SIZE),                                \
135         UX_DEVICE_CLASS_RNDIS_NX_ETHERNET_POOL_ALLOCSIZE_calc1_ovf)         \
136     UX_COMPILE_TIME_ASSERT(!UX_OVERFLOW_CHECK_ADD_ULONG(                    \
137         UX_DEVICE_CLASS_RNDIS_NX_PKPOOL_ENTRIES *                           \
138             UX_DEVICE_CLASS_RNDIS_NX_BUFF_SIZE,                             \
139         32), UX_DEVICE_CLASS_RNDIS_NX_ETHERNET_POOL_ALLOCSIZE_calc2_ovf)
140 #define UX_DEVICE_CLASS_RNDIS_NX_ETHERNET_POOL_ALLOCSIZE                        (UX_DEVICE_CLASS_RNDIS_NX_PKPOOL_ENTRIES * UX_DEVICE_CLASS_RNDIS_NX_BUFF_SIZE + 32)
141 
142 #define UX_DEVICE_CLASS_RNDIS_ETHERNET_SIZE                                     14
143 #define UX_DEVICE_CLASS_RNDIS_NODE_ID_LENGTH                                    6
144 #define UX_DEVICE_CLASS_RNDIS_VENDOR_DESCRIPTION_MAX_LENGTH                     64
145 #define UX_DEVICE_CLASS_RNDIS_MAC_OPTIONS                                       8
146 #define UX_DEVICE_CLASS_RNDIS_PACKET_HEADER_MSG                                 1
147 
148 #define UX_DEVICE_CLASS_RNDIS_OID_SUPPORTED_LIST_LENGTH                         30
149 
150 /* Device RNDIS Requests */
151 #define UX_DEVICE_CLASS_RNDIS_SEND_ENCAPSULATED_COMMAND                         0x00
152 #define UX_DEVICE_CLASS_RNDIS_GET_ENCAPSULATED_RESPONSE                         0x01
153 
154 /* Define RNDIS Versions.  Set to 1.0 here.  */
155 #define UX_DEVICE_CLASS_RNDIS_VERSION_MAJOR                                     0x00000001
156 #define UX_DEVICE_CLASS_RNDIS_VERSION_MINOR                                     0x00000000
157 
158 /* Define RNDIS Connection type supported. Set to conectionless.  */
159 #define UX_DEVICE_CLASS_RNDIS_DF_CONNECTIONLESS                                 0x00000001
160 #define UX_DEVICE_CLASS_RNDIS_DF_CONNECTION_ORIENTED                            0x00000002
161 #define UX_DEVICE_CLASS_RNDIS_DF_CONNECTION_SUPPORTED                           UX_DEVICE_CLASS_RNDIS_DF_CONNECTIONLESS
162 
163 /* Define RNDIS Medium supported by the device. */
164 #define UX_DEVICE_CLASS_RNDIS_MEDIUM_SUPPORTED                                  0x00000000
165 
166 /* Define RNDIS Packet size and types supported.  */
167 #define UX_DEVICE_CLASS_RNDIS_MAX_PACKET_PER_TRANSFER                           0x00000001
168 #define UX_DEVICE_CLASS_RNDIS_MAX_PACKET_TRANSFER_SIZE                          0x00000640
169 #define UX_DEVICE_CLASS_RNDIS_PACKET_ALIGNEMENT_FACTOR                          0x00000003
170 #define UX_DEVICE_CLASS_RNDIS_MAX_FRAME_SIZE                                    0x000005DC
171 #define UX_DEVICE_CLASS_RNDIS_MAX_PACKET_LENGTH                                 0x000005EA
172 
173 /* Define LINK speeds.  */
174 #define UX_DEVICE_CLASS_RNDIS_LINK_SPEED_FS                                     0x0001D4C0
175 
176 /* Define LINK statess.  */
177 #define UX_DEVICE_CLASS_RNDIS_LINK_STATE_DOWN                                   0
178 #define UX_DEVICE_CLASS_RNDIS_LINK_STATE_UP                                     1
179 #define UX_DEVICE_CLASS_RNDIS_LINK_STATE_PENDING_UP                             2
180 #define UX_DEVICE_CLASS_RNDIS_LINK_STATE_PENDING_DOWN                           3
181 
182 /* Define media connection values.  */
183 #define UX_DEVICE_CLASS_RNDIS_MEDIA_CONNECTED                                   0x00000000
184 #define UX_DEVICE_CLASS_RNDIS_MEDIA_DISCONNECTED                                0x00000001
185 
186 /* Define media supported values.  */
187 #define UX_DEVICE_CLASS_RNDIS_MEDIA_802_3                                       0x00000000
188 #define UX_DEVICE_CLASS_RNDIS_MEDIA_802_5                                       0x00000001
189 #define UX_DEVICE_CLASS_RNDIS_MEDIA_FDDI                                        0x00000002
190 #define UX_DEVICE_CLASS_RNDIS_MEDIA_WAN                                         0x00000003
191 #define UX_DEVICE_CLASS_RNDIS_MEDIA_LOCAL_TALK                                  0x00000004
192 #define UX_DEVICE_CLASS_RNDIS_MEDIA_DIX                                         0x00000005
193 #define UX_DEVICE_CLASS_RNDIS_MEDIA_ARCNET_RAW                                  0x00000006
194 #define UX_DEVICE_CLASS_RNDIS_MEDIA_ARCNET_878_2                                0x00000007
195 #define UX_DEVICE_CLASS_RNDIS_MEDIA_ATM                                         0x00000008
196 #define UX_DEVICE_CLASS_RNDIS_MEDIA_WIRELESS_WAN                                0x00000009
197 #define UX_DEVICE_CLASS_RNDIS_MEDIA_IRDA                                        0x0000000A
198 
199 /* Define RNDIS status values.  */
200 #define UX_DEVICE_CLASS_RNDIS_STATUS_SUCCESS                                    0x00000000
201 #define UX_DEVICE_CLASS_RNDIS_STATUS_FAILURE                                    0xC0000001
202 #define UX_DEVICE_CLASS_RNDIS_STATUS_INVALID_DATA                               0xC0010015
203 #define UX_DEVICE_CLASS_RNDIS_STATUS_NOT_SUPPORTED                              0xC00000BB
204 #define UX_DEVICE_CLASS_RNDIS_STATUS_MEDIA_CONNECTED                            0x4001000B
205 #define UX_DEVICE_CLASS_RNDIS_STATUS_MEDIA_DISCONNECT                           0x4001000C
206 
207 /* Define RNDIS Control Messages values.  */
208 #define UX_DEVICE_CLASS_RNDIS_MSG_INITIALIZE                                    0x00000002
209 #define UX_DEVICE_CLASS_RNDIS_MSG_HALT                                          0x00000003
210 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY                                         0x00000004
211 #define UX_DEVICE_CLASS_RNDIS_MSG_SET                                           0x00000005
212 #define UX_DEVICE_CLASS_RNDIS_MSG_RESET                                         0x00000006
213 #define UX_DEVICE_CLASS_RNDIS_MSG_INDICATE_STATUS                               0x00000007
214 #define UX_DEVICE_CLASS_RNDIS_MSG_KEEP_ALIVE                                    0x00000008
215 
216 /* Define RNDIS Control Completion values.  */
217 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE                                  0x80000002
218 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY                                       0x80000004
219 #define UX_DEVICE_CLASS_RNDIS_CMPLT_SET                                         0x80000005
220 #define UX_DEVICE_CLASS_RNDIS_CMPLT_RESET                                       0x80000006
221 #define UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE                                  0x80000008
222 
223 /* Define RNDIS Control Messages : MSG_INITIALIZE offsets.  */
224 #define UX_DEVICE_CLASS_RNDIS_MSG_INITIALIZE_MESSAGE_TYPE                       0x00000000
225 #define UX_DEVICE_CLASS_RNDIS_MSG_INITIALIZE_MESSAGE_LENGTH                     0x00000004
226 #define UX_DEVICE_CLASS_RNDIS_MSG_INITIALIZE_REQUEST_ID                         0x00000008
227 #define UX_DEVICE_CLASS_RNDIS_MSG_INITIALIZE_MAJOR_VERSION                      0x0000000C
228 #define UX_DEVICE_CLASS_RNDIS_MSG_INITIALIZE_MINOR_VERSION                      0x00000010
229 #define UX_DEVICE_CLASS_RNDIS_MSG_INITIALIZE_MAX_TRANSFER_SIZE                  0x00000014
230 
231 /* Define RNDIS Control Messages : CMPLT_INITIALIZE offsets.  */
232 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_MESSAGE_TYPE                     0x00000000
233 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_MESSAGE_LENGTH                   0x00000004
234 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_REQUEST_ID                       0x00000008
235 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_STATUS                           0x0000000C
236 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_MAJOR_VERSION                    0x00000010
237 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_MINOR_VERSION                    0x00000014
238 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_DEVICE_FLAGS                     0x00000018
239 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_MEDIUM                           0x0000001C
240 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_MAX_PACKETS_PER_TRANSFER         0x00000020
241 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_MAX_TRANSFER_SIZE                0x00000024
242 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_PACKET_ALIGNMENT                 0x00000028
243 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_AFL_LIST_OFFSET                  0x0000002C
244 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_AFL_LIST_SIZE                    0x00000030
245 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_RESPONSE_LENGTH                  0x00000034
246 
247 /* Define RNDIS Control Messages : MSG_HALT offsets.  */
248 #define UX_DEVICE_CLASS_RNDIS_MSG_HALT_MESSAGE_TYPE                             0x00000000
249 #define UX_DEVICE_CLASS_RNDIS_MSG_HALT_MESSAGE_LENGTH                           0x00000004
250 #define UX_DEVICE_CLASS_RNDIS_MSG_HALT_REQUEST_ID                               0x00000008
251 
252 /* Define RNDIS Control Messages : MSG_QUERY offsets.  */
253 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY_MESSAGE_TYPE                            0x00000000
254 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY_MESSAGE_LENGTH                          0x00000004
255 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY_REQUEST_ID                              0x00000008
256 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY_OID                                     0x0000000C
257 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY_INFO_BUFFER_LENGTH                      0x00000010
258 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY_INFO_BUFFER_OFFSET                      0x00000014
259 #define UX_DEVICE_CLASS_RNDIS_MSG_QUERY_DEVICE_VC_HANDLE                        0x00000018
260 
261 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_MESSAGE_TYPE                          0x00000000
262 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_MESSAGE_LENGTH                        0x00000004
263 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_REQUEST_ID                            0x00000008
264 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_STATUS                                0x0000000C
265 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_INFO_BUFFER_LENGTH                    0x00000010
266 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_INFO_BUFFER_OFFSET                    0x00000014
267 #define UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_INFO_BUFFER                           0x00000018
268 
269 /* Define RNDIS Control Messages : MSG_SET offsets.  */
270 #define UX_DEVICE_CLASS_RNDIS_MSG_SET_MESSAGE_TYPE                              0x00000000
271 #define UX_DEVICE_CLASS_RNDIS_MSG_SET_MESSAGE_LENGTH                            0x00000004
272 #define UX_DEVICE_CLASS_RNDIS_MSG_SET_REQUEST_ID                                0x00000008
273 #define UX_DEVICE_CLASS_RNDIS_MSG_SET_OID                                       0x0000000C
274 #define UX_DEVICE_CLASS_RNDIS_MSG_SET_INFO_BUFFER_LENGTH                        0x00000010
275 #define UX_DEVICE_CLASS_RNDIS_MSG_SET_INFO_BUFFER_OFFSET                        0x00000014
276 #define UX_DEVICE_CLASS_RNDIS_MSG_SET_DEVICE_VC_HANDLE                          0x00000018
277 #define UX_DEVICE_CLASS_RNDIS_CMPLT_SET_MESSAGE_TYPE                            0x00000000
278 #define UX_DEVICE_CLASS_RNDIS_CMPLT_SET_MESSAGE_LENGTH                          0x00000004
279 #define UX_DEVICE_CLASS_RNDIS_CMPLT_SET_REQUEST_ID                              0x00000008
280 #define UX_DEVICE_CLASS_RNDIS_CMPLT_SET_STATUS                                  0x0000000C
281 #define UX_DEVICE_CLASS_RNDIS_CMPLT_SET_RESPONSE_LENGTH                         0x00000010
282 
283 /* Define RNDIS Control Messages : MSG_RESET offsets.  */
284 #define UX_DEVICE_CLASS_RNDIS_MSG_RESET_MESSAGE_TYPE                            0x00000000
285 #define UX_DEVICE_CLASS_RNDIS_MSG_RESET_MESSAGE_LENGTH                          0x00000004
286 #define UX_DEVICE_CLASS_RNDIS_MSG_RESET_RESERVED                                0x00000008
287 #define UX_DEVICE_CLASS_RNDIS_CMPLT_RESET_MESSAGE_TYPE                          0x00000000
288 #define UX_DEVICE_CLASS_RNDIS_CMPLT_RESET_MESSAGE_LENGTH                        0x00000004
289 #define UX_DEVICE_CLASS_RNDIS_CMPLT_RESET_STATUS                                0x00000008
290 #define UX_DEVICE_CLASS_RNDIS_CMPLT_RESET_ADDRESSING_RESET                      0x0000000C
291 #define UX_DEVICE_CLASS_RNDIS_CMPLT_RESET_RESPONSE_LENGTH                       0x00000010
292 
293 /* Define RNDIS Control Messages : MSG_INDICATE_STATUS offsets.  */
294 #define UX_DEVICE_CLASS_RNDIS_MSG_INDICATE_STATUS_MESSAGE_TYPE                  0x00000000
295 #define UX_DEVICE_CLASS_RNDIS_MSG_INDICATE_STATUS_MESSAGE_LENGTH                0x00000004
296 #define UX_DEVICE_CLASS_RNDIS_MSG_INDICATE_STATUS_STATUS                        0x00000008
297 #define UX_DEVICE_CLASS_RNDIS_MSG_INDICATE_STATUS_STATUS_BUFFER_LENGTH          0x0000000C
298 #define UX_DEVICE_CLASS_RNDIS_MSG_INDICATE_STATUS_STATUS_BUFFER_OFFSET          0x00000010
299 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INDICATE_STATUS_DIAG                        0x00000000
300 #define UX_DEVICE_CLASS_RNDIS_CMPLT_INDICATE_STATUS_ERROR_OFFSET                0x00000004
301 
302 /* Define RNDIS Control Messages : MSG_KEEP_ALIVE offsets.  */
303 #define UX_DEVICE_CLASS_RNDIS_MSG_KEEP_ALIVE_MESSAGE_TYPE                       0x00000000
304 #define UX_DEVICE_CLASS_RNDIS_MSG_KEEP_ALIVE_MESSAGE_LENGTH                     0x00000004
305 #define UX_DEVICE_CLASS_RNDIS_MSG_KEEP_ALIVE_REQUEST_ID                         0x00000008
306 #define UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_MESSAGE_TYPE                     0x00000000
307 #define UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_MESSAGE_LENGTH                   0x00000004
308 #define UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_REQUEST_ID                       0x00000008
309 #define UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_STATUS                           0x0000000C
310 #define UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_RESPONSE_LENGTH                  0x00000010
311 
312 /* Define RNDIS State machine.  */
313 #define UX_DEVICE_CLASS_RNDIS_STATE_UNINITIALIZED                               0x00000000
314 #define UX_DEVICE_CLASS_RNDIS_STATE_INITIALIZED                                 0x00000001
315 #define UX_DEVICE_CLASS_RNDIS_STATE_DATA_INITIALIZED                            0x00000002
316 
317 /* Define Required Object IDs (OIDs) */
318 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_SUPPORTED_LIST                            0x00010101
319 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_HARDWARE_STATUS                           0x00010102
320 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MEDIA_SUPPORTED                           0x00010103
321 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MEDIA_IN_USE                              0x00010104
322 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MAXIMUM_LOOKAHEAD                         0x00010105
323 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MAXIMUM_FRAME_SIZE                        0x00010106
324 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_LINK_SPEED                                0x00010107
325 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_TRANSMIT_BUFFER_SPACE                     0x00010108
326 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RECEIVE_BUFFER_SPACE                      0x00010109
327 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_TRANSMIT_BLOCK_SIZE                       0x0001010A
328 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RECEIVE_BLOCK_SIZE                        0x0001010B
329 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_VENDOR_ID                                 0x0001010C
330 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_VENDOR_DESCRIPTION                        0x0001010D
331 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_CURRENT_PACKET_FILTER                     0x0001010E
332 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_CURRENT_LOOKAHEAD                         0x0001010F
333 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_DRIVER_VERSION                            0x00010110
334 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MAXIMUM_TOTAL_SIZE                        0x00010111
335 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_PROTOCOL_OPTIONS                          0x00010112
336 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MAC_OPTIONS                               0x00010113
337 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MEDIA_CONNECT_STATUS                      0x00010114
338 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MAXIMUM_SEND_PACKETS                      0x00010115
339 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_VENDOR_DRIVER_VERSION                     0x00010116
340 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_SUPPORTED_GUIDS                           0x00010117
341 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_NETWORK_LAYER_ADDRESSES                   0x00010118
342 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_TRANSPORT_HEADER_OFFSET                   0x00010119
343 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MACHINE_NAME                              0x0001021A
344 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RNDIS_CONFIG_PARAMETER                    0x0001021B
345 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_VLAN_ID                                   0x0001021C
346 
347 /* Define Optional OIDs */
348 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MEDIA_CAPABILITIES                        0x00010201
349 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_PHYSICAL_MEDIUM                           0x00010202
350 
351 /* Define Required statistics OIDs */
352 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_XMIT_OK                                   0x00020101
353 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RCV_OK                                    0x00020102
354 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_XMIT_ERROR                                0x00020103
355 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RCV_ERROR                                 0x00020104
356 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RCV_NO_BUFFER                             0x00020105
357 
358 /* Define Optional statistics OIDs */
359 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_DIRECTED_BYTES_XMIT                       0x00020201
360 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_DIRECTED_FRAMES_XMIT                      0x00020202
361 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MULTICAST_BYTES_XMIT                      0x00020203
362 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MULTICAST_FRAMES_XMIT                     0x00020204
363 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_BROADCAST_BYTES_XMIT                      0x00020205
364 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_BROADCAST_FRAMES_XMIT                     0x00020206
365 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_DIRECTED_BYTES_RCV                        0x00020207
366 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_DIRECTED_FRAMES_RCV                       0x00020208
367 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MULTICAST_BYTES_RCV                       0x00020209
368 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MULTICAST_FRAMES_RCV                      0x0002020A
369 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_BROADCAST_BYTES_RCV                       0x0002020B
370 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_BROADCAST_FRAMES_RCV                      0x0002020C
371 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RCV_CRC_ERROR                             0x0002020D
372 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_TRANSMIT_QUEUE_LENGTH                     0x0002020E
373 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_GET_TIME_CAPS                             0x0002020F
374 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_GET_NETCARD_TIME                          0x00020210
375 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_NETCARD_LOAD                              0x00020211
376 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_DEVICE_PROFILE                            0x00020212
377 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_INIT_TIME_MS                              0x00020213
378 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RESET_COUNTS                              0x00020214
379 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MEDIA_SENSE_COUNTS                        0x00020215
380 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_FRIENDLY_NAME                             0x00020216
381 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_MINIPORT_INFO                             0x00020217
382 #define UX_DEVICE_CLASS_RNDIS_OID_GEN_RESET_VERIFY_PARAMETERS                   0x00020218
383 
384 /* Define IEEE 802.3 (Ethernet) OIDs */
385 
386 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_PERMANENT_ADDRESS                       0x01010101
387 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_CURRENT_ADDRESS                         0x01010102
388 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_MULTICAST_LIST                          0x01010103
389 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_MAXIMUM_LIST_SIZE                       0x01010104
390 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_MAC_OPTIONS                             0x01010105
391 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_RCV_ERROR_ALIGNMENT                     0x01020101
392 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_ONE_COLLISION                      0x01020102
393 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_MORE_COLLISIONS                    0x01020103
394 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_DEFERRED                           0x01020201
395 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_MAX_COLLISIONS                     0x01020202
396 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_RCV_OVERRUN                             0x01020203
397 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_UNDERRUN                           0x01020204
398 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_HEARTBEAT_FAILURE                  0x01020205
399 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_TIMES_CRS_LOST                     0x01020206
400 #define UX_DEVICE_CLASS_RNDIS_OID_802_3_XMIT_LATE_COLLISIONS                    0x01020207
401 
402 /* Define Hardware status code.  */
403 #define UX_DEVICE_CLASS_RNDIS_OID_HW_STATUS_READY                               0x00000000
404 #define UX_DEVICE_CLASS_RNDIS_OID_HW_STATUS_INITIALIZING                        0x00000001
405 #define UX_DEVICE_CLASS_RNDIS_OID_HW_STATUS_RESET                               0x00000002
406 #define UX_DEVICE_CLASS_RNDIS_OID_HW_STATUS_CLOSING                             0x00000003
407 #define UX_DEVICE_CLASS_RNDIS_OID_HW_STATUS_NOT_READY                           0x00000004
408 
409 /* Define RNDIS Packet Header format.  */
410 #define UX_DEVICE_CLASS_RNDIS_PACKET_MESSAGE_TYPE                               0x00000000
411 #define UX_DEVICE_CLASS_RNDIS_PACKET_MESSAGE_LENGTH                             0x00000004
412 #define UX_DEVICE_CLASS_RNDIS_PACKET_DATA_OFFSET                                0x00000008
413 #define UX_DEVICE_CLASS_RNDIS_PACKET_DATA_LENGTH                                0x0000000C
414 #define UX_DEVICE_CLASS_RNDIS_PACKET_OOB_DATA_OFFSET                            0x00000010
415 #define UX_DEVICE_CLASS_RNDIS_PACKET_OOB_DATA_LENGTH                            0x00000014
416 #define UX_DEVICE_CLASS_RNDIS_PACKET_NUM_OOB_DATA_ELEMENTS                      0x00000018
417 #define UX_DEVICE_CLASS_RNDIS_PACKET_INFO_OFFSET                                0x0000001C
418 #define UX_DEVICE_CLASS_RNDIS_PACKET_INFO_LENGTH                                0x00000020
419 #define UX_DEVICE_CLASS_RNDIS_PACKET_VC_HANDLE                                  0x00000024
420 #define UX_DEVICE_CLASS_RNDIS_PACKET_RESERVED                                   0x00000028
421 #define UX_DEVICE_CLASS_RNDIS_PACKET_BUFFER                                     0x0000002C
422 #define UX_DEVICE_CLASS_RNDIS_PACKET_HEADER_LENGTH                              0x0000002C
423 
424 /* Define NetX errors inside the RNDIS class.  */
425 #define UX_DEVICE_CLASS_RNDIS_NX_SUCCESS                                        0x00
426 #define UX_DEVICE_CLASS_RNDIS_NX_NO_PACKET                                      0x01
427 #define UX_DEVICE_CLASS_RNDIS_NX_UNDERFLOW                                      0x02
428 #define UX_DEVICE_CLASS_RNDIS_NX_OVERFLOW                                       0x03
429 #define UX_DEVICE_CLASS_RNDIS_NX_NO_MAPPING                                     0x04
430 #define UX_DEVICE_CLASS_RNDIS_NX_DELETED                                        0x05
431 #define UX_DEVICE_CLASS_RNDIS_NX_POOL_ERROR                                     0x06
432 #define UX_DEVICE_CLASS_RNDIS_NX_PTR_ERROR                                      0x07
433 #define UX_DEVICE_CLASS_RNDIS_NX_WAIT_ERROR                                     0x08
434 #define UX_DEVICE_CLASS_RNDIS_NX_SIZE_ERROR                                     0x09
435 #define UX_DEVICE_CLASS_RNDIS_NX_OPTION_ERROR                                   0x0a
436 #define UX_DEVICE_CLASS_RNDIS_NX_DELETE_ERROR                                   0x10
437 #define UX_DEVICE_CLASS_RNDIS_NX_CALLER_ERROR                                   0x11
438 #define UX_DEVICE_CLASS_RNDIS_NX_INVALID_PACKET                                 0x12
439 #define UX_DEVICE_CLASS_RNDIS_NX_INVALID_SOCKET                                 0x13
440 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_ENABLED                                    0x14
441 #define UX_DEVICE_CLASS_RNDIS_NX_ALREADY_ENABLED                                0x15
442 #define UX_DEVICE_CLASS_RNDIS_NX_ENTRY_NOT_FOUND                                0x16
443 #define UX_DEVICE_CLASS_RNDIS_NX_NO_MORE_ENTRIES                                0x17
444 #define UX_DEVICE_CLASS_RNDIS_NX_ARP_TIMER_ERROR                                0x18
445 #define UX_DEVICE_CLASS_RNDIS_NX_RESERVED_CODE0                                 0x19
446 #define UX_DEVICE_CLASS_RNDIS_NX_WAIT_ABORTED                                   0x1A
447 #define UX_DEVICE_CLASS_RNDIS_NX_IP_INTERNAL_ERROR                              0x20
448 #define UX_DEVICE_CLASS_RNDIS_NX_IP_ADDRESS_ERROR                               0x21
449 #define UX_DEVICE_CLASS_RNDIS_NX_ALREADY_BOUND                                  0x22
450 #define UX_DEVICE_CLASS_RNDIS_NX_PORT_UNAVAILABLE                               0x23
451 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_BOUND                                      0x24
452 #define UX_DEVICE_CLASS_RNDIS_NX_RESERVED_CODE1                                 0x25
453 #define UX_DEVICE_CLASS_RNDIS_NX_SOCKET_UNBOUND                                 0x26
454 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_CREATED                                    0x27
455 #define UX_DEVICE_CLASS_RNDIS_NX_SOCKETS_BOUND                                  0x28
456 #define UX_DEVICE_CLASS_RNDIS_NX_NO_RESPONSE                                    0x29
457 #define UX_DEVICE_CLASS_RNDIS_NX_POOL_DELETED                                   0x30
458 #define UX_DEVICE_CLASS_RNDIS_NX_ALREADY_RELEASED                               0x31
459 #define UX_DEVICE_CLASS_RNDIS_NX_RESERVED_CODE2                                 0x32
460 #define UX_DEVICE_CLASS_RNDIS_NX_MAX_LISTEN                                     0x33
461 #define UX_DEVICE_CLASS_RNDIS_NX_DUPLICATE_LISTEN                               0x34
462 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_CLOSED                                     0x35
463 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_LISTEN_STATE                               0x36
464 #define UX_DEVICE_CLASS_RNDIS_NX_IN_PROGRESS                                    0x37
465 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_CONNECTED                                  0x38
466 #define UX_DEVICE_CLASS_RNDIS_NX_WINDOW_OVERFLOW                                0x39
467 #define UX_DEVICE_CLASS_RNDIS_NX_ALREADY_SUSPENDED                              0x40
468 #define UX_DEVICE_CLASS_RNDIS_NX_DISCONNECT_FAILED                              0x41
469 #define UX_DEVICE_CLASS_RNDIS_NX_STILL_BOUND                                    0x42
470 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_SUCCESSFUL                                 0x43
471 #define UX_DEVICE_CLASS_RNDIS_NX_UNHANDLED_COMMAND                              0x44
472 #define UX_DEVICE_CLASS_RNDIS_NX_NO_FREE_PORTS                                  0x45
473 #define UX_DEVICE_CLASS_RNDIS_NX_INVALID_PORT                                   0x46
474 #define UX_DEVICE_CLASS_RNDIS_NX_INVALID_RELISTEN                               0x47
475 #define UX_DEVICE_CLASS_RNDIS_NX_CONNECTION_PENDING                             0x48
476 #define UX_DEVICE_CLASS_RNDIS_NX_TX_QUEUE_DEPTH                                 0x49
477 #define UX_DEVICE_CLASS_RNDIS_NX_NOT_IMPLEMENTED                                0x80
478 
479 /* Define timeout packet allocation value.  */
480 #ifndef UX_DEVICE_CLASS_RNDIS_PACKET_POOL_WAIT
481 #define UX_DEVICE_CLASS_RNDIS_PACKET_POOL_WAIT                                  10
482 #endif
483 
484 #ifndef UX_DEVICE_CLASS_RNDIS_PACKET_POOL_INST_WAIT
485 #define UX_DEVICE_CLASS_RNDIS_PACKET_POOL_INST_WAIT                             100
486 #endif
487 
488 /* Calculate message buffer length (not overflow).  */
489 #define UX_DEVICE_CLASS_RNDIS_MAX_MSG_LENGTH                                    (UX_DEVICE_CLASS_RNDIS_MAX_PACKET_LENGTH + UX_DEVICE_CLASS_RNDIS_PACKET_HEADER_LENGTH)
490 #if UX_DEVICE_CLASS_RNDIS_MAX_MSG_LENGTH > UX_SLAVE_REQUEST_DATA_MAX_LENGTH
491 #error "Error: the maximum-sized RNDIS response cannot fit inside the control endpoint's data buffer. Increase UX_SLAVE_REQUEST_DATA_MAX_LENGTH."
492 #endif
493 
494 /* Calculate response buffer length.  */
495 #define UX_DEVICE_CLASS_RNDIS_OID_SUPPORTED_RESPONSE_LENGTH             (UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_INFO_BUFFER + UX_DEVICE_CLASS_RNDIS_OID_SUPPORTED_LIST_LENGTH * 4)
496 #define UX_DEVICE_CLASS_RNDIS_VENDOR_DESCRIPTION_MAX_RESPONSE_LENGTH    (UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_INFO_BUFFER + UX_DEVICE_CLASS_RNDIS_VENDOR_DESCRIPTION_MAX_LENGTH)
497 #define UX_DEVICE_CLASS_RNDIS_NODE_ID_RESPONSE_LENGTH                   (UX_DEVICE_CLASS_RNDIS_CMPLT_QUERY_INFO_BUFFER + UX_DEVICE_CLASS_RNDIS_NODE_ID_LENGTH)
498 
499 /* Decide maximum size of RNDIS response buffer (with 1 ~ 4 bytes as padding and aligned to 4 bytes).  */
500 #define UX_DEVICE_CLASS_RNDIS_MAX(a, b) (((a) > (b)) ? (a) : (b))
501 #define UX_DEVICE_CLASS_RNDIS_MAX_CONTROL_RESPONSE_LENGTH               (((                         \
502         UX_DEVICE_CLASS_RNDIS_MAX(UX_DEVICE_CLASS_RNDIS_CMPLT_INITIALIZE_RESPONSE_LENGTH,           \
503         UX_DEVICE_CLASS_RNDIS_MAX(UX_DEVICE_CLASS_RNDIS_CMPLT_KEEP_ALIVE_RESPONSE_LENGTH,           \
504         UX_DEVICE_CLASS_RNDIS_MAX(UX_DEVICE_CLASS_RNDIS_CMPLT_RESET_RESPONSE_LENGTH,                \
505         UX_DEVICE_CLASS_RNDIS_MAX(UX_DEVICE_CLASS_RNDIS_CMPLT_SET_RESPONSE_LENGTH,                  \
506         UX_DEVICE_CLASS_RNDIS_MAX(UX_DEVICE_CLASS_RNDIS_OID_SUPPORTED_RESPONSE_LENGTH,              \
507         UX_DEVICE_CLASS_RNDIS_MAX(UX_DEVICE_CLASS_RNDIS_VENDOR_DESCRIPTION_MAX_RESPONSE_LENGTH,     \
508         UX_DEVICE_CLASS_RNDIS_NODE_ID_RESPONSE_LENGTH))))))) & (~0x3)) + 0x4)
509 
510 /* Ensure maximum-sized RNDIS response can fit in the control endpoint's transfer buffer.  */
511 #if UX_DEVICE_CLASS_RNDIS_MAX_CONTROL_RESPONSE_LENGTH > UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH
512 #error "Error: the maximum-sized RNDIS response cannot fit inside the control endpoint's data buffer. Increase UX_SLAVE_REQUEST_CONTROL_MAX_LENGTH."
513 #endif
514 
515 /* Define Slave RNDIS Class Calling Parameter structure */
516 
517 typedef struct UX_SLAVE_CLASS_RNDIS_PARAMETER_STRUCT
518 {
519     VOID                    (*ux_slave_class_rndis_instance_activate)(VOID *);
520     VOID                    (*ux_slave_class_rndis_instance_deactivate)(VOID *);
521     ULONG                   ux_slave_class_rndis_parameter_media;
522     ULONG                   ux_slave_class_rndis_parameter_vendor_id;
523     ULONG                   ux_slave_class_rndis_parameter_driver_version;
524     UCHAR                   ux_slave_class_rndis_parameter_vendor_description[UX_DEVICE_CLASS_RNDIS_VENDOR_DESCRIPTION_MAX_LENGTH];
525     UCHAR                   ux_slave_class_rndis_parameter_local_node_id[UX_DEVICE_CLASS_RNDIS_NODE_ID_LENGTH];
526     UCHAR                   ux_slave_class_rndis_parameter_remote_node_id[UX_DEVICE_CLASS_RNDIS_NODE_ID_LENGTH];
527     NX_IP                   *ux_slave_class_rndis_parameter_nx_ip;
528     ULONG                   ux_slave_class_rndis_parameter_nx_ip_address;
529     ULONG                   ux_slave_class_rndis_parameter_nx_ip_network_mask;
530 
531 } UX_SLAVE_CLASS_RNDIS_PARAMETER;
532 
533 /* Define RNDIS Class structure.  */
534 
535 typedef struct UX_SLAVE_CLASS_RNDIS_STRUCT
536 {
537     UX_SLAVE_INTERFACE                      *ux_slave_class_rndis_interface;
538     UX_SLAVE_CLASS_RNDIS_PARAMETER          ux_slave_class_rndis_parameter;
539     UX_SEMAPHORE                            ux_slave_class_rndis_semaphore;
540     UX_SLAVE_ENDPOINT                       *ux_slave_class_rndis_interrupt_endpoint;
541     UX_SLAVE_ENDPOINT                       *ux_slave_class_rndis_bulkin_endpoint;
542     UX_SLAVE_ENDPOINT                       *ux_slave_class_rndis_bulkout_endpoint;
543     UCHAR                                   ux_slave_class_rndis_response[UX_DEVICE_CLASS_RNDIS_MAX_CONTROL_RESPONSE_LENGTH];
544     ULONG                                   ux_slave_class_rndis_response_length;
545     ULONG                                   ux_slave_class_rndis_state;
546     ULONG                                   ux_slave_class_rndis_major_version;
547     ULONG                                   ux_slave_class_rndis_minor_version;
548     ULONG                                   ux_slave_class_rndis_max_transfer_size;
549     ULONG                                   ux_slave_class_rndis_request_id;
550     ULONG                                   ux_slave_class_rndis_statistics_xmit_ok;
551     ULONG                                   ux_slave_class_rndis_statistics_rcv_ok;
552     ULONG                                   ux_slave_class_rndis_statistics_xmit_error;
553     ULONG                                   ux_slave_class_rndis_statistics_rcv_error;
554     ULONG                                   ux_slave_class_rndis_statistics_rcv_no_buffer;
555     ULONG                                   ux_slave_class_rndis_statistics_rcv_error_alignment;
556     ULONG                                   ux_slave_class_rndis_statistics_xmit_one_collision;
557     ULONG                                   ux_slave_class_rndis_statistics_xmit_more_collisions;
558     UCHAR                                   ux_slave_class_rndis_local_node_id[UX_DEVICE_CLASS_RNDIS_NODE_ID_LENGTH];
559     UCHAR                                   ux_slave_class_rndis_remote_node_id[UX_DEVICE_CLASS_RNDIS_NODE_ID_LENGTH];
560     ULONG                                   ux_slave_class_rndis_nx_ip_address;
561     ULONG                                   ux_slave_class_rndis_nx_ip_network_mask;
562 
563 #if !defined(UX_DEVICE_STANDALONE)
564     NX_IP                                   *ux_slave_class_rndis_nx_ip;
565     NX_INTERFACE                            *ux_slave_class_rndis_nx_interface;
566     NX_PACKET                               *ux_slave_class_rndis_xmit_queue;
567     NX_PACKET                               *ux_slave_class_rndis_receive_queue;
568     NX_PACKET_POOL                          *ux_slave_class_rndis_packet_pool;
569 #endif
570 
571 #if !defined(UX_DEVICE_STANDALONE)
572     UX_EVENT_FLAGS_GROUP                    ux_slave_class_rndis_event_flags_group;
573     UX_THREAD                               ux_slave_class_rndis_interrupt_thread;
574     UX_THREAD                               ux_slave_class_rndis_bulkin_thread;
575     UX_THREAD                               ux_slave_class_rndis_bulkout_thread;
576     UX_MUTEX                                ux_slave_class_rndis_mutex;
577     UCHAR                                   *ux_slave_class_rndis_interrupt_thread_stack;
578     UCHAR                                   *ux_slave_class_rndis_bulkin_thread_stack;
579     UCHAR                                   *ux_slave_class_rndis_bulkout_thread_stack;
580 #endif
581 
582     ULONG                                   ux_slave_class_rndis_link_state;
583     VOID                                    *ux_slave_class_rndis_network_handle;
584 
585 } UX_SLAVE_CLASS_RNDIS;
586 
587 
588 /* Requests - Ethernet Networking Control Model */
589 
590 #define UX_DEVICE_CLASS_RNDIS_SEND_ENCAPSULATED_COMMAND                        0x00
591                                         /* Issues a command in the format of the supported control
592                                            protocol. The intent of this mechanism is to support
593                                            networking devices (e.g., host-based cable modems)
594                                            that require an additional vendor-defined interface for
595                                            media specific hardware configuration and
596                                            management.  */
597 #define UX_DEVICE_CLASS_RNDIS_GET_ENCAPSULATED_RESPONSE                        0x01
598                                         /* Requests a response in the format of the supported
599                                            control protocol.  */
600 
601 
602 /* Define buffer length for IN/OUT pipes.  */
603 
604 #define UX_DEVICE_CLASS_RNDIS_BUFFER_SIZE                                       4096
605 
606 
607 /* Define Device RNDIS Class prototypes.  */
608 
609 UINT  _ux_device_class_rndis_activate(UX_SLAVE_CLASS_COMMAND *command);
610 UINT  _ux_device_class_rndis_control_request(UX_SLAVE_CLASS_COMMAND *command);
611 UINT  _ux_device_class_rndis_deactivate(UX_SLAVE_CLASS_COMMAND *command);
612 UINT  _ux_device_class_rndis_entry(UX_SLAVE_CLASS_COMMAND *command);
613 UINT  _ux_device_class_rndis_initialize(UX_SLAVE_CLASS_COMMAND *command);
614 UINT  _ux_device_class_rndis_write(VOID *rndis_class, NX_PACKET *packet);
615 UINT  _ux_device_class_rndis_msg_query(UX_SLAVE_CLASS_RNDIS *rndis, UX_SLAVE_TRANSFER *transfer_request);
616 UINT  _ux_device_class_rndis_msg_reset(UX_SLAVE_CLASS_RNDIS *rndis, UX_SLAVE_TRANSFER *transfer_request);
617 UINT  _ux_device_class_rndis_msg_set(UX_SLAVE_CLASS_RNDIS *rndis, UX_SLAVE_TRANSFER *transfer_request);
618 UINT  _ux_device_class_rndis_msg_initialize(UX_SLAVE_CLASS_RNDIS *rndis, UX_SLAVE_TRANSFER *transfer_request);
619 UINT  _ux_device_class_rndis_msg_keep_alive(UX_SLAVE_CLASS_RNDIS *rndis, UX_SLAVE_TRANSFER *transfer_request);
620 VOID  _ux_device_class_rndis_interrupt_thread(ULONG rndis_class);
621 VOID  _ux_device_class_rndis_bulkin_thread(ULONG rndis_class);
622 VOID  _ux_device_class_rndis_bulkout_thread(ULONG rndis_class);
623 
624 
625 /* Define Device RNDIS Class API prototypes.  */
626 
627 #define ux_device_class_rndis_entry        _ux_device_class_rndis_entry
628 
629 
630 /* Define OID supported List.  */
631 extern ULONG ux_device_class_rndis_oid_supported_list[];
632 
633 /* Determine if a C++ compiler is being used.  If so, complete the standard
634    C conditional started above.  */
635 #ifdef __cplusplus
636 }
637 #endif
638 
639 #endif /* UX_DEVICE_CLASS_RNDIS_H */
640