@ -48,17 +48,6 @@ uint8_t RNDIS_SendEncapsulatedCommand(void* Buffer, uint16_t Length)
. wIndex = 0 ,
. wIndex = 0 ,
. wLength = Length ,
. wLength = Length ,
} ;
} ;
printf ( " ==== RNDIS CONTROL REQUEST ==== \r \n " ) ;
uint8_t * Data = Buffer ;
for ( uint16_t i = 0 ; i < Length / 8 ; i + + )
{
for ( uint16_t j = 0 ; ( j < 8 ) & & i * 8 + j < Length ; j + + )
printf ( " %02X " , * ( Data + + ) ) ;
printf ( " \r \n " ) ;
}
printf ( " ==== ********************* ==== \r \n " ) ;
/* Select the control pipe for the request transfer */
/* Select the control pipe for the request transfer */
Pipe_SelectPipe ( PIPE_CONTROLPIPE ) ;
Pipe_SelectPipe ( PIPE_CONTROLPIPE ) ;
@ -83,6 +72,32 @@ uint8_t RNDIS_GetEncapsulatedResponse(void* Buffer, uint16_t Length)
return USB_Host_SendControlRequest ( Buffer ) ;
return USB_Host_SendControlRequest ( Buffer ) ;
}
}
uint8_t RNDIS_KeepAlive ( void )
{
uint8_t ErrorCode ;
RNDIS_KeepAlive_Message_t KeepAliveMessage ;
RNDIS_KeepAlive_Complete_t KeepAliveMessageResponse ;
KeepAliveMessage . MessageType = REMOTE_NDIS_KEEPALIVE_MSG ;
KeepAliveMessage . MessageLength = sizeof ( RNDIS_KeepAlive_Message_t ) ;
KeepAliveMessage . RequestId = RequestID + + ;
if ( ( ErrorCode = RNDIS_SendEncapsulatedCommand ( & KeepAliveMessage ,
sizeof ( RNDIS_KeepAlive_Message_t ) ) ) ! = HOST_SENDCONTROL_Successful )
{
return ErrorCode ;
}
if ( ( ErrorCode = RNDIS_GetEncapsulatedResponse ( & KeepAliveMessageResponse ,
sizeof ( RNDIS_KeepAlive_Complete_t ) ) ) ! = HOST_SENDCONTROL_Successful )
{
return ErrorCode ;
}
return HOST_SENDCONTROL_Successful ;
}
uint8_t RNDIS_InitializeDevice ( uint16_t MaxPacketSize , RNDIS_Initialize_Complete_t * InitMessageResponse )
uint8_t RNDIS_InitializeDevice ( uint16_t MaxPacketSize , RNDIS_Initialize_Complete_t * InitMessageResponse )
{
{
uint8_t ErrorCode ;
uint8_t ErrorCode ;
@ -131,7 +146,8 @@ uint8_t RNDIS_SetRNDISProperty(uint32_t Oid, void* Buffer, uint16_t Length)
SetMessageData . SetMessage . InformationBufferLength = Length ;
SetMessageData . SetMessage . InformationBufferLength = Length ;
SetMessageData . SetMessage . InformationBufferOffset = 0 ;
SetMessageData . SetMessage . InformationBufferOffset = 0 ;
SetMessageData . SetMessage . DeviceVcHandle = 0 ;
SetMessageData . SetMessage . DeviceVcHandle = 0 ;
memcpy ( & SetMessageData . ContigiousBuffer , Buffer , Length ) ;
if ( ( ErrorCode = RNDIS_SendEncapsulatedCommand ( & SetMessageData ,
if ( ( ErrorCode = RNDIS_SendEncapsulatedCommand ( & SetMessageData ,
SetMessageData . SetMessage . MessageLength ) ) ! = HOST_SENDCONTROL_Successful )
SetMessageData . SetMessage . MessageLength ) ) ! = HOST_SENDCONTROL_Successful )
@ -147,3 +163,57 @@ uint8_t RNDIS_SetRNDISProperty(uint32_t Oid, void* Buffer, uint16_t Length)
return HOST_SENDCONTROL_Successful ;
return HOST_SENDCONTROL_Successful ;
}
}
uint8_t RNDIS_QueryRNDISProperty ( uint32_t Oid , void * Buffer , uint16_t Length )
{
uint8_t ErrorCode ;
RNDIS_Query_Message_t QueryMessage ;
struct
{
RNDIS_Query_Complete_t QueryMessageResponse ;
uint8_t ContigiousBuffer [ Length ] ;
} QueryMessageResponseData ;
QueryMessage . MessageType = REMOTE_NDIS_QUERY_MSG ;
QueryMessage . MessageLength = sizeof ( RNDIS_Query_Message_t ) ;
QueryMessage . RequestId = RequestID + + ;
QueryMessage . Oid = Oid ;
QueryMessage . InformationBufferLength = Length ;
QueryMessage . InformationBufferOffset = 0 ;
QueryMessage . DeviceVcHandle = 0 ;
if ( ( ErrorCode = RNDIS_SendEncapsulatedCommand ( & QueryMessage ,
sizeof ( RNDIS_Query_Message_t ) ) ) ! = HOST_SENDCONTROL_Successful )
{
return ErrorCode ;
}
if ( ( ErrorCode = RNDIS_GetEncapsulatedResponse ( & QueryMessageResponseData ,
sizeof ( QueryMessageResponseData ) ) ) ! = HOST_SENDCONTROL_Successful )
{
return ErrorCode ;
}
memcpy ( Buffer , & QueryMessageResponseData . ContigiousBuffer , Length ) ;
return HOST_SENDCONTROL_Successful ;
}
uint8_t RNDIS_GetPacketSize ( uint16_t * PacketSize )
{
uint8_t ErrorCode ;
RNDIS_Packet_Message_t DeviceMessage ;
if ( ( ErrorCode = Pipe_Read_Stream_LE ( & DeviceMessage , sizeof ( RNDIS_Packet_Message_t ) ) ) ! = PIPE_RWSTREAM_NoError )
{
return ErrorCode ;
}
* PacketSize = ( uint16_t ) DeviceMessage . DataLength ;
return PIPE_RWSTREAM_NoError ;
}