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 
  33  *  Header file for RNDIS.c. 
  43                 #include "RNDISEthernet.h" 
  44                 #include "RNDISConstants.h" 
  48                 /** Implemented RNDIS Version Major. */ 
  49                 #define REMOTE_NDIS_VERSION_MAJOR             0x01 
  51                 /** Implemented RNDIS Version Minor. */ 
  52                 #define REMOTE_NDIS_VERSION_MINOR             0x00 
  54                 /** RNDIS request to issue a host-to-device NDIS command. */ 
  55                 #define REQ_SendEncapsulatedCommand           0x00 
  57                 /** RNDIS request to issue a device-to-host NDIS response. */ 
  58                 #define REQ_GetEncapsulatedResponse           0x01 
  61                 /** Enum for the possible NDIS adapter states. */ 
  64                         RNDIS_Uninitialized    
= 0, /**< Adapter currently uninitialized */ 
  65                         RNDIS_Initialized      
= 1, /**< Adapter currently initialized but not ready for data transfers */ 
  66                         RNDIS_Data_Initialized 
= 2, /**< Adapter currently initialized and ready for data transfers */ 
  69                 /** Enum for the NDIS hardware states. */ 
  70                 enum NDIS_Hardware_Status_t
 
  72                         NdisHardwareStatusReady
, /**< Hardware Ready to accept commands from the host */ 
  73                         NdisHardwareStatusInitializing
, /**< Hardware busy initializing */ 
  74                         NdisHardwareStatusReset
, /**< Hardware reset */ 
  75                         NdisHardwareStatusClosing
, /**< Hardware currently closing */ 
  76                         NdisHardwareStatusNotReady 
/**< Hardware not ready to accept commands from the host */ 
  80                 /** Type define for a RNDIS message header, sent before RNDIS messages. */ 
  83                         uint32_t MessageType
; /**< RNDIS message type, a REMOTE_NDIS_*_MSG constant */ 
  84                         uint32_t MessageLength
; /**< Total length of the RNDIS message, in bytes */ 
  85                 } RNDIS_Message_Header_t
; 
  87                 /** Type define for a RNDIS packet message, used to encapsulate Ethernet packets sent to and from the adapter. */ 
  91                         uint32_t MessageLength
; 
  94                         uint32_t OOBDataOffset
; 
  95                         uint32_t OOBDataLength
; 
  96                         uint32_t NumOOBDataElements
; 
  97                         uint32_t PerPacketInfoOffset
; 
  98                         uint32_t PerPacketInfoLength
; 
 101                 } RNDIS_Packet_Message_t
; 
 103                 /** Type define for a RNDIS Initialize command message. */ 
 106                         uint32_t MessageType
; 
 107                         uint32_t MessageLength
; 
 110                         uint32_t MajorVersion
; 
 111                         uint32_t MinorVersion
; 
 112                         uint32_t MaxTransferSize
; 
 113                 } RNDIS_Initialize_Message_t
; 
 115                 /** Type define for a RNDIS Initialize complete response message. */ 
 118                         uint32_t MessageType
; 
 119                         uint32_t MessageLength
; 
 123                         uint32_t MajorVersion
; 
 124                         uint32_t MinorVersion
; 
 125                         uint32_t DeviceFlags
; 
 127                         uint32_t MaxPacketsPerTransfer
; 
 128                         uint32_t MaxTransferSize
; 
 129                         uint32_t PacketAlignmentFactor
; 
 130                         uint32_t AFListOffset
; 
 132                 } RNDIS_Initialize_Complete_t
; 
 134                 /** Type define for a RNDIS Keep-alive command message. */ 
 137                         uint32_t MessageType
; 
 138                         uint32_t MessageLength
; 
 140                 } RNDIS_KeepAlive_Message_t
; 
 142                 /** Type define for a RNDIS Keep-alive complete message. */ 
 145                         uint32_t MessageType
; 
 146                         uint32_t MessageLength
; 
 149                 } RNDIS_KeepAlive_Complete_t
; 
 151                 /** Type define for a RNDIS Reset complete message. */ 
 154                         uint32_t MessageType
; 
 155                         uint32_t MessageLength
; 
 158                         uint32_t AddressingReset
; 
 159                 } RNDIS_Reset_Complete_t
; 
 161                 /** Type define for a RNDIS Set command message. */ 
 164                         uint32_t MessageType
; 
 165                         uint32_t MessageLength
; 
 169                         uint32_t InformationBufferLength
; 
 170                         uint32_t InformationBufferOffset
; 
 171                         uint32_t DeviceVcHandle
; 
 172                 } RNDIS_Set_Message_t
; 
 174                 /** Type define for a RNDIS Set complete response message. */ 
 177                         uint32_t MessageType
; 
 178                         uint32_t MessageLength
; 
 181                 } RNDIS_Set_Complete_t
; 
 183                 /** Type define for a RNDIS Query command message. */ 
 186                         uint32_t MessageType
; 
 187                         uint32_t MessageLength
; 
 191                         uint32_t InformationBufferLength
; 
 192                         uint32_t InformationBufferOffset
; 
 193                         uint32_t DeviceVcHandle
; 
 194                 } RNDIS_Query_Message_t
; 
 196                 /** Type define for a RNDIS Query complete response message. */ 
 199                         uint32_t MessageType
; 
 200                         uint32_t MessageLength
; 
 204                         uint32_t InformationBufferLength
; 
 205                         uint32_t InformationBufferOffset
; 
 206                 } RNDIS_Query_Complete_t
; 
 208         /* External Variables: */ 
 209                 extern uint8_t                 RNDISMessageBuffer
[]; 
 210                 extern RNDIS_Message_Header_t
* MessageHeader
; 
 211                 extern bool                    ResponseReady
; 
 212                 extern uint8_t                 CurrRNDISState
; 
 214         /* Function Prototypes: */ 
 215                 void ProcessRNDISControlMessage(void); 
 217                 #if defined(INCLUDE_FROM_RNDIS_C) 
 218                         static bool ProcessNDISQuery(const uint32_t OId
, 
 222                                                      uint16_t* ResponseSize
); 
 223                         static bool ProcessNDISSet(const uint32_t OId
,