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 * \note This file should not be included directly. It is automatically included as needed by the class driver
35 * dispatch header located in LUFA/Drivers/USB/Class/RNDIS.h.
38 /** \ingroup Group_USBClassRNDIS
39 * @defgroup Group_USBClassRNDISCommon Common Class Definitions
41 * \section Module Description
42 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
48 #ifndef _RNDIS_CLASS_COMMON_H_
49 #define _RNDIS_CLASS_COMMON_H_
52 #define __INCLUDE_FROM_CDC_DRIVER
55 #include "../../USB.h"
56 #include "RNDISConstants.h"
61 /* Enable C linkage for C++ Compilers: */
62 #if defined(__cplusplus)
66 /* Preprocessor Checks: */
67 #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)
68 #error Do not include this file directly. Include LUFA/Drivers/Class/RNDIS.h instead.
72 /** Implemented RNDIS Version Major */
73 #define REMOTE_NDIS_VERSION_MAJOR 0x01
75 /** Implemented RNDIS Version Minor */
76 #define REMOTE_NDIS_VERSION_MINOR 0x00
78 /** RNDIS request to issue a host-to-device NDIS command */
79 #define REQ_SendEncapsulatedCommand 0x00
81 /** RNDIS request to issue a device-to-host NDIS response */
82 #define REQ_GetEncapsulatedResponse 0x01
84 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
85 #define RNDIS_MESSAGE_BUFFER_SIZE 128
87 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard */
88 #define ETHERNET_FRAME_SIZE_MAX 1500
90 /** Notification request value for a RNDIS Response Available notification */
91 #define NOTIF_ResponseAvailable 1
94 /** Enum for the possible NDIS adapter states. */
97 RNDIS_Uninitialized
= 0, /**< Adapter currently uninitialized */
98 RNDIS_Initialized
= 1, /**< Adapter currently initialized but not ready for data transfers */
99 RNDIS_Data_Initialized
= 2, /**< Adapter currently initialized and ready for data transfers */
102 /** Enum for the NDIS hardware states */
103 enum NDIS_Hardware_Status_t
105 NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host */
106 NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing */
107 NDIS_HardwareStatus_Reset
, /**< Hardware reset */
108 NDIS_HardwareStatus_Closing
, /**< Hardware currently closing */
109 NDIS_HardwareStatus_NotReady
/**< Hardware not ready to accept commands from the host */
113 /** Type define for a physical MAC address of a device on a network */
116 uint8_t Octets
[6]; /**< Individual bytes of a MAC address */
119 /** Type define for an Ethernet frame buffer. */
122 uint8_t FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents */
123 uint16_t FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer */
124 bool FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer */
125 } Ethernet_Frame_Info_t
;
127 /** Type define for a RNDIS message header, sent before RNDIS messages */
130 uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
131 uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */
132 } RNDIS_Message_Header_t
;
134 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
137 uint32_t MessageType
;
138 uint32_t MessageLength
;
141 uint32_t OOBDataOffset
;
142 uint32_t OOBDataLength
;
143 uint32_t NumOOBDataElements
;
144 uint32_t PerPacketInfoOffset
;
145 uint32_t PerPacketInfoLength
;
148 } RNDIS_Packet_Message_t
;
150 /** Type define for a RNDIS Initialize command message */
153 uint32_t MessageType
;
154 uint32_t MessageLength
;
157 uint32_t MajorVersion
;
158 uint32_t MinorVersion
;
159 uint32_t MaxTransferSize
;
160 } RNDIS_Initialize_Message_t
;
162 /** Type define for a RNDIS Initialize complete response message */
165 uint32_t MessageType
;
166 uint32_t MessageLength
;
170 uint32_t MajorVersion
;
171 uint32_t MinorVersion
;
172 uint32_t DeviceFlags
;
174 uint32_t MaxPacketsPerTransfer
;
175 uint32_t MaxTransferSize
;
176 uint32_t PacketAlignmentFactor
;
177 uint32_t AFListOffset
;
179 } RNDIS_Initialize_Complete_t
;
181 /** Type define for a RNDIS Keepalive command message */
184 uint32_t MessageType
;
185 uint32_t MessageLength
;
187 } RNDIS_KeepAlive_Message_t
;
189 /** Type define for a RNDIS Keepalive complete message */
192 uint32_t MessageType
;
193 uint32_t MessageLength
;
196 } RNDIS_KeepAlive_Complete_t
;
198 /** Type define for a RNDIS Reset complete message */
201 uint32_t MessageType
;
202 uint32_t MessageLength
;
205 uint32_t AddressingReset
;
206 } RNDIS_Reset_Complete_t
;
208 /** Type define for a RNDIS Set command message */
211 uint32_t MessageType
;
212 uint32_t MessageLength
;
216 uint32_t InformationBufferLength
;
217 uint32_t InformationBufferOffset
;
218 uint32_t DeviceVcHandle
;
219 } RNDIS_Set_Message_t
;
221 /** Type define for a RNDIS Set complete response message */
224 uint32_t MessageType
;
225 uint32_t MessageLength
;
228 } RNDIS_Set_Complete_t
;
230 /** Type define for a RNDIS Query command message */
233 uint32_t MessageType
;
234 uint32_t MessageLength
;
238 uint32_t InformationBufferLength
;
239 uint32_t InformationBufferOffset
;
240 uint32_t DeviceVcHandle
;
241 } RNDIS_Query_Message_t
;
243 /** Type define for a RNDIS Query complete response message */
246 uint32_t MessageType
;
247 uint32_t MessageLength
;
251 uint32_t InformationBufferLength
;
252 uint32_t InformationBufferOffset
;
253 } RNDIS_Query_Complete_t
;
255 /* Disable C linkage for C++ Compilers: */
256 #if defined(__cplusplus)