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:
@@ -61,8 +61,7 @@ static void *conn_read_thread_fn(void *arg) {
|
||||
|
||||
struct Transport_Frame frame;
|
||||
frame.message_type = get_u16(header_buf, 0);
|
||||
frame.channel_id = get_u16(header_buf, 2);
|
||||
frame.payload_length = get_u32(header_buf, 4);
|
||||
frame.payload_length = get_u32(header_buf, 2);
|
||||
|
||||
if (frame.payload_length > conn->max_payload) {
|
||||
break;
|
||||
@@ -287,13 +286,12 @@ 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,
|
||||
uint16_t message_type,
|
||||
const uint8_t *payload, uint32_t length)
|
||||
{
|
||||
uint8_t header[TRANSPORT_FRAME_HEADER_SIZE];
|
||||
put_u16(header, 0, message_type);
|
||||
put_u16(header, 2, channel_id);
|
||||
put_u32(header, 4, length);
|
||||
put_u32(header, 2, length);
|
||||
|
||||
pthread_mutex_lock(&conn->write_mutex);
|
||||
int ok = write_exact(conn->fd, header, TRANSPORT_FRAME_HEADER_SIZE);
|
||||
|
||||
Reference in New Issue
Block a user