Added incomplete MIDIToneGenerator project.
[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 /** \ingroup Group_USBClassRNDIS
32 * @defgroup Group_USBClassRNDISCommon Common Class Definitions
33 *
34 * \section Module Description
35 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
36 * RNDIS Class.
37 *
38 * @{
39 */
40
41 #ifndef _RNDIS_CLASS_COMMON_H_
42 #define _RNDIS_CLASS_COMMON_H_
43
44 /* Macros: */
45 #define __INCLUDE_FROM_CDC_DRIVER
46
47 /* Includes: */
48 #include "../../USB.h"
49 #include "RNDISConstants.h"
50 #include "CDC.h"
51
52 #include <string.h>
53
54 /* Enable C linkage for C++ Compilers: */
55 #if defined(__cplusplus)
56 extern "C" {
57 #endif
58
59 /* Preprocessor Checks: */
60 #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)
61 #error Do not include this file directly. Include LUFA/Drivers/Class/RNDIS.h instead.
62 #endif
63
64 /* Macros: */
65 /** Implemented RNDIS Version Major */
66 #define REMOTE_NDIS_VERSION_MAJOR 0x01
67
68 /** Implemented RNDIS Version Minor */
69 #define REMOTE_NDIS_VERSION_MINOR 0x00
70
71 /** RNDIS request to issue a host-to-device NDIS command */
72 #define REQ_SendEncapsulatedCommand 0x00
73
74 /** RNDIS request to issue a device-to-host NDIS response */
75 #define REQ_GetEncapsulatedResponse 0x01
76
77 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
78 #define RNDIS_MESSAGE_BUFFER_SIZE 128
79
80 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard */
81 #define ETHERNET_FRAME_SIZE_MAX 1500
82
83 /** Notification request value for a RNDIS Response Available notification */
84 #define NOTIF_ResponseAvailable 1
85
86 /* Enums: */
87 /** Enum for the possible NDIS adapter states. */
88 enum RNDIS_States_t
89 {
90 RNDIS_Uninitialized = 0, /**< Adapter currently uninitialized */
91 RNDIS_Initialized = 1, /**< Adapter currently initialized but not ready for data transfers */
92 RNDIS_Data_Initialized = 2, /**< Adapter currently initialized and ready for data transfers */
93 };
94
95 /** Enum for the NDIS hardware states */
96 enum NDIS_Hardware_Status_t
97 {
98 NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host */
99 NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing */
100 NDIS_HardwareStatus_Reset, /**< Hardware reset */
101 NDIS_HardwareStatus_Closing, /**< Hardware currently closing */
102 NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host */
103 };
104
105 /* Type Defines: */
106 /** Type define for a physical MAC address of a device on a network */
107 typedef struct
108 {
109 uint8_t Octets[6]; /**< Individual bytes of a MAC address */
110 } MAC_Address_t;
111
112 /** Type define for an Ethernet frame buffer. */
113 typedef struct
114 {
115 uint8_t FrameData[ETHERNET_FRAME_SIZE_MAX]; /**< Ethernet frame contents */
116 uint16_t FrameLength; /**< Length in bytes of the Ethernet frame stored in the buffer */
117 bool FrameInBuffer; /**< Indicates if a frame is currently stored in the buffer */
118 } Ethernet_Frame_Info_t;
119
120 /** Type define for a RNDIS message header, sent before RNDIS messages */
121 typedef struct
122 {
123 uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
124 uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */
125 } RNDIS_Message_Header_t;
126
127 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
128 typedef struct
129 {
130 uint32_t MessageType;
131 uint32_t MessageLength;
132 uint32_t DataOffset;
133 uint32_t DataLength;
134 uint32_t OOBDataOffset;
135 uint32_t OOBDataLength;
136 uint32_t NumOOBDataElements;
137 uint32_t PerPacketInfoOffset;
138 uint32_t PerPacketInfoLength;
139 uint32_t VcHandle;
140 uint32_t Reserved;
141 } RNDIS_Packet_Message_t;
142
143 /** Type define for a RNDIS Initialize command message */
144 typedef struct
145 {
146 uint32_t MessageType;
147 uint32_t MessageLength;
148 uint32_t RequestId;
149
150 uint32_t MajorVersion;
151 uint32_t MinorVersion;
152 uint32_t MaxTransferSize;
153 } RNDIS_Initialize_Message_t;
154
155 /** Type define for a RNDIS Initialize complete response message */
156 typedef struct
157 {
158 uint32_t MessageType;
159 uint32_t MessageLength;
160 uint32_t RequestId;
161 uint32_t Status;
162
163 uint32_t MajorVersion;
164 uint32_t MinorVersion;
165 uint32_t DeviceFlags;
166 uint32_t Medium;
167 uint32_t MaxPacketsPerTransfer;
168 uint32_t MaxTransferSize;
169 uint32_t PacketAlignmentFactor;
170 uint32_t AFListOffset;
171 uint32_t AFListSize;
172 } RNDIS_Initialize_Complete_t;
173
174 /** Type define for a RNDIS Keepalive command message */
175 typedef struct
176 {
177 uint32_t MessageType;
178 uint32_t MessageLength;
179 uint32_t RequestId;
180 } RNDIS_KeepAlive_Message_t;
181
182 /** Type define for a RNDIS Keepalive complete message */
183 typedef struct
184 {
185 uint32_t MessageType;
186 uint32_t MessageLength;
187 uint32_t RequestId;
188 uint32_t Status;
189 } RNDIS_KeepAlive_Complete_t;
190
191 /** Type define for a RNDIS Reset complete message */
192 typedef struct
193 {
194 uint32_t MessageType;
195 uint32_t MessageLength;
196 uint32_t Status;
197
198 uint32_t AddressingReset;
199 } RNDIS_Reset_Complete_t;
200
201 /** Type define for a RNDIS Set command message */
202 typedef struct
203 {
204 uint32_t MessageType;
205 uint32_t MessageLength;
206 uint32_t RequestId;
207
208 uint32_t Oid;
209 uint32_t InformationBufferLength;
210 uint32_t InformationBufferOffset;
211 uint32_t DeviceVcHandle;
212 } RNDIS_Set_Message_t;
213
214 /** Type define for a RNDIS Set complete response message */
215 typedef struct
216 {
217 uint32_t MessageType;
218 uint32_t MessageLength;
219 uint32_t RequestId;
220 uint32_t Status;
221 } RNDIS_Set_Complete_t;
222
223 /** Type define for a RNDIS Query command message */
224 typedef struct
225 {
226 uint32_t MessageType;
227 uint32_t MessageLength;
228 uint32_t RequestId;
229
230 uint32_t Oid;
231 uint32_t InformationBufferLength;
232 uint32_t InformationBufferOffset;
233 uint32_t DeviceVcHandle;
234 } RNDIS_Query_Message_t;
235
236 /** Type define for a RNDIS Query complete response message */
237 typedef struct
238 {
239 uint32_t MessageType;
240 uint32_t MessageLength;
241 uint32_t RequestId;
242 uint32_t Status;
243
244 uint32_t InformationBufferLength;
245 uint32_t InformationBufferOffset;
246 } RNDIS_Query_Complete_t;
247
248 /* Disable C linkage for C++ Compilers: */
249 #if defined(__cplusplus)
250 }
251 #endif
252
253 #endif
254
255 /** @} */