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 
  32  *  \brief Common definitions and declarations for the library USB RNDIS Class driver. 
  34  *  Common definitions and declarations for the library USB RNDIS Class driver. 
  36  *  \note This file should not be included directly. It is automatically included as needed by the class driver 
  37  *        dispatch header located in LUFA/Drivers/USB/Class/RNDIS.h. 
  40 /** \ingroup Group_USBClassRNDIS 
  41  *  @defgroup Group_USBClassRNDISCommon  Common Class Definitions 
  43  *  \section Module Description 
  44  *  Constants, Types and Enum definitions that are common to both Device and Host modes for the USB 
  50 #ifndef _RNDIS_CLASS_COMMON_H_ 
  51 #define _RNDIS_CLASS_COMMON_H_ 
  54                 #define __INCLUDE_FROM_CDC_DRIVER 
  57                 #include "../../USB.h" 
  58                 #include "RNDISConstants.h" 
  63         /* Enable C linkage for C++ Compilers: */ 
  64                 #if defined(__cplusplus) 
  68         /* Preprocessor Checks: */ 
  69                 #if !defined(__INCLUDE_FROM_RNDIS_DRIVER) 
  70                         #error Do not include this file directly. Include LUFA/Drivers/Class/RNDIS.h instead. 
  74                 /** Implemented RNDIS Version Major */ 
  75                 #define REMOTE_NDIS_VERSION_MAJOR             0x01 
  77                 /** Implemented RNDIS Version Minor */ 
  78                 #define REMOTE_NDIS_VERSION_MINOR             0x00 
  80                 /** RNDIS request to issue a host-to-device NDIS command */ 
  81                 #define REQ_SendEncapsulatedCommand           0x00 
  83                 /** RNDIS request to issue a device-to-host NDIS response */ 
  84                 #define REQ_GetEncapsulatedResponse           0x01 
  86                 /** Maximum size in bytes of a RNDIS control message which can be sent or received */ 
  87                 #define RNDIS_MESSAGE_BUFFER_SIZE             128 
  89                 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard */ 
  90                 #define ETHERNET_FRAME_SIZE_MAX               1500 
  92                 /** Notification request value for a RNDIS Response Available notification */ 
  93                 #define NOTIF_ResponseAvailable               1 
  96                 /** Enum for the possible NDIS adapter states. */ 
  99                         RNDIS_Uninitialized    
= 0, /**< Adapter currently uninitialized */ 
 100                         RNDIS_Initialized      
= 1, /**< Adapter currently initialized but not ready for data transfers */ 
 101                         RNDIS_Data_Initialized 
= 2, /**< Adapter currently initialized and ready for data transfers */ 
 104                 /** Enum for the NDIS hardware states */ 
 105                 enum NDIS_Hardware_Status_t
 
 107                         NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host */ 
 108                         NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing */ 
 109                         NDIS_HardwareStatus_Reset
, /**< Hardware reset */ 
 110                         NDIS_HardwareStatus_Closing
, /**< Hardware currently closing */ 
 111                         NDIS_HardwareStatus_NotReady 
/**< Hardware not ready to accept commands from the host */ 
 115                 /** \brief MAC Address Structure. 
 117                  *  Type define for a physical MAC address of a device on a network 
 121                         uint8_t       Octets
[6]; /**< Individual bytes of a MAC address */ 
 124                 /** \brief RNDIS Ethernet Frame Packet Information Structure. 
 126                  *  Type define for an Ethernet frame buffer data and information structure. 
 130                         uint8_t       FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents */ 
 131                         uint16_t      FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer */ 
 132                         bool          FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer */ 
 133                 } Ethernet_Frame_Info_t
; 
 135                 /** \brief RNDIS Common Message Header Structure. 
 137                  *  Type define for a RNDIS message header, sent before RNDIS messages. 
 141                         uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */ 
 142                         uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */ 
 143                 } RNDIS_Message_Header_t
; 
 145                 /** \brief RNDIS Message Structure. 
 147                  *  Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter. 
 151                         uint32_t MessageType
; 
 152                         uint32_t MessageLength
; 
 155                         uint32_t OOBDataOffset
; 
 156                         uint32_t OOBDataLength
; 
 157                         uint32_t NumOOBDataElements
; 
 158                         uint32_t PerPacketInfoOffset
; 
 159                         uint32_t PerPacketInfoLength
; 
 162                 } RNDIS_Packet_Message_t
; 
 164                 /** \brief RNDIS Initialization Message Structure. 
 166                  *  Type define for a RNDIS Initialize command message. 
 170                         uint32_t MessageType
; 
 171                         uint32_t MessageLength
; 
 174                         uint32_t MajorVersion
; 
 175                         uint32_t MinorVersion
; 
 176                         uint32_t MaxTransferSize
; 
 177                 } RNDIS_Initialize_Message_t
; 
 179                 /** \brief RNDIS Initialize Complete Message Structure. 
 181                  *  Type define for a RNDIS Initialize Complete response message. 
 185                         uint32_t MessageType
; 
 186                         uint32_t MessageLength
; 
 190                         uint32_t MajorVersion
; 
 191                         uint32_t MinorVersion
; 
 192                         uint32_t DeviceFlags
; 
 194                         uint32_t MaxPacketsPerTransfer
; 
 195                         uint32_t MaxTransferSize
; 
 196                         uint32_t PacketAlignmentFactor
; 
 197                         uint32_t AFListOffset
; 
 199                 } RNDIS_Initialize_Complete_t
; 
 201                 /** \brief RNDIS Keep Alive Message Structure. 
 203                  *  Type define for a RNDIS Keep Alive command message. 
 207                         uint32_t MessageType
; 
 208                         uint32_t MessageLength
; 
 210                 } RNDIS_KeepAlive_Message_t
; 
 212                 /** \brief RNDIS Keep Alive Complete Message Structure. 
 214                  *  Type define for a RNDIS Keep Alive Complete response message. 
 218                         uint32_t MessageType
; 
 219                         uint32_t MessageLength
; 
 222                 } RNDIS_KeepAlive_Complete_t
; 
 224                 /** \brief RNDIS Reset Complete Message Structure. 
 226                  *  Type define for a RNDIS Reset Complete response message. 
 230                         uint32_t MessageType
; 
 231                         uint32_t MessageLength
; 
 234                         uint32_t AddressingReset
; 
 235                 } RNDIS_Reset_Complete_t
; 
 237                 /** \brief RNDIS OID Property Set Message Structure. 
 239                  *  Type define for a RNDIS OID Property Set command message. 
 243                         uint32_t MessageType
; 
 244                         uint32_t MessageLength
; 
 248                         uint32_t InformationBufferLength
; 
 249                         uint32_t InformationBufferOffset
; 
 250                         uint32_t DeviceVcHandle
; 
 251                 } RNDIS_Set_Message_t
; 
 253                 /** \brief RNDIS OID Property Set Complete Message Structure. 
 255                  *  Type define for a RNDIS OID Property Set Complete response message. 
 259                         uint32_t MessageType
; 
 260                         uint32_t MessageLength
; 
 263                 } RNDIS_Set_Complete_t
; 
 265                 /** \brief RNDIS OID Property Query Message Structure. 
 267                  *  Type define for a RNDIS OID Property Query command message. 
 271                         uint32_t MessageType
; 
 272                         uint32_t MessageLength
; 
 276                         uint32_t InformationBufferLength
; 
 277                         uint32_t InformationBufferOffset
; 
 278                         uint32_t DeviceVcHandle
; 
 279                 } RNDIS_Query_Message_t
; 
 281                 /** \brief RNDIS OID Property Query Complete Message Structure. 
 283                  *  Type define for a RNDIS OID Property Query Complete response message. 
 287                         uint32_t MessageType
; 
 288                         uint32_t MessageLength
; 
 292                         uint32_t InformationBufferLength
; 
 293                         uint32_t InformationBufferOffset
; 
 294                 } RNDIS_Query_Complete_t
; 
 296         /* Disable C linkage for C++ Compilers: */ 
 297                 #if defined(__cplusplus)