1(* 2 * Copyright (C) 2006-2007 XenSource Ltd. 3 * Copyright (C) 2008 Citrix Ltd. 4 * Author Vincent Hanquez <vincent.hanquez@eu.citrix.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published 8 * by the Free Software Foundation; version 2.1 only. with the special 9 * exception on linking described in file LICENSE. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 *) 16 17module Server_feature = struct 18 type t = 19 | Reconnection 20end 21 22module Server_features = Set.Make(struct 23 type t = Server_feature.t 24 let compare = compare 25end) 26 27external read: Xenmmap.mmap_interface -> bytes -> int -> int = "ml_interface_read" 28external write: Xenmmap.mmap_interface -> bytes -> int -> int = "ml_interface_write" 29 30external _internal_set_server_features: Xenmmap.mmap_interface -> int -> unit = "ml_interface_set_server_features" [@@noalloc] 31external _internal_get_server_features: Xenmmap.mmap_interface -> int = "ml_interface_get_server_features" [@@noalloc] 32 33let write_substring mmap buff len = 34 write mmap (Bytes.unsafe_of_string buff) len 35 36let get_server_features mmap = 37 (* NB only one feature currently defined above *) 38 let x = _internal_get_server_features mmap in 39 if x = 0 40 then Server_features.empty 41 else Server_features.singleton Server_feature.Reconnection 42 43let set_server_features mmap set = 44 (* NB only one feature currently defined above *) 45 let x = if set = Server_features.empty then 0 else 1 in 46 _internal_set_server_features mmap x 47 48external close: Xenmmap.mmap_interface -> unit = "ml_interface_close" [@@noalloc] 49