More Doxygen fixes - ensure no undocumented function parameters.
[pub/USBasp.git] / LUFA / Drivers / USB / Class / Common / RNDIS.h
1 /*
2 LUFA Library
3 Copyright (C) Dean Camera, 2009.
4
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
7 */
8
9 /*
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11
12 Permission to use, copy, modify, and distribute this software
13 and its documentation for any purpose and without fee is hereby
14 granted, provided that the above copyright notice appear in all
15 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 * @{
33 */
34
35 #ifndef _RNDIS_CLASS_COMMON_H_
36 #define _RNDIS_CLASS_COMMON_H_
37
38 /* Includes: */
39 #include "../../USB.h"
40
41 #include <string.h>
42
43 /* Enable C linkage for C++ Compilers: */
44 #if defined(__cplusplus)
45 extern "C" {
46 #endif
47
48 /* Macros: */
49 /** Implemented RNDIS Version Major */
50 #define REMOTE_NDIS_VERSION_MAJOR 0x01
51
52 /** Implemented RNDIS Version Minor */
53 #define REMOTE_NDIS_VERSION_MINOR 0x00
54
55 /** RNDIS request to issue a host-to-device NDIS command */
56 #define REQ_SendEncapsulatedCommand 0x00
57
58 /** RNDIS request to issue a device-to-host NDIS response */
59 #define REQ_GetEncapsulatedResponse 0x01
60
61 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
62 #define RNDIS_MESSAGE_BUFFER_SIZE 128
63
64 /** Maximum size in bytes of an Ethernet frame which can be sent or received */
65 #define ETHERNET_FRAME_SIZE_MAX 1500
66
67 /** Notification request value for a RNDIS Response Available notification */
68 #define NOTIF_ResponseAvailable 1
69
70 /* Enums: */
71 /** Enum for the possible NDIS adapter states. */
72 enum RNDIS_States_t
73 {
74 RNDIS_Uninitialized = 0, /**< Adapter currently uninitialized */
75 RNDIS_Initialized = 1, /**< Adapter currently initialized but not ready for data transfers */
76 RNDIS_Data_Initialized = 2, /**< Adapter currently initialized and ready for data transfers */
77 };
78
79 /** Enum for the NDIS hardware states */
80 enum NDIS_Hardware_Status_t
81 {
82 NDIS_HardwareStatus_Ready, /**< Hardware Ready to accept commands from the host */
83 NDIS_HardwareStatus_Initializing, /**< Hardware busy initializing */
84 NDIS_HardwareStatus_Reset, /**< Hardware reset */
85 NDIS_HardwareStatus_Closing, /**< Hardware currently closing */
86 NDIS_HardwareStatus_NotReady /**< Hardware not ready to accept commands from the host */
87 };
88
89 /* Type Defines: */
90 /** Type define for a physical MAC address of a device on a network */
91 typedef struct
92 {
93 uint8_t Octets[6]; /**< Individual bytes of a MAC address */
94 } MAC_Address_t;
95
96 /** Type define for a RNDIS message header, sent before RNDIS messages */
97 typedef struct
98 {
99 uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
100 uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */
101 } RNDIS_Message_Header_t;
102
103 /** Type define for an Ethernet frame buffer. */
104 typedef struct
105 {
106 uint8_t FrameData[ETHERNET_FRAME_SIZE_MAX]; /**< Ethernet frame contents */
107 uint16_t FrameLength; /**< Length in bytes of the Ethernet frame stored in the buffer */
108 bool FrameInBuffer; /**< Indicates if a frame is currently stored in the buffer */
109 } Ethernet_Frame_Info_t;
110
111 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
112 typedef struct
113 {
114 uint32_t MessageType;
115 uint32_t MessageLength;
116 uint32_t DataOffset;
117 uint32_t DataLength;
118 uint32_t OOBDataOffset;
119 uint32_t OOBDataLength;
120 uint32_t NumOOBDataElements;
121 uint32_t PerPacketInfoOffset;
122 uint32_t PerPacketInfoLength;
123 uint32_t VcHandle;
124 uint32_t Reserved;
125 } RNDIS_PACKET_MSG_t;
126
127 /** Type define for a RNDIS Initialize command message */
128 typedef struct
129 {
130 uint32_t MessageType;
131 uint32_t MessageLength;
132 uint32_t RequestId;
133
134 uint32_t MajorVersion;
135 uint32_t MinorVersion;
136 uint32_t MaxTransferSize;
137 } RNDIS_INITIALIZE_MSG_t;
138
139 /** Type define for a RNDIS Initialize complete response message */
140 typedef struct
141 {
142 uint32_t MessageType;
143 uint32_t MessageLength;
144 uint32_t RequestId;
145 uint32_t Status;
146
147 uint32_t MajorVersion;
148 uint32_t MinorVersion;
149 uint32_t DeviceFlags;
150 uint32_t Medium;
151 uint32_t MaxPacketsPerTransfer;
152 uint32_t MaxTransferSize;
153 uint32_t PacketAlignmentFactor;
154 uint32_t AFListOffset;
155 uint32_t AFListSize;
156 } RNDIS_INITIALIZE_CMPLT_t;
157
158 /** Type define for a RNDIS Keepalive command message */
159 typedef struct
160 {
161 uint32_t MessageType;
162 uint32_t MessageLength;
163 uint32_t RequestId;
164 } RNDIS_KEEPALIVE_MSG_t;
165
166 /** Type define for a RNDIS Keepalive complete message */
167 typedef struct
168 {
169 uint32_t MessageType;
170 uint32_t MessageLength;
171 uint32_t RequestId;
172 uint32_t Status;
173 } RNDIS_KEEPALIVE_CMPLT_t;
174
175 /** Type define for a RNDIS Reset complete message */
176 typedef struct
177 {
178 uint32_t MessageType;
179 uint32_t MessageLength;
180 uint32_t Status;
181
182 uint32_t AddressingReset;
183 } RNDIS_RESET_CMPLT_t;
184
185 /** Type define for a RNDIS Set command message */
186 typedef struct
187 {
188 uint32_t MessageType;
189 uint32_t MessageLength;
190 uint32_t RequestId;
191
192 uint32_t Oid;
193 uint32_t InformationBufferLength;
194 uint32_t InformationBufferOffset;
195 uint32_t DeviceVcHandle;
196 } RNDIS_SET_MSG_t;
197
198 /** Type define for a RNDIS Set complete response message */
199 typedef struct
200 {
201 uint32_t MessageType;
202 uint32_t MessageLength;
203 uint32_t RequestId;
204 uint32_t Status;
205 } RNDIS_SET_CMPLT_t;
206
207 /** Type define for a RNDIS Query command message */
208 typedef struct
209 {
210 uint32_t MessageType;
211 uint32_t MessageLength;
212 uint32_t RequestId;
213
214 uint32_t Oid;
215 uint32_t InformationBufferLength;
216 uint32_t InformationBufferOffset;
217 uint32_t DeviceVcHandle;
218 } RNDIS_QUERY_MSG_t;
219
220 /** Type define for a RNDIS Query complete response message */
221 typedef struct
222 {
223 uint32_t MessageType;
224 uint32_t MessageLength;
225 uint32_t RequestId;
226 uint32_t Status;
227
228 uint32_t InformationBufferLength;
229 uint32_t InformationBufferOffset;
230 } RNDIS_QUERY_CMPLT_t;
231
232 /** Class state structure. An instance of this structure should be made for each RNDIS interface
233 * within the user application, and passed to each of the RNDIS class driver functions as the
234 * RNDISInterfaceInfo parameter. The contents of this structure should be set to their correct
235 * values when used, or ommitted to force the library to use default values.
236 */
237 typedef struct
238 {
239 uint8_t ControlInterfaceNumber; /**< Interface number of the CDC control interface within the device */
240
241 uint8_t DataINEndpointNumber; /**< Endpoint number of the CDC interface's IN data endpoint */
242 uint16_t DataINEndpointSize; /**< Size in bytes of the CDC interface's IN data endpoint */
243
244 uint8_t DataOUTEndpointNumber; /**< Endpoint number of the CDC interface's OUT data endpoint */
245 uint16_t DataOUTEndpointSize; /**< Size in bytes of the CDC interface's OUT data endpoint */
246
247 uint8_t NotificationEndpointNumber; /**< Endpoint number of the CDC interface's IN notification endpoint, if used */
248 uint16_t NotificationEndpointSize; /**< Size in bytes of the CDC interface's IN notification endpoint, if used */
249
250 char* AdapterVendorDescription; /**< String description of the adapter vendor */
251 MAC_Address_t AdapterMACAddress; /**< MAC address of the adapter */
252
253 uint8_t RNDISMessageBuffer[RNDIS_MESSAGE_BUFFER_SIZE]; /**< Buffer to hold RNDIS messages to and from the host,
254 * managed by the class driver
255 */
256 bool ResponseReady; /**< Internal flag indicating if a RNDIS message is waiting to be returned to the host */
257 uint8_t CurrRNDISState; /**< Current RNDIS state of the adapter, a value from the RNDIS_States_t enum */
258 uint32_t CurrPacketFilter; /**< Current packet filter mode, used internally by the class driver */
259 Ethernet_Frame_Info_t FrameIN; /**< Structure holding the last received Ethernet frame from the host, for user
260 * processing
261 */
262 Ethernet_Frame_Info_t FrameOUT; /**< Structure holding the next Ethernet frame to send to the host, populated by the
263 * user application
264 */
265 } USB_ClassInfo_RNDIS_t;
266
267 /* Disable C linkage for C++ Compilers: */
268 #if defined(__cplusplus)
269 }
270 #endif
271
272 #endif
273
274 /** @} */