|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Portable single-transaction response-body sink implementation. More...
#include <stdio.h>#include <string.h>#include "mdl_fetch_body_internal.h"#include "mdl_urlname.h"Go to the source code of this file.
Functions | |
| static bool | internal_body_paths (mdl_fetch_body_t *body, const char *extension) |
| Replace both requested suffixes with one verified image suffix. | |
| static ra8_err_t | internal_body_begin (mdl_fetch_body_t *body) |
| Begin the exact or classified destination transaction once. | |
| static ra8_err_t | internal_body_flush_prefix (mdl_fetch_body_t *body) |
| Flush retained signature bytes into a newly active stage. | |
| static ra8_err_t | internal_body_reset (void *context) |
| Abort a prior retry attempt without beginning a new one. | |
| static uint32_t | internal_body_buffer_prefix (mdl_fetch_body_t *body, const uint8_t *bytes, uint32_t length) |
| Retain the bounded image prefix and return consumed source bytes. | |
| static ra8_err_t | internal_body_write (void *context, const uint8_t *bytes, uint32_t length, uint32_t *out_written) |
| Consume one exact or magic-typed network body chunk. | |
| 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 implementation.
Streams network body fragments into one injected transaction and validates complete content before publication.
Definition in file mdl_fetch_body.c.
|
static |
Begin the exact or classified destination transaction once.
Copies an exact destination or classifies buffered image magic, then delegates truthful create/replace policy to storage.
| [in,out] | body | Initialized response body. |
| k_ra8_ok | A transaction was already active or is now active. |
| k_ra8_err_validation_failed | Buffered image magic is unsupported. |
body is non-NULL and owns an initialized storage binding. Definition at line 68 of file mdl_fetch_body.c.
References fw_fs_transaction_t::active, mdl_fetch_body_t::actual_abs, internal_body_paths(), k_mdl_fetch_body_exact, k_ra8_err_invalid_size, k_ra8_err_validation_failed, k_ra8_ok, mdl_storage_txn_begin(), mdl_urlname_sniff_image_type(), mdl_fetch_body_t::mode, mdl_fetch_body_t::prefix, mdl_fetch_body_t::prefix_bytes, RA8_INTERNAL, mdl_fetch_body_t::storage, mdl_fetch_body_t::target_abs, mdl_storage_txn_t::transaction, and mdl_fetch_body_t::writer.
Referenced by internal_body_flush_prefix(), and internal_body_write().
|
static |
Retain the bounded image prefix and return consumed source bytes.
Copies only the remaining portion of the fixed magic-prefix buffer.
| [in,out] | body | Initialized image body. |
| [in] | bytes | Readable network bytes. |
| [in] | length | Available source extent. |
| 0 | The prefix was already full or the source was empty. |
body and bytes are non-NULL for nonempty input. Definition at line 169 of file mdl_fetch_body.c.
References k_mdl_fetch_magic_bytes, memcpy(), mdl_fetch_body_t::prefix, and mdl_fetch_body_t::prefix_bytes.
Referenced by internal_body_write().
|
static |
Flush retained signature bytes into a newly active stage.
Begins the selected transaction and writes the deferred prefix once.
| [in,out] | body | Initialized response body with a bounded prefix. |
| k_ra8_ok | The prefix is empty and its transaction is active. |
| other | The underlying classification or transaction operation failed. |
body is non-NULL and owns initialized storage. Definition at line 110 of file mdl_fetch_body.c.
References internal_body_begin(), k_ra8_ok, mdl_storage_txn_write(), mdl_fetch_body_t::prefix, mdl_fetch_body_t::prefix_bytes, RA8_INTERNAL, and mdl_fetch_body_t::writer.
Referenced by internal_body_write(), and priv_mdl_fetch_body_prepare().
|
static |
Replace both requested suffixes with one verified image suffix.
Formats absolute and relative destinations from their last suffix.
| [in,out] | body | Initialized magic-typed response body. |
| [in] | extension | Verified suffix without a leading dot. |
| true | Both paths were written completely. |
| false | A suffix was absent or one result exceeded capacity. |
body and extension are non-NULL. Definition at line 30 of file mdl_fetch_body.c.
References mdl_fetch_body_t::actual_abs, mdl_fetch_body_t::actual_rel, RA8_INTERNAL, strrchr(), mdl_fetch_body_t::target_abs, and mdl_fetch_body_t::target_rel.
Referenced by internal_body_begin().
|
static |
Abort a prior retry attempt without beginning a new one.
Implements the network reset callback over caller-owned body state.
| [in,out] | context | Borrowed mdl_fetch_body_t context. |
| k_ra8_ok | No private stage or accepted response byte remains. |
| k_ra8_err_invalid_arg | The context is NULL. |
Definition at line 136 of file mdl_fetch_body.c.
References mdl_fetch_body_t::actual_abs, mdl_fetch_body_t::actual_rel, k_ra8_err_invalid_arg, k_ra8_ok, mdl_storage_txn_abort(), mdl_fetch_body_t::prefix_bytes, RA8_INTERNAL, mdl_fetch_body_t::received, and mdl_fetch_body_t::writer.
Referenced by priv_mdl_fetch_body_sink().
|
static |
Consume one exact or magic-typed network body chunk.
Defers a bounded magic prefix, begins one destination transaction, and appends every accepted byte through the running identity writer.
| [in,out] | context | Borrowed mdl_fetch_body_t context. |
| [in] | bytes | Readable source bytes or NULL for an empty chunk. |
| [in] | length | Source extent. |
| [out] | out_written | Exact accepted extent on success. |
| k_ra8_ok | The complete chunk was accepted. |
| k_ra8_err_invalid_arg | A required pointer contract is invalid. |
bytes covers length bytes whenever length is nonzero. length. Definition at line 197 of file mdl_fetch_body.c.
References fw_fs_transaction_t::active, internal_body_begin(), internal_body_buffer_prefix(), internal_body_flush_prefix(), k_mdl_fetch_body_image, k_mdl_fetch_magic_bytes, k_ra8_err_invalid_arg, k_ra8_ok, mdl_storage_txn_write(), mdl_fetch_body_t::mode, mdl_fetch_body_t::prefix_bytes, mdl_fetch_body_t::received, mdl_storage_txn_t::transaction, and mdl_fetch_body_t::writer.
Referenced by priv_mdl_fetch_body_sink().
| 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().