Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mirage/mirage
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 7d8555039c56
Choose a base ref
...
head repository: mirage/mirage
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 098dc402e52f
Choose a head ref
  • 2 commits
  • 5 files changed
  • 2 contributors

Commits on Dec 20, 2018

  1. Copy the full SHA
    7d94375 View commit details

Commits on Jan 2, 2019

  1. Merge pull request #958 from hannesm/socket-unix

    default to socket stack on unix and macosx when using generic_stackv4
    avsm authored Jan 2, 2019

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    098dc40 View commit details
Showing with 20 additions and 18 deletions.
  1. +4 −3 lib/mirage.mli
  2. +10 −9 lib/mirage_impl_stackv4.ml
  3. +1 −1 lib/mirage_impl_stackv4.mli
  4. +4 −4 lib/mirage_key.ml
  5. +1 −1 lib/mirage_key.mli
7 changes: 4 additions & 3 deletions lib/mirage.mli
Original file line number Diff line number Diff line change
@@ -390,9 +390,10 @@ val dhcp_ipv4_stack: ?group:string -> ?random:random impl -> ?time:time impl ->
val static_ipv4_stack: ?group:string -> ?config:ipv4_config -> ?arp:(ethernet impl -> arpv4 impl) -> network impl -> stackv4 impl

(** Generic stack using a [dhcp] and a [net] keys: {!Key.net} and {!Key.dhcp}.
- If [target] = [Qubes] then {!qubes_ipv4_stack} is used.
- If [net] = [socket] then {!socket_stackv4} is used.
- If [target] = [Qubes] then {!qubes_ipv4_stack} is used
- Else, if [net] = [socket] then {!socket_stackv4} is used
- Else, if [dhcp] then {!dhcp_ipv4_stack} is used
- Else, if [unix or macosx] then {!socket_stackv4} is used
- Else, {!static_ipv4_stack} is used.
If a key is not provided, it uses {!Key.net} or {!Key.dhcp} (with the
@@ -401,7 +402,7 @@ val static_ipv4_stack: ?group:string -> ?config:ipv4_config -> ?arp:(ethernet im
val generic_stackv4:
?group:string -> ?config:ipv4_config ->
?dhcp_key:bool value ->
?net_key:[ `Direct | `Socket ] value ->
?net_key:[ `Direct | `Socket ] option value ->
network impl -> stackv4 impl

(** {2 Resolver configuration} *)
19 changes: 10 additions & 9 deletions lib/mirage_impl_stackv4.ml
Original file line number Diff line number Diff line change
@@ -94,17 +94,18 @@ let generic_stackv4
?(dhcp_key = Key.value @@ Key.dhcp ?group ())
?(net_key = Key.value @@ Key.net ?group ())
(tap : network impl) : stackv4 impl =
let eq a b = Key.(pure ((=) a) $ b) in
let choose qubes socket dhcp =
if qubes then `Qubes
else if socket then `Socket
else if dhcp then `Dhcp
else `Static
let choose target net dhcp =
match target, net, dhcp with
| `Qubes, _, _ -> `Qubes
| _, Some `Socket, _ -> `Socket
| _, _, true -> `Dhcp
| (`Unix | `MacOSX), None, false -> `Socket
| _, _, _ -> `Static
in
let p = Functoria_key.((pure choose)
$ eq `Qubes Key.(value target)
$ eq `Socket net_key
$ eq true dhcp_key) in
$ Key.(value target)
$ net_key
$ dhcp_key) in
match_impl p [
`Dhcp, dhcp_ipv4_stack ?group tap;
`Socket, socket_stackv4 ?group [Ipaddr.V4.any];
2 changes: 1 addition & 1 deletion lib/mirage_impl_stackv4.mli
Original file line number Diff line number Diff line change
@@ -45,6 +45,6 @@ val generic_stackv4 :
?group:string
-> ?config:Mirage_impl_ip.ipv4_config
-> ?dhcp_key:bool Functoria.value
-> ?net_key:[`Direct | `Socket] Functoria.value
-> ?net_key:[`Direct | `Socket] option Functoria.value
-> Mirage_impl_network.network Functoria.impl
-> stackv4 Functoria.impl
8 changes: 4 additions & 4 deletions lib/mirage_key.ml
Original file line number Diff line number Diff line change
@@ -278,17 +278,17 @@ let dhcp ?group () =
create_simple
~doc ?group ~stage:`Configure ~default:false Arg.bool "dhcp"

let net ?group (): [`Socket | `Direct] Key.key =
let net ?group (): [`Socket | `Direct] option Key.key =
let conv = Cmdliner.Arg.enum ["socket", `Socket ; "direct", `Direct] in
let serialize fmt = function
| `Socket -> Fmt.pf fmt "`Socket"
| `Direct -> Fmt.pf fmt "`Direct"
| `Socket -> Fmt.string fmt "`Socket"
| `Direct -> Fmt.string fmt "`Direct"
in
let conv = Arg.conv ~conv ~runtime_conv:"net" ~serialize in
let doc =
Fmt.strf "Use $(i,socket) or $(i,direct) group for %a." pp_group group
in
create_simple ~doc ?group ~stage:`Configure ~default:`Direct conv "net"
create_simple ~doc ?group ~stage:`Configure ~default:None (Arg.some conv) "net"

(** {3 Network keys} *)

2 changes: 1 addition & 1 deletion lib/mirage_key.mli
Original file line number Diff line number Diff line change
@@ -93,7 +93,7 @@ val prng : ?group:string -> unit -> [ `Stdlib | `Nocrypto ] key
val dhcp : ?group:string -> unit -> bool key
(** Enable dhcp. Is either [true] or [false]. *)

val net : ?group:string -> unit -> [ `Direct | `Socket ] key
val net : ?group:string -> unit -> [ `Direct | `Socket ] option key
(** The type of stack. Is either ["direct"] or ["socket"]. *)

(** {3 Network keys} *)