more cleanups

This commit is contained in:
Hannes Mehnert 2018-10-23 21:38:34 +02:00
parent 611d234e1a
commit f3c67f626a
3 changed files with 11 additions and 45 deletions

View File

@ -88,17 +88,6 @@ let image =
type version = [ `AV0 | `AV1 | `AV2 ]
let version_of_int = function
| 0 -> Ok `AV0
| 1 -> Ok `AV1
| 2 -> Ok `AV2
| _ -> Error (`Msg "couldn't parse version")
let version_to_int = function
| `AV0 -> 0
| `AV1 -> 1
| `AV2 -> 2
let pp_version ppf v =
Fmt.int ppf
(match v with
@ -418,10 +407,15 @@ let policy_cmd =
(explicit 2 null))
let version =
let f data = match version_of_int data with
| Ok v -> v
| Error (`Msg m) -> Asn.S.error (`Parse m)
and g = version_to_int
let f data = match data with
| 0 -> `AV0
| 1 -> `AV1
| 2 -> `AV2
| _ -> Asn.S.error (`Parse "unknown version number")
and g = function
| `AV0 -> 0
| `AV1 -> 1
| `AV2 -> 2
in
Asn.S.map f g Asn.S.int

View File

@ -29,21 +29,9 @@ end
module IS = Set.Make(I)
module IM = Map.Make(I)
module IM64 = Map.Make(Int64)
type vmtype = [ `Hvt_amd64 | `Hvt_arm64 | `Hvt_amd64_compressed ]
let vmtype_to_int = function
| `Hvt_amd64 -> 0
| `Hvt_arm64 -> 1
| `Hvt_amd64_compressed -> 2
let int_to_vmtype = function
| 0 -> Some `Hvt_amd64
| 1 -> Some `Hvt_arm64
| 2 -> Some `Hvt_amd64_compressed
| _ -> None
let pp_vmtype ppf = function
| `Hvt_amd64 -> Fmt.pf ppf "hvt-amd64"
| `Hvt_amd64_compressed -> Fmt.pf ppf "hvt-amd64-compressed"
@ -188,14 +176,6 @@ let translate_tap vm tap =
| [ (_, b) ] -> Some b
| _ -> None
let identifier serial =
match Hex.of_cstruct @@ Nocrypto.Hash.SHA256.digest @@
Nocrypto.Numeric.Z.to_cstruct_be @@ serial
with
| `Hex str -> str
let id cert = identifier (X509.serial cert)
let name cert = X509.common_name_to_string cert
(* this separates the leaf and top-level certificate from the chain,

View File

@ -14,13 +14,7 @@ module IM : sig
include Map.S with type key = I.t
end
module IM64 : sig
include Map.S with type key = Int64.t
end
type vmtype = [ `Hvt_amd64 | `Hvt_amd64_compressed | `Hvt_arm64 ]
val vmtype_to_int : vmtype -> int
val int_to_vmtype : int -> vmtype option
val pp_vmtype : vmtype Fmt.t
type id = string list
@ -32,8 +26,8 @@ val domain : 'a list -> 'a list
val pp_id : id Fmt.t
type bridge =
[ `External of string * Ipaddr.V4.t * Ipaddr.V4.t * Ipaddr.V4.t * int
| `Internal of string ]
[ `External of string * Ipaddr.V4.t * Ipaddr.V4.t * Ipaddr.V4.t * int
| `Internal of string ]
val pp_bridge : bridge Fmt.t
type policy = {
@ -81,8 +75,6 @@ type vm = {
val pp_vm : vm Fmt.t
val translate_tap : vm -> string -> string option
val identifier : Nocrypto.Numeric.Z.t -> string
val id : X509.t -> string
val name : X509.t -> string
val separate_chain : 'a list -> ('a * 'a list, [> `Msg of string ]) result