28typedef enum : uint16_t {
100 if (state->
http !=
nullptr) {
104 state->
url[0] =
'\0';
138 if (lhs ==
nullptr) {
142 while ((lhs[index] !=
'\0') && (rhs[index] !=
'\0')) {
143 unsigned char left = (
unsigned char)lhs[index];
144 unsigned char right = (
unsigned char)rhs[index];
145 if ((left >= (
unsigned char)
'A') && (left <= (
unsigned char)
'Z')) {
146 left = (
unsigned char)(left + ((
unsigned char)
'a' - (
unsigned char)
'A'));
148 if ((right >= (
unsigned char)
'A') && (right <= (
unsigned char)
'Z')) {
149 right = (
unsigned char)(right + ((
unsigned char)
'a' - (
unsigned char)
'A'));
156 return (lhs[index] ==
'\0') && (rhs[index] ==
'\0');
180 destination[0] =
'\0';
181 if ((source ==
nullptr) || (source[0] ==
'\0')) {
184 const size_t length =
strnlen(source, capacity);
185 if (length >= capacity) {
188 for (
size_t i = 0U; i < length; ++i) {
189 if ((source[i] ==
'\r') || (source[i] ==
'\n')) {
193 memcpy(destination, source, length + 1U);
217 *destination =
nullptr;
253 if ((event ==
nullptr) || (event->
user_data ==
nullptr)) {
263 if (destination ==
nullptr) {
293 .url =
"https://127.0.0.1/",
297 .disable_auto_redirect =
true,
303 if (state->
http ==
nullptr) {
331 if (value[0] ==
'\0') {
380 const uint32_t timeout =
421 const size_t https_prefix_len =
sizeof(
"https://") - 1U;
425 if (
strncmp(request->
url,
"https://", https_prefix_len) != 0) {
428 if (request->
url[https_prefix_len] ==
'\0') {
442 if (url_status !=
ESP_OK) {
480 if (open_status !=
ESP_OK) {
492 state->
total = (content_length >= 0) ? (uint64_t)content_length : 0U;
519 uint64_t* total_bytes,
541 *total_bytes = state->
total;
574 uint64_t* total_bytes)
576 if (state->
received > (UINT64_MAX - (uint64_t)read)) {
580 const uint64_t next_received = state->
received + (uint64_t)read;
582 if (next_received > state->
total) {
592 *got = (uint16_t)read;
593 *total_bytes = state->
total;
624 uint64_t* total_bytes,
644 if ((uint32_t)read > (uint32_t)cap) {
760 const uint8_t* request,
764 size_t* response_len)
766 if (response_len ==
nullptr) {
@ ESP_ERR_TIMEOUT
The operation did not finish in time.
@ ESP_ERR_INVALID_SIZE
A length or buffer size was rejected.
@ ESP_ERR_INVALID_CRC
A checksum did not verify.
@ ESP_ERR_INVALID_STATE
Legal call, wrong moment to make it.
@ ESP_ERR_INVALID_RESPONSE
Reply was malformed or unexpected.
@ ESP_ERR_NO_MEM
Allocation failed.
@ ESP_ERR_NOT_SUPPORTED
The co-processor image lacks this.
@ ESP_ERR_NOT_FOUND
The requested item does not exist.
@ ESP_FAIL
Generic failure with no more specific code available.
@ ESP_ERR_INVALID_ARG
A parameter was out of range or null.
int esp_err_t
Result of an esp-hosted call: zero on success, non-zero otherwise.
ESP-IDF media-service declarations for target builds and AST audits.
#define mbedtls_sha256_update
Map the parser SHA-256 update operation to its private stand-in.
#define esp_http_client_read
Map the parser body reader to its module-private stand-in.
#define esp_http_client_open
Map the parser HTTP open operation to its private stand-in.
#define mbedtls_sha256_starts
Map the parser SHA-256 start operation to its private stand-in.
#define esp_http_client_fetch_headers
Map the parser header fetch to its module-private stand-in.
#define esp_http_client_close
Map the parser HTTP close operation to its private stand-in.
struct esp_http_client * esp_http_client_handle_t
Opaque host-parser stand-in for an ESP-IDF HTTP client.
#define esp_crt_bundle_attach
Map the parser bundle callback to its module-private stand-in.
#define esp_http_client_init
Map the parser HTTP constructor to its module-private stand-in.
@ HTTP_EVENT_ON_HEADER
One response header is available.
#define esp_http_client_delete_header
Map the parser request-header remover to its private stand-in.
#define mbedtls_sha256_init
Map the parser SHA-256 initializer to its private stand-in.
#define esp_http_client_set_timeout_ms
Map the parser timeout setter to its private stand-in.
#define esp_http_client_set_url
Map the parser URL setter to its module-private stand-in.
#define esp_http_client_set_header
Map the parser request-header setter to its private stand-in.
#define mbedtls_sha256_finish
Map the parser SHA-256 finalizer to its private stand-in.
#define esp_http_client_get_status_code
Map the parser status accessor to its module-private stand-in.
#define esp_http_client_is_complete_data_received
Map the parser completion query to its module-private stand-in.
static esp_err_t internal_mdl_to_esp_status(ra8_err_t result)
Translate a portable media-service result into ESP-IDF's error domain.
esp_err_t esp_hosted_custom_rpc_sync_handler(uint32_t message_id, const uint8_t *request, size_t request_len, uint8_t *response, size_t response_cap, size_t *response_len)
Strong implementation consumed by the pinned ESP-hosted patch.
struct mdl_http_state mdl_http_state_t
static void internal_mdl_select_response_header(mdl_http_state_t *state, const char *key, char **destination, size_t *capacity)
Select retained storage for one response header.
static ra8_err_t internal_mdl_http_init(mdl_http_state_t *state)
Create the retained ESP-IDF client and SHA context once.
static esp_err_t internal_mdl_http_event(esp_http_client_event_t *event)
Capture selected response headers from ESP-IDF events.
static ra8_err_t internal_mdl_http_finish(mdl_http_state_t *state, uint64_t *total_bytes, bool *complete, uint8_t sha256[k_ra8_mdl_sha256_bytes], ra8_mdl_http_response_t *response)
Validate EOF and publish the terminal length and digest.
static ra8_err_t internal_mdl_http_cancel(void *ctx)
Cancel the active HTTP job while retaining one-time objects.
static ra8_err_t internal_mdl_http_apply_request(mdl_http_state_t *state, const ra8_mdl_request_t *request)
Copy and apply the complete bounded request policy.
static ra8_err_t internal_mdl_http_read(void *ctx, uint8_t *out, uint16_t cap, uint16_t *got, uint64_t *total_bytes, bool *complete, uint8_t sha256[k_ra8_mdl_sha256_bytes], ra8_mdl_http_response_t *response)
Pull one bounded body span or verified terminal metadata.
static bool internal_mdl_header_equal(const char *lhs, const char *rhs)
Compare one HTTP header name without ASCII case sensitivity.
static ra8_err_t internal_mdl_copy_field(char *destination, size_t capacity, const char *source)
Copy one optional bounded HTTP field into retained storage.
static void internal_mdl_http_reset_job(mdl_http_state_t *state)
Close one request while retaining the one-time client/hash objects.
static bool s_initialised
static mdl_http_state_t s_http
static ra8_err_t internal_mdl_http_set_header(mdl_http_state_t *state, const char *name, const char *value)
Replace one optional retained request header.
static ra8_err_t internal_mdl_http_open(mdl_http_state_t *state)
Open lazily so Start returns without waiting for network exchange.
static ra8_err_t internal_mdl_http_account_read(mdl_http_state_t *state, const uint8_t *out, int read, uint16_t *got, uint64_t *total_bytes)
Account one successful nonzero body read into job state.
static mdl_component_abi_fn_t volatile s_component_abi
uint32_t ra8_mdl_service_component_abi(void)
Return the linked first-party media component ABI version.
static ra8_err_t internal_mdl_http_begin(void *ctx, const ra8_mdl_request_t *request)
Validate and prepare one typed HTTPS-artifact job.
static ra8_mdl_service_t s_service
mdl_http_const_t
Fixed HTTP policy values for the concrete ESP-IDF adapter.
@ k_mdl_http_status_min
Lowest valid terminal status.
@ k_mdl_http_status_max
Highest valid terminal status.
@ k_mdl_http_timeout_ms
Default whole-request timeout.
uint32_t(* mdl_component_abi_fn_t)(void)
Return the first-party media component ABI marker.
Annotation-attribute framework macros for ra8-firmware.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
Media service dispatch contract for the ESP32-C6 integration.
struct ra8_mdl_service ra8_mdl_service_t
ra8_err_t ra8_mdl_service_dispatch(void *ctx, uint32_t operation, const uint8_t *request, size_t request_len, uint8_t *response, size_t response_cap, size_t *response_len)
Dispatch Start, Next, or Cancel generated protobuf payloads.
ra8_err_t ra8_mdl_service_init(ra8_mdl_service_t *service, const ra8_mdl_service_backend_t *backend)
Initialise portable service state with a complete backend seam.
struct ra8_mdl_service_backend ra8_mdl_service_backend_t
@ k_ra8_err_no_mem
Static buffer exhausted (no dynamic memory on this project).
@ k_ra8_err_busy
Resource busy – blocking operation cannot proceed.
@ k_ra8_err_checksum_mismatch
Stored / transmitted checksum does not match computed value.
@ k_ra8_fail
Generic unspecified failure.
@ k_ra8_err_invalid_arg
Invalid function argument.
@ k_ra8_err_invalid_state
Module in wrong state for requested operation.
@ k_ra8_err_validation_failed
Validation rule failed (caller-supplied invariant not satisfied).
@ 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_protocol_error
Protocol-level error (e.g.
@ k_ra8_err_timeout
Operation exceeded its time budget.
@ k_ra8_err_not_found
Requested item not found (lookup / search missed).
@ 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 strncmp(const char *s1, const char *s2, size_t n)
Compare two strings up to a specified length.
void * memcpy(void *dst, const void *src, size_t n)
Copy memory area between non-overlapping regions.
size_t strnlen(const char *s, size_t maxlen)
Calculate bounded string length.
@ k_ra8_mdl_user_agent_max
Maximum User-Agent size, including NUL.
@ k_ra8_mdl_referer_max
Maximum Referer size, including NUL.
@ k_ra8_mdl_chunk_data_max
Maximum raw body bytes in one chunk.
@ k_ra8_mdl_url_max
Maximum URL buffer size, including NUL.
@ 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_sha256_bytes
SHA-256 digest size in bytes.
@ k_ra8_mdl_rpc_start
Start one typed-artifact job.
@ k_ra8_mdl_rpc_cancel
Cancel one active job.
@ k_ra8_mdl_rpc_next
Pull one ordered bounded chunk.
Public integration contract for the ESP32-C6 media RPC component.
uint32_t ra8_mdl_service_component_abi(void)
Return the linked first-party media component ABI version.
Exact consumed subset of ESP-IDF's HTTP client configuration.
Parser mirror of the ESP-IDF HTTP event record.
void * user_data
Configuration context.
char * header_value
Header value for ON_HEADER.
esp_http_client_event_id_t event_id
Event selector.
char * header_key
Header name for ON_HEADER.
Parser-only storage standing in for ESP-IDF's SHA-256 context.
Single retained ESP-IDF client and one serialized remote transfer.
uint64_t total
Advertised body length, or zero.
esp_http_client_handle_t http
Retained ESP HTTP client handle.
uint64_t received
Independently counted body bytes.
char if_none_match[k_ra8_mdl_etag_max]
Active If-None-Match request value.
bool total_known
Whether Content-Length was present.
char if_modified_since[k_ra8_mdl_http_date_max]
Active If-Modified-Since request value.
char url[k_ra8_mdl_url_max]
Bounded active HTTPS URL.
mdl_format_t format
Requested artifact identity.
char referer[k_ra8_mdl_referer_max]
Active Referer request value.
bool hashing
Whether a SHA operation is active.
mbedtls_sha256_context sha
Retained streaming SHA context.
ra8_mdl_http_response_t response
Selected terminal response metadata.
bool opened
Whether response headers were accepted.
char user_agent[k_ra8_mdl_user_agent_max]
Active User-Agent request value.
ra8_err_t header_error
First response-header capture failure.
uint32_t timeout_ms
Whole-request timeout, or zero for default.
const char * if_modified_since
If-Modified-Since value, or null/empty.
const char * if_none_match
If-None-Match value, or null/empty to omit.
const char * user_agent
User-Agent value, or null/empty to omit.
const char * referer
Referer value, or null/empty to omit.
HTTP status and selected response headers proven by the C6 backend.
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.
Complete typed HTTPS request accepted by protocol version 3.
mdl_format_t format
Exact returned artifact identity.
ra8_mdl_http_policy_t http
Forwarded request policy.
const char * url
Absolute HTTPS source URL.