vmnet
Apple's vmnet.framework bindings for Rust.
Installation
Add this to your Cargo.toml:
[]
= "0.1.0"
Usage
Ensure that your software either has an com.apple.vm.networking entitlement or is running with elevated privileges.
Start a NAT interface and receive some packets destined to it:
let shared_mode = Shared ;
let mut iface = new.unwrap;
let = sync_channel;
iface.set_event_callback.unwrap;
let pkts = rx.recv.unwrap;
println!;
for _ in 0..pkts
drop;
iface.finalize.unwrap;
Quirks and missing functionality
- due to Apple's usage of blocks as a way to retrieve API call results, some methods like
set_event_callback()require the provided closure to have a'staticlifetime- this manifests itself in not being able to use
Interfacefrom such closure - however, this can be easily worked around by using interior mutability pattern or simply by using the callback as a signal carrier
- this manifests itself in not being able to use
- no port forwarding support
vmnet_copy_shared_interface_list()is not yet implemented- due to
API_AVAILABLEmacro not being supported it is assumed that this package is running on macOS 11.0 or newer