Module Lwt_vmnet
Lwt async interface to MacOS X userlevel network bridging.
type mode
= Vmnet.mode
=
|
Host_mode
|
Shared_mode
mode
controls the level of sharing exposed to the vmnet interface.Host_mode
lets the guest network interface communicate with other guest network interfaces in the host mode and to the native host.Shared_mode
lets the guest network interface reach the Internet using a network address translator.
Note that in MacOS X Yosemite,
Host_mode
also provides a NAT to the guest, but with the subnet and DNS options not set (so it has no way to communicate externally but can still retrieve host-local network configuration via DHCP).
type error
= Vmnet.error
=
|
Failure
|
Mem_failure
|
Invalid_argument
|
Setup_incomplete
|
Invalid_access
|
Packet_too_big
|
Buffer_exhausted
|
Too_many_packets
|
Unknown of int
error
represents hard failures from the underlying vmnet functions.
exception
Error of error
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
val mac : t -> Macaddr.t
mac t
will return the MAC address bound to the guest network interface.
val mtu : t -> int
mtu t
will return the Maximum Transmission unit bound to the guest network interfacet
.
val max_packet_size : t -> int
max_packet_size t
will return the maximum allowed packet buffer that can be passed towrite
. Exceeding this will raisePacket_too_big
fromwrite
.
val init : ?mode:mode -> unit -> t Lwt.t
init ?mode
will initialise a fresh vmnet interface, defaulting toShared_mode
for the output. RaisesError
if something goes wrong.
val read : t -> Cstruct.t -> Cstruct.t Lwt.t
read t buf
will read a network packet into thebuf
Cstruct
.t and return a fresh subview that represents the packet with the correct length and offset. It blocks until a packet is available.
val write : t -> Cstruct.t -> unit Lwt.t
write t buf
will transmit a network packet contained inbuf
. This will normally not block, but the vmnet interface isnt clear on whether this might happen.