rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Toggle main menu visibility
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
44
extern
"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
58
typedef
enum
{
59
WA_REQ_READ
= 0,
60
WA_REQ_CODE
,
61
WA_REQ_UPLOAD
,
62
}
wa_req_kind_t
;
63
65
typedef
enum
{
66
WA_GUARD_OK = 0,
67
WA_GUARD_HOST
,
68
WA_GUARD_BODY
,
69
WA_GUARD_BIG
,
70
WA_GUARD_ORIGIN
,
71
WA_GUARD_UPLOAD
,
72
}
wa_guard_t
;
73
75
typedef
struct
{
76
const
char
*
name
;
77
uint8_t
ip
[4];
79
}
wa_self_t
;
80
86
typedef
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
100
bool
wa_host_ok
(
const
char
*host,
const
wa_self_t
*self);
101
110
bool
wa_origin_ok
(
const
char
*origin,
const
char
*referer,
111
const
wa_self_t
*self);
112
121
wa_guard_t
wa_guard
(
wa_req_kind_t
kind,
const
wa_req_t
*req,
122
const
wa_self_t
*self);
123
130
const
char
*
wa_guard_status
(
wa_guard_t
g);
131
132
#ifdef __cplusplus
133
}
134
#endif
135
136
#endif
/* RCBENCH_WA_GUARD_H */
wa_req_t
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
wa_req_t::host
const char * host
Definition
wa_guard.h:87
wa_req_t::upload
const char * upload
Definition
wa_guard.h:90
wa_req_t::origin
const char * origin
Definition
wa_guard.h:88
wa_req_t::referer
const char * referer
Definition
wa_guard.h:89
wa_req_t::body
uint64_t body
Definition
wa_guard.h:91
wa_self_t
The panel as a request may name it.
Definition
wa_guard.h:75
wa_self_t::name
const char * name
Definition
wa_guard.h:76
wa_self_t::ip
uint8_t ip[4]
Definition
wa_guard.h:77
wa_req_kind_t
wa_req_kind_t
What the request is to the guard.
Definition
wa_guard.h:58
WA_REQ_UPLOAD
@ WA_REQ_UPLOAD
Definition
wa_guard.h:61
WA_REQ_READ
@ WA_REQ_READ
Definition
wa_guard.h:59
WA_REQ_CODE
@ WA_REQ_CODE
Definition
wa_guard.h:60
wa_guard_t
wa_guard_t
The guard's answer.
Definition
wa_guard.h:65
WA_GUARD_BODY
@ WA_GUARD_BODY
Definition
wa_guard.h:68
WA_GUARD_UPLOAD
@ WA_GUARD_UPLOAD
Definition
wa_guard.h:71
WA_GUARD_BIG
@ WA_GUARD_BIG
Definition
wa_guard.h:69
WA_GUARD_HOST
@ WA_GUARD_HOST
Definition
wa_guard.h:67
WA_GUARD_ORIGIN
@ WA_GUARD_ORIGIN
Definition
wa_guard.h:70
wa_host_ok
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
wa_origin_ok
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
wa_guard_status
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
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
shared
webaccess
include
wa_guard.h
Generated by
1.18.0