Fix nasty bug in USBInterrupt.c which would cause a lockup if the control endpoint...
[pub/USBasp.git] / Demos / Host / LowLevel / RNDISEthernetHost / Lib / RNDISCommands.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 *
33 * Header file for RNDISCommands.c.
34 */
35
36 #ifndef _RNDIS_COMMANDS_H_
37 #define _RNDIS_COMMANDS_H_
38
39 /* Includes: */
40 #include <avr/io.h>
41 #include <stdio.h>
42 #include <string.h>
43
44 #include <LUFA/Drivers/USB/USB.h>
45
46 #include "RNDISConstants.h"
47
48 /* Type Defines: */
49 /** Type define for a RNDIS message header, sent before RNDIS messages */
50 typedef struct
51 {
52 uint32_t MessageType; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
53 uint32_t MessageLength; /**< Total length of the RNDIS message, in bytes */
54 } RNDIS_Message_Header_t;
55
56 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
57 typedef struct
58 {
59 uint32_t MessageType;
60 uint32_t MessageLength;
61 uint32_t DataOffset;
62 uint32_t DataLength;
63 uint32_t OOBDataOffset;
64 uint32_t OOBDataLength;
65 uint32_t NumOOBDataElements;
66 uint32_t PerPacketInfoOffset;
67 uint32_t PerPacketInfoLength;
68 uint32_t VcHandle;
69 uint32_t Reserved;
70 } RNDIS_Packet_Message_t;
71
72 /** Type define for a RNDIS Initialize command message */
73 typedef struct
74 {
75 uint32_t MessageType;
76 uint32_t MessageLength;
77 uint32_t RequestId;
78
79 uint32_t MajorVersion;
80 uint32_t MinorVersion;
81 uint32_t MaxTransferSize;
82 } RNDIS_Initialize_Message_t;
83
84 /** Type define for a RNDIS Initialize complete response message */
85 typedef struct
86 {
87 uint32_t MessageType;
88 uint32_t MessageLength;
89 uint32_t RequestId;
90 uint32_t Status;
91
92 uint32_t MajorVersion;
93 uint32_t MinorVersion;
94 uint32_t DeviceFlags;
95 uint32_t Medium;
96 uint32_t MaxPacketsPerTransfer;
97 uint32_t MaxTransferSize;
98 uint32_t PacketAlignmentFactor;
99 uint32_t AFListOffset;
100 uint32_t AFListSize;
101 } RNDIS_Initialize_Complete_t;
102
103 /** Type define for a RNDIS Keepalive command message */
104 typedef struct
105 {
106 uint32_t MessageType;
107 uint32_t MessageLength;
108 uint32_t RequestId;
109 } RNDIS_KeepAlive_Message_t;
110
111 /** Type define for a RNDIS Keepalive complete message */
112 typedef struct
113 {
114 uint32_t MessageType;
115 uint32_t MessageLength;
116 uint32_t RequestId;
117 uint32_t Status;
118 } RNDIS_KeepAlive_Complete_t;
119
120 /** Type define for a RNDIS Reset complete message */
121 typedef struct
122 {
123 uint32_t MessageType;
124 uint32_t MessageLength;
125 uint32_t Status;
126
127 uint32_t AddressingReset;
128 } RNDIS_Reset_Complete_t;
129
130 /** Type define for a RNDIS Set command message */
131 typedef struct
132 {
133 uint32_t MessageType;
134 uint32_t MessageLength;
135 uint32_t RequestId;
136
137 uint32_t Oid;
138 uint32_t InformationBufferLength;
139 uint32_t InformationBufferOffset;
140 uint32_t DeviceVcHandle;
141 } RNDIS_Set_Message_t;
142
143 /** Type define for a RNDIS Set complete response message */
144 typedef struct
145 {
146 uint32_t MessageType;
147 uint32_t MessageLength;
148 uint32_t RequestId;
149 uint32_t Status;
150 } RNDIS_Set_Complete_t;
151
152 /** Type define for a RNDIS Query command message */
153 typedef struct
154 {
155 uint32_t MessageType;
156 uint32_t MessageLength;
157 uint32_t RequestId;
158
159 uint32_t Oid;
160 uint32_t InformationBufferLength;
161 uint32_t InformationBufferOffset;
162 uint32_t DeviceVcHandle;
163 } RNDIS_Query_Message_t;
164
165 /** Type define for a RNDIS Query complete response message */
166 typedef struct
167 {
168 uint32_t MessageType;
169 uint32_t MessageLength;
170 uint32_t RequestId;
171 uint32_t Status;
172
173 uint32_t InformationBufferLength;
174 uint32_t InformationBufferOffset;
175 } RNDIS_Query_Complete_t;
176
177 /* Macros: */
178 /** RNDIS request to issue a host-to-device NDIS command */
179 #define REQ_SendEncapsulatedCommand 0x00
180
181 /** RNDIS request to issue a device-to-host NDIS response */
182 #define REQ_GetEncapsulatedResponse 0x01
183
184 /** Implemented RNDIS Version Major */
185 #define REMOTE_NDIS_VERSION_MAJOR 0x01
186
187 /** Implemented RNDIS Version Minor */
188 #define REMOTE_NDIS_VERSION_MINOR 0x00
189
190 /** Pipe number for the RNDIS data IN pipe */
191 #define RNDIS_DATAPIPE_IN 1
192
193 /** Pipe number for the RNDIS data OUT pipe */
194 #define RNDIS_DATAPIPE_OUT 2
195
196 /** Pipe number for the RNDIS notification pipe */
197 #define RNDIS_NOTIFICATIONPIPE 3
198
199 /** Additional error code for RNDIS functions when a device returns a logical command failure */
200 #define RNDIS_COMMAND_FAILED 0xC0
201
202 /* Function Prototypes: */
203 uint8_t RNDIS_SendEncapsulatedCommand(void* const Buffer, const uint16_t Length);
204 uint8_t RNDIS_GetEncapsulatedResponse(void* const Buffer, const uint16_t Length);
205
206 uint8_t RNDIS_SendKeepAlive(void);
207 uint8_t RNDIS_InitializeDevice(const uint16_t HostMaxPacketSize, uint16_t* const DeviceMaxPacketSize);
208 uint8_t RNDIS_SetRNDISProperty(const uint32_t Oid, void* Buffer, const uint16_t Length);
209 uint8_t RNDIS_QueryRNDISProperty(const uint32_t Oid, void* Buffer, const uint16_t MaxLength);
210 uint8_t RNDIS_GetPacketLength(uint16_t* const PacketLength);
211
212 #endif