2 * @brief Common definitions and declarations for the library USB RNDIS Class driver
\r
5 * Copyright(C) NXP Semiconductors, 2012
\r
6 * Copyright(C) Dean Camera, 2011, 2012
\r
7 * All rights reserved.
\r
10 * Software that is described herein is for illustrative purposes only
\r
11 * which provides customers with programming information regarding the
\r
12 * LPC products. This software is supplied "AS IS" without any warranties of
\r
13 * any kind, and NXP Semiconductors and its licensor disclaim any and
\r
14 * all warranties, express or implied, including all implied warranties of
\r
15 * merchantability, fitness for a particular purpose and non-infringement of
\r
16 * intellectual property rights. NXP Semiconductors assumes no responsibility
\r
17 * or liability for the use of the software, conveys no license or rights under any
\r
18 * patent, copyright, mask work right, or any other intellectual property rights in
\r
19 * or to any products. NXP Semiconductors reserves the right to make changes
\r
20 * in the software without notification. NXP Semiconductors also makes no
\r
21 * representation or warranty that such application will be suitable for the
\r
22 * specified use without further testing or modification.
\r
25 * Permission to use, copy, modify, and distribute this software and its
\r
26 * documentation is hereby granted, under NXP Semiconductors' and its
\r
27 * licensor's relevant copyrights in the software, without fee, provided that it
\r
28 * is used in conjunction with NXP Semiconductors microcontrollers. This
\r
29 * copyright, permission, and disclaimer notice must appear in all copies of
\r
33 /** @ingroup Group_USBClassRNDIS
\r
34 * @defgroup Group_USBClassRNDISCommon Common Class Definitions
\r
36 * @section Sec_ModDescription Module Description
\r
37 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
\r
43 #ifndef _RNDIS_CLASS_COMMON_H_
\r
44 #define _RNDIS_CLASS_COMMON_H_
\r
47 #define __INCLUDE_FROM_CDC_DRIVER
\r
50 #include "../../Core/StdDescriptors.h"
\r
51 #include "CDCClassCommon.h"
\r
53 /* Enable C linkage for C++ Compilers: */
\r
54 #if defined(__cplusplus)
\r
58 /* Preprocessor Checks: */
\r
59 #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)
\r
60 #error Do not include this file directly. Include LPCUSBlib/Drivers/USB.h instead.
\r
64 /** Additional error code for RNDIS functions when a device returns a logical command failure. */
\r
65 #define RNDIS_ERROR_LOGICAL_CMD_FAILED 0x80
\r
67 /** Implemented RNDIS Version Major. */
\r
68 #define REMOTE_NDIS_VERSION_MAJOR 0x01
\r
70 /** Implemented RNDIS Version Minor. */
\r
71 #define REMOTE_NDIS_VERSION_MINOR 0x00
\r
73 /** @name RNDIS Message Values */
\r
75 #define REMOTE_NDIS_PACKET_MSG 0x00000001UL
\r
76 #define REMOTE_NDIS_INITIALIZE_MSG 0x00000002UL
\r
77 #define REMOTE_NDIS_HALT_MSG 0x00000003UL
\r
78 #define REMOTE_NDIS_QUERY_MSG 0x00000004UL
\r
79 #define REMOTE_NDIS_SET_MSG 0x00000005UL
\r
80 #define REMOTE_NDIS_RESET_MSG 0x00000006UL
\r
81 #define REMOTE_NDIS_INDICATE_STATUS_MSG 0x00000007UL
\r
82 #define REMOTE_NDIS_KEEPALIVE_MSG 0x00000008UL
\r
85 /** @name RNDIS Response Values */
\r
87 #define REMOTE_NDIS_INITIALIZE_CMPLT 0x80000002UL
\r
88 #define REMOTE_NDIS_QUERY_CMPLT 0x80000004UL
\r
89 #define REMOTE_NDIS_SET_CMPLT 0x80000005UL
\r
90 #define REMOTE_NDIS_RESET_CMPLT 0x80000006UL
\r
91 #define REMOTE_NDIS_KEEPALIVE_CMPLT 0x80000008UL
\r
94 /** @name RNDIS Status Values */
\r
96 #define REMOTE_NDIS_STATUS_SUCCESS 0x00000000UL
\r
97 #define REMOTE_NDIS_STATUS_FAILURE 0xC0000001UL
\r
98 #define REMOTE_NDIS_STATUS_INVALID_DATA 0xC0010015UL
\r
99 #define REMOTE_NDIS_STATUS_NOT_SUPPORTED 0xC00000BBUL
\r
100 #define REMOTE_NDIS_STATUS_MEDIA_CONNECT 0x4001000BUL
\r
101 #define REMOTE_NDIS_STATUS_MEDIA_DISCONNECT 0x4001000CUL
\r
104 /** @name RNDIS Media States */
\r
106 #define REMOTE_NDIS_MEDIA_STATE_CONNECTED 0x00000000UL
\r
107 #define REMOTE_NDIS_MEDIA_STATE_DISCONNECTED 0x00000001UL
\r
110 #define REMOTE_NDIS_MEDIUM_802_3 0x00000000UL
\r
112 /** @name RNDIS Connection Types */
\r
114 #define REMOTE_NDIS_DF_CONNECTIONLESS 0x00000001UL
\r
115 #define REMOTE_NDIS_DF_CONNECTION_ORIENTED 0x00000002UL
\r
118 /** @name RNDIS Packet Types */
\r
120 #define REMOTE_NDIS_PACKET_DIRECTED 0x00000001UL
\r
121 #define REMOTE_NDIS_PACKET_MULTICAST 0x00000002UL
\r
122 #define REMOTE_NDIS_PACKET_ALL_MULTICAST 0x00000004UL
\r
123 #define REMOTE_NDIS_PACKET_BROADCAST 0x00000008UL
\r
124 #define REMOTE_NDIS_PACKET_SOURCE_ROUTING 0x00000010UL
\r
125 #define REMOTE_NDIS_PACKET_PROMISCUOUS 0x00000020UL
\r
126 #define REMOTE_NDIS_PACKET_SMT 0x00000040UL
\r
127 #define REMOTE_NDIS_PACKET_ALL_LOCAL 0x00000080UL
\r
128 #define REMOTE_NDIS_PACKET_GROUP 0x00001000UL
\r
129 #define REMOTE_NDIS_PACKET_ALL_FUNCTIONAL 0x00002000UL
\r
130 #define REMOTE_NDIS_PACKET_FUNCTIONAL 0x00004000UL
\r
131 #define REMOTE_NDIS_PACKET_MAC_FRAME 0x00008000UL
\r
134 /** @name RNDIS OID Values */
\r
136 #define OID_GEN_SUPPORTED_LIST 0x00010101UL
\r
137 #define OID_GEN_HARDWARE_STATUS 0x00010102UL
\r
138 #define OID_GEN_MEDIA_SUPPORTED 0x00010103UL
\r
139 #define OID_GEN_MEDIA_IN_USE 0x00010104UL
\r
140 #define OID_GEN_MAXIMUM_FRAME_SIZE 0x00010106UL
\r
141 #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL
\r
142 #define OID_GEN_LINK_SPEED 0x00010107UL
\r
143 #define OID_GEN_TRANSMIT_BLOCK_SIZE 0x0001010AUL
\r
144 #define OID_GEN_RECEIVE_BLOCK_SIZE 0x0001010BUL
\r
145 #define OID_GEN_VENDOR_ID 0x0001010CUL
\r
146 #define OID_GEN_VENDOR_DESCRIPTION 0x0001010DUL
\r
147 #define OID_GEN_CURRENT_PACKET_FILTER 0x0001010EUL
\r
148 #define OID_GEN_MAXIMUM_TOTAL_SIZE 0x00010111UL
\r
149 #define OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL
\r
150 #define OID_GEN_PHYSICAL_MEDIUM 0x00010202UL
\r
151 #define OID_GEN_XMIT_OK 0x00020101UL
\r
152 #define OID_GEN_RCV_OK 0x00020102UL
\r
153 #define OID_GEN_XMIT_ERROR 0x00020103UL
\r
154 #define OID_GEN_RCV_ERROR 0x00020104UL
\r
155 #define OID_GEN_RCV_NO_BUFFER 0x00020105UL
\r
156 #define OID_802_3_PERMANENT_ADDRESS 0x01010101UL
\r
157 #define OID_802_3_CURRENT_ADDRESS 0x01010102UL
\r
158 #define OID_802_3_MULTICAST_LIST 0x01010103UL
\r
159 #define OID_802_3_MAXIMUM_LIST_SIZE 0x01010104UL
\r
160 #define OID_802_3_RCV_ERROR_ALIGNMENT 0x01020101UL
\r
161 #define OID_802_3_XMIT_ONE_COLLISION 0x01020102UL
\r
162 #define OID_802_3_XMIT_MORE_COLLISIONS 0x01020103UL
\r
165 /** Maximum size in bytes of a RNDIS control message which can be sent or received. */
\r
166 #define RNDIS_MESSAGE_BUFFER_SIZE 128
\r
168 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */
\r
169 #define ETHERNET_FRAME_SIZE_MAX 1500
\r
172 /** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */
\r
173 enum RNDIS_ClassRequests_t
\r
175 RNDIS_REQ_SendEncapsulatedCommand = 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */
\r
176 RNDIS_REQ_GetEncapsulatedResponse = 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */
\r
179 /** Enum for the possible NDIS adapter states. */
\r
180 enum RNDIS_States_t
\r
182 RNDIS_Uninitialized = 0, /**< Adapter currently uninitialized. */
\r
183 RNDIS_Initialized = 1, /**< Adapter currently initialized but not ready for data transfers. */
\r
184 RNDIS_Data_Initialized = 2, /**< Adapter currently initialized and ready for data transfers. */
\r
187 /** Enum for the RNDIS class specific notification requests that can be issued by a RNDIS device to a host. */
\r
188 enum RNDIS_ClassNotifications_t
\r
190 RNDIS_NOTIF_ResponseAvailable = 0x01, /**< Notification request value for a RNDIS Response Available notification. */
\r
193 /** Enum for the NDIS hardware states. */
\r
194 enum NDIS_Hardware_Status_t
\r
196 NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host. */
\r
197 NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing. */
\r
198 NDIS_HardwareStatus_Reset, /**< Hardware reset. */
\r
199 NDIS_HardwareStatus_Closing, /**< Hardware currently closing. */
\r
200 NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host. */
\r
203 /* Type Defines: */
\r
204 /** @brief MAC Address Structure.
\r
206 * Type define for a physical MAC address of a device on a network.
\r
208 typedef ATTR_IAR_PACKED struct
\r
210 uint8_t Octets[6]; /**< Individual bytes of a MAC address */
\r
211 } ATTR_PACKED MAC_Address_t;
\r
213 /** @brief RNDIS Common Message Header Structure.
\r
215 * Type define for a RNDIS message header, sent before RNDIS messages.
\r
217 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
219 typedef ATTR_IAR_PACKED struct
\r
221 uint32_t MessageType; /**< RNDIS message type, a \c REMOTE_NDIS_*_MSG constant */
\r
222 uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */
\r
223 } ATTR_PACKED RNDIS_Message_Header_t;
\r
225 /** @brief RNDIS Message Structure.
\r
227 * Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter.
\r
229 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
231 typedef ATTR_IAR_PACKED struct
\r
233 uint32_t MessageType;
\r
234 uint32_t MessageLength;
\r
235 uint32_t DataOffset;
\r
236 uint32_t DataLength;
\r
237 uint32_t OOBDataOffset;
\r
238 uint32_t OOBDataLength;
\r
239 uint32_t NumOOBDataElements;
\r
240 uint32_t PerPacketInfoOffset;
\r
241 uint32_t PerPacketInfoLength;
\r
244 } ATTR_PACKED RNDIS_Packet_Message_t;
\r
246 /** @brief RNDIS Initialization Message Structure.
\r
248 * Type define for a RNDIS Initialize command message.
\r
250 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
252 typedef ATTR_IAR_PACKED struct
\r
254 uint32_t MessageType;
\r
255 uint32_t MessageLength;
\r
256 uint32_t RequestId;
\r
258 uint32_t MajorVersion;
\r
259 uint32_t MinorVersion;
\r
260 uint32_t MaxTransferSize;
\r
261 } ATTR_PACKED RNDIS_Initialize_Message_t;
\r
263 /** @brief RNDIS Initialize Complete Message Structure.
\r
265 * Type define for a RNDIS Initialize Complete response message.
\r
267 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
269 typedef ATTR_IAR_PACKED struct
\r
271 uint32_t MessageType;
\r
272 uint32_t MessageLength;
\r
273 uint32_t RequestId;
\r
276 uint32_t MajorVersion;
\r
277 uint32_t MinorVersion;
\r
278 uint32_t DeviceFlags;
\r
280 uint32_t MaxPacketsPerTransfer;
\r
281 uint32_t MaxTransferSize;
\r
282 uint32_t PacketAlignmentFactor;
\r
283 uint32_t AFListOffset;
\r
284 uint32_t AFListSize;
\r
285 } ATTR_PACKED RNDIS_Initialize_Complete_t;
\r
287 /** @brief RNDIS Keep Alive Message Structure.
\r
289 * Type define for a RNDIS Keep Alive command message.
\r
291 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
293 typedef ATTR_IAR_PACKED struct
\r
295 uint32_t MessageType;
\r
296 uint32_t MessageLength;
\r
297 uint32_t RequestId;
\r
298 } ATTR_PACKED RNDIS_KeepAlive_Message_t;
\r
300 /** @brief RNDIS Keep Alive Complete Message Structure.
\r
302 * Type define for a RNDIS Keep Alive Complete response message.
\r
304 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
306 typedef ATTR_IAR_PACKED struct
\r
308 uint32_t MessageType;
\r
309 uint32_t MessageLength;
\r
310 uint32_t RequestId;
\r
312 } ATTR_PACKED RNDIS_KeepAlive_Complete_t;
\r
314 /** @brief RNDIS Reset Complete Message Structure.
\r
316 * Type define for a RNDIS Reset Complete response message.
\r
318 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
320 typedef ATTR_IAR_PACKED struct
\r
322 uint32_t MessageType;
\r
323 uint32_t MessageLength;
\r
326 uint32_t AddressingReset;
\r
327 } ATTR_PACKED RNDIS_Reset_Complete_t;
\r
329 /** @brief RNDIS OID Property Set Message Structure.
\r
331 * Type define for a RNDIS OID Property Set command message.
\r
333 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
335 typedef ATTR_IAR_PACKED struct
\r
337 uint32_t MessageType;
\r
338 uint32_t MessageLength;
\r
339 uint32_t RequestId;
\r
342 uint32_t InformationBufferLength;
\r
343 uint32_t InformationBufferOffset;
\r
344 uint32_t DeviceVcHandle;
\r
345 } ATTR_PACKED RNDIS_Set_Message_t;
\r
347 /** @brief RNDIS OID Property Set Complete Message Structure.
\r
349 * Type define for a RNDIS OID Property Set Complete response message.
\r
351 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
353 typedef ATTR_IAR_PACKED struct
\r
355 uint32_t MessageType;
\r
356 uint32_t MessageLength;
\r
357 uint32_t RequestId;
\r
359 } ATTR_PACKED RNDIS_Set_Complete_t;
\r
361 /** @brief RNDIS OID Property Query Message Structure.
\r
363 * Type define for a RNDIS OID Property Query command message.
\r
365 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
367 typedef ATTR_IAR_PACKED struct
\r
369 uint32_t MessageType;
\r
370 uint32_t MessageLength;
\r
371 uint32_t RequestId;
\r
374 uint32_t InformationBufferLength;
\r
375 uint32_t InformationBufferOffset;
\r
376 uint32_t DeviceVcHandle;
\r
377 } ATTR_PACKED RNDIS_Query_Message_t;
\r
379 /** @brief RNDIS OID Property Query Complete Message Structure.
\r
381 * Type define for a RNDIS OID Property Query Complete response message.
\r
383 * @note Regardless of CPU architecture, these values should be stored as little endian.
\r
385 typedef ATTR_IAR_PACKED struct
\r
387 uint32_t MessageType;
\r
388 uint32_t MessageLength;
\r
389 uint32_t RequestId;
\r
392 uint32_t InformationBufferLength;
\r
393 uint32_t InformationBufferOffset;
\r
394 } ATTR_PACKED RNDIS_Query_Complete_t;
\r
396 /* Disable C linkage for C++ Compilers: */
\r
397 #if defined(__cplusplus)
\r