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