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
tcp/http/httpshim/httpshim.c@158:3adf725c0804, 2019-09-07 (annotated)
- Committer:
- andrewboyson
- Date:
- Sat Sep 07 18:57:57 2019 +0000
- Revision:
- 158:3adf725c0804
- Parent:
- 157:b0bdb77e27f3
Added main routine for use, ultimately, by TLS and asynchronous decryption.
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| andrewboyson | 146:0fc66d610fd6 | 1 | #include <stdbool.h> |
| andrewboyson | 146:0fc66d610fd6 | 2 | |
| andrewboyson | 146:0fc66d610fd6 | 3 | #include "http.h" |
| andrewboyson | 146:0fc66d610fd6 | 4 | #include "tcp.h" |
| andrewboyson | 146:0fc66d610fd6 | 5 | #include "tcpbuf.h" |
| andrewboyson | 146:0fc66d610fd6 | 6 | #include "tls.h" |
| andrewboyson | 158:3adf725c0804 | 7 | #include "led.h" |
| andrewboyson | 146:0fc66d610fd6 | 8 | |
| andrewboyson | 146:0fc66d610fd6 | 9 | /* |
| andrewboyson | 146:0fc66d610fd6 | 10 | The shim acts as the switch between TCP, TLS and HTTP. |
| andrewboyson | 146:0fc66d610fd6 | 11 | It means HTTP does not need to know if it is talking directly to TCP as HTTP or via TLS in the form of HTTPS. |
| andrewboyson | 146:0fc66d610fd6 | 12 | It means TCP does not need to know if it is talking directly to HTTP or via TLS. |
| andrewboyson | 146:0fc66d610fd6 | 13 | */ |
| andrewboyson | 157:b0bdb77e27f3 | 14 | void HttpShimReset(bool secure, int connection) |
| andrewboyson | 146:0fc66d610fd6 | 15 | { |
| andrewboyson | 156:be12b8fd5b21 | 16 | if (secure) TlsReset(connection); //Only reset TLS if appropriate |
| andrewboyson | 156:be12b8fd5b21 | 17 | HttpFunctionReset(connection); //Always reset Http |
| andrewboyson | 156:be12b8fd5b21 | 18 | } |
| andrewboyson | 157:b0bdb77e27f3 | 19 | void HttpShimRequest(bool secure, int connection, int size, char* pRequestStream, uint32_t positionInRequestStream) |
| andrewboyson | 156:be12b8fd5b21 | 20 | { |
| andrewboyson | 156:be12b8fd5b21 | 21 | if (secure) TlsRequest (connection, size, (uint8_t*)pRequestStream, positionInRequestStream); |
| andrewboyson | 156:be12b8fd5b21 | 22 | else HttpFunctionRequest(connection, size, pRequestStream, positionInRequestStream); |
| andrewboyson | 146:0fc66d610fd6 | 23 | } |
| andrewboyson | 146:0fc66d610fd6 | 24 | |
| andrewboyson | 146:0fc66d610fd6 | 25 | static bool tlsRequired; |
| andrewboyson | 157:b0bdb77e27f3 | 26 | bool HttpShimPoll (bool secure, int connection, bool clientFinished) |
| andrewboyson | 146:0fc66d610fd6 | 27 | { |
| andrewboyson | 146:0fc66d610fd6 | 28 | tlsRequired = secure; |
| andrewboyson | 156:be12b8fd5b21 | 29 | if (tlsRequired) return TlsPoll (connection, clientFinished); |
| andrewboyson | 156:be12b8fd5b21 | 30 | else return HttpFunctionPoll(connection, clientFinished); |
| andrewboyson | 147:a6093b52e654 | 31 | } |
| andrewboyson | 155:22f249751106 | 32 | void HttpShimAddChar(char c) |
| andrewboyson | 146:0fc66d610fd6 | 33 | { |
| andrewboyson | 146:0fc66d610fd6 | 34 | if (tlsRequired) TlsAddChar(c); |
| andrewboyson | 146:0fc66d610fd6 | 35 | else TcpBufAddChar(c); |
| andrewboyson | 146:0fc66d610fd6 | 36 | } |
| andrewboyson | 146:0fc66d610fd6 | 37 | |
| andrewboyson | 146:0fc66d610fd6 | 38 | bool HttpShimBufFilled() |
| andrewboyson | 146:0fc66d610fd6 | 39 | { |
| andrewboyson | 146:0fc66d610fd6 | 40 | return TcpBufFilled(); |
| andrewboyson | 146:0fc66d610fd6 | 41 | } |
| andrewboyson | 157:b0bdb77e27f3 | 42 | bool HttpShimGetTrace(bool secure) |
| andrewboyson | 146:0fc66d610fd6 | 43 | { |
| andrewboyson | 157:b0bdb77e27f3 | 44 | if (secure) return HttpTrace || TlsTrace; |
| andrewboyson | 157:b0bdb77e27f3 | 45 | else return HttpTrace; |
| andrewboyson | 146:0fc66d610fd6 | 46 | } |