3 Copyright (C) Dean Camera, 2009.
5 dean [at] fourwalledcubicle [dot] com
6 www.fourwalledcubicle.com
10 Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
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.
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 #include "../../USB.h"
50 /* Enable C linkage for C++ Compilers: */
51 #if defined(__cplusplus)
56 /** Implemented RNDIS Version Major */
57 #define REMOTE_NDIS_VERSION_MAJOR 0x01
59 /** Implemented RNDIS Version Minor */
60 #define REMOTE_NDIS_VERSION_MINOR 0x00
62 /** RNDIS request to issue a host-to-device NDIS command */
63 #define REQ_SendEncapsulatedCommand 0x00
65 /** RNDIS request to issue a device-to-host NDIS response */
66 #define REQ_GetEncapsulatedResponse 0x01
68 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
69 #define RNDIS_MESSAGE_BUFFER_SIZE 128
71 /** Maximum size in bytes of an Ethernet frame which can be sent or received */
72 #define ETHERNET_FRAME_SIZE_MAX 1500
74 /** Notification request value for a RNDIS Response Available notification */
75 #define NOTIF_ResponseAvailable 1
78 /** Enum for the possible NDIS adapter states. */
81 RNDIS_Uninitialized
= 0, /**< Adapter currently uninitialized */
82 RNDIS_Initialized
= 1, /**< Adapter currently initialized but not ready for data transfers */
83 RNDIS_Data_Initialized
= 2, /**< Adapter currently initialized and ready for data transfers */
86 /** Enum for the NDIS hardware states */
87 enum NDIS_Hardware_Status_t
89 NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host */
90 NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing */
91 NDIS_HardwareStatus_Reset
, /**< Hardware reset */
92 NDIS_HardwareStatus_Closing
, /**< Hardware currently closing */
93 NDIS_HardwareStatus_NotReady
/**< Hardware not ready to accept commands from the host */
97 /** Type define for a physical MAC address of a device on a network */
100 uint8_t Octets
[6]; /**< Individual bytes of a MAC address */
103 /** Type define for an Ethernet frame buffer. */
106 uint8_t FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents */
107 uint16_t FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer */
108 bool FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer */
109 } Ethernet_Frame_Info_t
;
111 /** Type define for a RNDIS message header, sent before RNDIS messages */
114 uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
115 uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */
116 } RNDIS_Message_Header_t
;
118 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
121 uint32_t MessageType
;
122 uint32_t MessageLength
;
125 uint32_t OOBDataOffset
;
126 uint32_t OOBDataLength
;
127 uint32_t NumOOBDataElements
;
128 uint32_t PerPacketInfoOffset
;
129 uint32_t PerPacketInfoLength
;
132 } RNDIS_Packet_Message_t
;
134 /** Type define for a RNDIS Initialize command message */
137 uint32_t MessageType
;
138 uint32_t MessageLength
;
141 uint32_t MajorVersion
;
142 uint32_t MinorVersion
;
143 uint32_t MaxTransferSize
;
144 } RNDIS_Initialize_Message_t
;
146 /** Type define for a RNDIS Initialize complete response message */
149 uint32_t MessageType
;
150 uint32_t MessageLength
;
154 uint32_t MajorVersion
;
155 uint32_t MinorVersion
;
156 uint32_t DeviceFlags
;
158 uint32_t MaxPacketsPerTransfer
;
159 uint32_t MaxTransferSize
;
160 uint32_t PacketAlignmentFactor
;
161 uint32_t AFListOffset
;
163 } RNDIS_Initialize_Complete_t
;
165 /** Type define for a RNDIS Keepalive command message */
168 uint32_t MessageType
;
169 uint32_t MessageLength
;
171 } RNDIS_KeepAlive_Message_t
;
173 /** Type define for a RNDIS Keepalive complete message */
176 uint32_t MessageType
;
177 uint32_t MessageLength
;
180 } RNDIS_KeepAlive_Complete_t
;
182 /** Type define for a RNDIS Reset complete message */
185 uint32_t MessageType
;
186 uint32_t MessageLength
;
189 uint32_t AddressingReset
;
190 } RNDIS_Reset_Complete_t
;
192 /** Type define for a RNDIS Set command message */
195 uint32_t MessageType
;
196 uint32_t MessageLength
;
200 uint32_t InformationBufferLength
;
201 uint32_t InformationBufferOffset
;
202 uint32_t DeviceVcHandle
;
203 } RNDIS_Set_Message_t
;
205 /** Type define for a RNDIS Set complete response message */
208 uint32_t MessageType
;
209 uint32_t MessageLength
;
212 } RNDIS_Set_Complete_t
;
214 /** Type define for a RNDIS Query command message */
217 uint32_t MessageType
;
218 uint32_t MessageLength
;
222 uint32_t InformationBufferLength
;
223 uint32_t InformationBufferOffset
;
224 uint32_t DeviceVcHandle
;
225 } RNDIS_Query_Message_t
;
227 /** Type define for a RNDIS Query complete response message */
230 uint32_t MessageType
;
231 uint32_t MessageLength
;
235 uint32_t InformationBufferLength
;
236 uint32_t InformationBufferOffset
;
237 } RNDIS_Query_Complete_t
;
239 /* Disable C linkage for C++ Compilers: */
240 #if defined(__cplusplus)