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

Committer:
andrewboyson
Date:
Tue May 14 15:09:39 2019 +0000
Revision:
145:206bf0d073c7
Added a shim module between the web server and TCP to switch between http (direct) and https (tls).

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andrewboyson 145:206bf0d073c7 1 #include <stdbool.h>
andrewboyson 145:206bf0d073c7 2
andrewboyson 145:206bf0d073c7 3 #include "tcp.h"
andrewboyson 145:206bf0d073c7 4 #include "tcpbuf.h"
andrewboyson 145:206bf0d073c7 5 #include "tls.h"
andrewboyson 145:206bf0d073c7 6
andrewboyson 145:206bf0d073c7 7 //Plumb into these from your html server
andrewboyson 145:206bf0d073c7 8 void (*HttpRequestFunction)(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pState);
andrewboyson 145:206bf0d073c7 9 bool (*HttpReplyPollFunction)(char* pState, bool clientFinished);
andrewboyson 145:206bf0d073c7 10
andrewboyson 145:206bf0d073c7 11 void HttpRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pState)
andrewboyson 145:206bf0d073c7 12 {
andrewboyson 145:206bf0d073c7 13 HttpRequestFunction(size, pRequestStream, positionInRequestStream, pState);
andrewboyson 145:206bf0d073c7 14 }
andrewboyson 145:206bf0d073c7 15 void HttpsRequest(int size, char* pRequestStream, uint32_t positionInRequestStream, char* pState)
andrewboyson 145:206bf0d073c7 16 {
andrewboyson 145:206bf0d073c7 17 TlsRequest (size, pRequestStream, positionInRequestStream, pState);
andrewboyson 145:206bf0d073c7 18 }
andrewboyson 145:206bf0d073c7 19 bool HttpBufFilled(void)
andrewboyson 145:206bf0d073c7 20 {
andrewboyson 145:206bf0d073c7 21 return TcpBufFilled();
andrewboyson 145:206bf0d073c7 22 }
andrewboyson 145:206bf0d073c7 23
andrewboyson 145:206bf0d073c7 24 static bool tlsRequired;
andrewboyson 145:206bf0d073c7 25 bool HttpReplyPoll (char* pState, bool clientFinished)
andrewboyson 145:206bf0d073c7 26 {
andrewboyson 145:206bf0d073c7 27 tlsRequired = false;
andrewboyson 145:206bf0d073c7 28 return HttpReplyPollFunction(pState, clientFinished);
andrewboyson 145:206bf0d073c7 29 }
andrewboyson 145:206bf0d073c7 30 bool HttpsReplyPoll(char* pState, bool clientFinished)
andrewboyson 145:206bf0d073c7 31 {
andrewboyson 145:206bf0d073c7 32 tlsRequired = true;
andrewboyson 145:206bf0d073c7 33 return TlsReplyPoll(pState, clientFinished);
andrewboyson 145:206bf0d073c7 34 }
andrewboyson 145:206bf0d073c7 35 void HttpAddChar (char c)
andrewboyson 145:206bf0d073c7 36 {
andrewboyson 145:206bf0d073c7 37 if (tlsRequired) TlsAddChar(c);
andrewboyson 145:206bf0d073c7 38 else TcpBufAddChar(c);
andrewboyson 145:206bf0d073c7 39 }