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:
- 145:206bf0d073c7
- Parent:
- 144:6bd5c54efc7d
- Child:
- 146:0fc66d610fd6
diff -r 6bd5c54efc7d -r 206bf0d073c7 tcp/tcpsend.c --- a/tcp/tcpsend.c Sun May 12 17:17:49 2019 +0000 +++ b/tcp/tcpsend.c Tue May 14 15:09:39 2019 +0000 @@ -12,7 +12,6 @@ #include "ip4.h" #include "dhcp.h" #include "http.h" -#include "https.h" #include "led.h" #include "tcpsend.h" #include "mstimer.h" @@ -46,15 +45,18 @@ return false; } } -static int addApplicationData(int *pDataLength, void* pPacket, uint16_t port, uint32_t start, int mss, char* pAppData) +static bool addApplicationData(int *pDataLength, void* pPacket, uint16_t port, uint32_t start, int mss, char* pAppState, bool clientFinished) { char* pData = (char*)pPacket + TcpHdrSizeGet(); + TcpBufStart(start, mss, pData); + bool finished = false; switch (port) { - case 80: return HttpSendReply (pDataLength, pData, start, mss, pAppData); - case 443: return HttpsSendReply(pDataLength, pData, start, mss, pAppData); - default: return 0; //0: not started; +1: started; -1: finished + case 80: finished = HttpReplyPoll (pAppState, clientFinished); break; + case 443: finished = HttpsReplyPoll(pAppState, clientFinished); break; } + *pDataLength = TcpBufLength(); + return finished; } static int preparePacket(void* pPacket, struct tcb* pTcb, int dataLength, int* pSize) { @@ -96,9 +98,8 @@ { if (pTcb->bytesSentToRem - pTcb->bytesAckdByRem < pTcb->window) { - //0: not started; +1: started; -1: finished - int state = addApplicationData(&dataLength, pPacket, pTcb->locPort, pTcb->bytesSentToRem - 1, pTcb->remMss, pTcb->appData); - if (state == TCP_APP_FINISHED || state == TCP_APP_NOT_STARTED && pTcb->rcvdFin) + bool finished = addApplicationData(&dataLength, pPacket, pTcb->locPort, pTcb->bytesSentToRem - 1, pTcb->remMss, pTcb->appData, pTcb->rcvdFin); + if (finished) { TcpHdrFIN = true; pTcb->sentFin = true; @@ -145,16 +146,15 @@ case TCB_ESTABLISHED: case TCB_CLOSE_FIN_WAIT: - if (pTcb->appStarted) { - bool added = addApplicationData(&dataLength, pPacket, pTcb->locPort, seqNum - 1, pTcb->remMss, pTcb->appData); - if (added && dataLength < pTcb->remMss) + bool finished = addApplicationData(&dataLength, pPacket, pTcb->locPort, seqNum - 1, pTcb->remMss, pTcb->appData, pTcb->rcvdFin); + if (finished) { TcpHdrFIN = true; pTcb->sentFin = true; } + break; } - break; } TcpHdrAckNum = pTcb->bytesAckdToRem + pTcb->remIsn; //Set up the acknowledgement field ready to send