Documentation
¶
Overview ¶
Package vmnet provides Go bindings for the vmnet framework.
Connect with network interfaces to read and write packets on guest operating systems.
The vmnet framework is an API for virtual machines to read and write packets.
Essentials ¶
- com.apple.vm.networking: A Boolean that indicates whether the app manages virtual network interfaces without escalating privileges to the root user.
Starting and Stopping Interfaces ¶
- vmnet_start_interface(_:_:_:): Starts host or shared mode on an interface with a specified configuration.
- vmnet_interface_set_event_callback(_:_:_:_:): Schedules a callback to be executed when events for the specified interface are received.
- vmnet_stop_interface(_:_:_:): Stops the interface.
Reading and Writing Packets ¶
- vmnet_read(_:_:_:): Attempts to read a specified number of packets from an interface.
- vmnet_write(_:_:_:): Attempts to write specified packets to an interface.
Data Types ¶
- vmnet_return_t: Values returned by functions in the vmnet Framework.
- vmpktdesc: Describes a packet.
- interface_ref: A virtual network interface.
- interface_event_t: Interface event types.
- operating_modes_t: The operating modes for an interface.
Constants ¶
- interface_desc XPC Dictionary Keys: XPC dictionary keys supported by the parameter passed to the function to describe the parameters of the network interface.
- interface_param XPC Dictionary Keys: XPC dictionary keys used by the argument returned by the completion handler of the function that describes the parameters that should be used to configure the network interface.
- event XPC Dictionary: XPC dictionary keys used by the value returned to the client in the callback specified by the function that provides information about the callback event.
Variables ¶
- vmnet_enable_virtio_header_key
- vmnet_read_max_packets_key
- vmnet_write_max_packets_key
Functions ¶
- vmnet_interface_start_with_network(_:_:_:_:)
- vmnet_network_configuration_add_dhcp_reservation(_:_:_:)
- vmnet_network_configuration_add_port_forwarding_rule(_:_:_:_:_:_:)
- vmnet_network_configuration_create(_:_:)
- vmnet_network_configuration_disable_dhcp(_:)
- vmnet_network_configuration_disable_dns_proxy(_:)
- vmnet_network_configuration_disable_nat44(_:)
- vmnet_network_configuration_disable_nat66(_:)
- vmnet_network_configuration_disable_router_advertisement(_:)
- vmnet_network_configuration_set_external_interface(_:_:)
- vmnet_network_configuration_set_ipv4_subnet(_:_:_:)
- vmnet_network_configuration_set_ipv6_prefix(_:_:_:)
- vmnet_network_configuration_set_mtu(_:_:)
- vmnet_network_copy_serialization(_:_:)
- vmnet_network_create(_:_:)
- vmnet_network_create_with_serialization(_:_:)
- vmnet_network_get_ipv4_subnet(_:_:_:)
- vmnet_network_get_ipv6_prefix(_:_:_:)
Type Aliases ¶
- vmnet_mode_t
- vmnet_network_configuration_ref
- vmnet_network_ref
Code generated from Apple documentation. DO NOT EDIT.
Index ¶
- func Vmnet_copy_shared_interface_list() unsafe.Pointer
- func Vmnet_network_configuration_disable_dhcp(config Vmnet_network_configuration_ref)
- func Vmnet_network_configuration_disable_dns_proxy(config Vmnet_network_configuration_ref)
- func Vmnet_network_configuration_disable_nat44(config Vmnet_network_configuration_ref)
- func Vmnet_network_configuration_disable_nat66(config Vmnet_network_configuration_ref)
- func Vmnet_network_configuration_disable_router_advertisement(config Vmnet_network_configuration_ref)
- func Vmnet_network_copy_serialization(network Vmnet_network_ref, status *Vmnet_return_t) unsafe.Pointer
- func Vmnet_network_get_ipv4_subnet(network Vmnet_network_ref, subnet uintptr, mask uintptr)
- func Vmnet_network_get_ipv6_prefix(network Vmnet_network_ref, prefix uintptr, prefix_len *uint8)
- type Interface_event_t
- type Interface_ref
- type Operating_modes_t
- type Vmnet_interface_completion_handler_t
- type Vmnet_interface_event_callback_t
- type Vmnet_interface_get_ip_port_forwarding_rules_handler_t
- type Vmnet_interface_get_port_forwarding_rules_handler_t
- type Vmnet_mode_t
- type Vmnet_network_configuration_ref
- type Vmnet_network_ref
- type Vmnet_return_t
- func Vmnet_interface_add_ip_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, ...) Vmnet_return_t
- func Vmnet_interface_add_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, ...) Vmnet_return_tdeprecated
- func Vmnet_interface_get_ip_port_forwarding_rules(interface_ Interface_ref, address_family kernel.U_int8_t, ...) Vmnet_return_t
- func Vmnet_interface_get_port_forwarding_rules(interface_ Interface_ref, ...) Vmnet_return_tdeprecated
- func Vmnet_interface_remove_ip_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, ...) Vmnet_return_t
- func Vmnet_interface_remove_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, ...) Vmnet_return_tdeprecated
- func Vmnet_interface_set_event_callback(interface_ Interface_ref, event_mask Interface_event_t, queue dispatch.Queue, ...) Vmnet_return_t
- func Vmnet_ip_port_forwarding_rule_get_details(rule unsafe.Pointer, protocol_ *uint8, external_port *uint16, ...) Vmnet_return_t
- func Vmnet_network_configuration_add_port_forwarding_rule(config Vmnet_network_configuration_ref, protocol_ uint8, address_family uint8, ...) Vmnet_return_t
- func Vmnet_network_configuration_set_external_interface(config Vmnet_network_configuration_ref, interface_name string) Vmnet_return_t
- func Vmnet_network_configuration_set_ipv4_subnet(config Vmnet_network_configuration_ref, subnet_addr uintptr, ...) Vmnet_return_t
- func Vmnet_network_configuration_set_ipv6_prefix(config Vmnet_network_configuration_ref, prefix uintptr, len_ uint8) Vmnet_return_t
- func Vmnet_network_configuration_set_mtu(config Vmnet_network_configuration_ref, mtu uint32) Vmnet_return_t
- func Vmnet_port_forwarding_rule_get_details(rule unsafe.Pointer, protocol_ *uint8, external_port *uint16, ...) Vmnet_return_tdeprecated
- func Vmnet_read(interface_ Interface_ref, packets *Vmpktdesc, pktcnt []int) Vmnet_return_t
- func Vmnet_stop_interface(interface_ Interface_ref, queue dispatch.Queue, ...) Vmnet_return_t
- func Vmnet_write(interface_ Interface_ref, packets *Vmpktdesc, pktcnt []int) Vmnet_return_t
- type Vmnet_start_interface_completion_handler_t
- type Vmpktdesc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Vmnet_copy_shared_interface_list ¶
Vmnet_copy_shared_interface_list.
See: https://developer.apple.com/documentation/vmnet/vmnet_copy_shared_interface_list()
func Vmnet_network_configuration_disable_dhcp ¶
func Vmnet_network_configuration_disable_dhcp(config Vmnet_network_configuration_ref)
Vmnet_network_configuration_disable_dhcp.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_disable_dhcp(_:)
func Vmnet_network_configuration_disable_dns_proxy ¶
func Vmnet_network_configuration_disable_dns_proxy(config Vmnet_network_configuration_ref)
Vmnet_network_configuration_disable_dns_proxy.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_disable_dns_proxy(_:)
func Vmnet_network_configuration_disable_nat44 ¶
func Vmnet_network_configuration_disable_nat44(config Vmnet_network_configuration_ref)
Vmnet_network_configuration_disable_nat44.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_disable_nat44(_:)
func Vmnet_network_configuration_disable_nat66 ¶
func Vmnet_network_configuration_disable_nat66(config Vmnet_network_configuration_ref)
Vmnet_network_configuration_disable_nat66.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_disable_nat66(_:)
func Vmnet_network_configuration_disable_router_advertisement ¶
func Vmnet_network_configuration_disable_router_advertisement(config Vmnet_network_configuration_ref)
Vmnet_network_configuration_disable_router_advertisement.
func Vmnet_network_copy_serialization ¶
func Vmnet_network_copy_serialization(network Vmnet_network_ref, status *Vmnet_return_t) unsafe.Pointer
Vmnet_network_copy_serialization.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_copy_serialization(_:_:)
func Vmnet_network_get_ipv4_subnet ¶
func Vmnet_network_get_ipv4_subnet(network Vmnet_network_ref, subnet uintptr, mask uintptr)
Vmnet_network_get_ipv4_subnet.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_get_ipv4_subnet(_:_:_:)
func Vmnet_network_get_ipv6_prefix ¶
func Vmnet_network_get_ipv6_prefix(network Vmnet_network_ref, prefix uintptr, prefix_len *uint8)
Vmnet_network_get_ipv6_prefix.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_get_ipv6_prefix(_:_:_:)
Types ¶
type Interface_event_t ¶
type Interface_event_t uint32
See: https://developer.apple.com/documentation/vmnet/interface_event_t
const ( // VMNET_INTERFACE_PACKETS_AVAILABLE: # Discussion VMNET_INTERFACE_PACKETS_AVAILABLE Interface_event_t = 1 )
func (Interface_event_t) String ¶
func (e Interface_event_t) String() string
type Interface_ref ¶
type Interface_ref = uintptr
Interface_ref is a virtual network interface.
See: https://developer.apple.com/documentation/vmnet/interface_ref
func Vmnet_interface_start_with_network ¶
func Vmnet_interface_start_with_network(network Vmnet_network_ref, interface_desc unsafe.Pointer, queue dispatch.Queue, start_block Vmnet_start_interface_completion_handler_t) Interface_ref
Vmnet_interface_start_with_network.
See: https://developer.apple.com/documentation/vmnet/vmnet_interface_start_with_network(_:_:_:_:)
func Vmnet_start_interface ¶
func Vmnet_start_interface(interface_desc unsafe.Pointer, queue dispatch.Queue, handler Vmnet_start_interface_completion_handler_t) Interface_ref
Vmnet_start_interface starts host or shared mode on an interface with a specified configuration.
See: https://developer.apple.com/documentation/vmnet/vmnet_start_interface(_:_:_:)
type Operating_modes_t ¶
type Operating_modes_t uint32
See: https://developer.apple.com/documentation/vmnet/operating_modes_t
const ( VMNET_BRIDGED_MODE Operating_modes_t = 1002 // VMNET_HOST_MODE: # Discussion VMNET_HOST_MODE Operating_modes_t = 1000 // VMNET_SHARED_MODE: # Discussion VMNET_SHARED_MODE Operating_modes_t = 1001 )
func (Operating_modes_t) String ¶ added in v0.5.1
func (e Operating_modes_t) String() string
type Vmnet_interface_completion_handler_t ¶
type Vmnet_interface_completion_handler_t = func(Vmnet_return_t)
See: https://developer.apple.com/documentation/vmnet/vmnet_interface_completion_handler_t
type Vmnet_interface_event_callback_t ¶
type Vmnet_interface_event_callback_t = func(Interface_event_t, objectivec.Object)
See: https://developer.apple.com/documentation/vmnet/vmnet_interface_event_callback_t
type Vmnet_interface_get_ip_port_forwarding_rules_handler_t ¶
type Vmnet_interface_get_ip_port_forwarding_rules_handler_t = func(objectivec.Object)
type Vmnet_interface_get_port_forwarding_rules_handler_t ¶
type Vmnet_interface_get_port_forwarding_rules_handler_t = func(objectivec.Object)
See: https://developer.apple.com/documentation/vmnet/vmnet_interface_get_port_forwarding_rules_handler_t
type Vmnet_mode_t ¶
type Vmnet_mode_t = Operating_modes_t
See: https://developer.apple.com/documentation/vmnet/vmnet_mode_t
type Vmnet_network_configuration_ref ¶
type Vmnet_network_configuration_ref = uintptr
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_ref
func Vmnet_network_configuration_create ¶
func Vmnet_network_configuration_create(mode Operating_modes_t, status *Vmnet_return_t) Vmnet_network_configuration_ref
Vmnet_network_configuration_create.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_create(_:_:)
type Vmnet_network_ref ¶
type Vmnet_network_ref = uintptr
See: https://developer.apple.com/documentation/vmnet/vmnet_network_ref
func Vmnet_network_create ¶
func Vmnet_network_create(configuration Vmnet_network_configuration_ref, status *Vmnet_return_t) Vmnet_network_ref
Vmnet_network_create.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_create(_:_:)
func Vmnet_network_create_with_serialization ¶
func Vmnet_network_create_with_serialization(network unsafe.Pointer, status *Vmnet_return_t) Vmnet_network_ref
Vmnet_network_create_with_serialization.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_create_with_serialization(_:_:)
type Vmnet_return_t ¶
type Vmnet_return_t uint32
See: https://developer.apple.com/documentation/vmnet/vmnet_return_t
const ( // VMNET_BUFFER_EXHAUSTED: # Discussion VMNET_BUFFER_EXHAUSTED Vmnet_return_t = 1007 // VMNET_FAILURE: # Discussion VMNET_FAILURE Vmnet_return_t = 1001 // VMNET_INVALID_ACCESS: # Discussion VMNET_INVALID_ACCESS Vmnet_return_t = 1005 // VMNET_INVALID_ARGUMENT: # Discussion VMNET_INVALID_ARGUMENT Vmnet_return_t = 1003 // VMNET_MEM_FAILURE: # Discussion VMNET_MEM_FAILURE Vmnet_return_t = 1002 VMNET_NOT_AUTHORIZED Vmnet_return_t = 1010 // VMNET_PACKET_TOO_BIG: # Discussion VMNET_PACKET_TOO_BIG Vmnet_return_t = 1006 // VMNET_SETUP_INCOMPLETE: # Discussion VMNET_SETUP_INCOMPLETE Vmnet_return_t = 1004 VMNET_SHARING_SERVICE_BUSY Vmnet_return_t = 1009 // VMNET_SUCCESS: # Discussion VMNET_SUCCESS Vmnet_return_t = 1000 // VMNET_TOO_MANY_PACKETS: # Discussion VMNET_TOO_MANY_PACKETS Vmnet_return_t = 1008 )
func Vmnet_interface_add_ip_port_forwarding_rule ¶
func Vmnet_interface_add_ip_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, address_family uint8, internal_address unsafe.Pointer, internal_port uint16, handler Vmnet_interface_completion_handler_t) Vmnet_return_t
Vmnet_interface_add_ip_port_forwarding_rule.
func Vmnet_interface_add_port_forwarding_rule
deprecated
func Vmnet_interface_add_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, internal_address uintptr, internal_port uint16, handler Vmnet_interface_completion_handler_t) Vmnet_return_t
Vmnet_interface_add_port_forwarding_rule.
Deprecated: Deprecated since macOS 12.0.
func Vmnet_interface_get_ip_port_forwarding_rules ¶
func Vmnet_interface_get_ip_port_forwarding_rules(interface_ Interface_ref, address_family kernel.U_int8_t, handler Vmnet_interface_get_ip_port_forwarding_rules_handler_t) Vmnet_return_t
Vmnet_interface_get_ip_port_forwarding_rules.
See: https://developer.apple.com/documentation/vmnet/vmnet_interface_get_ip_port_forwarding_rules(_:_:_:)
func Vmnet_interface_get_port_forwarding_rules
deprecated
func Vmnet_interface_get_port_forwarding_rules(interface_ Interface_ref, handler Vmnet_interface_get_port_forwarding_rules_handler_t) Vmnet_return_t
Vmnet_interface_get_port_forwarding_rules.
Deprecated: Deprecated since macOS 12.0.
See: https://developer.apple.com/documentation/vmnet/vmnet_interface_get_port_forwarding_rules(_:_:)
func Vmnet_interface_remove_ip_port_forwarding_rule ¶
func Vmnet_interface_remove_ip_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, address_family uint8, handler Vmnet_interface_completion_handler_t) Vmnet_return_t
Vmnet_interface_remove_ip_port_forwarding_rule.
func Vmnet_interface_remove_port_forwarding_rule
deprecated
func Vmnet_interface_remove_port_forwarding_rule(interface_ Interface_ref, protocol_ uint8, external_port uint16, handler Vmnet_interface_completion_handler_t) Vmnet_return_t
Vmnet_interface_remove_port_forwarding_rule.
Deprecated: Deprecated since macOS 12.0.
func Vmnet_interface_set_event_callback ¶
func Vmnet_interface_set_event_callback(interface_ Interface_ref, event_mask Interface_event_t, queue dispatch.Queue, callback Vmnet_interface_event_callback_t) Vmnet_return_t
Vmnet_interface_set_event_callback schedules a callback to be executed when events for the specified interface are received.
See: https://developer.apple.com/documentation/vmnet/vmnet_interface_set_event_callback(_:_:_:_:)
func Vmnet_ip_port_forwarding_rule_get_details ¶
func Vmnet_ip_port_forwarding_rule_get_details(rule unsafe.Pointer, protocol_ *uint8, external_port *uint16, address_family uint8, internal_address unsafe.Pointer, internal_port *uint16) Vmnet_return_t
Vmnet_ip_port_forwarding_rule_get_details.
func Vmnet_network_configuration_add_port_forwarding_rule ¶
func Vmnet_network_configuration_add_port_forwarding_rule(config Vmnet_network_configuration_ref, protocol_ uint8, address_family uint8, internal_port uint16, external_port uint16, internal_address unsafe.Pointer) Vmnet_return_t
Vmnet_network_configuration_add_port_forwarding_rule.
func Vmnet_network_configuration_set_external_interface ¶
func Vmnet_network_configuration_set_external_interface(config Vmnet_network_configuration_ref, interface_name string) Vmnet_return_t
Vmnet_network_configuration_set_external_interface.
func Vmnet_network_configuration_set_ipv4_subnet ¶
func Vmnet_network_configuration_set_ipv4_subnet(config Vmnet_network_configuration_ref, subnet_addr uintptr, subnet_mask uintptr) Vmnet_return_t
Vmnet_network_configuration_set_ipv4_subnet.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_set_ipv4_subnet(_:_:_:)
func Vmnet_network_configuration_set_ipv6_prefix ¶
func Vmnet_network_configuration_set_ipv6_prefix(config Vmnet_network_configuration_ref, prefix uintptr, len_ uint8) Vmnet_return_t
Vmnet_network_configuration_set_ipv6_prefix.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_set_ipv6_prefix(_:_:_:)
func Vmnet_network_configuration_set_mtu ¶
func Vmnet_network_configuration_set_mtu(config Vmnet_network_configuration_ref, mtu uint32) Vmnet_return_t
Vmnet_network_configuration_set_mtu.
See: https://developer.apple.com/documentation/vmnet/vmnet_network_configuration_set_mtu(_:_:)
func Vmnet_port_forwarding_rule_get_details
deprecated
func Vmnet_port_forwarding_rule_get_details(rule unsafe.Pointer, protocol_ *uint8, external_port *uint16, internal_address uintptr, internal_port *uint16) Vmnet_return_t
Vmnet_port_forwarding_rule_get_details.
Deprecated: Deprecated since macOS 12.0.
See: https://developer.apple.com/documentation/vmnet/vmnet_port_forwarding_rule_get_details(_:_:_:_:_:)
func Vmnet_read ¶
func Vmnet_read(interface_ Interface_ref, packets *Vmpktdesc, pktcnt []int) Vmnet_return_t
Vmnet_read attempts to read a specified number of packets from an interface.
See: https://developer.apple.com/documentation/vmnet/vmnet_read(_:_:_:)
func Vmnet_stop_interface ¶
func Vmnet_stop_interface(interface_ Interface_ref, queue dispatch.Queue, handler Vmnet_interface_completion_handler_t) Vmnet_return_t
Vmnet_stop_interface stops the interface.
See: https://developer.apple.com/documentation/vmnet/vmnet_stop_interface(_:_:_:)
func Vmnet_write ¶
func Vmnet_write(interface_ Interface_ref, packets *Vmpktdesc, pktcnt []int) Vmnet_return_t
Vmnet_write attempts to write specified packets to an interface.
See: https://developer.apple.com/documentation/vmnet/vmnet_write(_:_:_:)
func (Vmnet_return_t) String ¶ added in v0.5.1
func (e Vmnet_return_t) String() string
type Vmnet_start_interface_completion_handler_t ¶
type Vmnet_start_interface_completion_handler_t = func(Vmnet_return_t, objectivec.Object)
See: https://developer.apple.com/documentation/vmnet/vmnet_start_interface_completion_handler_t
type Vmpktdesc ¶
type Vmpktdesc struct {
Vm_pkt_size uintptr // The size of the packet, in bytes.
Vm_pkt_iovcnt uint32 // The number of packet buffers in `vm_pkt_iov`.
Vm_flags uint32 // Option flags. Should be set to `0` on read.
Vm_pkt_iov *kernel.Iovec // An array of packet buffers.
}
Vmpktdesc - Describes a packet.
[Full Topic] [Full Topic]: https://developer.apple.com/documentation/vmnet/vmpktdesc