3 Copyright (C) Dean Camera, 2010.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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
31 /** \ingroup Group_USBClassRNDIS
32 * @defgroup Group_USBClassRNDISCommon Common Class Definitions
34 * \section Module Description
35 * Constants, Types and Enum definitions that are common to both Device and Host modes for the USB
41 #ifndef _RNDIS_CLASS_COMMON_H_
42 #define _RNDIS_CLASS_COMMON_H_
45 #define __INCLUDE_FROM_CDC_DRIVER
48 #include "../../USB.h"
49 #include "RNDISConstants.h"
54 /* Enable C linkage for C++ Compilers: */
55 #if defined(__cplusplus)
59 /* Preprocessor Checks: */
60 #if !defined(__INCLUDE_FROM_RNDIS_DRIVER)
61 #error Do not include this file directly. Include LUFA/Drivers/Class/RNDIS.h instead.
65 /** Implemented RNDIS Version Major */
66 #define REMOTE_NDIS_VERSION_MAJOR 0x01
68 /** Implemented RNDIS Version Minor */
69 #define REMOTE_NDIS_VERSION_MINOR 0x00
71 /** RNDIS request to issue a host-to-device NDIS command */
72 #define REQ_SendEncapsulatedCommand 0x00
74 /** RNDIS request to issue a device-to-host NDIS response */
75 #define REQ_GetEncapsulatedResponse 0x01
77 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
78 #define RNDIS_MESSAGE_BUFFER_SIZE 128
80 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard */
81 #define ETHERNET_FRAME_SIZE_MAX 1500
83 /** Notification request value for a RNDIS Response Available notification */
84 #define NOTIF_ResponseAvailable 1
87 /** Enum for the possible NDIS adapter states. */
90 RNDIS_Uninitialized
= 0, /**< Adapter currently uninitialized */
91 RNDIS_Initialized
= 1, /**< Adapter currently initialized but not ready for data transfers */
92 RNDIS_Data_Initialized
= 2, /**< Adapter currently initialized and ready for data transfers */
95 /** Enum for the NDIS hardware states */
96 enum NDIS_Hardware_Status_t
98 NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host */
99 NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing */
100 NDIS_HardwareStatus_Reset
, /**< Hardware reset */
101 NDIS_HardwareStatus_Closing
, /**< Hardware currently closing */
102 NDIS_HardwareStatus_NotReady
/**< Hardware not ready to accept commands from the host */
106 /** Type define for a physical MAC address of a device on a network */
109 uint8_t Octets
[6]; /**< Individual bytes of a MAC address */
112 /** Type define for an Ethernet frame buffer. */
115 uint8_t FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents */
116 uint16_t FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer */
117 bool FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer */
118 } Ethernet_Frame_Info_t
;
120 /** Type define for a RNDIS message header, sent before RNDIS messages */
123 uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
124 uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */
125 } RNDIS_Message_Header_t
;
127 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
130 uint32_t MessageType
;
131 uint32_t MessageLength
;
134 uint32_t OOBDataOffset
;
135 uint32_t OOBDataLength
;
136 uint32_t NumOOBDataElements
;
137 uint32_t PerPacketInfoOffset
;
138 uint32_t PerPacketInfoLength
;
141 } RNDIS_Packet_Message_t
;
143 /** Type define for a RNDIS Initialize command message */
146 uint32_t MessageType
;
147 uint32_t MessageLength
;
150 uint32_t MajorVersion
;
151 uint32_t MinorVersion
;
152 uint32_t MaxTransferSize
;
153 } RNDIS_Initialize_Message_t
;
155 /** Type define for a RNDIS Initialize complete response message */
158 uint32_t MessageType
;
159 uint32_t MessageLength
;
163 uint32_t MajorVersion
;
164 uint32_t MinorVersion
;
165 uint32_t DeviceFlags
;
167 uint32_t MaxPacketsPerTransfer
;
168 uint32_t MaxTransferSize
;
169 uint32_t PacketAlignmentFactor
;
170 uint32_t AFListOffset
;
172 } RNDIS_Initialize_Complete_t
;
174 /** Type define for a RNDIS Keepalive command message */
177 uint32_t MessageType
;
178 uint32_t MessageLength
;
180 } RNDIS_KeepAlive_Message_t
;
182 /** Type define for a RNDIS Keepalive complete message */
185 uint32_t MessageType
;
186 uint32_t MessageLength
;
189 } RNDIS_KeepAlive_Complete_t
;
191 /** Type define for a RNDIS Reset complete message */
194 uint32_t MessageType
;
195 uint32_t MessageLength
;
198 uint32_t AddressingReset
;
199 } RNDIS_Reset_Complete_t
;
201 /** Type define for a RNDIS Set command message */
204 uint32_t MessageType
;
205 uint32_t MessageLength
;
209 uint32_t InformationBufferLength
;
210 uint32_t InformationBufferOffset
;
211 uint32_t DeviceVcHandle
;
212 } RNDIS_Set_Message_t
;
214 /** Type define for a RNDIS Set complete response message */
217 uint32_t MessageType
;
218 uint32_t MessageLength
;
221 } RNDIS_Set_Complete_t
;
223 /** Type define for a RNDIS Query command message */
226 uint32_t MessageType
;
227 uint32_t MessageLength
;
231 uint32_t InformationBufferLength
;
232 uint32_t InformationBufferOffset
;
233 uint32_t DeviceVcHandle
;
234 } RNDIS_Query_Message_t
;
236 /** Type define for a RNDIS Query complete response message */
239 uint32_t MessageType
;
240 uint32_t MessageLength
;
244 uint32_t InformationBufferLength
;
245 uint32_t InformationBufferOffset
;
246 } RNDIS_Query_Complete_t
;
248 /* Disable C linkage for C++ Compilers: */
249 #if defined(__cplusplus)