Simplify frame header to message_type + payload_length (6 bytes)

Removes channel_id from the header. All message-specific identifiers
(stream_id, request_id, etc.) now live at the start of the payload,
interpreted by each message type handler. A relay seeing an unknown
type can skip or forward it using only payload_length, with no
knowledge of the payload structure.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-26 22:00:43 +00:00
parent ff48559b12
commit 197ab7d5db
4 changed files with 30 additions and 27 deletions

View File

@@ -3,7 +3,7 @@
#include <stdint.h>
#include "error.h"
#define TRANSPORT_FRAME_HEADER_SIZE 8u
#define TRANSPORT_FRAME_HEADER_SIZE 6u
#define TRANSPORT_DEFAULT_MAX_PAYLOAD (16u * 1024u * 1024u)
struct Transport_Conn;
@@ -13,10 +13,13 @@ struct Transport_Server;
* A received frame. payload is malloc'd by the transport layer;
* the on_frame callback takes ownership and must free it.
* payload is NULL when payload_length is 0.
*
* The header carries only message_type and payload_length.
* All message-specific fields (stream_id, request_id, etc.) are
* the first bytes of the payload, interpreted by the message handler.
*/
struct Transport_Frame {
uint16_t message_type;
uint16_t channel_id;
uint32_t payload_length;
uint8_t *payload;
};
@@ -77,7 +80,6 @@ struct App_Error transport_connect(struct Transport_Conn **out,
*/
struct App_Error transport_send_frame(struct Transport_Conn *conn,
uint16_t message_type,
uint16_t channel_id,
const uint8_t *payload,
uint32_t length);