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