Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: oldheating gps motorhome heating
Diff: tcp/tcpsend.c
- Revision:
- 88:1ba13e6062a3
- Parent:
- 87:40d46a979cdb
- Child:
- 89:9b765a67699b
--- a/tcp/tcpsend.c Sun Nov 18 15:34:56 2018 +0000 +++ b/tcp/tcpsend.c Tue Nov 20 17:21:38 2018 +0000 @@ -17,6 +17,16 @@ #define MAX_RETRANSMISSIONS 10 #define TIMEOUT_BROKEN_LINK 600 +static bool doTrace(uint16_t port) +{ + switch (port) + { + case 80: + if (HttpTrace) return true; + default: + return false; + } +} static int addApplicationData(void* pPacket, uint16_t port, uint32_t start, int mss, int todo) { int dataLength = 0; @@ -32,14 +42,14 @@ return dataLength; } -static int preparePacket(void* pPacket, struct tcb* pTcb, int dataLength, int* pSize) +static int preparePacket(void* pPacket, uint16_t locPort, uint16_t remPort, int dataLength, int* pSize) { //Set the acknowledge flag TcpHdrACK = true; //Swap the ports for the reply - TcpHdrSrcPort = pTcb->locPort; - TcpHdrDstPort = pTcb->remPort; + TcpHdrSrcPort = locPort; + TcpHdrDstPort = remPort; //Specify the receive window size to not throttle TcpHdrWindow = 4000; @@ -50,7 +60,7 @@ //Calculate the size of the reply *pSize = TcpHdrSizeGet() + dataLength; - return ActionMakeFromDestAndTrace(UNICAST, TcpDoTrace && NetTraceStack); + return ActionMakeFromDestAndTrace(UNICAST, doTrace(locPort) && NetTraceStack); } int TcpSend(int* pSize, void* pPacket, struct tcb* pTcb) { @@ -114,7 +124,7 @@ //Only send a packet if have bytes or an acknowledgement to send if (!rcvdSeqHasAdvanced && !bytesToSend) return DO_NOTHING; - return preparePacket(pPacket, pTcb, dataLength, pSize); + return preparePacket(pPacket, pTcb->locPort, pTcb->remPort, dataLength, pSize); } int TcpResendLastUnAcked(int* pSize, void *pPacket, struct tcb* pTcb) { @@ -146,7 +156,7 @@ TcpHdrAckNum = pTcb->bytesAckdToRem + pTcb->remIsn; //Set up the acknowledgement field ready to send TcpHdrSeqNum = seqNum + pTcb->locIsn; //Set up the start of the message before adding the bytes sent - return preparePacket(pPacket, pTcb, dataLength, pSize); + return preparePacket(pPacket, pTcb->locPort, pTcb->remPort, dataLength, pSize); } int TcpResendLastAck(int* pSize, void *pPacket, struct tcb* pTcb) { @@ -155,7 +165,7 @@ TcpHdrAckNum = pTcb->bytesAckdToRem + pTcb->remIsn; //Set up the acknowledgement field ready to send TcpHdrSeqNum = pTcb->bytesSentToRem + pTcb->locIsn; //Set up the start of the message before adding the bytes sent - return preparePacket(pPacket, pTcb, dataLength, pSize); + return preparePacket(pPacket, pTcb->locPort, pTcb->remPort, dataLength, pSize); } int TcpSendReset(int* pSize, void *pPacket, struct tcb* pTcb) { @@ -166,7 +176,7 @@ TcpHdrRST = true; - return preparePacket(pPacket, pTcb, dataLength, pSize); + return preparePacket(pPacket, pTcb->locPort, pTcb->remPort, dataLength, pSize); } int TcpSendClose(int* pSize, void *pPacket, struct tcb* pTcb) { @@ -178,7 +188,7 @@ TcpHdrAckNum = pTcb->bytesAckdToRem + pTcb->remIsn; //Set up the acknowledgement field ready to send TcpHdrSeqNum = pTcb->bytesSentToRem + pTcb->locIsn; //Set up the start of the message before adding the bytes sent - return preparePacket(pPacket, pTcb, dataLength, pSize); + return preparePacket(pPacket, pTcb->locPort, pTcb->remPort, dataLength, pSize); } int TcpPollForPacketToSend(int* pSize, void* pPacket, int ipType, int* pRemArIndex, int* pLocIpScope)