|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Portable single-transaction response-body sink for media fetches. More...
#include <limits.h>#include <stddef.h>#include <stdint.h>#include "mdl_net.h"#include "mdl_state.h"#include "mdl_storage.h"#include "ra8_attributes.h"#include "ra8_err.h"Go to the source code of this file.
Data Structures | |
| struct | mdl_fetch_body_t |
| Caller-owned state for one retryable streamed fetch. More... | |
Enumerations | |
| enum | mdl_fetch_body_limit_t : uint8_t { k_mdl_fetch_magic_bytes = 16U } |
| Bounded signature extent retained before image publication begins. More... | |
| enum | mdl_fetch_body_mode_t : uint8_t { k_mdl_fetch_body_exact = 0U , k_mdl_fetch_body_image = 1U } |
| Destination policy for one response body. More... | |
Functions | |
| ra8_err_t | priv_mdl_fetch_body_init_exact (mdl_fetch_body_t *body, mdl_storage_t *storage, const char *target_abs) |
| Initialize an exact-path transactional body sink. | |
| ra8_err_t | priv_mdl_fetch_body_init_image (mdl_fetch_body_t *body, mdl_storage_t *storage, const char *target_abs, const char *target_rel) |
| Initialize a magic-typed image body sink. | |
| mdl_net_body_sink_t | priv_mdl_fetch_body_sink (mdl_fetch_body_t *body) |
| Return the network sink view of one body state. | |
| ra8_err_t | priv_mdl_fetch_body_prepare (mdl_fetch_body_t *body) |
| Finish prefix classification and make a nonempty stage commit-ready. | |
| ra8_err_t | priv_mdl_fetch_body_commit (mdl_fetch_body_t *body) |
| Validate exact size/hash and publish one prepared body. | |
| ra8_err_t | priv_mdl_fetch_body_abort (mdl_fetch_body_t *body) |
| Abort any private stage owned by a body sink. | |
Portable single-transaction response-body sink for media fetches.
Declares the caller-owned state and lifecycle used to stage, verify, commit, or abort one bounded response body.
Definition in file mdl_fetch_body_internal.h.
| enum mdl_fetch_body_limit_t : uint8_t |
Bounded signature extent retained before image publication begins.
| Enumerator | |
|---|---|
| k_mdl_fetch_magic_bytes | Largest supported image signature prefix. |
Definition at line 22 of file mdl_fetch_body_internal.h.
| enum mdl_fetch_body_mode_t : uint8_t |
Destination policy for one response body.
| Enumerator | |
|---|---|
| k_mdl_fetch_body_exact | Publish under the supplied exact path. |
| k_mdl_fetch_body_image | Derive the suffix from image magic. |
Definition at line 27 of file mdl_fetch_body_internal.h.
| ra8_err_t priv_mdl_fetch_body_abort | ( | mdl_fetch_body_t * | body | ) |
Abort any private stage owned by a body sink.
Delegates stage cleanup and clears accepted bytes on success.
| [in,out] | body | Initialized body state. |
| k_ra8_ok | No private stage remains. |
| k_ra8_err_invalid_arg | The body pointer is NULL. |
body is non-NULL and exclusively owned. Definition at line 292 of file mdl_fetch_body.c.
References k_ra8_err_invalid_arg, k_ra8_ok, mdl_storage_txn_abort(), mdl_fetch_body_t::prefix_bytes, mdl_fetch_body_t::received, and mdl_fetch_body_t::writer.
Referenced by internal_cover_finish(), internal_cover_publish_cached(), internal_cover_stream(), internal_download_page_image(), internal_fetch_asset_execute(), internal_mdl_fetch_prepare_page(), internal_mdl_fetch_publish_page(), internal_mdl_fetch_resolve_not_modified(), and internal_publish_page_image().
| ra8_err_t priv_mdl_fetch_body_commit | ( | mdl_fetch_body_t * | body | ) |
Validate exact size/hash and publish one prepared body.
Independently rereads the private stage before one durable commit.
| [in,out] | body | Prepared body transaction. |
| k_ra8_ok | The independently verified body was published. |
| other | Validation, publication, or cleanup failed. |
Definition at line 284 of file mdl_fetch_body.c.
References fw_fs_transaction_t::active, k_ra8_err_invalid_arg, mdl_storage_txn_commit(), mdl_storage_txn_t::transaction, and mdl_fetch_body_t::writer.
Referenced by internal_cover_finish(), internal_fetch_asset_execute(), internal_mdl_fetch_publish_page(), and internal_publish_page_image().
| ra8_err_t priv_mdl_fetch_body_init_exact | ( | mdl_fetch_body_t * | body, |
| mdl_storage_t * | storage, | ||
| const char * | target_abs ) |
Initialize an exact-path transactional body sink.
Binds the caller's storage and destination without filesystem I/O.
| [out] | body | Caller-owned sink state. |
| [in,out] | storage | Initialized exclusive storage binding. |
| [in] | target_abs | Canonical exact destination. |
| k_ra8_ok | The body is ready to bind to the network seam. |
| k_ra8_err_invalid_arg | A required pointer/path is invalid. |
body is inactive and writable. target_abs remains valid through the synchronous fetch. Definition at line 233 of file mdl_fetch_body.c.
References k_mdl_fetch_body_exact, k_ra8_err_invalid_arg, and k_ra8_ok.
Referenced by internal_fetch_asset_execute().
| ra8_err_t priv_mdl_fetch_body_init_image | ( | mdl_fetch_body_t * | body, |
| mdl_storage_t * | storage, | ||
| const char * | target_abs, | ||
| const char * | target_rel ) |
Initialize a magic-typed image body sink.
Binds requested paths while deferring suffix selection to body magic.
| [out] | body | Caller-owned sink state. |
| [in,out] | storage | Initialized exclusive storage binding. |
| [in] | target_abs | URL-derived absolute destination. |
| [in] | target_rel | URL-derived relative destination. |
| k_ra8_ok | The body is ready with no transaction created. |
| k_ra8_err_invalid_arg | A required pointer/path is invalid. |
Definition at line 248 of file mdl_fetch_body.c.
References k_mdl_fetch_body_image, k_ra8_err_invalid_arg, and k_ra8_ok.
Referenced by internal_cover_publish_cached(), internal_cover_stream(), internal_download_page_image(), and internal_mdl_fetch_prepare_page().
| ra8_err_t priv_mdl_fetch_body_prepare | ( | mdl_fetch_body_t * | body | ) |
Finish prefix classification and make a nonempty stage commit-ready.
Flushes a short retained signature after a successful response.
| [in,out] | body | Completed successful non-304 response body. |
| k_ra8_ok | The actual paths and complete private stage are ready. |
| k_ra8_err_invalid_size | The body was empty. |
| k_ra8_err_validation_failed | Image magic was unsupported. |
| other | Path or transaction failure propagated. |
body is initialized and exclusively owned. Definition at line 270 of file mdl_fetch_body.c.
References fw_fs_transaction_t::active, internal_body_flush_prefix(), k_ra8_err_invalid_arg, k_ra8_err_invalid_size, k_ra8_ok, mdl_fetch_body_t::received, mdl_fetch_body_t::storage, mdl_storage_txn_t::transaction, and mdl_fetch_body_t::writer.
Referenced by internal_cover_finish(), internal_fetch_asset_execute(), internal_mdl_fetch_publish_page(), and internal_publish_page_image().
| mdl_net_body_sink_t priv_mdl_fetch_body_sink | ( | mdl_fetch_body_t * | body | ) |
Return the network sink view of one body state.
Exposes reset/write callbacks borrowing the supplied body context.
| [in,out] | body | Initialized body state. |
body. | mdl_net_body_sink_t | A complete synchronous callback view. |
body remains live until the network call returns. body is initialized and exclusively owned. body. Definition at line 264 of file mdl_fetch_body.c.
References internal_body_reset(), and internal_body_write().
Referenced by internal_cover_publish_cached(), internal_cover_stream(), internal_download_page_image(), internal_fetch_asset_execute(), internal_mdl_fetch_prepare_page(), and internal_mdl_fetch_resolve_not_modified().