wired
libc-free QUIC/HTTP3 SDK in C for x86_64-linux
Loading...
Searching...
No Matches
wtwire.h File Reference

WebTransport wire-format helpers (pure functions, no state). More...

Go to the source code of this file.

Functions

usz wired_wtwire_signal_put (u8 *buf, usz cap, int bidi, u64 session_id)
 Write the uni (bidi=0) / bidi (bidi=1) stream signal prefix into buf.
usz wtwire_qsid_put (u8 *buf, usz cap, u64 session_id)
 Write the datagram quarter-stream-ID prefix varint(session_id / 4).
usz wired_wtwire_qsid_take (wired_span dg, u64 *session_id)
 Read the quarter-stream-ID varint at the head of a datagram.
int wired_wtwire_get_parse (wired_span line, wired_span *file)
 Parse a "GET <filename>" line.
usz wired_wtwire_get_put (u8 *buf, usz cap, wired_span filename)
 Write "GET <filename>" (no trailing newline) into buf.
int wired_wtwire_push_parse (wired_span msg, wired_span *name, wired_span *content)
 Parse a "PUSH <name>\n<content>" message.
usz wired_wtwire_push_head_put (u8 *buf, usz cap, wired_span basename)
 Write the push header "PUSH <basename>\n" into buf.
wired_span wired_wtwire_basename (wired_span path)
 View of the path component after the last '/'; the whole path if it has no '/'.

Detailed Description

WebTransport wire-format helpers (pure functions, no state).

Covers three small wire shapes used against the webtransport-go reference implementation in the quic-interop-runner:

  • Stream signal prefix: a WebTransport stream opens with varint(0x54) (unidirectional) or varint(0x41) (bidirectional) followed by varint(session_id), where session_id is the QUIC stream ID of the Extended CONNECT stream itself (always a multiple of 4, not divided).
  • HTTP Datagram prefix (RFC 9297 SS2.1): varint(session_id / 4), the quarter stream ID.
  • The interop-runner line protocol: "GET <filename>" requests and "PUSH <name>\n<content>" pushes.

Function Documentation

◆ wired_wtwire_basename()

wired_span wired_wtwire_basename ( wired_span path)

View of the path component after the last '/'; the whole path if it has no '/'.

A path ending in '/' yields an empty span.

Parameters
paththe input path
Returns
the basename view (borrows path's bytes)

◆ wired_wtwire_get_parse()

int wired_wtwire_get_parse ( wired_span line,
wired_span * file )

Parse a "GET <filename>" line.

The filename is trimmed of surrounding spaces, tabs, and line endings; an empty trimmed name is an error.

Parameters
linethe request line (trailing newline optional)
fileset to a view of the trimmed filename on success
Returns
1 on success, 0 on failure

◆ wired_wtwire_get_put()

usz wired_wtwire_get_put ( u8 * buf,
usz cap,
wired_span filename )

Write "GET <filename>" (no trailing newline) into buf.

Parameters
bufdestination
capcapacity of buf
filenamethe requested file name
Returns
bytes written, or 0 if it does not fit

◆ wired_wtwire_push_head_put()

usz wired_wtwire_push_head_put ( u8 * buf,
usz cap,
wired_span basename )

Write the push header "PUSH <basename>\n" into buf.

Parameters
bufdestination
capcapacity of buf
basenamethe pushed file's base name
Returns
bytes written, or 0 if it does not fit

◆ wired_wtwire_push_parse()

int wired_wtwire_push_parse ( wired_span msg,
wired_span * name,
wired_span * content )

Parse a "PUSH <name>\n<content>" message.

The split is at the first newline; the name is trimmed, and an empty trimmed name or a missing newline is an error. content may be empty.

Parameters
msgthe full push message
nameset to a view of the trimmed name on success
contentset to a view of the bytes after the newline on success
Returns
1 on success, 0 on failure

◆ wired_wtwire_qsid_take()

usz wired_wtwire_qsid_take ( wired_span dg,
u64 * session_id )

Read the quarter-stream-ID varint at the head of a datagram.

RFC 9297 SS2.1: a Quarter Stream ID above 2^60-1 does not map to any legal QUIC stream ID (session_id = qsid * 4 would exceed the 2^62-1 stream ID space) and is a decode failure, same as a truncated varint.

Parameters
dgthe datagram payload
session_idset to quarter stream ID * 4 on success
Returns
bytes consumed, or 0 if the varint is truncated/missing/too large

◆ wired_wtwire_signal_put()

usz wired_wtwire_signal_put ( u8 * buf,
usz cap,
int bidi,
u64 session_id )

Write the uni (bidi=0) / bidi (bidi=1) stream signal prefix into buf.

Parameters
bufdestination
capcapacity of buf
bidinonzero for a bidirectional stream (0x41), else 0x54
session_idQUIC stream ID of the Extended CONNECT stream
Returns
bytes written, or 0 if it does not fit

◆ wtwire_qsid_put()

usz wtwire_qsid_put ( u8 * buf,
usz cap,
u64 session_id )

Write the datagram quarter-stream-ID prefix varint(session_id / 4).

Parameters
bufdestination
capcapacity of buf
session_idQUIC stream ID of the Extended CONNECT stream
Returns
bytes written, or 0 if it does not fit