rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
wa_guard.h
Go to the documentation of this file.
1
36
37#ifndef RCBENCH_WA_GUARD_H
38#define RCBENCH_WA_GUARD_H
39
40#include <stdbool.h>
41#include <stdint.h>
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
48#define WA_UPLOAD_HDR "X-Rcbench-Upload"
50#define WA_UPLOAD_VAL "1"
53#define WA_CODE_BODY_MAX 95u
55#define WA_HTTP_PORT 80u
56
63
73
75typedef struct {
76 const char *name;
77 uint8_t ip[4];
79} wa_self_t;
80
86typedef struct {
87 const char *host;
88 const char *origin;
89 const char *referer;
90 const char *upload;
91 uint64_t body;
92} wa_req_t;
93
100bool wa_host_ok(const char *host, const wa_self_t *self);
101
110bool wa_origin_ok(const char *origin, const char *referer,
111 const wa_self_t *self);
112
122 const wa_self_t *self);
123
130const char *wa_guard_status(wa_guard_t g);
131
132#ifdef __cplusplus
133}
134#endif
135
136#endif /* RCBENCH_WA_GUARD_H */
The request's headers as the guard reads them. NULL is a header not sent; a value longer than the pla...
Definition wa_guard.h:86
const char * host
Definition wa_guard.h:87
const char * upload
Definition wa_guard.h:90
const char * origin
Definition wa_guard.h:88
const char * referer
Definition wa_guard.h:89
uint64_t body
Definition wa_guard.h:91
The panel as a request may name it.
Definition wa_guard.h:75
const char * name
Definition wa_guard.h:76
uint8_t ip[4]
Definition wa_guard.h:77
wa_req_kind_t
What the request is to the guard.
Definition wa_guard.h:58
@ WA_REQ_UPLOAD
Definition wa_guard.h:61
@ WA_REQ_READ
Definition wa_guard.h:59
@ WA_REQ_CODE
Definition wa_guard.h:60
wa_guard_t
The guard's answer.
Definition wa_guard.h:65
@ WA_GUARD_BODY
Definition wa_guard.h:68
@ WA_GUARD_UPLOAD
Definition wa_guard.h:71
@ WA_GUARD_BIG
Definition wa_guard.h:69
@ WA_GUARD_HOST
Definition wa_guard.h:67
@ WA_GUARD_ORIGIN
Definition wa_guard.h:70
bool wa_host_ok(const char *host, const wa_self_t *self)
Whether host, a Host header's value, names the panel.
Definition wa_guard.c:93
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.
Definition wa_guard.c:118
const char * wa_guard_status(wa_guard_t g)
The HTTP status line of a refusal, "421 Misdirected Request" and the like.
Definition wa_guard.c:152
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.
Definition wa_guard.c:127