20typedef enum : uint8_t {
35 "C6 and downloader Retry-After capacities must match");
37 "C6 and downloader ETag capacities must match");
39 "C6 and downloader HTTP-date capacities must match");
41 "C6 and downloader Content-Type capacities must match");
62 if ((output ==
nullptr) || (destination ==
nullptr) || (destination[0] ==
'\0')) {
97 if ((output->
length >= output->
cap) || ((
size_t)len > (output->
cap - output->
length - 1U))) {
102 uint32_t accepted = 0U;
107 if (accepted != len) {
204 .sha256 = backend->
sha256,
221 if (resp !=
nullptr) {
235 if (out_len !=
nullptr) {
284 uint16_t chunk_bytes,
287 if ((net ==
nullptr) || (backend ==
nullptr)) {
292 if ((link ==
nullptr) || (sha256 ==
nullptr) || (sha256->
init ==
nullptr) ||
293 (sha256->
update ==
nullptr) || (sha256->
final ==
nullptr) || (sha256->
ctx ==
nullptr)) {
302 .chunk_bytes = chunk_bytes,
303 .max_chunks = max_chunks,
ra8_err_t priv_mdl_net_classify_http(long status)
Classify one observed HTTP response status.
@ k_mdl_last_mod_max
Raw Last-Modified header value buffer bytes.
@ k_mdl_content_type_max
Raw Content-Type header value buffer bytes.
@ k_mdl_retry_after_max
Raw Retry-After header value buffer bytes.
@ k_mdl_etag_max
Raw ETag header value buffer bytes.
static void internal_c6_destroy(void *ctx)
Release the backend-private state (called by mdl_net_destroy).
static ra8_err_t internal_c6_output_begin(void *ctx, const char *destination)
Begin the local half of one transfer transaction.
static ra8_err_t internal_c6_output_abort(void *ctx)
Discard caller-visible partial bytes after a failed transfer.
ra8_err_t mdl_net_c6link_init(mdl_net_iface_t *net, mdl_net_c6link_t *backend, ra8_c6link_t *link, const ra8_mdl_sha256_iface_t *sha256, uint16_t chunk_bytes, uint32_t max_chunks)
Bind an open C6 link as a portable media network backend.
static ra8_err_t internal_c6_get(mdl_net_c6link_t *backend, const char *url, const mdl_net_req_t *req, mdl_c6_output_t *output, size_t *out_len, mdl_net_resp_t *resp)
Execute one digest-verified policy-preserving C6 GET.
static ra8_err_t internal_c6_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).
static ra8_err_t internal_c6_output_commit(void *ctx)
Publish the completed response to the caller-visible output.
static ra8_err_t internal_c6_output_write(void *ctx, const uint8_t *data, uint16_t len, uint16_t *written)
Append one verified-order C6 chunk to the selected output.
static ra8_err_t internal_c6_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.
mdl_c6_output_kind_t
Output destination selected for one synchronous adapter call.
@ k_mdl_c6_output_buffer
Bounded NUL-terminated caller buffer.
@ k_mdl_c6_output_sink
Injected streaming body sink.
Media network backend over the ESP32-C6 raw HTTPS transport.
Private HTTP classification shared by downloader network backends.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
struct ra8_c6link ra8_c6link_t
struct ra8_mdl_sha256_iface ra8_mdl_sha256_iface_t
ra8_err_t ra8_c6link_mdl_transfer(ra8_c6link_t *link, const char *url, const char *destination, const ra8_mdl_transfer_config_t *config, ra8_mdl_transfer_result_t *result)
Fetch, verify, and atomically publish one remote byte stream.
struct ra8_mdl_transfer_config ra8_mdl_transfer_config_t
struct ra8_mdl_transfer_result ra8_mdl_transfer_result_t
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
@ k_ra8_err_null_ptr
Pointer was NULL where a valid pointer was required.
@ k_ra8_err_invalid_size
Invalid size parameter (too large, too small, or misaligned).
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
@ k_ra8_mdl_chunk_data_max
Maximum raw body bytes in one chunk.
@ k_ra8_mdl_http_date_max
Maximum HTTP-date size, including NUL.
@ k_ra8_mdl_etag_max
Maximum ETag size, including NUL.
@ k_ra8_mdl_content_type_max
Maximum Content-Type size, including NUL.
@ k_ra8_mdl_retry_after_max
Maximum Retry-After size, including NUL.
Transaction state that turns one C6 body into a network response.
size_t cap
Text-buffer capacity.
mdl_net_body_sink_t * sink
Streaming sink or null.
size_t length
Bytes accepted so far.
char * buffer
Text buffer or null.
mdl_c6_output_kind_t kind
Selected output union member.
Caller-owned lifecycle and write seam for one response body.
mdl_net_body_write_fn write
Consume one response chunk.
void * ctx
Caller-owned callback state.
mdl_net_body_reset_fn reset
Clear/abort prior attempt state.
Caller-owned state for one serialized C6 media network backend.
ra8_c6link_t * link
Borrowed open C6 link.
uint32_t max_chunks
Hard pull bound for one response.
uint16_t chunk_bytes
Requested bytes per remote pull.
ra8_mdl_sha256_iface_t sha256
Caller-owned independent digest.
A network backend handle: an immutable method table plus its state.
Per-request session parameters.
const char * referer
Referer header value, or NULL to omit.
const char * if_none_match
If-None-Match conditional header (ETag), or NULL.
const char * if_modified_since
If-Modified-Since header (Last-Modified), or NULL.
const char * user_agent
Session User-Agent; never per-request random.
uint32_t timeout_ms
Whole-request time budget, milliseconds.
Per-transfer response metadata surfaced to the politeness governor.
long status
Finished transfer's HTTP status, 0 if none.
char retry_after[k_mdl_retry_after_max]
Raw Retry-After value, "" when absent.
char etag[k_mdl_etag_max]
Raw ETag value, "" when absent.
char last_modified[k_mdl_last_mod_max]
Raw Last-Modified value, "" when absent.
char content_type[k_mdl_content_type_max]
Raw Content-Type value, "" when absent.
Method table one network backend registers (Dependency Inversion).
char last_modified[k_ra8_mdl_http_date_max]
Last-Modified or empty.
int32_t status
Final HTTP status.
char retry_after[k_ra8_mdl_retry_after_max]
Retry-After or empty.
char content_type[k_ra8_mdl_content_type_max]
Content-Type or empty.
char etag[k_ra8_mdl_etag_max]
ETag or empty.
ra8_err_t(* update)(void *ctx, const uint8_t *data, uint16_t len)
Feed one ordered byte span to the running hash.
ra8_err_t(* init)(void *ctx)
Reset the caller-owned context for a SHA-256 operation.
void * ctx
Hash context passed to every function.
ra8_err_t(* final)(void *ctx, uint8_t out[k_ra8_mdl_sha256_bytes])
Finalise the hash into the caller-provided digest.
ra8_mdl_http_response_t response
Proven terminal HTTP metadata.
uint64_t bytes_stored
Bytes atomically committed.