2015-12-30 06:59:32 -05:00
|
|
|
(* Copyright (C) 2015, Thomas Leonard <thomas.leonard@unikernel.com>
|
|
|
|
See the README file for details. *)
|
|
|
|
|
|
|
|
(** Wrapper for XenStore and QubesDB databases. *)
|
|
|
|
|
2016-10-01 09:42:27 -04:00
|
|
|
module ClientVif : sig
|
|
|
|
type t = {
|
|
|
|
domid : int;
|
|
|
|
device_id : int;
|
|
|
|
}
|
|
|
|
val pp : t Fmt.t
|
|
|
|
end
|
|
|
|
module VifMap : sig
|
|
|
|
include Map.S with type key = ClientVif.t
|
|
|
|
val find : key -> 'a t -> 'a option
|
|
|
|
end
|
|
|
|
|
|
|
|
val watch_clients : (Ipaddr.V4.t VifMap.t -> unit) -> 'a Lwt.t
|
|
|
|
(** [watch_clients fn] calls [fn clients] with the list of backend clients
|
|
|
|
in XenStore, and again each time XenStore updates. *)
|
2015-12-30 06:59:32 -05:00
|
|
|
|
|
|
|
type network_config = {
|
2023-07-05 05:56:19 -04:00
|
|
|
from_cmdline : bool; (* Specify if we have network configuration from command line or from qubesDB*)
|
2023-06-30 09:31:30 -04:00
|
|
|
netvm_ip : Ipaddr.V4.t; (* The IP address of NetVM (our gateway) *)
|
|
|
|
our_ip : Ipaddr.V4.t; (* The IP address of our interface to NetVM *)
|
2021-11-10 09:26:17 -05:00
|
|
|
dns : Ipaddr.V4.t;
|
2022-09-07 10:53:45 -04:00
|
|
|
dns2 : Ipaddr.V4.t;
|
2015-12-30 06:59:32 -05:00
|
|
|
}
|
|
|
|
|
2019-04-28 11:06:03 -04:00
|
|
|
val read_network_config : Qubes.DB.t -> network_config Lwt.t
|
|
|
|
(** [read_network_config db] fetches the configuration from QubesDB.
|
|
|
|
If it isn't there yet, it waits until it is. *)
|
2015-12-30 06:59:32 -05:00
|
|
|
|
2020-04-29 09:58:01 -04:00
|
|
|
val db_root : Ipaddr.V4.t -> string
|
|
|
|
(** Returns the root path of the firewall rules in the QubesDB for a given IP address. *)
|
|
|
|
|
|
|
|
val read_rules : string Qubes.DB.KeyMap.t -> Ipaddr.V4.t -> Pf_qubes.Parse_qubes.rule list
|
|
|
|
(** [read_rules bindings ip] extracts firewall rule information for [ip] from [bindings].
|
|
|
|
If any rules fail to parse, it will return only one rule denying all traffic. *)
|
|
|
|
|
2023-06-30 10:58:08 -04:00
|
|
|
val print_network_config : network_config -> unit
|
|
|
|
|
2015-12-30 06:59:32 -05:00
|
|
|
val set_iptables_error : Qubes.DB.t -> string -> unit Lwt.t
|