DEV9: Generate unique MAC for TAP, much like pcap backend does

This commit is contained in:
TheLastRar 2020-12-29 22:57:54 +00:00 committed by refractionpcsx2
parent 5f2441e832
commit bae445d9d2
1 changed files with 22 additions and 1 deletions

View File

@ -197,10 +197,19 @@ vector<tap_adapter>* GetTapAdapters()
return tap_nic;
}
static int TAPGetMACAddress(HANDLE handle, u8* addr)
{
DWORD len = 0;
return DeviceIoControl(handle, TAP_IOCTL_GET_MAC,
addr, 6,
addr, 6, &len, NULL);
}
//Set the connection status
static int TAPSetStatus(HANDLE handle, int status)
{
unsigned long len = 0;
DWORD len = 0;
return DeviceIoControl(handle, TAP_IOCTL_SET_MEDIA_STATUS,
&status, sizeof(status),
@ -275,6 +284,18 @@ TAPAdapter::TAPAdapter()
cancel = CreateEvent(NULL, TRUE, FALSE, NULL);
u8 hostMAC[6];
u8 newMAC[6];
TAPGetMACAddress(htap, hostMAC);
memcpy(newMAC, ps2MAC, 6);
//Lets take the hosts last 2 bytes to make it unique on Xlink
newMAC[5] = hostMAC[4];
newMAC[4] = hostMAC[5];
SetMACAddress(newMAC);
isActive = true;
}