X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/b9b03aadb219d06fbad9d110e508db93e45461af..d11ed10c5314c44dc01c06954d1d73d4894cbff8:/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c diff --git a/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c b/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c index c5202bcd1..6c365eeae 100644 --- a/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c +++ b/Demos/Device/LowLevel/RNDISEthernet/Lib/RNDIS.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, provided that the above copyright notice appear in all - copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + Permission to use, copy, modify, distribute, and sell this + software and its documentation for any purpose is hereby granted + without fee, provided that the above copyright notice appear in + all copies and that both that the copyright notice and this + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -37,7 +37,6 @@ #define INCLUDE_FROM_RNDIS_C #include "RNDIS.h" -/* Global Variables: */ /** Physical MAC address of the network adapter, which becomes the MAC address of the host for packets sent to the adapter. */ static MAC_Address_t PROGMEM AdapterMACAddress = {ADAPTER_MAC_ADDRESS}; @@ -82,7 +81,7 @@ static const uint32_t PROGMEM AdapterSupportedOIDList[] = * Supported OID list, plus the response header. The buffer is half-duplex, and is written to as it is read to save on SRAM - for this * reason, care must be taken when constructing RNDIS responses that unread data is not overwritten when writing in responses. */ -uint8_t RNDISMessageBuffer[sizeof(AdapterSupportedOIDList) + sizeof(RNDIS_QUERY_CMPLT_t)]; +uint8_t RNDISMessageBuffer[sizeof(AdapterSupportedOIDList) + sizeof(RNDIS_Query_Complete_t)]; /** Pointer to the RNDIS message header at the top of the RNDIS message buffer, for convenience. */ RNDIS_Message_Header_t* MessageHeader = (RNDIS_Message_Header_t*)&RNDISMessageBuffer; @@ -112,11 +111,11 @@ void ProcessRNDISControlMessage(void) ResponseReady = true; - RNDIS_INITIALIZE_MSG_t* INITIALIZE_Message = (RNDIS_INITIALIZE_MSG_t*)&RNDISMessageBuffer; - RNDIS_INITIALIZE_CMPLT_t* INITIALIZE_Response = (RNDIS_INITIALIZE_CMPLT_t*)&RNDISMessageBuffer; + RNDIS_Initialize_Message_t* INITIALIZE_Message = (RNDIS_Initialize_Message_t*)&RNDISMessageBuffer; + RNDIS_Initialize_Complete_t* INITIALIZE_Response = (RNDIS_Initialize_Complete_t*)&RNDISMessageBuffer; INITIALIZE_Response->MessageType = REMOTE_NDIS_INITIALIZE_CMPLT; - INITIALIZE_Response->MessageLength = sizeof(RNDIS_INITIALIZE_CMPLT_t); + INITIALIZE_Response->MessageLength = sizeof(RNDIS_Initialize_Complete_t); INITIALIZE_Response->RequestId = INITIALIZE_Message->RequestId; INITIALIZE_Response->Status = REMOTE_NDIS_STATUS_SUCCESS; @@ -125,7 +124,7 @@ void ProcessRNDISControlMessage(void) INITIALIZE_Response->DeviceFlags = REMOTE_NDIS_DF_CONNECTIONLESS; INITIALIZE_Response->Medium = REMOTE_NDIS_MEDIUM_802_3; INITIALIZE_Response->MaxPacketsPerTransfer = 1; - INITIALIZE_Response->MaxTransferSize = (sizeof(RNDIS_PACKET_MSG_t) + ETHERNET_FRAME_SIZE_MAX); + INITIALIZE_Response->MaxTransferSize = (sizeof(RNDIS_Packet_Message_t) + ETHERNET_FRAME_SIZE_MAX); INITIALIZE_Response->PacketAlignmentFactor = 0; INITIALIZE_Response->AFListOffset = 0; INITIALIZE_Response->AFListSize = 0; @@ -147,17 +146,17 @@ void ProcessRNDISControlMessage(void) ResponseReady = true; - RNDIS_QUERY_MSG_t* QUERY_Message = (RNDIS_QUERY_MSG_t*)&RNDISMessageBuffer; - RNDIS_QUERY_CMPLT_t* QUERY_Response = (RNDIS_QUERY_CMPLT_t*)&RNDISMessageBuffer; - uint32_t Query_Oid = QUERY_Message->Oid; + RNDIS_Query_Message_t* QUERY_Message = (RNDIS_Query_Message_t*)&RNDISMessageBuffer; + RNDIS_Query_Complete_t* QUERY_Response = (RNDIS_Query_Complete_t*)&RNDISMessageBuffer; + uint32_t Query_Oid = QUERY_Message->Oid; void* QueryData = &RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + QUERY_Message->InformationBufferOffset]; - void* ResponseData = &RNDISMessageBuffer[sizeof(RNDIS_QUERY_CMPLT_t)]; + void* ResponseData = &RNDISMessageBuffer[sizeof(RNDIS_Query_Complete_t)]; uint16_t ResponseSize; QUERY_Response->MessageType = REMOTE_NDIS_QUERY_CMPLT; - QUERY_Response->MessageLength = sizeof(RNDIS_QUERY_CMPLT_t); + QUERY_Response->MessageLength = sizeof(RNDIS_Query_Complete_t); if (ProcessNDISQuery(Query_Oid, QueryData, QUERY_Message->InformationBufferLength, ResponseData, &ResponseSize)) @@ -166,7 +165,7 @@ void ProcessRNDISControlMessage(void) QUERY_Response->MessageLength += ResponseSize; QUERY_Response->InformationBufferLength = ResponseSize; - QUERY_Response->InformationBufferOffset = (sizeof(RNDIS_QUERY_CMPLT_t) - sizeof(RNDIS_Message_Header_t)); + QUERY_Response->InformationBufferOffset = (sizeof(RNDIS_Query_Complete_t) - sizeof(RNDIS_Message_Header_t)); } else { @@ -182,12 +181,12 @@ void ProcessRNDISControlMessage(void) ResponseReady = true; - RNDIS_SET_MSG_t* SET_Message = (RNDIS_SET_MSG_t*)&RNDISMessageBuffer; - RNDIS_SET_CMPLT_t* SET_Response = (RNDIS_SET_CMPLT_t*)&RNDISMessageBuffer; - uint32_t SET_Oid = SET_Message->Oid; + RNDIS_Set_Message_t* SET_Message = (RNDIS_Set_Message_t*)&RNDISMessageBuffer; + RNDIS_Set_Complete_t* SET_Response = (RNDIS_Set_Complete_t*)&RNDISMessageBuffer; + uint32_t SET_Oid = SET_Message->Oid; SET_Response->MessageType = REMOTE_NDIS_SET_CMPLT; - SET_Response->MessageLength = sizeof(RNDIS_SET_CMPLT_t); + SET_Response->MessageLength = sizeof(RNDIS_Set_Complete_t); SET_Response->RequestId = SET_Message->RequestId; void* SetData = &RNDISMessageBuffer[sizeof(RNDIS_Message_Header_t) + @@ -204,10 +203,10 @@ void ProcessRNDISControlMessage(void) ResponseReady = true; - RNDIS_RESET_CMPLT_t* RESET_Response = (RNDIS_RESET_CMPLT_t*)&RNDISMessageBuffer; + RNDIS_Reset_Complete_t* RESET_Response = (RNDIS_Reset_Complete_t*)&RNDISMessageBuffer; RESET_Response->MessageType = REMOTE_NDIS_RESET_CMPLT; - RESET_Response->MessageLength = sizeof(RNDIS_RESET_CMPLT_t); + RESET_Response->MessageLength = sizeof(RNDIS_Reset_Complete_t); RESET_Response->Status = REMOTE_NDIS_STATUS_SUCCESS; RESET_Response->AddressingReset = 0; @@ -217,11 +216,11 @@ void ProcessRNDISControlMessage(void) ResponseReady = true; - RNDIS_KEEPALIVE_MSG_t* KEEPALIVE_Message = (RNDIS_KEEPALIVE_MSG_t*)&RNDISMessageBuffer; - RNDIS_KEEPALIVE_CMPLT_t* KEEPALIVE_Response = (RNDIS_KEEPALIVE_CMPLT_t*)&RNDISMessageBuffer; + RNDIS_KeepAlive_Message_t* KEEPALIVE_Message = (RNDIS_KeepAlive_Message_t*)&RNDISMessageBuffer; + RNDIS_KeepAlive_Complete_t* KEEPALIVE_Response = (RNDIS_KeepAlive_Complete_t*)&RNDISMessageBuffer; KEEPALIVE_Response->MessageType = REMOTE_NDIS_KEEPALIVE_CMPLT; - KEEPALIVE_Response->MessageLength = sizeof(RNDIS_KEEPALIVE_CMPLT_t); + KEEPALIVE_Response->MessageLength = sizeof(RNDIS_KeepAlive_Complete_t); KEEPALIVE_Response->RequestId = KEEPALIVE_Message->RequestId; KEEPALIVE_Response->Status = REMOTE_NDIS_STATUS_SUCCESS; @@ -232,11 +231,11 @@ void ProcessRNDISControlMessage(void) /** Processes RNDIS query commands, retrieving information from the adapter and reporting it back to the host. The requested * parameter is given as an OID value. * - * \param OId OId value of the parameter being queried - * \param QueryData Pointer to any extra query data being sent by the host to the device inside the RNDIS message buffer - * \param QuerySize Size in bytes of the extra query data being sent by the host - * \param ResponseData Pointer to the start of the query response inside the RNDIS message buffer - * \param ResponseSize Pointer to the size in bytes of the response data being sent to the host + * \param[in] OId OId value of the parameter being queried + * \param[in] QueryData Pointer to any extra query data being sent by the host to the device inside the RNDIS message buffer + * \param[in] QuerySize Size in bytes of the extra query data being sent by the host + * \param[out] ResponseData Pointer to the start of the query response inside the RNDIS message buffer + * \param[out] ResponseSize Pointer to the size in bytes of the response data being sent to the host * * \return Boolean true if the query was handled, false otherwise */ @@ -364,9 +363,9 @@ static bool ProcessNDISQuery(uint32_t OId, void* QueryData, uint16_t QuerySize, /** Processes RNDIS set commands, setting adapter parameters to values given by the host. The requested parameter is given * as an OID value. * - * \param OId OId value of the parameter being set - * \param SetData Pointer to the parameter value in the RNDIS message buffer - * \param SetSize Size in bytes of the parameter value being sent by the host + * \param[in] OId OId value of the parameter being set + * \param[in] SetData Pointer to the parameter value in the RNDIS message buffer + * \param[in] SetSize Size in bytes of the parameter value being sent by the host * * \return Boolean true if the set was handled, false otherwise */