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"
43 /* Enable C linkage for C++ Compilers: */
44 #if defined(__cplusplus)
49 /** Implemented RNDIS Version Major */
50 #define REMOTE_NDIS_VERSION_MAJOR 0x01
52 /** Implemented RNDIS Version Minor */
53 #define REMOTE_NDIS_VERSION_MINOR 0x00
55 /** RNDIS request to issue a host-to-device NDIS command */
56 #define REQ_SendEncapsulatedCommand 0x00
58 /** RNDIS request to issue a device-to-host NDIS response */
59 #define REQ_GetEncapsulatedResponse 0x01
61 /** Maximum size in bytes of a RNDIS control message which can be sent or received */
62 #define RNDIS_MESSAGE_BUFFER_SIZE 128
64 /** Maximum size in bytes of an Ethernet frame which can be sent or received */
65 #define ETHERNET_FRAME_SIZE_MAX 1500
67 /** Notification request value for a RNDIS Response Available notification */
68 #define NOTIF_ResponseAvailable 1
71 /** Enum for the possible NDIS adapter states. */
74 RNDIS_Uninitialized
= 0, /**< Adapter currently uninitialized */
75 RNDIS_Initialized
= 1, /**< Adapter currently initialized but not ready for data transfers */
76 RNDIS_Data_Initialized
= 2, /**< Adapter currently initialized and ready for data transfers */
79 /** Enum for the NDIS hardware states */
80 enum NDIS_Hardware_Status_t
82 NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host */
83 NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing */
84 NDIS_HardwareStatus_Reset
, /**< Hardware reset */
85 NDIS_HardwareStatus_Closing
, /**< Hardware currently closing */
86 NDIS_HardwareStatus_NotReady
/**< Hardware not ready to accept commands from the host */
90 /** Type define for a physical MAC address of a device on a network */
93 uint8_t Octets
[6]; /**< Individual bytes of a MAC address */
96 /** Type define for an Ethernet frame buffer. */
99 uint8_t FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents */
100 uint16_t FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer */
101 bool FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer */
102 } Ethernet_Frame_Info_t
;
104 /** Type define for a RNDIS message header, sent before RNDIS messages */
107 uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */
108 uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */
109 } RNDIS_Message_Header_t
;
111 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */
114 uint32_t MessageType
;
115 uint32_t MessageLength
;
118 uint32_t OOBDataOffset
;
119 uint32_t OOBDataLength
;
120 uint32_t NumOOBDataElements
;
121 uint32_t PerPacketInfoOffset
;
122 uint32_t PerPacketInfoLength
;
125 } RNDIS_Packet_Message_t
;
127 /** Type define for a RNDIS Initialize command message */
130 uint32_t MessageType
;
131 uint32_t MessageLength
;
134 uint32_t MajorVersion
;
135 uint32_t MinorVersion
;
136 uint32_t MaxTransferSize
;
137 } RNDIS_Initialize_Message_t
;
139 /** Type define for a RNDIS Initialize complete response message */
142 uint32_t MessageType
;
143 uint32_t MessageLength
;
147 uint32_t MajorVersion
;
148 uint32_t MinorVersion
;
149 uint32_t DeviceFlags
;
151 uint32_t MaxPacketsPerTransfer
;
152 uint32_t MaxTransferSize
;
153 uint32_t PacketAlignmentFactor
;
154 uint32_t AFListOffset
;
156 } RNDIS_Initialize_Complete_t
;
158 /** Type define for a RNDIS Keepalive command message */
161 uint32_t MessageType
;
162 uint32_t MessageLength
;
164 } RNDIS_KeepAlive_Message_t
;
166 /** Type define for a RNDIS Keepalive complete message */
169 uint32_t MessageType
;
170 uint32_t MessageLength
;
173 } RNDIS_KeepAlive_Complete_t
;
175 /** Type define for a RNDIS Reset complete message */
178 uint32_t MessageType
;
179 uint32_t MessageLength
;
182 uint32_t AddressingReset
;
183 } RNDIS_Reset_Complete_t
;
185 /** Type define for a RNDIS Set command message */
188 uint32_t MessageType
;
189 uint32_t MessageLength
;
193 uint32_t InformationBufferLength
;
194 uint32_t InformationBufferOffset
;
195 uint32_t DeviceVcHandle
;
196 } RNDIS_Set_Message_t
;
198 /** Type define for a RNDIS Set complete response message */
201 uint32_t MessageType
;
202 uint32_t MessageLength
;
205 } RNDIS_Set_Complete_t
;
207 /** Type define for a RNDIS Query command message */
210 uint32_t MessageType
;
211 uint32_t MessageLength
;
215 uint32_t InformationBufferLength
;
216 uint32_t InformationBufferOffset
;
217 uint32_t DeviceVcHandle
;
218 } RNDIS_Query_Message_t
;
220 /** Type define for a RNDIS Query complete response message */
223 uint32_t MessageType
;
224 uint32_t MessageLength
;
228 uint32_t InformationBufferLength
;
229 uint32_t InformationBufferOffset
;
230 } RNDIS_Query_Complete_t
;
232 /* Disable C linkage for C++ Compilers: */
233 #if defined(__cplusplus)