package mirage

  1. Overview
  2. Docs
The MirageOS library operating system

Install

dune-project
 Dependency

Authors

Maintainers

Sources

mirage-4.10.0.tbz
sha256=795cc176ffbc67363d4c4ef69354aced9681c0b1e24bf93f0a270975ee0b608b
sha512=96a2fb3971613b146371a02af1ce59c73ca86dd1f42c0c47334bfbabe7d5f4cffb080c2c585e2e21fe3d33133bbe86b703cb9d276dd86ce3a90a544f03293af5

doc/src/mirage.devices/network.ml.html

Source file network.ml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
open Functoria.DSL
open Functoria.Action
open Misc

type network = NETWORK

let network = typ NETWORK
let all_networks = ref []
let add_new_network name = all_networks := name :: !all_networks

let network_conf ?(intf : string runtime_arg option) name =
  let runtime_args = Option.to_list (Option.map Runtime_arg.v intf) in
  let packages_v =
    Key.match_ Key.(value target) @@ function
    | `Unix -> [ package ~min:"3.0.0" ~max:"4.0.0" "mirage-net-unix" ]
    | `MacOSX -> [ package ~min:"1.8.0" ~max:"2.0.0" "mirage-net-macosx" ]
    | `Xen -> [ package ~min:"2.1.0" ~max:"3.0.0" "mirage-net-xen" ]
    | `Qubes ->
        [ package ~min:"2.1.0" ~max:"3.0.0" "mirage-net-xen"; Qubesdb.pkg ]
    | #Key.mode_solo5 ->
        [ package ~min:"0.8.0" ~max:"0.9.0" "mirage-net-solo5" ]
    | #Key.mode_unikraft ->
        [ package ~min:"1.0.0" ~max:"2.0.0" "mirage-net-unikraft" ]
  in
  let connect _ modname = function
    | [] -> code ~pos:__POS__ "%s.connect %S" modname name
    | [ intf ] -> code ~pos:__POS__ "%s.connect %s" modname intf
    | _ -> connect_err "network_conf (sometimes 0 arguments)" 1
  in
  let configure _ =
    add_new_network name;
    ok ()
  in
  impl ~runtime_args ~packages_v ~connect ~configure "Netif" network

let netif ?group dev =
  if_impl Key.is_solo5 (network_conf dev)
    (network_conf ~intf:(Runtime_arg.interface ?group dev) dev)

let default_network =
  match_impl
    Key.(value target)
    [
      (`Unix, netif "tap0");
      (`MacOSX, netif "tap0");
      (* On Solo5 targets, a single default network is customarily
       * named just 'service' *)
      (`Hvt, netif "service");
      (`Spt, netif "service");
      (`Virtio, netif "service");
      (`Muen, netif "service");
      (`Genode, netif "service");
    ]
    ~default:(netif "0")