APID-based virtual switch for SpaceOS inter-guest routing
1(** APID virtual switch orchestrator.
2
3 Accepts guest connections, routes frames between tenants, enforces APID
4 ownership and inter-guest policy. *)
5
6type t
7(** The switch instance. *)
8
9val v :
10 config:Config.t ->
11 ?on_system:(Space_wire.Msg.t -> Space_wire.Msg.t option) ->
12 ?on_uplink:(Space_wire.Msg.t -> unit) ->
13 unit ->
14 t
15(** [v ~config ?on_system ?on_uplink ()] builds a switch.
16
17 @param on_system
18 Handler for system-range APIDs (0x001–0x00F). Returns an optional response
19 frame.
20 @param on_uplink Handler for frames destined for DTN uplink. *)
21
22val pp : Format.formatter -> t -> unit
23(** Pretty-print a switch (shows configuration summary). *)
24
25val run : t -> sw:Eio.Switch.t -> net:_ Eio.Net.t -> unit
26(** [run t ~sw ~net] starts the switch: creates per-tenant Unix sockets, accepts
27 guests, and routes frames. *)
28
29val inject : t -> Space_wire.Msg.t -> unit
30(** [inject t frame] injects a frame from DTN (no source validation). *)
31
32val stop : t -> unit
33(** [stop t] signals the switch to stop. *)
34
35val space_packet_uplink :
36 seq_count:(unit -> int) -> Space_wire.Msg.t -> Space_packet.t option
37(** [space_packet_uplink ~seq_count frame] wraps a SpaceOS frame in a CCSDS
38 Space Packet for DTN uplink. Returns [None] if the APID is out of range. *)