aboutsummaryrefslogtreecommitdiff
path: root/Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
diff options
context:
space:
mode:
authorDean Camera <[email protected]>2009-08-07 06:55:31 +0000
committerDean Camera <[email protected]>2009-08-07 06:55:31 +0000
commitd423090b26ade8912e669d6c6d3c5463e0669429 (patch)
treef443783209b96313146c539de92c408788d2778d /Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
parent85c2716f2d37bb50d126102fcdd09fb78d26ebc5 (diff)
downloadqmk_firmware-d423090b26ade8912e669d6c6d3c5463e0669429.tar.gz
qmk_firmware-d423090b26ade8912e669d6c6d3c5463e0669429.zip
Cleanups to RNDIS device demos. Fix issue in RNDIS demos where the memory would become corrupted due to an incorrect bounds check when iterating over the port state table, causing random resets.
Revert change to Template_Endpoint_Control_R.c, which broke control stream reads. Remove uneeded ADC.h include in the class driver AudioOutput demo.
Diffstat (limited to 'Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c')
-rw-r--r--Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c b/Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
index 57b3f3a8cf..2537286b76 100644
--- a/Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
+++ b/Demos/Device/LowLevel/RNDISEthernet/Lib/TCP.c
@@ -58,19 +58,18 @@ TCP_ConnectionState_t ConnectionStateTable[MAX_TCP_CONNECTIONS];
*/
void TCP_Task(void)
{
- /* Task to hand off TCP packets to and from the listening applications. */
-
/* Run each application in sequence, to process incoming and generate outgoing packets */
for (uint8_t CSTableEntry = 0; CSTableEntry < MAX_TCP_CONNECTIONS; CSTableEntry++)
{
/* Find the corresponding port entry in the port table */
- for (uint8_t PTableEntry = 0; PTableEntry < MAX_TCP_CONNECTIONS; PTableEntry++)
+ for (uint8_t PTableEntry = 0; PTableEntry < MAX_OPEN_TCP_PORTS; PTableEntry++)
{
/* Run the application handler for the port */
if ((PortStateTable[PTableEntry].Port == ConnectionStateTable[CSTableEntry].Port) &&
(PortStateTable[PTableEntry].State == TCP_Port_Open))
{
- PortStateTable[PTableEntry].ApplicationHandler(&ConnectionStateTable[CSTableEntry], &ConnectionStateTable[CSTableEntry].Info.Buffer);
+ PortStateTable[PTableEntry].ApplicationHandler(&ConnectionStateTable[CSTableEntry],
+ &ConnectionStateTable[CSTableEntry].Info.Buffer);
}
}
}
@@ -89,7 +88,7 @@ void TCP_Task(void)
Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&FrameOUT.FrameData;
IP_Header_t* IPHeaderOUT = (IP_Header_t*)&FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];
TCP_Header_t* TCPHeaderOUT = (TCP_Header_t*)&FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
- sizeof(IP_Header_t)];
+ sizeof(IP_Header_t)];
void* TCPDataOUT = &FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +
sizeof(IP_Header_t) +
sizeof(TCP_Header_t)];
@@ -367,11 +366,12 @@ int16_t TCP_ProcessTCPPacket(void* IPHeaderInStart, void* TCPHeaderInStart, void
/* Detect RST from host to abort existing connection */
if (TCPHeaderIN->Flags & TCP_FLAG_RST)
{
- TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK);
- PacketResponse = true;
-
- TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,
- TCPHeaderIN->SourcePort, TCP_Connection_Closed);
+ if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,
+ TCPHeaderIN->SourcePort, TCP_Connection_Closed))
+ {
+ TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK);
+ PacketResponse = true;
+ }
}
else
{
@@ -584,10 +584,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,
* complimented.
*
- * \param[in] TCPHeaderOutStart Pointer to the start of the packet's outgoing TCP header
- * \param[in] SourceAddress Source protocol IP address of the outgoing IP header
- * \param[in] DestinationAddress Destination protocol IP address of the outgoing IP header
- * \param[in] TCPOutSize Size in bytes of the TCP data header and payload
+ * \param[in] TCPHeaderOutStart Pointer to the start of the packet's outgoing TCP header
+ * \param[in] SourceAddress Source protocol IP address of the outgoing IP header
+ * \param[in] DestinationAddress Destination protocol IP address of the outgoing IP header
+ * \param[in] TCPOutSize Size in bytes of the TCP data header and payload
*
* \return A 16-bit TCP checksum value
*/