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                 #include "../../USB.h" 
  47                 #include "RNDISConstants.h" 
  51         /* Enable C linkage for C++ Compilers: */ 
  52                 #if defined(__cplusplus) 
  57                 /** Implemented RNDIS Version Major */ 
  58                 #define REMOTE_NDIS_VERSION_MAJOR             0x01 
  60                 /** Implemented RNDIS Version Minor */ 
  61                 #define REMOTE_NDIS_VERSION_MINOR             0x00 
  63                 /** RNDIS request to issue a host-to-device NDIS command */ 
  64                 #define REQ_SendEncapsulatedCommand           0x00 
  66                 /** RNDIS request to issue a device-to-host NDIS response */ 
  67                 #define REQ_GetEncapsulatedResponse           0x01 
  69                 /** Maximum size in bytes of a RNDIS control message which can be sent or received */ 
  70                 #define RNDIS_MESSAGE_BUFFER_SIZE             128 
  72                 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard */ 
  73                 #define ETHERNET_FRAME_SIZE_MAX               1500 
  75                 /** Notification request value for a RNDIS Response Available notification */ 
  76                 #define NOTIF_ResponseAvailable               1 
  79                 /** Enum for the possible NDIS adapter states. */ 
  82                         RNDIS_Uninitialized    
= 0, /**< Adapter currently uninitialized */ 
  83                         RNDIS_Initialized      
= 1, /**< Adapter currently initialized but not ready for data transfers */ 
  84                         RNDIS_Data_Initialized 
= 2, /**< Adapter currently initialized and ready for data transfers */ 
  87                 /** Enum for the NDIS hardware states */ 
  88                 enum NDIS_Hardware_Status_t
 
  90                         NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host */ 
  91                         NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing */ 
  92                         NDIS_HardwareStatus_Reset
, /**< Hardware reset */ 
  93                         NDIS_HardwareStatus_Closing
, /**< Hardware currently closing */ 
  94                         NDIS_HardwareStatus_NotReady 
/**< Hardware not ready to accept commands from the host */ 
  98                 /** Type define for a physical MAC address of a device on a network */ 
 101                         uint8_t       Octets
[6]; /**< Individual bytes of a MAC address */ 
 104                 /** Type define for an Ethernet frame buffer. */ 
 107                         uint8_t       FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents */ 
 108                         uint16_t      FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer */ 
 109                         bool          FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer */ 
 110                 } Ethernet_Frame_Info_t
; 
 112                 /** Type define for a RNDIS message header, sent before RNDIS messages */ 
 115                         uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */ 
 116                         uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */ 
 117                 } RNDIS_Message_Header_t
; 
 119                 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter */ 
 122                         uint32_t MessageType
; 
 123                         uint32_t MessageLength
; 
 126                         uint32_t OOBDataOffset
; 
 127                         uint32_t OOBDataLength
; 
 128                         uint32_t NumOOBDataElements
; 
 129                         uint32_t PerPacketInfoOffset
; 
 130                         uint32_t PerPacketInfoLength
; 
 133                 } RNDIS_Packet_Message_t
; 
 135                 /** Type define for a RNDIS Initialize command message */ 
 138                         uint32_t MessageType
; 
 139                         uint32_t MessageLength
; 
 142                         uint32_t MajorVersion
; 
 143                         uint32_t MinorVersion
; 
 144                         uint32_t MaxTransferSize
; 
 145                 } RNDIS_Initialize_Message_t
; 
 147                 /** Type define for a RNDIS Initialize complete response message */ 
 150                         uint32_t MessageType
; 
 151                         uint32_t MessageLength
; 
 155                         uint32_t MajorVersion
; 
 156                         uint32_t MinorVersion
; 
 157                         uint32_t DeviceFlags
; 
 159                         uint32_t MaxPacketsPerTransfer
; 
 160                         uint32_t MaxTransferSize
; 
 161                         uint32_t PacketAlignmentFactor
; 
 162                         uint32_t AFListOffset
; 
 164                 } RNDIS_Initialize_Complete_t
; 
 166                 /** Type define for a RNDIS Keepalive command message */ 
 169                         uint32_t MessageType
; 
 170                         uint32_t MessageLength
; 
 172                 } RNDIS_KeepAlive_Message_t
; 
 174                 /** Type define for a RNDIS Keepalive complete message */ 
 177                         uint32_t MessageType
; 
 178                         uint32_t MessageLength
; 
 181                 } RNDIS_KeepAlive_Complete_t
; 
 183                 /** Type define for a RNDIS Reset complete message */ 
 186                         uint32_t MessageType
; 
 187                         uint32_t MessageLength
; 
 190                         uint32_t AddressingReset
; 
 191                 } RNDIS_Reset_Complete_t
; 
 193                 /** Type define for a RNDIS Set command message */ 
 196                         uint32_t MessageType
; 
 197                         uint32_t MessageLength
; 
 201                         uint32_t InformationBufferLength
; 
 202                         uint32_t InformationBufferOffset
; 
 203                         uint32_t DeviceVcHandle
; 
 204                 } RNDIS_Set_Message_t
; 
 206                 /** Type define for a RNDIS Set complete response message */ 
 209                         uint32_t MessageType
; 
 210                         uint32_t MessageLength
; 
 213                 } RNDIS_Set_Complete_t
; 
 215                 /** Type define for a RNDIS Query command message */ 
 218                         uint32_t MessageType
; 
 219                         uint32_t MessageLength
; 
 223                         uint32_t InformationBufferLength
; 
 224                         uint32_t InformationBufferOffset
; 
 225                         uint32_t DeviceVcHandle
; 
 226                 } RNDIS_Query_Message_t
; 
 228                 /** Type define for a RNDIS Query complete response message */ 
 231                         uint32_t MessageType
; 
 232                         uint32_t MessageLength
; 
 236                         uint32_t InformationBufferLength
; 
 237                         uint32_t InformationBufferOffset
; 
 238                 } RNDIS_Query_Complete_t
; 
 240         /* Disable C linkage for C++ Compilers: */ 
 241                 #if defined(__cplusplus)