Add extra tests to the MassStorage device demo and class driver for validating comman...
[pub/USBasp.git] / Demos / Device / ClassDriver / RNDISEthernet / Lib / TCP.c
index 7c3f3b4..6746433 100644 (file)
@@ -56,7 +56,7 @@ TCP_ConnectionState_t  ConnectionStateTable[MAX_TCP_CONNECTIONS];
  *  level. If an application produces a response, this task constructs the appropriate Ethernet frame and places it into the Ethernet OUT\r
  *  buffer for later transmission.\r
  */\r
-void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)\r
+void TCP_TCPTask(USB_ClassInfo_RNDIS_Device_t* RNDISInterfaceInfo)\r
 {\r
        /* Task to hand off TCP packets to and from the listening applications. */\r
 \r
@@ -76,7 +76,7 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
        }\r
        \r
        /* Bail out early if there is already a frame waiting to be sent in the Ethernet OUT buffer */\r
-       if (RNDISInterfaceInfo->FrameOUT.FrameInBuffer)\r
+       if (RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer)\r
          return;\r
        \r
        /* Send response packets from each application as the TCP packet buffers are filled by the applications */\r
@@ -86,11 +86,11 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
                if ((ConnectionStateTable[CSTableEntry].Info.Buffer.Direction == TCP_PACKETDIR_OUT) &&\r
                    (ConnectionStateTable[CSTableEntry].Info.Buffer.Ready))\r
                {\r
-                       Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData;\r
-                       IP_Header_t*    IPHeaderOUT  = (IP_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];\r
-                       TCP_Header_t*   TCPHeaderOUT = (TCP_Header_t*)&RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +\r
+                       Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData;\r
+                       IP_Header_t*    IPHeaderOUT  = (IP_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];\r
+                       TCP_Header_t*   TCPHeaderOUT = (TCP_Header_t*)&RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +\r
                                                                                                              sizeof(IP_Header_t)];                                             \r
-                       void*           TCPDataOUT     = &RNDISInterfaceInfo->FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +\r
+                       void*           TCPDataOUT     = &RNDISInterfaceInfo->State.FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +\r
                                                                                                 sizeof(IP_Header_t) +\r
                                                                                                 sizeof(TCP_Header_t)];\r
 \r
@@ -145,8 +145,8 @@ void TCP_TCPTask(USB_ClassInfo_RNDIS_t* RNDISInterfaceInfo)
                        PacketSize += sizeof(Ethernet_Frame_Header_t);\r
 \r
                        /* Set the response length in the buffer and indicate that a response is ready to be sent */\r
-                       RNDISInterfaceInfo->FrameOUT.FrameLength   = PacketSize;\r
-                       RNDISInterfaceInfo->FrameOUT.FrameInBuffer = true;\r
+                       RNDISInterfaceInfo->State.FrameOUT.FrameLength   = PacketSize;\r
+                       RNDISInterfaceInfo->State.FrameOUT.FrameInBuffer = true;\r
                        \r
                        ConnectionStateTable[CSTableEntry].Info.Buffer.Ready = false;\r
                        \r
@@ -171,9 +171,9 @@ void TCP_Init(void)
 \r
 /** Sets the state and callback handler of the given port, specified in big endian to the given state.\r
  *\r
- *  \param Port     Port whose state and callback function to set, specified in big endian\r
- *  \param State    New state of the port, a value from the TCP_PortStates_t enum\r
- *  \param Handler  Application callback handler for the port\r
+ *  \param[in] Port     Port whose state and callback function to set, specified in big endian\r
+ *  \param[in] State    New state of the port, a value from the TCP_PortStates_t enum\r
+ *  \param[in] Handler  Application callback handler for the port\r
  *\r
  *  \return Boolean true if the port state was set, false otherwise (no more space in the port state table)\r
  */\r
@@ -220,7 +220,7 @@ bool TCP_SetPortState(uint16_t Port, uint8_t State, void (*Handler)(TCP_Connecti
 \r
 /** Retrieves the current state of a given TCP port, specified in big endian.\r
  *\r
- *  \param Port  TCP port whose state is to be retrieved, given in big-endian\r
+ *  \param[in] Port  TCP port whose state is to be retrieved, given in big-endian\r
  *\r
  *  \return A value from the TCP_PortStates_t enum\r
  */\r
@@ -242,10 +242,10 @@ uint8_t TCP_GetPortState(uint16_t Port)
 /** Sets the connection state of the given port, remote address and remote port to the given TCP connection state. If the\r
  *  connection exists in the connection state table it is updated, otherwise it is created if possible.\r
  *\r
- *  \param Port           TCP port of the connection on the device, specified in big endian\r
- *  \param RemoteAddress  Remote protocol IP address of the connected device\r
- *  \param RemotePort     TCP port of the remote device in the connection, specified in big endian\r
- *  \param State          TCP connection state, a value from the TCP_ConnectionStates_t enum\r
+ *  \param[in] Port           TCP port of the connection on the device, specified in big endian\r
+ *  \param[in] RemoteAddress  Remote protocol IP address of the connected device\r
+ *  \param[in] RemotePort     TCP port of the remote device in the connection, specified in big endian\r
+ *  \param[in] State          TCP connection state, a value from the TCP_ConnectionStates_t enum\r
  *\r
  *  \return Boolean true if the connection was updated or created, false otherwise (no more space in the connection state table)\r
  */\r
@@ -283,9 +283,9 @@ bool TCP_SetConnectionState(uint16_t Port, IP_Address_t RemoteAddress, uint16_t
 \r
 /** Retrieves the current state of a given TCP connection to a host.\r
  *\r
- *  \param Port           TCP port on the device in the connection, specified in big endian\r
- *  \param RemoteAddress  Remote protocol IP address of the connected host\r
- *  \param RemotePort     Remote TCP port of the connected host, specified in big endian\r
+ *  \param[in] Port           TCP port on the device in the connection, specified in big endian\r
+ *  \param[in] RemoteAddress  Remote protocol IP address of the connected host\r
+ *  \param[in] RemotePort     Remote TCP port of the connected host, specified in big endian\r
  *\r
  *  \return A value from the TCP_ConnectionStates_t enum\r
  */\r
@@ -310,9 +310,9 @@ uint8_t TCP_GetConnectionState(uint16_t Port, IP_Address_t RemoteAddress, uint16
 \r
 /** Retrieves the connection info structure of a given connection to a host.\r
  *\r
- *  \param Port           TCP port on the device in the connection, specified in big endian\r
- *  \param RemoteAddress  Remote protocol IP address of the connected host\r
- *  \param RemotePort     Remote TCP port of the connected host, specified in big endian\r
+ *  \param[in] Port           TCP port on the device in the connection, specified in big endian\r
+ *  \param[in] RemoteAddress  Remote protocol IP address of the connected host\r
+ *  \param[in] RemotePort     Remote TCP port of the connected host, specified in big endian\r
  *\r
  *  \return ConnectionInfo structure of the connection if found, NULL otherwise\r
  */\r
@@ -337,9 +337,9 @@ TCP_ConnectionInfo_t* TCP_GetConnectionInfo(uint16_t Port, IP_Address_t RemoteAd
 /** Processes a TCP packet inside an Ethernet frame, and writes the appropriate response\r
  *  to the output Ethernet frame if one is created by a application handler.\r
  *\r
- *  \param IPHeaderInStart    Pointer to the start of the incoming packet's IP header\r
- *  \param TCPHeaderInStart   Pointer to the start of the incoming packet's TCP header\r
- *  \param TCPHeaderOutStart  Pointer to the start of the outgoing packet's TCP header\r
+ *  \param[in] IPHeaderInStart     Pointer to the start of the incoming packet's IP header\r
+ *  \param[in] TCPHeaderInStart    Pointer to the start of the incoming packet's TCP header\r
+ *  \param[out] TCPHeaderOutStart  Pointer to the start of the outgoing packet's TCP header\r
  *\r
  *  \return The number of bytes written to the out Ethernet frame if any, NO_RESPONSE if no\r
  *           response was generated, NO_PROCESS if the packet processing was deferred until the\r
@@ -579,10 +579,10 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, void* TCPHeaderInStart, void
 /** Calculates the appropriate TCP checksum, consisting of the addition of the one's compliment of each word,\r
  *  complimented.\r
  *\r
- *  \param TCPHeaderOutStart  Pointer to the start of the packet's outgoing TCP header\r
- *  \param SourceAddress      Source protocol IP address of the outgoing IP header\r
- *  \param DestinationAddress DestinationAddress protocol IP address of the outgoing IP header\r
- *  \param TCPOutSize         Size in bytes of the TCP data header and payload\r
+ *  \param[in] TCPHeaderOutStart   Pointer to the start of the packet's outgoing TCP header\r
+ *  \param[in] SourceAddress       Source protocol IP address of the outgoing IP header\r
+ *  \param[in] DestinationAddress  Destination protocol IP address of the outgoing IP header\r
+ *  \param[in] TCPOutSize          Size in bytes of the TCP data header and payload\r
  *\r
  *  \return A 16-bit TCP checksum value\r
  */\r