mirror of
https://github.com/open-simh/simh.git
synced 2026-01-29 05:11:56 +00:00
Keep track of generated vmnet MAC addr
The vmnet interface created for a simh instance has its own MAC address. It doesn't seem too useful to for simh itself (you can just use whatever MAC address and send/receive frames with that), but it does make referencing it in other places (i.e. SHOW ETHERNET vs. ifconfig) easier. The generated MAC address is provided at interface creation time; while we could look it up earlier like with pcap, this seems more efficient.
This commit is contained in:
committed by
Paul Koning
parent
a0df08ad95
commit
6fd146ae66
22
sim_ether.c
22
sim_ether.c
@@ -1805,6 +1805,10 @@ return tool;
|
|||||||
|
|
||||||
static void eth_get_nic_hw_addr(ETH_DEV* dev, const char *devname, int set_on)
|
static void eth_get_nic_hw_addr(ETH_DEV* dev, const char *devname, int set_on)
|
||||||
{
|
{
|
||||||
|
// we set this at interface creation time in open_port for vmnet
|
||||||
|
if (dev->eth_api == ETH_API_VMN) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
memset(&dev->host_nic_phy_hw_addr, 0, sizeof(dev->host_nic_phy_hw_addr));
|
memset(&dev->host_nic_phy_hw_addr, 0, sizeof(dev->host_nic_phy_hw_addr));
|
||||||
dev->have_host_nic_phy_addr = 0;
|
dev->have_host_nic_phy_addr = 0;
|
||||||
if (dev->eth_api != ETH_API_PCAP)
|
if (dev->eth_api != ETH_API_PCAP)
|
||||||
@@ -2361,9 +2365,27 @@ memset(errbuf, 0, PCAP_ERRBUF_SIZE);
|
|||||||
|
|
||||||
cb_finished = dispatch_semaphore_create(0);
|
cb_finished = dispatch_semaphore_create(0);
|
||||||
|
|
||||||
|
// Set the MAC address
|
||||||
|
__block ETH_DEV *eth_dev = (ETH_DEV*)opaque;
|
||||||
|
|
||||||
vmn_interface = vmnet_start_interface(if_desc, vmn_queue, ^(vmnet_return_t status, xpc_object_t params){
|
vmn_interface = vmnet_start_interface(if_desc, vmn_queue, ^(vmnet_return_t status, xpc_object_t params){
|
||||||
vmn_status = status;
|
vmn_status = status;
|
||||||
|
|
||||||
|
if (vmn_status == VMNET_SUCCESS) {
|
||||||
|
// Scan like eth_scan_mac but simplified (only one format)
|
||||||
|
const char *mac_string = xpc_dictionary_get_string(params, vmnet_mac_address_key);
|
||||||
|
int a[6];
|
||||||
|
if (6 == sscanf(mac_string, "%x:%x:%x:%x:%x:%x", &a[0], &a[1], &a[2], &a[3], &a[4], &a[5])) {
|
||||||
|
eth_dev->have_host_nic_phy_addr = 1;
|
||||||
|
eth_dev->host_nic_phy_hw_addr[0] = a[0];
|
||||||
|
eth_dev->host_nic_phy_hw_addr[1] = a[1];
|
||||||
|
eth_dev->host_nic_phy_hw_addr[2] = a[2];
|
||||||
|
eth_dev->host_nic_phy_hw_addr[3] = a[3];
|
||||||
|
eth_dev->host_nic_phy_hw_addr[4] = a[4];
|
||||||
|
eth_dev->host_nic_phy_hw_addr[5] = a[5];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dispatch_semaphore_signal(cb_finished);
|
dispatch_semaphore_signal(cb_finished);
|
||||||
});
|
});
|
||||||
dispatch_semaphore_wait(cb_finished, DISPATCH_TIME_FOREVER);
|
dispatch_semaphore_wait(cb_finished, DISPATCH_TIME_FOREVER);
|
||||||
|
|||||||
Reference in New Issue
Block a user