53 const char* destination,
57 if ((link ==
nullptr) || (url ==
nullptr) || (destination ==
nullptr) || (config ==
nullptr) ||
58 (result ==
nullptr)) {
116 return (cancel_result !=
k_ra8_ok) ? cancel_result : abort_result;
139 uint64_t* bytes_stored)
141 if (*bytes_stored > (UINT64_MAX - chunk->
data_len)) {
144 uint16_t written = 0U;
155 *bytes_stored += written;
184 uint64_t bytes_stored,
185 uint32_t chunks_received,
196 if (
memcmp(digest, chunk->
sha256,
sizeof(digest)) != 0) {
208 .bytes_stored = bytes_stored,
209 .chunks_received = chunks_received,
222 uint64_t bytes_stored,
223 uint32_t chunks_received,
256 const char* destination,
279 .http = config->
http,
288 const char* destination,
297 uint64_t bytes_stored = 0U;
Annotation-attribute framework macros for ra8-firmware.
#define RA8_TEST_HELPER
Mark a symbol as externally-linked but only callable from tests.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
struct ra8_c6link ra8_c6link_t
ra8_err_t ra8_c6link_mdl_next(ra8_c6link_t *link, ra8_mdl_session_t *session, uint16_t max_bytes, ra8_mdl_chunk_t *chunk)
Pull the next bounded chunk while acknowledging the prior offset.
ra8_err_t ra8_c6link_mdl_cancel(ra8_c6link_t *link, ra8_mdl_session_t *session)
Cancel one active remote job and invalidate its local session.
ra8_err_t ra8_c6link_mdl_start_request(ra8_c6link_t *link, const ra8_mdl_request_t *request, ra8_mdl_session_t *session)
Start one typed request while preserving downloader HTTP policy.
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.
static ra8_err_t internal_mdl_transfer_begin(ra8_c6link_t *link, const char *url, const char *destination, const ra8_mdl_transfer_config_t *config, ra8_mdl_transfer_result_t *result, mdl_transfer_state_t *state)
Validate configuration, then start local storage and the remote job.
static ra8_err_t internal_mdl_transfer_abort(mdl_transfer_state_t *state, ra8_err_t cause)
Cancel the remote job when active and always abort local temporary state.
ra8_err_t ra8_c6link_mdl_transfer_commit_test(const ra8_mdl_transfer_config_t *config, const ra8_mdl_chunk_t *chunk, uint64_t bytes_stored, uint32_t chunks_received, ra8_mdl_transfer_result_t *result)
Run the terminal commit stage against a caller-supplied chunk.
static ra8_err_t internal_mdl_transfer_store(const ra8_mdl_transfer_config_t *config, const ra8_mdl_chunk_t *chunk, uint64_t *bytes_stored)
Persist and hash one non-terminal ordered chunk.
static ra8_err_t internal_mdl_transfer_commit(mdl_transfer_state_t *state, const ra8_mdl_chunk_t *chunk, uint64_t bytes_stored, uint32_t chunks_received, ra8_mdl_transfer_result_t *result)
Verify terminal metadata, validate identity, and commit the object.
static ra8_err_t internal_mdl_transfer_validate(const ra8_c6link_t *link, const char *url, const char *destination, const ra8_mdl_transfer_config_t *config, const ra8_mdl_transfer_result_t *result)
Validate every injected mechanism before creating temporary state.
Transactional RA8-side coordinator for C6 media byte streams.
struct ra8_mdl_transfer_config ra8_mdl_transfer_config_t
@ k_ra8_mdl_transfer_bytes_max
Maximum one-object byte budget.
struct ra8_mdl_transfer_result ra8_mdl_transfer_result_t
Private commit-stage seam for the transactional media coordinator.
@ k_ra8_err_checksum_mismatch
Stored / transmitted checksum does not match computed value.
@ 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_timeout
Operation exceeded its time budget.
@ k_ra8_err_cancelled
Operation cancelled before completion.
@ 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.
int memcmp(const void *a, const void *b, size_t n)
Compare bytes in two memory areas.
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_sha256_bytes
SHA-256 digest size in bytes.
@ k_ra8_mdl_state_cancelled
Job ended through explicit cancellation.
@ k_ra8_mdl_state_complete
Response carries terminal size and digest.
@ k_ra8_mdl_state_downloading
Response carries non-empty ordered bytes.
State that must be unwound together after storage begins.
ra8_c6link_t * link
Active media RPC link.
ra8_mdl_session_t session
Correlated remote session.
const ra8_mdl_transfer_config_t * config
Injected storage/hash seams.
bool storage_active
Whether local temporary storage needs abort.
One correlated bounded raw-byte response.
ra8_mdl_http_response_t response
Terminal HTTP metadata.
uint8_t data[k_ra8_mdl_chunk_data_max]
Bounded raw body bytes.
uint16_t data_len
Valid bytes in data.
uint64_t total_bytes
Advertised or independently counted total.
uint8_t sha256[k_ra8_mdl_sha256_bytes]
Complete-body SHA-256.
ra8_mdl_state_t state
DOWNLOADING or terminal state.
bool has_sha256
Whether sha256 is valid.
Complete typed HTTPS request accepted by protocol version 3.
RA8-local state for one accepted remote artifact job.
bool active
Whether next/cancel is currently valid.
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_err_t(* write)(void *ctx, const uint8_t *data, uint16_t len, uint16_t *written)
Append len bytes and report the exact number persisted.
ra8_err_t(* commit)(void *ctx)
Atomically publish the complete temporary object.
void * ctx
Backend context passed to every function.
ra8_err_t(* begin)(void *ctx, const char *destination)
Create private temporary state for destination.
ra8_err_t(* validate)(void *ctx, uint64_t total_bytes, const uint8_t sha256[k_ra8_mdl_sha256_bytes])
Validate artifact identity and structure before publication.
ra8_err_t(* abort)(void *ctx)
Destroy temporary state; valid after every successful begin.
ra8_mdl_sha256_iface_t sha256
Independent running digest.
void * cancel_ctx
Context for cancel_requested.
mdl_format_t format
Requested and validated artifact.
ra8_mdl_cancel_requested_fn cancel_requested
Optional cooperative cancel query.
ra8_mdl_http_policy_t http
Forwarded downloader request policy.
uint16_t chunk_bytes
Maximum bytes requested per pull.
uint32_t max_chunks
Absolute number of permitted pulls.
ra8_mdl_storage_iface_t storage
Transactional RA8-local destination.
uint8_t sha256[k_ra8_mdl_sha256_bytes]
Independently verified digest.