|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Which requests the Wi-Fi page answers at all: the Host header, the Origin or Referer of a write, the upload's own header and the size of a body. More...
#include <stdbool.h>#include <stdint.h>Go to the source code of this file.
Data Structures | |
| struct | wa_self_t |
| The panel as a request may name it. More... | |
| struct | wa_req_t |
| The request's headers as the guard reads them. NULL is a header not sent; a value longer than the platform's buffer is passed as "", sent and matching nothing. More... | |
Enumerations | |
| enum | wa_req_kind_t { WA_REQ_READ = 0 , WA_REQ_CODE , WA_REQ_UPLOAD } |
| What the request is to the guard. More... | |
| enum | wa_guard_t { WA_GUARD_OK = 0 , WA_GUARD_HOST , WA_GUARD_BODY , WA_GUARD_BIG , WA_GUARD_ORIGIN , WA_GUARD_UPLOAD } |
| The guard's answer. More... | |
Functions | |
| bool | wa_host_ok (const char *host, const wa_self_t *self) |
Whether host, a Host header's value, names the panel. | |
| bool | wa_origin_ok (const char *origin, const char *referer, const wa_self_t *self) |
| Whether a write comes from the panel's own page. | |
| wa_guard_t | wa_guard (wa_req_kind_t kind, const wa_req_t *req, const wa_self_t *self) |
| The guard: Host first, then the body, then a write's Origin and the upload's header. | |
| const char * | wa_guard_status (wa_guard_t g) |
| The HTTP status line of a refusal, "421 Misdirected Request" and the like. | |
Which requests the Wi-Fi page answers at all: the Host header, the Origin or Referer of a write, the upload's own header and the size of a body.
Three attacks are refused here, before any access code or card read.
And a slow body: a read takes none (WA_GUARD_BODY, HTTP 400), the code form at most WA_CODE_BODY_MAX bytes (WA_GUARD_BIG, HTTP 413). The body of a refused request is never read; the connection closes with the answer.
Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).
SPDX-License-Identifier: MIT
| enum wa_guard_t |
| enum wa_req_kind_t |
| wa_guard_t wa_guard | ( | wa_req_kind_t | kind, |
| const wa_req_t * | req, | ||
| const wa_self_t * | self ) |
The guard: Host first, then the body, then a write's Origin and the upload's header.
| kind | what the request is |
| req | its headers |
| self | the panel |
| const char * wa_guard_status | ( | wa_guard_t | g | ) |
The HTTP status line of a refusal, "421 Misdirected Request" and the like.
| g | the answer; WA_GUARD_OK gives "200 OK" |
| bool wa_host_ok | ( | const char * | host, |
| const wa_self_t * | self ) |
Whether host, a Host header's value, names the panel.
| host | the value; NULL refuses |
| self | the panel |
| bool wa_origin_ok | ( | const char * | origin, |
| const char * | referer, | ||
| const wa_self_t * | self ) |
Whether a write comes from the panel's own page.
| origin | the Origin header, or NULL |
| referer | the Referer header, read only when origin is NULL |
| self | the panel |