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
35 #ifndef _RNDIS_CLASS_COMMON_H_
36 #define _RNDIS_CLASS_COMMON_H_
39 #include "../../USB.h"
44 /* Enable C linkage for C++ Compilers: */
45 #if defined(__cplusplus)
50 /** Implemented RNDIS Version Major */
51 #define REMOTE_NDIS_VERSION_MAJOR 0x01
53 /** Implemented RNDIS Version Minor */
54 #define REMOTE_NDIS_VERSION_MINOR 0x00
56 /** RNDIS request to issue a host-to-device NDIS command */
57 #define REQ_SendEncapsulatedCommand 0x00
59 /** RNDIS request to issue a device-to-host NDIS response */
60 #define REQ_GetEncapsulatedResponse 0x01
62 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
63 #define RNDIS_MESSAGE_BUFFER_SIZE 128
65 /** Maximum size in bytes of an Ethernet frame which can be sent or received */
66 #define ETHERNET_FRAME_SIZE_MAX 1500
68 /** Notification request value for a RNDIS Response Available notification */
69 #define NOTIF_ResponseAvailable 1
72 /** Enum for the possible NDIS adapter states. */
75 RNDIS_Uninitialized
= 0, /**< Adapter currently uninitialized */
76 RNDIS_Initialized
= 1, /**< Adapter currently initialized but not ready for data transfers */
77 RNDIS_Data_Initialized
= 2, /**< Adapter currently initialized and ready for data transfers */
80 /** Enum for the NDIS hardware states */
81 enum NDIS_Hardware_Status_t
83 NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host */
84 NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing */
85 NDIS_HardwareStatus_Reset
, /**< Hardware reset */
86 NDIS_HardwareStatus_Closing
, /**< Hardware currently closing */
87 NDIS_HardwareStatus_NotReady
/**< Hardware not ready to accept commands from the host */
91 /** Type define for a physical MAC address of a device on a network */
94 uint8_t Octets
[6]; /**< Individual bytes of a MAC address */
97 /** Type define for an Ethernet frame buffer. */
100 uint8_t FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents */
101 uint16_t FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer */
102 bool FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer */
103 } Ethernet_Frame_Info_t
;
105 /** Type define for a RNDIS message header, sent before RNDIS messages */
108 uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
109 uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */
110 } RNDIS_Message_Header_t
;
112 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
115 uint32_t MessageType
;
116 uint32_t MessageLength
;
119 uint32_t OOBDataOffset
;
120 uint32_t OOBDataLength
;
121 uint32_t NumOOBDataElements
;
122 uint32_t PerPacketInfoOffset
;
123 uint32_t PerPacketInfoLength
;
126 } RNDIS_Packet_Message_t
;
128 /** Type define for a RNDIS Initialize command message */
131 uint32_t MessageType
;
132 uint32_t MessageLength
;
135 uint32_t MajorVersion
;
136 uint32_t MinorVersion
;
137 uint32_t MaxTransferSize
;
138 } RNDIS_Initialize_Message_t
;
140 /** Type define for a RNDIS Initialize complete response message */
143 uint32_t MessageType
;
144 uint32_t MessageLength
;
148 uint32_t MajorVersion
;
149 uint32_t MinorVersion
;
150 uint32_t DeviceFlags
;
152 uint32_t MaxPacketsPerTransfer
;
153 uint32_t MaxTransferSize
;
154 uint32_t PacketAlignmentFactor
;
155 uint32_t AFListOffset
;
157 } RNDIS_Initialize_Complete_t
;
159 /** Type define for a RNDIS Keepalive command message */
162 uint32_t MessageType
;
163 uint32_t MessageLength
;
165 } RNDIS_KeepAlive_Message_t
;
167 /** Type define for a RNDIS Keepalive complete message */
170 uint32_t MessageType
;
171 uint32_t MessageLength
;
174 } RNDIS_KeepAlive_Complete_t
;
176 /** Type define for a RNDIS Reset complete message */
179 uint32_t MessageType
;
180 uint32_t MessageLength
;
183 uint32_t AddressingReset
;
184 } RNDIS_Reset_Complete_t
;
186 /** Type define for a RNDIS Set command message */
189 uint32_t MessageType
;
190 uint32_t MessageLength
;
194 uint32_t InformationBufferLength
;
195 uint32_t InformationBufferOffset
;
196 uint32_t DeviceVcHandle
;
197 } RNDIS_Set_Message_t
;
199 /** Type define for a RNDIS Set complete response message */
202 uint32_t MessageType
;
203 uint32_t MessageLength
;
206 } RNDIS_Set_Complete_t
;
208 /** Type define for a RNDIS Query command message */
211 uint32_t MessageType
;
212 uint32_t MessageLength
;
216 uint32_t InformationBufferLength
;
217 uint32_t InformationBufferOffset
;
218 uint32_t DeviceVcHandle
;
219 } RNDIS_Query_Message_t
;
221 /** Type define for a RNDIS Query complete response message */
224 uint32_t MessageType
;
225 uint32_t MessageLength
;
229 uint32_t InformationBufferLength
;
230 uint32_t InformationBufferOffset
;
231 } RNDIS_Query_Complete_t
;
233 /* Disable C linkage for C++ Compilers: */
234 #if defined(__cplusplus)