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