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