Skip to main content

Crate gbp_stack

Crate gbp_stack 

Source
Expand description

C ABI surface for the Group Protocol Stack.

Designed for consumption from .NET (or any FFI-capable runtime) via P/Invoke. The C ABI is grouped into the following families:

  • GBP (gbp_node_*) — the IP-like base layer: framing, AEAD, replay window, control plane.
  • GTP (gtp_client_*) — text sub-protocol.
  • GAP (gap_client_*) — audio sub-protocol.
  • GSP (gsp_client_*) — signalling sub-protocol.
  • MLS (gbp_mls_*) — RFC 9420 context.

Conventions:

  • Handle-based — every long-lived object lives in a Rust-side registry keyed by an i32 handle.
  • GbpBuffer — binary blobs are returned as (ptr, len, cap) triples and MUST be released with gbp_buffer_free.
  • Owned C-string — text values are returned as owned *mut c_char and MUST be released with gbp_string_free.
  • Last error — every fallible call writes to a thread-local error slot that callers can read via gbp_last_error.

Structs§

GbpBuffer
Binary buffer produced by Rust. The caller MUST release it via gbp_buffer_free.

Functions§

gap_client_accept
Accepts a GAP audio payload.
gap_client_create
Creates a stateful GAP client.
gap_client_destroy
Destroys a GAP client.
gap_client_reset
Clears the client state. Intended for use after an epoch change.
gap_client_send
Sends an Opus audio frame via GAP.
gbp_buffer_free
Releases a GbpBuffer.
gbp_error_lookup
Returns a CBOR-encoded ErrorObject for the given code.
gbp_frame_encode_v
CBOR-encodes a [gbp::GbpFrame] with an arbitrary version byte.
gbp_last_error
Returns the text of the last error, or an empty string if none.
gbp_mls_accept_welcome
Replaces the local group with the one described by the given Welcome.
gbp_mls_clear_pending_commit
Discards any pending commit without applying it. Used on ABORT_TRANSITION to roll back to the pre-commit MLS state.
gbp_mls_create
Creates a new MLS context. Returns the new handle, or 0 on failure.
gbp_mls_destroy
Destroys an MLS context.
gbp_mls_epoch
Returns the current epoch of the MLS context, or 0 on failure.
gbp_mls_export_key_package
Exports the TLS-serialised KeyPackage that can be used to invite this member into someone else’s group.
gbp_mls_finalize_commit
Merges any pending commit produced by gbp_mls_invite_full or gbp_mls_remove. Returns true on success, false on failure.
gbp_mls_group_id
Writes the 16-byte group identifier into out16.
gbp_mls_invite
Invites the given KeyPackage into the local group. Returns the TLS-serialised Welcome bytes that the invitee must consume with gbp_mls_accept_welcome.
gbp_mls_invite_full
Invites the given KeyPackage and returns BOTH the MLS Commit (which the caller MUST broadcast to existing members so they can advance their MLS epoch) and the Welcome (which the caller MUST unicast to the new joiner).
gbp_mls_process_message
Applies a Commit (or staged Proposal) message to the local MLS group. Returns: 1 — Commit applied (epoch advanced) 2 — Application message (no-op for GBP) 3 — Proposal staged 4 — External message (no group state change) 0 — failure (see gbp_last_error).
gbp_mls_remove
Removes the member at the given MLS LeafIndex and returns the TLS-serialised Commit. Caller MUST broadcast the Commit to remaining members so they advance their MLS epoch.
gbp_node_apply_transition
Applies an epoch transition locally.
gbp_node_bootstrap_creator
Drives the node to ACTIVE as a creator.
gbp_node_bootstrap_joiner
Drives the node to ACTIVE as a joiner. expected_first_tid lets the joiner pre-arm pending transition state so that the first EXECUTE_TRANSITION after Welcome is accepted; pass 0 if the joiner recovered out-of-band and is already current.
gbp_node_create
Creates a new GBP node and returns its handle.
gbp_node_destroy
Destroys a GBP node.
gbp_node_drain_events
Drains the queued events (without consuming any wire bytes).
gbp_node_epoch
Returns the node’s current epoch.
gbp_node_last_transition_id
Returns the node’s last applied transition_id.
gbp_node_on_wire
Feeds wire bytes to the node. Returns a JSON-encoded array of events.
gbp_node_send_control
Sends a control plane message on Stream 0.
gbp_node_set_epoch
Forcibly sets the node’s current_epoch (intended for tests of late peers and EPOCH_MISMATCH recovery).
gbp_node_state
Returns the current NodeState encoded as u32.
gbp_string_free
Releases a string previously returned by an FFI function.
gbp_version
Returns the FFI library version with a short summary of the layers.
gsp_client_accept
Accepts a GSP signal payload.
gsp_client_create
Creates a stateful GSP client.
gsp_client_destroy
Destroys a GSP client.
gsp_client_reset
Clears the client state. Intended for use after an epoch change.
gsp_client_send
Sends a GSP signal.
gtp_client_accept
Accepts a plaintext payload that the GBP layer surfaced via a payload_received event. Returns a JSON object of the form {"status":"new|duplicate|error", ...}.
gtp_client_create
Creates a stateful GTP client (idempotency tracking).
gtp_client_destroy
Destroys a GTP client.
gtp_client_reset
Clears the client state. Intended for use after an epoch change.
gtp_client_send
Sends a text message via GTP.