3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
12 Permission to use, copy, modify, distribute, and sell this
13 software and its documentation for any purpose is hereby granted
14 without fee, provided that the above copyright notice appear in
15 all copies and that both that the copyright notice and this
16 permission notice and warranty disclaimer appear in supporting
17 documentation, and that the name of the author not be used in
18 advertising or publicity pertaining to distribution of the
19 software without specific, written prior permission.
21 The author disclaim all warranties with regard to this
22 software, including all implied warranties of merchantability
23 and fitness. In no event shall the author be liable for any
24 special, indirect or consequential damages or any damages
25 whatsoever resulting from loss of use, data or profits, whether
26 in an action of contract, negligence or other tortious action,
27 arising out of or in connection with the use or performance of
32 * \brief Common definitions and declarations for the library USB RNDIS Class driver.
34 * Common definitions and declarations for the library USB RNDIS Class driver.
36 * \note This file should not be included directly. It is automatically included as needed by the class driver
37 * dispatch header located in LUFA/Drivers/USB/Class/RNDIS.h.
40 /** \ingroup Group_USBClassRNDIS
41 * @defgroup Group_USBClassRNDISCommon Common Class Definitions
43 * \section Module Description
44 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
50 #ifndef _RNDIS_CLASS_COMMON_H_
51 #define _RNDIS_CLASS_COMMON_H_
54 #define __INCLUDE_FROM_CDC_DRIVER
57 #include "../../USB.h"
58 #include "RNDISConstants.h"
63 /* Enable C linkage for C++ Compilers: */
64 #if defined(__cplusplus)
68 /* Preprocessor Checks: */
69 #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)
70 #error Do not include this file directly. Include LUFA/Drivers/Class/RNDIS.h instead.
74 /** Implemented RNDIS Version Major. */
75 #define REMOTE_NDIS_VERSION_MAJOR 0x01
77 /** Implemented RNDIS Version Minor. */
78 #define REMOTE_NDIS_VERSION_MINOR 0x00
80 /** Maximum size in bytes of a RNDIS control message which can be sent or received. */
81 #define RNDIS_MESSAGE_BUFFER_SIZE 128
83 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */
84 #define ETHERNET_FRAME_SIZE_MAX 1500
86 /** Notification request value for a RNDIS Response Available notification. */
87 #define NOTIF_ResponseAvailable 1
90 /** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */
91 enum RNDIS_ClassRequests_t
93 RNDIS_REQ_SendEncapsulatedCommand
= 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */
94 RNDIS_REQ_GetEncapsulatedResponse
= 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */
97 /** Enum for the possible NDIS adapter states. */
100 RNDIS_Uninitialized
= 0, /**< Adapter currently uninitialized. */
101 RNDIS_Initialized
= 1, /**< Adapter currently initialized but not ready for data transfers. */
102 RNDIS_Data_Initialized
= 2, /**< Adapter currently initialized and ready for data transfers. */
105 /** Enum for the NDIS hardware states. */
106 enum NDIS_Hardware_Status_t
108 NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host. */
109 NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing. */
110 NDIS_HardwareStatus_Reset
, /**< Hardware reset. */
111 NDIS_HardwareStatus_Closing
, /**< Hardware currently closing. */
112 NDIS_HardwareStatus_NotReady
/**< Hardware not ready to accept commands from the host. */
116 /** \brief MAC Address Structure.
118 * Type define for a physical MAC address of a device on a network.
122 uint8_t Octets
[6]; /**< Individual bytes of a MAC address */
125 /** \brief RNDIS Ethernet Frame Packet Information Structure.
127 * Type define for an Ethernet frame buffer data and information structure.
131 uint8_t FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents. */
132 uint16_t FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer. */
133 bool FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer. */
134 } Ethernet_Frame_Info_t
;
136 /** \brief RNDIS Common Message Header Structure.
138 * Type define for a RNDIS message header, sent before RNDIS messages.
142 uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
143 uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */
144 } RNDIS_Message_Header_t
;
146 /** \brief RNDIS Message Structure.
148 * Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter.
152 uint32_t MessageType
;
153 uint32_t MessageLength
;
156 uint32_t OOBDataOffset
;
157 uint32_t OOBDataLength
;
158 uint32_t NumOOBDataElements
;
159 uint32_t PerPacketInfoOffset
;
160 uint32_t PerPacketInfoLength
;
163 } RNDIS_Packet_Message_t
;
165 /** \brief RNDIS Initialization Message Structure.
167 * Type define for a RNDIS Initialize command message.
171 uint32_t MessageType
;
172 uint32_t MessageLength
;
175 uint32_t MajorVersion
;
176 uint32_t MinorVersion
;
177 uint32_t MaxTransferSize
;
178 } RNDIS_Initialize_Message_t
;
180 /** \brief RNDIS Initialize Complete Message Structure.
182 * Type define for a RNDIS Initialize Complete response message.
186 uint32_t MessageType
;
187 uint32_t MessageLength
;
191 uint32_t MajorVersion
;
192 uint32_t MinorVersion
;
193 uint32_t DeviceFlags
;
195 uint32_t MaxPacketsPerTransfer
;
196 uint32_t MaxTransferSize
;
197 uint32_t PacketAlignmentFactor
;
198 uint32_t AFListOffset
;
200 } RNDIS_Initialize_Complete_t
;
202 /** \brief RNDIS Keep Alive Message Structure.
204 * Type define for a RNDIS Keep Alive command message.
208 uint32_t MessageType
;
209 uint32_t MessageLength
;
211 } RNDIS_KeepAlive_Message_t
;
213 /** \brief RNDIS Keep Alive Complete Message Structure.
215 * Type define for a RNDIS Keep Alive Complete response message.
219 uint32_t MessageType
;
220 uint32_t MessageLength
;
223 } RNDIS_KeepAlive_Complete_t
;
225 /** \brief RNDIS Reset Complete Message Structure.
227 * Type define for a RNDIS Reset Complete response message.
231 uint32_t MessageType
;
232 uint32_t MessageLength
;
235 uint32_t AddressingReset
;
236 } RNDIS_Reset_Complete_t
;
238 /** \brief RNDIS OID Property Set Message Structure.
240 * Type define for a RNDIS OID Property Set command message.
244 uint32_t MessageType
;
245 uint32_t MessageLength
;
249 uint32_t InformationBufferLength
;
250 uint32_t InformationBufferOffset
;
251 uint32_t DeviceVcHandle
;
252 } RNDIS_Set_Message_t
;
254 /** \brief RNDIS OID Property Set Complete Message Structure.
256 * Type define for a RNDIS OID Property Set Complete response message.
260 uint32_t MessageType
;
261 uint32_t MessageLength
;
264 } RNDIS_Set_Complete_t
;
266 /** \brief RNDIS OID Property Query Message Structure.
268 * Type define for a RNDIS OID Property Query command message.
272 uint32_t MessageType
;
273 uint32_t MessageLength
;
277 uint32_t InformationBufferLength
;
278 uint32_t InformationBufferOffset
;
279 uint32_t DeviceVcHandle
;
280 } RNDIS_Query_Message_t
;
282 /** \brief RNDIS OID Property Query Complete Message Structure.
284 * Type define for a RNDIS OID Property Query Complete response message.
288 uint32_t MessageType
;
289 uint32_t MessageLength
;
293 uint32_t InformationBufferLength
;
294 uint32_t InformationBufferOffset
;
295 } RNDIS_Query_Complete_t
;
297 /* Disable C linkage for C++ Compilers: */
298 #if defined(__cplusplus)