ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
mdl_net.h
Go to the documentation of this file.
1
30#pragma once
31
32#include <stddef.h>
33#include <stdint.h>
34
35#include "ra8_err.h"
36
43typedef struct {
44 const char* user_agent;
45 const char* referer;
46 const char* if_none_match;
47 const char* if_modified_since;
48 uint32_t timeout_ms;
50
60typedef struct {
61 const uint8_t* data;
62 size_t length;
64
90
98
127
137typedef ra8_err_t (*mdl_net_body_reset_fn)(void* ctx);
138
151typedef ra8_err_t (*mdl_net_body_write_fn)(void* ctx,
152 const uint8_t* bytes,
153 uint32_t length,
154 uint32_t* out_written);
155
167
186typedef struct {
198 ra8_err_t (*get_buf)(void* ctx,
199 const char* url,
200 const mdl_net_req_t* req,
201 char* buf,
202 size_t cap,
203 size_t* out_len,
204 mdl_net_resp_t* resp);
205
216 ra8_err_t (*get_body)(void* ctx,
217 const char* url,
218 const mdl_net_req_t* req,
220 size_t* out_len,
221 mdl_net_resp_t* resp);
222
227 void (*destroy)(void* ctx);
229
252
276typedef struct mdl_net_provider {
277 void* ctx;
285 ra8_err_t (*open)(void* ctx, const mdl_net_policy_t* policy, mdl_net_iface_t* out_net);
287
315[[nodiscard]] ra8_err_t mdl_net_provider_open(const mdl_net_provider_t* provider,
316 const mdl_net_policy_t* policy,
317 mdl_net_iface_t* out_net);
318
340
380 const char* url,
381 const mdl_net_req_t* req,
382 char* buf,
383 size_t cap,
384 size_t* out_len,
385 mdl_net_resp_t* resp);
386
424 const char* url,
425 const mdl_net_req_t* req,
427 size_t* out_len,
428 mdl_net_resp_t* resp);
ra8_err_t(* mdl_net_body_write_fn)(void *ctx, const uint8_t *bytes, uint32_t length, uint32_t *out_written)
Consume one bounded response-body chunk.
Definition mdl_net.h:151
ra8_err_t mdl_net_get_buf(mdl_net_iface_t *net, const char *url, const mdl_net_req_t *req, char *buf, size_t cap, size_t *out_len, mdl_net_resp_t *resp)
GET url fully into a caller buffer (used for HTML pages).
Definition mdl_net.c:78
ra8_err_t(* mdl_net_body_reset_fn)(void *ctx)
Reset one caller-owned response-body sink before a transfer attempt.
Definition mdl_net.h:137
void mdl_net_destroy(mdl_net_iface_t *net)
Deinitialise a caller-owned network interface.
Definition mdl_net.c:120
mdl_net_resp_size_t
Captured-response-field buffer sizes.
Definition mdl_net.h:92
@ k_mdl_last_mod_max
Raw Last-Modified header value buffer bytes.
Definition mdl_net.h:95
@ k_mdl_content_type_max
Raw Content-Type header value buffer bytes.
Definition mdl_net.h:96
@ k_mdl_retry_after_max
Raw Retry-After header value buffer bytes.
Definition mdl_net.h:93
@ k_mdl_etag_max
Raw ETag header value buffer bytes.
Definition mdl_net.h:94
ra8_err_t mdl_net_get_body(mdl_net_iface_t *net, const char *url, const mdl_net_req_t *req, mdl_net_body_sink_t *sink, size_t *out_len, mdl_net_resp_t *resp)
GET url and stream its body through a caller-owned sink.
Definition mdl_net.c:97
ra8_err_t mdl_net_provider_open(const mdl_net_provider_t *provider, const mdl_net_policy_t *policy, mdl_net_iface_t *out_net)
Open a transport through an injected provider.
Definition mdl_net.c:64
struct mdl_net_iface mdl_net_iface_t
-proof
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Caller-owned lifecycle and write seam for one response body.
Definition mdl_net.h:162
void * ctx
Caller-owned callback state.
Definition mdl_net.h:165
mdl_net_body_reset_fn reset
Clear/abort prior attempt state.
Definition mdl_net.h:163
Read-only caller-owned byte view retained by a network backend.
Definition mdl_net.h:60
const uint8_t * data
First caller-owned byte, or NULL when empty.
Definition mdl_net.h:61
size_t length
Exact readable byte count at data.
Definition mdl_net.h:62
A network backend handle: an immutable method table plus its state.
const mdl_net_vtable_t * vtable
Backend method table (never NULL).
Definition mdl_net.h:249
void * ctx
Backend-private state passed to methods.
Definition mdl_net.h:250
Session-wide security policy for the network backend.
Definition mdl_net.h:81
mdl_net_bytes_t cookies
Newline-delimited input cookies.
Definition mdl_net.h:87
bool allow_cross_host_redirect
Permit a redirect to a different host.
Definition mdl_net.h:83
uint64_t max_response_bytes
Per-response byte cap (0 = unlimited).
Definition mdl_net.h:84
const char * socks5
SOCKS5 proxy URL, or NULL for none.
Definition mdl_net.h:86
mdl_net_bytes_t ca_pem
Complete PEM CA bundle, or an empty view.
Definition mdl_net.h:88
const char * proxy
HTTP/HTTPS proxy URL, or NULL for none.
Definition mdl_net.h:85
bool allow_private_hosts
Permit loopback/private/link-local peers.
Definition mdl_net.h:82
An injected FACTORY for mdl_net_iface_t: which backend, decided once.
ra8_err_t(* open)(void *ctx, const mdl_net_policy_t *policy, mdl_net_iface_t *out_net)
Open one hardened interface over the factory's private storage.
Definition mdl_net.h:285
void * ctx
Factory-private state; the dispatcher only forwards it.
Definition mdl_net.h:277
Per-request session parameters.
Definition mdl_net.h:43
const char * referer
Referer header value, or NULL to omit.
Definition mdl_net.h:45
const char * if_none_match
If-None-Match conditional header (ETag), or NULL.
Definition mdl_net.h:46
const char * if_modified_since
If-Modified-Since header (Last-Modified), or NULL.
Definition mdl_net.h:47
const char * user_agent
Session User-Agent; never per-request random.
Definition mdl_net.h:44
uint32_t timeout_ms
Whole-request time budget, milliseconds.
Definition mdl_net.h:48
Per-transfer response metadata surfaced to the politeness governor.
Definition mdl_net.h:120
long status
Finished transfer's HTTP status, 0 if none.
Definition mdl_net.h:121
char retry_after[k_mdl_retry_after_max]
Raw Retry-After value, "" when absent.
Definition mdl_net.h:122
char etag[k_mdl_etag_max]
Raw ETag value, "" when absent.
Definition mdl_net.h:123
char last_modified[k_mdl_last_mod_max]
Raw Last-Modified value, "" when absent.
Definition mdl_net.h:124
char content_type[k_mdl_content_type_max]
Raw Content-Type value, "" when absent.
Definition mdl_net.h:125
Method table one network backend registers (Dependency Inversion).
Definition mdl_net.h:186
ra8_err_t(* get_buf)(void *ctx, const char *url, const mdl_net_req_t *req, char *buf, size_t cap, size_t *out_len, mdl_net_resp_t *resp)
GET url fully into a caller buffer (used for HTML pages).
Definition mdl_net.h:198
ra8_err_t(* get_body)(void *ctx, const char *url, const mdl_net_req_t *req, mdl_net_body_sink_t *sink, size_t *out_len, mdl_net_resp_t *resp)
GET url and stream the body through an injected sink.
Definition mdl_net.h:216
void(* destroy)(void *ctx)
Release the backend-private state (called by mdl_net_destroy).
Definition mdl_net.h:227