Add file-level brief documentation.
[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 * \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.
36 */
37
38 /** \ingroup Group_USBClassRNDIS
39 * @defgroup Group_USBClassRNDISCommon Common Class Definitions
40 *
41 * \section Module Description
42 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
43 * RNDIS Class.
44 *
45 * @{
46 */
47
48 #ifndef _RNDIS_CLASS_COMMON_H_
49 #define _RNDIS_CLASS_COMMON_H_
50
51 /* Macros: */
52 #define __INCLUDE_FROM_CDC_DRIVER
53
54 /* Includes: */
55 #include "../../USB.h"
56 #include "RNDISConstants.h"
57 #include "CDC.h"
58
59 #include <string.h>
60
61 /* Enable C linkage for C++ Compilers: */
62 #if defined(__cplusplus)
63 extern "C" {
64 #endif
65
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.
69 #endif
70
71 /* Macros: */
72 /** Implemented RNDIS Version Major */
73 #define REMOTE_NDIS_VERSION_MAJOR 0x01
74
75 /** Implemented RNDIS Version Minor */
76 #define REMOTE_NDIS_VERSION_MINOR 0x00
77
78 /** RNDIS request to issue a host-to-device NDIS command */
79 #define REQ_SendEncapsulatedCommand 0x00
80
81 /** RNDIS request to issue a device-to-host NDIS response */
82 #define REQ_GetEncapsulatedResponse 0x01
83
84 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
85 #define RNDIS_MESSAGE_BUFFER_SIZE 128
86
87 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard */
88 #define ETHERNET_FRAME_SIZE_MAX 1500
89
90 /** Notification request value for a RNDIS Response Available notification */
91 #define NOTIF_ResponseAvailable 1
92
93 /* Enums: */
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 NDIS hardware states */
103 enum NDIS_Hardware_Status_t
104 {
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 */
110 };
111
112 /* Type Defines: */
113 /** Type define for a physical MAC address of a device on a network */
114 typedef struct
115 {
116 uint8_t Octets[6]; /**< Individual bytes of a MAC address */
117 } MAC_Address_t;
118
119 /** Type define for an Ethernet frame buffer. */
120 typedef struct
121 {
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;
126
127 /** Type define for a RNDIS message header, sent before RNDIS messages */
128 typedef struct
129 {
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;
133
134 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
135 typedef struct
136 {
137 uint32_t MessageType;
138 uint32_t MessageLength;
139 uint32_t DataOffset;
140 uint32_t DataLength;
141 uint32_t OOBDataOffset;
142 uint32_t OOBDataLength;
143 uint32_t NumOOBDataElements;
144 uint32_t PerPacketInfoOffset;
145 uint32_t PerPacketInfoLength;
146 uint32_t VcHandle;
147 uint32_t Reserved;
148 } RNDIS_Packet_Message_t;
149
150 /** Type define for a RNDIS Initialize command message */
151 typedef struct
152 {
153 uint32_t MessageType;
154 uint32_t MessageLength;
155 uint32_t RequestId;
156
157 uint32_t MajorVersion;
158 uint32_t MinorVersion;
159 uint32_t MaxTransferSize;
160 } RNDIS_Initialize_Message_t;
161
162 /** Type define for a RNDIS Initialize complete response message */
163 typedef struct
164 {
165 uint32_t MessageType;
166 uint32_t MessageLength;
167 uint32_t RequestId;
168 uint32_t Status;
169
170 uint32_t MajorVersion;
171 uint32_t MinorVersion;
172 uint32_t DeviceFlags;
173 uint32_t Medium;
174 uint32_t MaxPacketsPerTransfer;
175 uint32_t MaxTransferSize;
176 uint32_t PacketAlignmentFactor;
177 uint32_t AFListOffset;
178 uint32_t AFListSize;
179 } RNDIS_Initialize_Complete_t;
180
181 /** Type define for a RNDIS Keepalive command message */
182 typedef struct
183 {
184 uint32_t MessageType;
185 uint32_t MessageLength;
186 uint32_t RequestId;
187 } RNDIS_KeepAlive_Message_t;
188
189 /** Type define for a RNDIS Keepalive complete message */
190 typedef struct
191 {
192 uint32_t MessageType;
193 uint32_t MessageLength;
194 uint32_t RequestId;
195 uint32_t Status;
196 } RNDIS_KeepAlive_Complete_t;
197
198 /** Type define for a RNDIS Reset complete message */
199 typedef struct
200 {
201 uint32_t MessageType;
202 uint32_t MessageLength;
203 uint32_t Status;
204
205 uint32_t AddressingReset;
206 } RNDIS_Reset_Complete_t;
207
208 /** Type define for a RNDIS Set command message */
209 typedef struct
210 {
211 uint32_t MessageType;
212 uint32_t MessageLength;
213 uint32_t RequestId;
214
215 uint32_t Oid;
216 uint32_t InformationBufferLength;
217 uint32_t InformationBufferOffset;
218 uint32_t DeviceVcHandle;
219 } RNDIS_Set_Message_t;
220
221 /** Type define for a RNDIS Set complete response message */
222 typedef struct
223 {
224 uint32_t MessageType;
225 uint32_t MessageLength;
226 uint32_t RequestId;
227 uint32_t Status;
228 } RNDIS_Set_Complete_t;
229
230 /** Type define for a RNDIS Query command message */
231 typedef struct
232 {
233 uint32_t MessageType;
234 uint32_t MessageLength;
235 uint32_t RequestId;
236
237 uint32_t Oid;
238 uint32_t InformationBufferLength;
239 uint32_t InformationBufferOffset;
240 uint32_t DeviceVcHandle;
241 } RNDIS_Query_Message_t;
242
243 /** Type define for a RNDIS Query complete response message */
244 typedef struct
245 {
246 uint32_t MessageType;
247 uint32_t MessageLength;
248 uint32_t RequestId;
249 uint32_t Status;
250
251 uint32_t InformationBufferLength;
252 uint32_t InformationBufferOffset;
253 } RNDIS_Query_Complete_t;
254
255 /* Disable C linkage for C++ Compilers: */
256 #if defined(__cplusplus)
257 }
258 #endif
259
260 #endif
261
262 /** @} */