common library

Common layer: re-exports the magpie_bridge SDK facades.

Import this for the shared SDK surface:

Classes

BasePacket
Delegation base shared by all public packet classes.
BridgePacket
BridgePacket (B=1): packets exchanged with the relay server, or forwarded by the server between two clients. These packets carry target/source bids and MAY be signed (HMAC-SHA256) once a secret has been established.
BridgePacketFactory
Creates and parses bridge packets (B=1, client <-> server).
Command
Reserved system command values.
DirectPacket
DirectPacket (B=0): peer-to-peer packets without relay. No target/source bids are carried. The protocol does not require an attachment; an app may append an optional 32-byte HMAC-SHA256 tail when it needs integrity checking (the parser exposes it as a ReliablePacket).
DirectPacketFactory
Creates and parses direct packets (B=0, client <-> client).
HmacSha256
HMAC-SHA-256 utility (facade for MacGenerator).
MacGenerator
Interface for computing MAC (Message Authentication Code) values, e.g. HMAC with various underlying hash algorithms.
Magpie
Core message interface. Every packet on the wire is a Magpie. All properties are read-only.
MessagePacket
The concrete, pack-only implementation of Packet.
MessagePacketFactory
Validate a raw datagram and decode its header fields.
Packet
A Magpie whose header-level flags (A/B/C/D/E) and the two lengths are visible; this is the shape MessagePacket implements.
ReliablePacket
A packet that carries a 32-byte HMAC-SHA256 attachment (verify code).

Mixins

HumanReadablePacket
Human-readable one-line dump shared by all packet classes.

Constants

ATTACHMENT_LENGTH → const int
Attachment length: HMAC-SHA256, 32 bytes.
MAGIC_CODE → const int
Magic Code: 'M', 'P', '\0', '\1' (Messaging Protocol v1).
MAX_HEADER_LENGTH → const int
Maximum header size (all optional fields present, E=4).
MAX_PAYLOAD_LENGTH → const int
Suggested payload cap on the sender side (bytes).
MIN_HEADER_LENGTH → const int
Fixed header size: magic(4) + type(1) + headerLen(1) + payloadLen(2).
MSS → const int
Max datagram size (IPv6 minimum MTU 1280 - 40 ipv6 header - 8 udp header) MSS hard cap: header + payload (+ attachment) <= 1232.

Functions

calcCmd(int command) → int
C flag: command == 0 => C=0 (plain DATA).
calcDsn(int sn) → int
D flag: sn == 0 => D=0 (system command).
calcExt(int count) → int
E width: count >= 65536 => 4; count >= 2 => 2; else 0.
calcHeaderLength({required int bid, required int cmd, required int dsn, required int ext}) → int
Header length: N = 8 + 8B + 4D + 2E + 4C.
calcType({required int ack, required int bid, required int cmd, required int dsn, required int ext}) → int
Compose the type byte: A(7) B(6) C(5) D(4) E(low 3 bits).