From: Eric Karge Date: Fri, 11 Oct 2024 14:43:54 +0000 (+0200) Subject: Read vmnet options from config X-Git-Url: https://www.tinc-vpn.org/git/?a=commitdiff_plain;h=0c7f7dbc87fb1582a09beb81adac5c7110c891a1;p=tinc Read vmnet options from config --- diff --git a/src/bsd/darwin/vmnet.c b/src/bsd/darwin/vmnet.c index 74196e8b..8eef73de 100644 --- a/src/bsd/darwin/vmnet.c +++ b/src/bsd/darwin/vmnet.c @@ -49,6 +49,14 @@ int macos_vmnet_open(void) { xpc_dictionary_set_uint64(if_desc, vmnet_operation_mode_key, VMNET_HOST_MODE); xpc_dictionary_set_bool(if_desc, vmnet_enable_isolation_key, 0); xpc_dictionary_set_bool(if_desc, vmnet_allocate_mac_address_key, false); + if (macos_vmnet_addr) { + xpc_dictionary_set_string(if_desc, vmnet_start_address_key, macos_vmnet_addr); + xpc_dictionary_set_string(if_desc, vmnet_end_address_key, macos_vmnet_addr); + xpc_dictionary_set_string(if_desc, vmnet_subnet_mask_key, macos_vmnet_netmask); + } + if (macos_vmnet_nat66_prefix) { + xpc_dictionary_set_string(if_desc, vmnet_nat66_prefix_key, macos_vmnet_nat66_prefix); + } dispatch_semaphore_t if_started_sem = dispatch_semaphore_create(0); vmnet_if = vmnet_start_interface( diff --git a/src/bsd/darwin/vmnet.h b/src/bsd/darwin/vmnet.h index 87b83823..08cc35d1 100644 --- a/src/bsd/darwin/vmnet.h +++ b/src/bsd/darwin/vmnet.h @@ -22,6 +22,10 @@ #include +char * macos_vmnet_addr; +char * macos_vmnet_netmask; +char * macos_vmnet_nat66_prefix; + int macos_vmnet_open(void); int macos_vmnet_close(int fd); ssize_t macos_vmnet_write(uint8_t *buffer, size_t buflen); diff --git a/src/bsd/device.c b/src/bsd/device.c index 84357fd2..9294860c 100644 --- a/src/bsd/device.c +++ b/src/bsd/device.c @@ -156,6 +156,9 @@ static bool setup_device(void) { else if(!strcasecmp(type, "vmnet")) { device = xstrdup("vmnet"); device_type = DEVICE_TYPE_VMNET; + get_config_string(lookup_config(&config_tree, "VmnetAddr"), &macos_vmnet_addr); + get_config_string(lookup_config(&config_tree, "VmnetNetmask"), &macos_vmnet_netmask); + get_config_string(lookup_config(&config_tree, "VmnetNat66Prefix"), &macos_vmnet_nat66_prefix); } #endif