Module Vmnet
macOS userspace network bridging.
val sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.t
type mode=|Host_mode|Shared_modemodecontrols the level of sharing exposed to the vmnet interface.Host_modelets the guest network interface communicate with other guest network interfaces in the host mode and to the native host.Shared_modelets the guest network interface reach the Internet using a network address translator.
Note that in MacOS X Yosemite,
Host_modealso 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=|Failure|Mem_failure|Invalid_argument|Setup_incomplete|Invalid_access|Packet_too_big|Buffer_exhausted|Too_many_packets|Unknown of interrorrepresents hard failures from the underlying vmnet functions.
exceptionError of error
val init : ?mode:mode -> unit -> tinit ?modewill initialise a fresh vmnet interface, defaulting toShared_modefor the output. RaisesErrorif something goes wrong.
val mac : t -> Macaddr.tmac twill return the MAC address bound to the guest network interface.
val mtu : t -> intmtu twill return the Maximum Transmission Unit (MTU) bound to the guest network interface.
val max_packet_size : t -> intmax_packet_size twill return the maximum allowed packet buffer that can be passed towrite. Exceeding this will raisePacket_too_bigfromwrite. This is also the minimum buffer size that must be passed toread.
val set_event_handler : t -> unitset_event_handler twill initalise the internal thread state in the library that listen for event notifications from the library. Thewait_for_eventfunction should not be called until thisset_event_handlerbeen called once.
val wait_for_event : t -> unitwait_for_event twill block the current OCaml thread until an event notification has been received on thetvmnet interface.
val read : t -> Cstruct.t -> Cstruct.tread t bufwill read a network packet into thebufCstruct.t and return a fresh subview that represents the packet with the correct length and offset. It will raiseNo_packets_waitingif there is nothing to read.
val write : t -> Cstruct.t -> unitwrite t bufwill transmit a network packet contained inbuf. This will normally not block, but the vmnet interface isnt clear on whether this might happen.