SpaceOS wire protocol codecs for host-guest communication
1(** Parameter Store entry codec.
2
3 {v
4 0x00 uint32 param_id
5 0x04 uint16 len
6 0x06 uint16 generation
7 0x08 bytes value (len bytes, padded to 4-byte alignment)
8 0x?? uint32 crc32 (CRC-32C of param_id through value)
9 v}
10
11 The parameter store occupies blocks 1-16 of the virtio-blk device. Entries
12 are appended sequentially. The guest reads the highest-generation entry for
13 each param_id. *)
14
15(** {1 Constants} *)
16
17val max_value_len : int
18(** Maximum value length: 240 bytes (248 - 8 header bytes). *)
19
20(** {1 Type} *)
21
22type t = {
23 param_id : int;
24 len : int;
25 generation : int;
26 value : string;
27 crc32 : int;
28}
29
30val codec : t Wire.Codec.t
31(** Wire codec for a parameter entry. The value is stored as a fixed 240-byte
32 field (zero-padded). Total size: 252 bytes. *)
33
34val v : param_id:int -> generation:int -> string -> t
35(** [v ~param_id ~generation value] builds a parameter entry with computed CRC.
36 Value is truncated to {!max_value_len}. *)
37
38val value_bytes : t -> string
39(** [value_bytes t] returns the meaningful value (first [len] bytes). *)
40
41val check_crc : t -> bool
42(** [check_crc t] validates the CRC-32C. *)
43
44val pp : t Fmt.t
45(** Pretty-print a parameter entry. *)
46
47val equal : t -> t -> bool
48(** Structural equality. *)