]> tinc-vpn.org Git - tinc/commitdiff
Read vmnet options from config
authorEric Karge <eric.karge@innoq.com>
Fri, 11 Oct 2024 14:43:54 +0000 (16:43 +0200)
committerGuus Sliepen <guus@tinc-vpn.org>
Mon, 30 Mar 2026 20:32:34 +0000 (22:32 +0200)
src/bsd/darwin/vmnet.c
src/bsd/darwin/vmnet.h
src/bsd/device.c

index 74196e8b1780ca499ddc905b6c4b5e76dabf7ced..8eef73de2d2162c01ee0413dae9e71cc5dd83d2d 100644 (file)
@@ -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(
index 87b8382336e93ce73d51dbd8e61ca859a2ac7bf5..08cc35d1ecaa09b11172f5bbbad84852c6ac48a1 100644 (file)
 
 #include <sys/types.h>
 
+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);
index 84357fd23de0980b24da6cdfff5d4c050b4f058f..9294860c8b083f2623a8496444bf624a405aa9b5 100644 (file)
@@ -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