dev9ghzdrk: Make the MAC truely unique, fixes issue #552

-Version bump to reflect the awesomeness
-Put most of the mac variables in one place (not that they do much)
This commit is contained in:
refractionpcsx2 2015-06-24 01:36:01 +01:00
parent ee9b1caaa4
commit 819133ee45
4 changed files with 25 additions and 13 deletions

View File

@ -56,7 +56,7 @@ u32 *iopPC;
const unsigned char version = PS2E_DEV9_VERSION;
const unsigned char revision = 0;
const unsigned char build = 3; // increase that with each version
const unsigned char build = 4; // increase that with each version
static char *libraryName = "GiGaHeRz's DEV9 Driver"

View File

@ -143,7 +143,7 @@ typedef struct _full_arp_packet
extern mac_address virtual_mac;
extern mac_address broadcast_mac;
extern mac_address gateway_mac;
extern ip_address virtual_ip;
#define mac_compare(a,b) (memcmp(&(a),&(b),6))

View File

@ -29,10 +29,10 @@ extern "C" {
#include <vector>
//extern "C" int emu_printf(const char *fmt, ...);
mac_address gateway_mac = { 0x76, 0x6D, 0x61, 0x63, 0x30, 0x32 };
mac_address virtual_mac = { 0x76, 0x6D, 0x61, 0x63, 0x30, 0x31 };
mac_address broadcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
/*
mac_address gateway_mac = { 0x76, 0x6D, 0x61, 0x63, 0x31, 0x32 };
mac_address virtual_mac = { 0x76, 0x6D, 0x61, 0x63, 0x31, 0x31 };
mac_address broadcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };*/
//mac_address host_mac = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

View File

@ -32,12 +32,13 @@ pcap_m_e pcap_mode=switched;
mac_address virtual_mac = { 0x76, 0x6D, 0x61, 0x63, 0x30, 0x31 };
//mac_address virtual_mac = { 0x6D, 0x76, 0x63, 0x61, 0x31, 0x30 };
mac_address broadcast_mac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
mac_address gateway_mac = { 0x76, 0x6D, 0x61, 0x63, 0x31, 0x32 };
ip_address virtual_ip = { 192, 168, 1, 4};
pcap_t *adhandle;
int pcap_io_running=0;
extern u8 eeprom[];
char errbuf[PCAP_ERRBUF_SIZE];
char namebuff[256];
@ -82,14 +83,25 @@ int pcap_io_init(char *adapter)
int dlt;
char *dlt_name;
emu_printf("Opening adapter '%s'...",adapter);
u16 checksum;
GetMACAddress(adapter,&host_mac);
//Lets take the hosts first 3 bytes to bytes to make it unique
virtual_mac.bytes[0] = host_mac.bytes[0];
virtual_mac.bytes[1] = host_mac.bytes[1];
virtual_mac.bytes[2] = host_mac.bytes[2];
//Near copy of the host mac, butchered slightly, should be pretty good!
eeprom[0] = host_mac.bytes[0];
eeprom[1] = host_mac.bytes[1];
eeprom[2] = host_mac.bytes[2];
eeprom[3] = host_mac.bytes[2];
eeprom[4] = host_mac.bytes[5];
eeprom[5] = host_mac.bytes[4];
//The checksum seems to be all the values of the mac added up in 16bit chunks
checksum = dev9.eeprom[0] + dev9.eeprom[1] + dev9.eeprom[2] & 0xffff;
dev9.eeprom[3] = checksum;
//emu_printf("eeprom Mac set to %x %x %x %x %x %x", eeprom[0], eeprom[1], eeprom[2], eeprom[3], eeprom[4], eeprom[5]);
//emu_printf("Checksum %x %x", eeprom[6], eeprom[7]);
/* Open the adapter */
if ((adhandle= pcap_open_live(adapter, // name of the device
65536, // portion of the packet to capture.