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                 /** Maximum size in bytes of a RNDIS control message which can be sent or received. */ 
  81                 #define RNDIS_MESSAGE_BUFFER_SIZE             128 
  83                 /** Maximum size in bytes of an Ethernet frame according to the Ethernet standard. */ 
  84                 #define ETHERNET_FRAME_SIZE_MAX               1500 
  87                 /** Enum for the RNDIS class specific control requests that can be issued by the USB bus host. */ 
  88                 enum RNDIS_ClassRequests_t
 
  90                         RNDIS_REQ_SendEncapsulatedCommand 
= 0x00, /**< RNDIS request to issue a host-to-device NDIS command. */ 
  91                         RNDIS_REQ_GetEncapsulatedResponse 
= 0x01, /**< RNDIS request to issue a device-to-host NDIS response. */ 
  94                 /** Enum for the possible NDIS adapter states. */ 
  97                         RNDIS_Uninitialized    
= 0, /**< Adapter currently uninitialized. */ 
  98                         RNDIS_Initialized      
= 1, /**< Adapter currently initialized but not ready for data transfers. */ 
  99                         RNDIS_Data_Initialized 
= 2, /**< Adapter currently initialized and ready for data transfers. */ 
 102                 /** Enum for the RNDIS class specific notification requests that can be issued by a RNDIS device to a host. */ 
 103                 enum RNDIS_ClassNotifications_t
 
 105                         RNDIS_NOTIF_ResponseAvailable             
= 0x01, /**< Notification request value for a RNDIS Response Available notification. */ 
 108                 /** Enum for the NDIS hardware states. */ 
 109                 enum NDIS_Hardware_Status_t
 
 111                         NDIS_HardwareStatus_Ready
, /**< Hardware Ready to accept commands from the host. */ 
 112                         NDIS_HardwareStatus_Initializing
, /**< Hardware busy initializing. */ 
 113                         NDIS_HardwareStatus_Reset
, /**< Hardware reset. */ 
 114                         NDIS_HardwareStatus_Closing
, /**< Hardware currently closing. */ 
 115                         NDIS_HardwareStatus_NotReady 
/**< Hardware not ready to accept commands from the host. */ 
 119                 /** \brief MAC Address Structure. 
 121                  *  Type define for a physical MAC address of a device on a network. 
 125                         uint8_t       Octets
[6]; /**< Individual bytes of a MAC address */ 
 128                 /** \brief RNDIS Ethernet Frame Packet Information Structure. 
 130                  *  Type define for an Ethernet frame buffer data and information structure. 
 134                         uint8_t       FrameData
[ETHERNET_FRAME_SIZE_MAX
]; /**< Ethernet frame contents. */ 
 135                         uint16_t      FrameLength
; /**< Length in bytes of the Ethernet frame stored in the buffer. */ 
 136                         bool          FrameInBuffer
; /**< Indicates if a frame is currently stored in the buffer. */ 
 137                 } Ethernet_Frame_Info_t
; 
 139                 /** \brief RNDIS Common Message Header Structure. 
 141                  *  Type define for a RNDIS message header, sent before RNDIS messages. 
 145                         uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */ 
 146                         uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */ 
 147                 } RNDIS_Message_Header_t
; 
 149                 /** \brief RNDIS Message Structure. 
 151                  *  Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter. 
 155                         uint32_t MessageType
; 
 156                         uint32_t MessageLength
; 
 159                         uint32_t OOBDataOffset
; 
 160                         uint32_t OOBDataLength
; 
 161                         uint32_t NumOOBDataElements
; 
 162                         uint32_t PerPacketInfoOffset
; 
 163                         uint32_t PerPacketInfoLength
; 
 166                 } RNDIS_Packet_Message_t
; 
 168                 /** \brief RNDIS Initialization Message Structure. 
 170                  *  Type define for a RNDIS Initialize command message. 
 174                         uint32_t MessageType
; 
 175                         uint32_t MessageLength
; 
 178                         uint32_t MajorVersion
; 
 179                         uint32_t MinorVersion
; 
 180                         uint32_t MaxTransferSize
; 
 181                 } RNDIS_Initialize_Message_t
; 
 183                 /** \brief RNDIS Initialize Complete Message Structure. 
 185                  *  Type define for a RNDIS Initialize Complete response message. 
 189                         uint32_t MessageType
; 
 190                         uint32_t MessageLength
; 
 194                         uint32_t MajorVersion
; 
 195                         uint32_t MinorVersion
; 
 196                         uint32_t DeviceFlags
; 
 198                         uint32_t MaxPacketsPerTransfer
; 
 199                         uint32_t MaxTransferSize
; 
 200                         uint32_t PacketAlignmentFactor
; 
 201                         uint32_t AFListOffset
; 
 203                 } RNDIS_Initialize_Complete_t
; 
 205                 /** \brief RNDIS Keep Alive Message Structure. 
 207                  *  Type define for a RNDIS Keep Alive command message. 
 211                         uint32_t MessageType
; 
 212                         uint32_t MessageLength
; 
 214                 } RNDIS_KeepAlive_Message_t
; 
 216                 /** \brief RNDIS Keep Alive Complete Message Structure. 
 218                  *  Type define for a RNDIS Keep Alive Complete response message. 
 222                         uint32_t MessageType
; 
 223                         uint32_t MessageLength
; 
 226                 } RNDIS_KeepAlive_Complete_t
; 
 228                 /** \brief RNDIS Reset Complete Message Structure. 
 230                  *  Type define for a RNDIS Reset Complete response message. 
 234                         uint32_t MessageType
; 
 235                         uint32_t MessageLength
; 
 238                         uint32_t AddressingReset
; 
 239                 } RNDIS_Reset_Complete_t
; 
 241                 /** \brief RNDIS OID Property Set Message Structure. 
 243                  *  Type define for a RNDIS OID Property Set command message. 
 247                         uint32_t MessageType
; 
 248                         uint32_t MessageLength
; 
 252                         uint32_t InformationBufferLength
; 
 253                         uint32_t InformationBufferOffset
; 
 254                         uint32_t DeviceVcHandle
; 
 255                 } RNDIS_Set_Message_t
; 
 257                 /** \brief RNDIS OID Property Set Complete Message Structure. 
 259                  *  Type define for a RNDIS OID Property Set Complete response message. 
 263                         uint32_t MessageType
; 
 264                         uint32_t MessageLength
; 
 267                 } RNDIS_Set_Complete_t
; 
 269                 /** \brief RNDIS OID Property Query Message Structure. 
 271                  *  Type define for a RNDIS OID Property Query command message. 
 275                         uint32_t MessageType
; 
 276                         uint32_t MessageLength
; 
 280                         uint32_t InformationBufferLength
; 
 281                         uint32_t InformationBufferOffset
; 
 282                         uint32_t DeviceVcHandle
; 
 283                 } RNDIS_Query_Message_t
; 
 285                 /** \brief RNDIS OID Property Query Complete Message Structure. 
 287                  *  Type define for a RNDIS OID Property Query Complete response message. 
 291                         uint32_t MessageType
; 
 292                         uint32_t MessageLength
; 
 296                         uint32_t InformationBufferLength
; 
 297                         uint32_t InformationBufferOffset
; 
 298                 } RNDIS_Query_Complete_t
; 
 300         /* Disable C linkage for C++ Compilers: */ 
 301                 #if defined(__cplusplus)