-
-
Save AntonioMeireles/ece4e39d4b0234d4d8ca37e9f52462b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/components/host/darwin/misc/uuid2ip/uuid2ip.c b/components/host/darwin/misc/uuid2ip/uuid2ip.c | |
index 7152699..f103087 100644 | |
--- a/components/host/darwin/misc/uuid2ip/uuid2ip.c | |
+++ b/components/host/darwin/misc/uuid2ip/uuid2ip.c | |
@@ -67,6 +67,8 @@ vmnet_get_mac_address_from_uuid(char *guest_uuid_str) { | |
__block char* mac = malloc(18); | |
dispatch_semaphore_t iface_created, iface_stopped; | |
dispatch_queue_t if_create_q, if_stop_q; | |
+ dispatch_queue_t if_q; | |
+ struct vmnet_state *vms; | |
uint32_t uuid_status; | |
interface_desc = xpc_dictionary_create(NULL, NULL, 0); | |
@@ -81,6 +83,12 @@ vmnet_get_mac_address_from_uuid(char *guest_uuid_str) { | |
xpc_dictionary_set_uuid(interface_desc, vmnet_interface_id_key, uuid); | |
iface = NULL; | |
iface_status = 0; | |
+ vms = malloc(sizeof(struct vmnet_state)); | |
+ | |
+ if (!vms) { | |
+ fprintf(stderr, "ISE (:89)\n"); | |
+ return NULL; | |
+ } | |
if_create_q = dispatch_queue_create("org.xhyve.vmnet.create", DISPATCH_QUEUE_SERIAL); | |
@@ -95,10 +103,14 @@ vmnet_get_mac_address_from_uuid(char *guest_uuid_str) { | |
return; | |
} | |
- //printf("%s\n", xpc_dictionary_get_string(interface_param, vmnet_mac_address_key)); | |
const char *macStr = xpc_dictionary_get_string(interface_param, vmnet_mac_address_key); | |
strcpy(mac, macStr); | |
+ vms->mtu = (unsigned) | |
+ xpc_dictionary_get_uint64(interface_param, vmnet_mtu_key); | |
+ vms->max_packet_size = (unsigned) | |
+ xpc_dictionary_get_uint64(interface_param, | |
+ vmnet_max_packet_size_key); | |
dispatch_semaphore_signal(iface_created); | |
}); | |
@@ -108,6 +120,7 @@ vmnet_get_mac_address_from_uuid(char *guest_uuid_str) { | |
if (iface == NULL || iface_status != VMNET_SUCCESS) { | |
fprintf(stderr, "virtio_net: Could not create vmnet interface, " | |
"permission denied or no entitlement?\n"); | |
+ free(vms); | |
return NULL; | |
} | |
@@ -130,6 +143,7 @@ vmnet_get_mac_address_from_uuid(char *guest_uuid_str) { | |
if (iface_status != VMNET_SUCCESS) { | |
fprintf(stderr, "virtio_net: Could not stop vmnet interface, " | |
"permission denied or no entitlement?\n"); | |
+ free(vms); | |
return NULL; | |
} | |
diff --git a/components/host/darwin/misc/uuid2ip/uuid2ip.h b/components/host/darwin/misc/uuid2ip/uuid2ip.h | |
index da950e9..d62577e 100644 | |
--- a/components/host/darwin/misc/uuid2ip/uuid2ip.h | |
+++ b/components/host/darwin/misc/uuid2ip/uuid2ip.h | |
@@ -50,6 +50,13 @@ struct uuid { | |
uint8_t clock_seq_low; | |
uint8_t node[_UUID_NODE_LEN]; | |
}; | |
+struct vmnet_state { | |
+ interface_ref iface; | |
+ uint8_t mac[6]; | |
+ unsigned int mtu; | |
+ unsigned int max_packet_size; | |
+}; | |
+ | |
#pragma clang diagnostic pop | |
typedef struct uuid uuid_internal_t; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment