Fixed LowLevel JoystickHostWithParser demo not saving the chosen HID interface's...
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Common / RNDIS.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2010.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
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.
20
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
28 this software.
29 */
30
31 /** \file
32 * \brief Common definitions and declarations for the library USB RNDIS Class driver.
33 *
34 * Common definitions and declarations for the library USB RNDIS Class driver.
35 *
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.
38 */
39
40 /** \ingroup Group_USBClassRNDIS
41 * @defgroup Group_USBClassRNDISCommon Common Class Definitions
42 *
43 * \section Module Description
44 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
45 * RNDIS Class.
46 *
47 * @{
48 */
49
50 #ifndef _RNDIS_CLASS_COMMON_H_
51 #define _RNDIS_CLASS_COMMON_H_
52
53 /* Macros: */
54 #define __INCLUDE_FROM_CDC_DRIVER
55
56 /* Includes: */
57 #include "../../USB.h"
58 #include "RNDISConstants.h"
59 #include "CDC.h"
60
61 #include <string.h>
62
63 /* Enable C linkage for C++ Compilers: */
64 #if defined(__cplusplus)
65 extern "C" {
66 #endif
67
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.
71 #endif
72
73 /* Macros: */
74 /** Implemented RNDIS Version Major. */
75 #define REMOTE_NDIS_VERSION_MAJOR 0x01
76
77 /** Implemented RNDIS Version Minor. */
78 #define REMOTE_NDIS_VERSION_MINOR 0x00
79
80 /** Maximum size in bytes of a RNDIS control message which can be sent or received. */
81 #define RNDIS_MESSAGE_BUFFER_SIZE 128
82
83 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */
84 #define ETHERNET_FRAME_SIZE_MAX 1500
85
86 /* Enums: */
87 /** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */
88 enum RNDIS_ClassRequests_t
89 {
90 RNDIS_REQ_SendEncapsulatedCommand = 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */
91 RNDIS_REQ_GetEncapsulatedResponse = 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */
92 };
93
94 /** Enum for the possible NDIS adapter states. */
95 enum RNDIS_States_t
96 {
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. */
100 };
101
102 /** Enum for the RNDIS class specific notification requests that can be issued by a RNDIS device to a host. */
103 enum RNDIS_ClassNotifications_t
104 {
105 RNDIS_NOTIF_ResponseAvailable = 0x01, /**< Notification request value for a RNDIS Response Available notification. */
106 };
107
108 /** Enum for the NDIS hardware states. */
109 enum NDIS_Hardware_Status_t
110 {
111 NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host. */
112 NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing. */
113 NDIS_HardwareStatus_Reset, /**< Hardware reset. */
114 NDIS_HardwareStatus_Closing, /**< Hardware currently closing. */
115 NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host. */
116 };
117
118 /* Type Defines: */
119 /** \brief MAC Address Structure.
120 *
121 * Type define for a physical MAC address of a device on a network.
122 */
123 typedef struct
124 {
125 uint8_t Octets[6]; /**< Individual bytes of a MAC address */
126 } MAC_Address_t;
127
128 /** \brief RNDIS Ethernet Frame Packet Information Structure.
129 *
130 * Type define for an Ethernet frame buffer data and information structure.
131 */
132 typedef struct
133 {
134 uint8_t FrameData[ETHERNET_FRAME_SIZE_MAX]; /**< Ethernet frame contents. */
135 uint16_t FrameLength; /**< Length in bytes of the Ethernet frame stored in the buffer. */
136 bool FrameInBuffer; /**< Indicates if a frame is currently stored in the buffer. */
137 } Ethernet_Frame_Info_t;
138
139 /** \brief RNDIS Common Message Header Structure.
140 *
141 * Type define for a RNDIS message header, sent before RNDIS messages.
142 */
143 typedef struct
144 {
145 uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
146 uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */
147 } RNDIS_Message_Header_t;
148
149 /** \brief RNDIS Message Structure.
150 *
151 * Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter.
152 */
153 typedef struct
154 {
155 uint32_t MessageType;
156 uint32_t MessageLength;
157 uint32_t DataOffset;
158 uint32_t DataLength;
159 uint32_t OOBDataOffset;
160 uint32_t OOBDataLength;
161 uint32_t NumOOBDataElements;
162 uint32_t PerPacketInfoOffset;
163 uint32_t PerPacketInfoLength;
164 uint32_t VcHandle;
165 uint32_t Reserved;
166 } RNDIS_Packet_Message_t;
167
168 /** \brief RNDIS Initialization Message Structure.
169 *
170 * Type define for a RNDIS Initialize command message.
171 */
172 typedef struct
173 {
174 uint32_t MessageType;
175 uint32_t MessageLength;
176 uint32_t RequestId;
177
178 uint32_t MajorVersion;
179 uint32_t MinorVersion;
180 uint32_t MaxTransferSize;
181 } RNDIS_Initialize_Message_t;
182
183 /** \brief RNDIS Initialize Complete Message Structure.
184 *
185 * Type define for a RNDIS Initialize Complete response message.
186 */
187 typedef struct
188 {
189 uint32_t MessageType;
190 uint32_t MessageLength;
191 uint32_t RequestId;
192 uint32_t Status;
193
194 uint32_t MajorVersion;
195 uint32_t MinorVersion;
196 uint32_t DeviceFlags;
197 uint32_t Medium;
198 uint32_t MaxPacketsPerTransfer;
199 uint32_t MaxTransferSize;
200 uint32_t PacketAlignmentFactor;
201 uint32_t AFListOffset;
202 uint32_t AFListSize;
203 } RNDIS_Initialize_Complete_t;
204
205 /** \brief RNDIS Keep Alive Message Structure.
206 *
207 * Type define for a RNDIS Keep Alive command message.
208 */
209 typedef struct
210 {
211 uint32_t MessageType;
212 uint32_t MessageLength;
213 uint32_t RequestId;
214 } RNDIS_KeepAlive_Message_t;
215
216 /** \brief RNDIS Keep Alive Complete Message Structure.
217 *
218 * Type define for a RNDIS Keep Alive Complete response message.
219 */
220 typedef struct
221 {
222 uint32_t MessageType;
223 uint32_t MessageLength;
224 uint32_t RequestId;
225 uint32_t Status;
226 } RNDIS_KeepAlive_Complete_t;
227
228 /** \brief RNDIS Reset Complete Message Structure.
229 *
230 * Type define for a RNDIS Reset Complete response message.
231 */
232 typedef struct
233 {
234 uint32_t MessageType;
235 uint32_t MessageLength;
236 uint32_t Status;
237
238 uint32_t AddressingReset;
239 } RNDIS_Reset_Complete_t;
240
241 /** \brief RNDIS OID Property Set Message Structure.
242 *
243 * Type define for a RNDIS OID Property Set command message.
244 */
245 typedef struct
246 {
247 uint32_t MessageType;
248 uint32_t MessageLength;
249 uint32_t RequestId;
250
251 uint32_t Oid;
252 uint32_t InformationBufferLength;
253 uint32_t InformationBufferOffset;
254 uint32_t DeviceVcHandle;
255 } RNDIS_Set_Message_t;
256
257 /** \brief RNDIS OID Property Set Complete Message Structure.
258 *
259 * Type define for a RNDIS OID Property Set Complete response message.
260 */
261 typedef struct
262 {
263 uint32_t MessageType;
264 uint32_t MessageLength;
265 uint32_t RequestId;
266 uint32_t Status;
267 } RNDIS_Set_Complete_t;
268
269 /** \brief RNDIS OID Property Query Message Structure.
270 *
271 * Type define for a RNDIS OID Property Query command message.
272 */
273 typedef struct
274 {
275 uint32_t MessageType;
276 uint32_t MessageLength;
277 uint32_t RequestId;
278
279 uint32_t Oid;
280 uint32_t InformationBufferLength;
281 uint32_t InformationBufferOffset;
282 uint32_t DeviceVcHandle;
283 } RNDIS_Query_Message_t;
284
285 /** \brief RNDIS OID Property Query Complete Message Structure.
286 *
287 * Type define for a RNDIS OID Property Query Complete response message.
288 */
289 typedef struct
290 {
291 uint32_t MessageType;
292 uint32_t MessageLength;
293 uint32_t RequestId;
294 uint32_t Status;
295
296 uint32_t InformationBufferLength;
297 uint32_t InformationBufferOffset;
298 } RNDIS_Query_Complete_t;
299
300 /* Disable C linkage for C++ Compilers: */
301 #if defined(__cplusplus)
302 }
303 #endif
304
305 #endif
306
307 /** @} */