*/\r
void TCP_Task(void)\r
{\r
- /* Task to hand off TCP packets to and from the listening applications. */\r
-\r
/* Run each application in sequence, to process incoming and generate outgoing packets */\r
for (uint8_t CSTableEntry = 0; CSTableEntry < MAX_TCP_CONNECTIONS; CSTableEntry++)\r
{\r
/* Find the corresponding port entry in the port table */\r
- for (uint8_t PTableEntry = 0; PTableEntry < MAX_TCP_CONNECTIONS; PTableEntry++)\r
+ for (uint8_t PTableEntry = 0; PTableEntry < MAX_OPEN_TCP_PORTS; PTableEntry++)\r
{\r
/* Run the application handler for the port */\r
if ((PortStateTable[PTableEntry].Port == ConnectionStateTable[CSTableEntry].Port) && \r
(PortStateTable[PTableEntry].State == TCP_Port_Open))\r
{\r
- PortStateTable[PTableEntry].ApplicationHandler(&ConnectionStateTable[CSTableEntry], &ConnectionStateTable[CSTableEntry].Info.Buffer);\r
+ PortStateTable[PTableEntry].ApplicationHandler(&ConnectionStateTable[CSTableEntry],\r
+ &ConnectionStateTable[CSTableEntry].Info.Buffer);\r
}\r
}\r
}\r
Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&FrameOUT.FrameData;\r
IP_Header_t* IPHeaderOUT = (IP_Header_t*)&FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t)];\r
TCP_Header_t* TCPHeaderOUT = (TCP_Header_t*)&FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +\r
- sizeof(IP_Header_t)]; \r
+ sizeof(IP_Header_t)];\r
void* TCPDataOUT = &FrameOUT.FrameData[sizeof(Ethernet_Frame_Header_t) +\r
sizeof(IP_Header_t) +\r
sizeof(TCP_Header_t)];\r
/* Detect RST from host to abort existing connection */\r
if (TCPHeaderIN->Flags & TCP_FLAG_RST)\r
{\r
- TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK); \r
- PacketResponse = true;\r
- \r
- TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,\r
- TCPHeaderIN->SourcePort, TCP_Connection_Closed); \r
+ if (TCP_SetConnectionState(TCPHeaderIN->DestinationPort, IPHeaderIN->SourceAddress,\r
+ TCPHeaderIN->SourcePort, TCP_Connection_Closed))\r
+ {\r
+ TCPHeaderOUT->Flags = (TCP_FLAG_RST | TCP_FLAG_ACK); \r
+ PacketResponse = true; \r
+ }\r
}\r
else\r
{\r
/** Calculates the appropriate TCP checksum, consisting of the addition of the one's compliment of each word,\r
* complimented.\r
*\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
+ * \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