make MAC randomization optional
This commit is contained in:
parent
c29e630314
commit
abccc44eec
|
@ -56,6 +56,8 @@ ConfigEntry ConfigFile[] =
|
|||
{"DSiFirmwarePath", 1, DSiFirmwarePath, 0, "", 1023},
|
||||
{"DSiNANDPath", 1, DSiNANDPath, 0, "", 1023},
|
||||
|
||||
{"RandomizeMAC", 0, &RandomizeMAC, 0, NULL, 0},
|
||||
|
||||
#ifdef JIT_ENABLED
|
||||
{"JIT_Enable", 0, &JIT_Enable, 0, NULL, 0},
|
||||
{"JIT_MaxBlockSize", 0, &JIT_MaxBlockSize, 32, NULL, 0},
|
||||
|
|
|
@ -51,6 +51,8 @@ extern char DSiBIOS7Path[1024];
|
|||
extern char DSiFirmwarePath[1024];
|
||||
extern char DSiNANDPath[1024];
|
||||
|
||||
extern int RandomizeMAC;
|
||||
|
||||
#ifdef JIT_ENABLED
|
||||
extern int JIT_Enable;
|
||||
extern int JIT_MaxBlockSize;
|
||||
|
|
25
src/SPI.cpp
25
src/SPI.cpp
|
@ -179,24 +179,25 @@ void Reset()
|
|||
//Firmware[userdata+0x64] &= 0xBF;
|
||||
|
||||
*(u16*)&Firmware[userdata+0x72] = CRC16(&Firmware[userdata], 0x70, 0xFFFF);
|
||||
|
||||
if (Config::RandomizeMAC)
|
||||
{
|
||||
// replace MAC address with random address
|
||||
Firmware[0x36] = 0x00;
|
||||
Firmware[0x37] = 0x09;
|
||||
Firmware[0x38] = 0xBF;
|
||||
Firmware[0x39] = rand()&0xFF;
|
||||
Firmware[0x3A] = rand()&0xFF;
|
||||
Firmware[0x3B] = rand()&0xFF;
|
||||
|
||||
*(u16*)&Firmware[0x2A] = CRC16(&Firmware[0x2C], *(u16*)&Firmware[0x2C], 0x0000);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
// replace MAC address with random address
|
||||
// TODO: make optional?
|
||||
Firmware[0x36] = 0x00;
|
||||
Firmware[0x37] = 0x09;
|
||||
Firmware[0x38] = 0xBF;
|
||||
Firmware[0x39] = rand()&0xFF;
|
||||
Firmware[0x3A] = rand()&0xFF;
|
||||
Firmware[0x3B] = rand()&0xFF;
|
||||
#endif
|
||||
printf("MAC: %02X:%02X:%02X:%02X:%02X:%02X\n",
|
||||
Firmware[0x36], Firmware[0x37], Firmware[0x38],
|
||||
Firmware[0x39], Firmware[0x3A], Firmware[0x3B]);
|
||||
|
||||
//*(u16*)&Firmware[0x2A] = CRC16(&Firmware[0x2C], *(u16*)&Firmware[0x2C], 0x0000);
|
||||
|
||||
// verify shit
|
||||
printf("FW: WIFI CRC16 = %s\n", VerifyCRC16(0x0000, 0x2C, *(u16*)&Firmware[0x2C], 0x2A)?"GOOD":"BAD");
|
||||
printf("FW: AP1 CRC16 = %s\n", VerifyCRC16(0x0000, 0x7FA00&FirmwareMask, 0xFE, 0x7FAFE&FirmwareMask)?"GOOD":"BAD");
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "types.h"
|
||||
#include "Platform.h"
|
||||
|
@ -41,6 +41,10 @@
|
|||
|
||||
WifiSettingsDialog* WifiSettingsDialog::currentDlg = nullptr;
|
||||
|
||||
bool WifiSettingsDialog::needsReset = false;
|
||||
|
||||
extern bool RunningSomething;
|
||||
|
||||
|
||||
WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(new Ui::WifiSettingsDialog)
|
||||
{
|
||||
|
@ -53,6 +57,7 @@ WifiSettingsDialog::WifiSettingsDialog(QWidget* parent) : QDialog(parent), ui(ne
|
|||
ui->cbDirectMode->setText("Direct mode (requires " PCAP_NAME " and ethernet connection)");
|
||||
|
||||
ui->cbBindAnyAddr->setChecked(Config::SocketBindAnyAddr != 0);
|
||||
ui->cbRandomizeMAC->setChecked(Config::RandomizeMAC != 0);
|
||||
|
||||
int sel = 0;
|
||||
for (int i = 0; i < LAN_PCap::NumAdapters; i++)
|
||||
|
@ -77,33 +82,49 @@ WifiSettingsDialog::~WifiSettingsDialog()
|
|||
delete ui;
|
||||
}
|
||||
|
||||
void WifiSettingsDialog::on_WifiSettingsDialog_accepted()
|
||||
void WifiSettingsDialog::done(int r)
|
||||
{
|
||||
Config::SocketBindAnyAddr = ui->cbBindAnyAddr->isChecked() ? 1:0;
|
||||
Config::DirectLAN = ui->cbDirectMode->isChecked() ? 1:0;
|
||||
needsReset = false;
|
||||
|
||||
int sel = ui->cbxDirectAdapter->currentIndex();
|
||||
if (sel < 0 || sel >= LAN_PCap::NumAdapters) sel = 0;
|
||||
if (LAN_PCap::NumAdapters < 1)
|
||||
if (r == QDialog::Accepted)
|
||||
{
|
||||
Config::LANDevice[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(Config::LANDevice, LAN_PCap::Adapters[sel].DeviceName, 127);
|
||||
Config::LANDevice[127] = '\0';
|
||||
int randommac = ui->cbRandomizeMAC->isChecked() ? 1:0;
|
||||
|
||||
if (randommac != Config::RandomizeMAC)
|
||||
{
|
||||
if (RunningSomething
|
||||
&& QMessageBox::warning(this, "Reset necessary to apply changes",
|
||||
"The emulation will be reset for the changes to take place.",
|
||||
QMessageBox::Ok, QMessageBox::Cancel) != QMessageBox::Ok)
|
||||
return;
|
||||
}
|
||||
|
||||
Config::SocketBindAnyAddr = ui->cbBindAnyAddr->isChecked() ? 1:0;
|
||||
Config::RandomizeMAC = randommac;
|
||||
Config::DirectLAN = ui->cbDirectMode->isChecked() ? 1:0;
|
||||
|
||||
int sel = ui->cbxDirectAdapter->currentIndex();
|
||||
if (sel < 0 || sel >= LAN_PCap::NumAdapters) sel = 0;
|
||||
if (LAN_PCap::NumAdapters < 1)
|
||||
{
|
||||
Config::LANDevice[0] = '\0';
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy(Config::LANDevice, LAN_PCap::Adapters[sel].DeviceName, 127);
|
||||
Config::LANDevice[127] = '\0';
|
||||
}
|
||||
|
||||
Config::Save();
|
||||
|
||||
needsReset = true;
|
||||
}
|
||||
|
||||
Config::Save();
|
||||
QDialog::done(r);
|
||||
|
||||
closeDlg();
|
||||
}
|
||||
|
||||
void WifiSettingsDialog::on_WifiSettingsDialog_rejected()
|
||||
{
|
||||
closeDlg();
|
||||
}
|
||||
|
||||
void WifiSettingsDialog::on_cbDirectMode_stateChanged(int state)
|
||||
{
|
||||
updateAdapterControls();
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
}
|
||||
|
||||
currentDlg = new WifiSettingsDialog(parent);
|
||||
currentDlg->show();
|
||||
currentDlg->open();
|
||||
return currentDlg;
|
||||
}
|
||||
static void closeDlg()
|
||||
|
@ -50,9 +50,10 @@ public:
|
|||
currentDlg = nullptr;
|
||||
}
|
||||
|
||||
static bool needsReset;
|
||||
|
||||
private slots:
|
||||
void on_WifiSettingsDialog_accepted();
|
||||
void on_WifiSettingsDialog_rejected();
|
||||
void done(int r);
|
||||
|
||||
void on_cbDirectMode_stateChanged(int state);
|
||||
void on_cbxDirectAdapter_currentIndexChanged(int sel);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>479</width>
|
||||
<height>217</height>
|
||||
<height>240</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
|
@ -39,6 +39,16 @@
|
|||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="cbRandomizeMAC">
|
||||
<property name="whatsThis">
|
||||
<string><html><head/><body><p>Randomizes the console's MAC address upon reset. Required for local multiplayer if each melonDS instance uses the same firmware file.</p></body></html></string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Randomize MAC address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
@ -1747,14 +1747,14 @@ void MainWindow::onAudioSettingsFinished(int res)
|
|||
|
||||
void MainWindow::onOpenWifiSettings()
|
||||
{
|
||||
emuThread->emuPause();
|
||||
|
||||
WifiSettingsDialog* dlg = WifiSettingsDialog::openDlg(this);
|
||||
connect(dlg, &WifiSettingsDialog::finished, this, &MainWindow::onWifiSettingsFinished);
|
||||
}
|
||||
|
||||
void MainWindow::onWifiSettingsFinished(int res)
|
||||
{
|
||||
emuThread->emuPause();
|
||||
|
||||
if (Wifi::MPInited)
|
||||
{
|
||||
Platform::MP_DeInit();
|
||||
|
@ -1764,6 +1764,9 @@ void MainWindow::onWifiSettingsFinished(int res)
|
|||
Platform::LAN_DeInit();
|
||||
Platform::LAN_Init();
|
||||
|
||||
if (WifiSettingsDialog::needsReset)
|
||||
onReset();
|
||||
|
||||
emuThread->emuUnpause();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue