Skip to content

Commit

Permalink
When net_tap driver can't initialize, emit human error
Browse files Browse the repository at this point in the history
Fixes #164.
  • Loading branch information
dsheets committed Nov 21, 2014
1 parent 97833d7 commit d7b2ca3
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/mirage.ml
Expand Up @@ -1225,6 +1225,8 @@ module STACKV4_direct = struct
@ Impl.libraries t.network
@ Impl.libraries t.random

let tuntap_help = "Is tun/tap enabled and have you permissions?\\n\\n"

let configure t =
let name = name t in
Impl.configure t.clock;
Expand Down Expand Up @@ -1254,8 +1256,17 @@ module STACKV4_direct = struct
(driver_initialisation_error (Impl.name t.console));
append_main " | `Ok console ->";
append_main " %s () >>= function" (Impl.name t.network);
append_main " | `Error _ -> %s"
(driver_initialisation_error (Impl.name t.network));
append_main " | `Error e ->";
let name = Impl.name t.network in begin
append_main " fail (Failure begin match e with";
append_main " %s -> \"\\n\\n\"^%S^\": \"^msg^\"\\n%s\""
"| `Unknown msg" name tuntap_help;
append_main " %s -> \"\\n\\n\"^%S^\": operation unimplemented\\n\\n\""
"| `Unimplemented" name;
append_main " %s -> \"\\n\\n\"^%S^\": disconnected\\n\\n\""
"| `Disconnected" name;
append_main " end)";
end;
append_main " | `Ok interface ->";
append_main " let config = {";
append_main " V1_LWT.name = %S;" name;
Expand Down

0 comments on commit d7b2ca3

Please sign in to comment.