A stack which works with or without an Mbed os library. Provides IPv4 or IPv6 with a full 1500 byte buffer.
Dependents: oldheating gps motorhome heating
Diff: tcp/tcprecv.c
- Revision:
- 86:55bc5ddac16c
- Parent:
- 82:20781198d26d
- Child:
- 88:1ba13e6062a3
--- a/tcp/tcprecv.c Sat Nov 17 18:50:48 2018 +0000 +++ b/tcp/tcprecv.c Sun Nov 18 12:13:15 2018 +0000 @@ -80,9 +80,13 @@ int TcpHandleReceivedPacket(void (*traceback)(void), int sizeRx, void* pPacketRx, int* pSizeTx, void* pPacketTx, int ipType, int remArIndex, int locIpScope) { + int action = DO_NOTHING; + + Led1Set(true); if (remArIndex < 0) { LogTimeF("Invalid remote AR index %d", remArIndex); + Led1Set(false); return DO_NOTHING; } @@ -107,6 +111,7 @@ default: logTraceBack(traceback, "TCP - unknown port %d", TcpHdrDstPort); + Led1Set(false); return DO_NOTHING; //Ignore unknown ports } @@ -116,6 +121,7 @@ if (!pTcb) //Bomb out if no more tcbs are available { logTraceBack(traceback, "TCP - no more tcbs are available"); + Led1Set(false); return DO_NOTHING; } pTcb->timeLastRcvd = TcbElapsed; @@ -134,6 +140,7 @@ logTraceBack(traceback, "TCP - received reset - resetting TCB"); pTcb->state = TCB_EMPTY; } + Led1Set(false); return DO_NOTHING; //Don't reply } @@ -144,7 +151,9 @@ { logReset("received a SYN on port %d when connection open", TcpHdrSrcPort); pTcb->state = TCB_EMPTY; - return TcpSendReset(pSizeTx, pPacketTx, pTcb); + action = TcpSendReset(pSizeTx, pPacketTx, pTcb); + Led1Set(false); + return action; } else { @@ -179,7 +188,9 @@ pTcb->bytesAckdToRem = TcpHdrSeqNum + seqLengthRcvd; //Ack number logReset("non SYN packet received on a closed connection"); pTcb->state = TCB_EMPTY; - return TcpSendReset(pSizeTx, pPacketTx, pTcb); + action = TcpSendReset(pSizeTx, pPacketTx, pTcb); + Led1Set(false); + return action; } //Check if the acks of bytes sent has progressed and reset the timer @@ -207,9 +218,11 @@ { logTraceBack(traceback, "TCP - resending last ACK on port %d as seq rcvd is %d and last seq ackd was %d", TcpHdrSrcPort, seqRcvdFromRem, pTcb->bytesAckdToRem); } - return TcpResendLastAck(pSizeTx, pPacketTx, pTcb); + action = TcpResendLastAck(pSizeTx, pPacketTx, pTcb); + Led1Set(false); + return action; } - + Led2Set(true); //Handle FIN if (TcpHdrFIN) pTcb->rcvdFin = true; //When reply is all sent only a passive close is needed @@ -229,7 +242,10 @@ { logReset("data received before connection established"); pTcb->state = TCB_EMPTY; - return TcpSendReset(pSizeTx, pPacketTx, pTcb); + action = TcpSendReset(pSizeTx, pPacketTx, pTcb); + Led1Set(false); + Led2Set(false); + return action; } pTcb->state = TCB_ESTABLISHED; break; @@ -251,5 +267,9 @@ } - return TcpSend(pSizeTx, pPacketTx, pTcb); + action = TcpSend(pSizeTx, pPacketTx, pTcb); + Led1Set(false); + Led2Set(false); + + return action; }