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