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