mirror of https://github.com/PCSX2/pcsx2.git
Config: Add DEV9 options to global struct
Additionally switch to using std::string in various locations in DEV9
This commit is contained in:
parent
6df50992c4
commit
5ff49a78eb
|
@ -784,9 +784,6 @@ if(PCSX2_CORE)
|
||||||
list(APPEND pcsx2SPU2Headers
|
list(APPEND pcsx2SPU2Headers
|
||||||
SPU2/WavFile.cpp
|
SPU2/WavFile.cpp
|
||||||
)
|
)
|
||||||
list(APPEND pcsx2DEV9Sources
|
|
||||||
DEV9/Linux/Config.cpp
|
|
||||||
)
|
|
||||||
endif()
|
endif()
|
||||||
elseif(WIN32)
|
elseif(WIN32)
|
||||||
list(APPEND pcsx2SPU2Sources
|
list(APPEND pcsx2SPU2Sources
|
||||||
|
@ -807,7 +804,6 @@ elseif(WIN32)
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND pcsx2DEV9Sources
|
list(APPEND pcsx2DEV9Sources
|
||||||
DEV9/Win32/DEV9WinConfig.cpp
|
|
||||||
DEV9/Win32/pcap_io_win32.cpp
|
DEV9/Win32/pcap_io_win32.cpp
|
||||||
DEV9/Win32/tap-win32.cpp
|
DEV9/Win32/tap-win32.cpp
|
||||||
)
|
)
|
||||||
|
@ -878,10 +874,6 @@ else()
|
||||||
SPU2/wx/wxConfig.h
|
SPU2/wx/wxConfig.h
|
||||||
)
|
)
|
||||||
|
|
||||||
list(APPEND pcsx2DEV9Sources
|
|
||||||
DEV9/Linux/Config.cpp
|
|
||||||
)
|
|
||||||
|
|
||||||
list(APPEND pcsx2USBSources
|
list(APPEND pcsx2USBSources
|
||||||
USB/icon_buzz_24.cpp
|
USB/icon_buzz_24.cpp
|
||||||
USB/linux/config-gtk.cpp
|
USB/linux/config-gtk.cpp
|
||||||
|
|
|
@ -633,6 +633,80 @@ struct Pcsx2Config
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DEV9Options
|
||||||
|
{
|
||||||
|
enum struct NetApi : int
|
||||||
|
{
|
||||||
|
Unset = 0,
|
||||||
|
PCAP_Bridged = 1,
|
||||||
|
PCAP_Switched = 2,
|
||||||
|
TAP = 3,
|
||||||
|
};
|
||||||
|
|
||||||
|
static const char* NetApiNames[];
|
||||||
|
|
||||||
|
bool EthEnable{false};
|
||||||
|
NetApi EthApi{NetApi::Unset};
|
||||||
|
std::string EthDevice;
|
||||||
|
bool EthLogDNS{false};
|
||||||
|
|
||||||
|
bool InterceptDHCP{false};
|
||||||
|
u8 PS2IP[4]{};
|
||||||
|
u8 Mask[4]{};
|
||||||
|
u8 Gateway[4]{};
|
||||||
|
u8 DNS1[4]{};
|
||||||
|
u8 DNS2[4]{};
|
||||||
|
bool AutoMask{true};
|
||||||
|
bool AutoGateway{true};
|
||||||
|
bool AutoDNS1{true};
|
||||||
|
bool AutoDNS2{true};
|
||||||
|
|
||||||
|
bool HddEnable{false};
|
||||||
|
std::string HddFile;
|
||||||
|
|
||||||
|
/* The PS2's HDD max size is 2TB
|
||||||
|
* which is 2^32 * 512 byte sectors
|
||||||
|
* Note that we don't yet support
|
||||||
|
* 48bit LBA, so our limit is lower */
|
||||||
|
uint HddSizeSectors{0};
|
||||||
|
|
||||||
|
DEV9Options();
|
||||||
|
|
||||||
|
void LoadSave(SettingsWrapper& wrap);
|
||||||
|
|
||||||
|
bool operator==(const DEV9Options& right) const
|
||||||
|
{
|
||||||
|
return OpEqu(EthEnable) &&
|
||||||
|
OpEqu(EthApi) &&
|
||||||
|
OpEqu(EthDevice) &&
|
||||||
|
OpEqu(EthLogDNS) &&
|
||||||
|
|
||||||
|
OpEqu(InterceptDHCP) &&
|
||||||
|
(*(int*)PS2IP == *(int*)right.PS2IP) &&
|
||||||
|
(*(int*)Gateway == *(int*)right.Gateway) &&
|
||||||
|
(*(int*)DNS1 == *(int*)right.DNS1) &&
|
||||||
|
(*(int*)DNS2 == *(int*)right.DNS2) &&
|
||||||
|
|
||||||
|
OpEqu(AutoMask) &&
|
||||||
|
OpEqu(AutoGateway) &&
|
||||||
|
OpEqu(AutoDNS1) &&
|
||||||
|
OpEqu(AutoDNS2) &&
|
||||||
|
|
||||||
|
OpEqu(HddEnable) &&
|
||||||
|
OpEqu(HddFile) &&
|
||||||
|
OpEqu(HddSizeSectors);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool operator!=(const DEV9Options& right) const
|
||||||
|
{
|
||||||
|
return !this->operator==(right);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
static void LoadIPHelper(u8* field, const std::string& setting);
|
||||||
|
static std::string SaveIPHelper(u8* field);
|
||||||
|
};
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// NOTE: The GUI's GameFixes panel is dependent on the order of bits in this structure.
|
// NOTE: The GUI's GameFixes panel is dependent on the order of bits in this structure.
|
||||||
struct GamefixOptions
|
struct GamefixOptions
|
||||||
|
@ -833,6 +907,7 @@ struct Pcsx2Config
|
||||||
DebugOptions Debugger;
|
DebugOptions Debugger;
|
||||||
FramerateOptions Framerate;
|
FramerateOptions Framerate;
|
||||||
SPU2Options SPU2;
|
SPU2Options SPU2;
|
||||||
|
DEV9Options DEV9;
|
||||||
|
|
||||||
TraceLogFilters Trace;
|
TraceLogFilters Trace;
|
||||||
|
|
||||||
|
|
|
@ -171,7 +171,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//Info
|
//Info
|
||||||
void CreateHDDinfo(int sizeMb);
|
void CreateHDDinfo(u64 sizeSectors);
|
||||||
void CreateHDDinfoCsum();
|
void CreateHDDinfoCsum();
|
||||||
|
|
||||||
//State
|
//State
|
||||||
|
|
|
@ -44,11 +44,11 @@ void ATA::WritePaddedString(u8* data, int* index, std::string value, u32 len)
|
||||||
*index += len;
|
*index += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ATA::CreateHDDinfo(int sizeMb)
|
void ATA::CreateHDDinfo(u64 sizeSectors)
|
||||||
{
|
{
|
||||||
const u16 sectorSize = 512;
|
const u16 sectorSize = 512;
|
||||||
DevCon.WriteLn("DEV9: HddSize : %i", config.HddSize);
|
DevCon.WriteLn("DEV9: HddSize : %i", sizeSectors * sectorSize / (1024 * 1024));
|
||||||
const u64 nbSectors = ((u64)(sizeMb / sectorSize) * 1024 * 1024);
|
const u64 nbSectors = sizeSectors;
|
||||||
DevCon.WriteLn("DEV9: nbSectors : %i", nbSectors);
|
DevCon.WriteLn("DEV9: nbSectors : %i", nbSectors);
|
||||||
|
|
||||||
memset(&identifyData, 0, sizeof(identifyData));
|
memset(&identifyData, 0, sizeof(identifyData));
|
||||||
|
|
|
@ -31,14 +31,14 @@ int ATA::Open(fs::path hddPath)
|
||||||
readBufferLen = 256 * 512;
|
readBufferLen = 256 * 512;
|
||||||
readBuffer = new u8[readBufferLen];
|
readBuffer = new u8[readBufferLen];
|
||||||
|
|
||||||
CreateHDDinfo(config.HddSize);
|
CreateHDDinfo(EmuConfig.DEV9.HddSizeSectors);
|
||||||
|
|
||||||
//Open File
|
//Open File
|
||||||
if (!fs::exists(hddPath))
|
if (!fs::exists(hddPath))
|
||||||
{
|
{
|
||||||
HddCreate hddCreator;
|
HddCreate hddCreator;
|
||||||
hddCreator.filePath = hddPath;
|
hddCreator.filePath = hddPath;
|
||||||
hddCreator.neededSize = config.HddSize;
|
hddCreator.neededSize = ((u64)EmuConfig.DEV9.HddSizeSectors) * 512;
|
||||||
hddCreator.Start();
|
hddCreator.Start();
|
||||||
|
|
||||||
if (hddCreator.errored)
|
if (hddCreator.errored)
|
||||||
|
@ -396,7 +396,7 @@ bool ATA::HDD_CanAccess(int* sectors)
|
||||||
s64 posEnd;
|
s64 posEnd;
|
||||||
s64 maxLBA;
|
s64 maxLBA;
|
||||||
|
|
||||||
maxLBA = std::min<s64>((s64)config.HddSize * 1024 * 1024 / 512, hddImageSize) - 1;
|
maxLBA = std::min<s64>(EmuConfig.DEV9.HddSizeSectors, hddImageSize / 512) - 1;
|
||||||
if ((regSelect & 0x40) == 0) //CHS mode
|
if ((regSelect & 0x40) == 0) //CHS mode
|
||||||
maxLBA = std::min<s64>(maxLBA, curCylinders * curHeads * curSectors);
|
maxLBA = std::min<s64>(maxLBA, curCylinders * curHeads * curSectors);
|
||||||
|
|
||||||
|
|
|
@ -73,7 +73,7 @@ void ATA::HDD_IdentifyDevice()
|
||||||
DevCon.WriteLn("DEV9: HddidentifyDevice");
|
DevCon.WriteLn("DEV9: HddidentifyDevice");
|
||||||
|
|
||||||
//IDE transfer start
|
//IDE transfer start
|
||||||
CreateHDDinfo(config.HddSize);
|
CreateHDDinfo(EmuConfig.DEV9.HddSizeSectors);
|
||||||
|
|
||||||
pioDRQEndTransferFunc = nullptr;
|
pioDRQEndTransferFunc = nullptr;
|
||||||
DRQCmdPIODataToHost(identifyData, 256 * 2, 0, 256 * 2, true);
|
DRQCmdPIODataToHost(identifyData, 256 * 2, 0, 256 * 2, true);
|
||||||
|
|
|
@ -32,8 +32,13 @@ void HddCreate::Start()
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int reqMiB = (neededSize + ((1024 * 1024) - 1)) / (1024 * 1024);
|
||||||
|
|
||||||
|
#ifndef PCSX2_CORE
|
||||||
//This creates a modeless dialog
|
//This creates a modeless dialog
|
||||||
progressDialog = new wxProgressDialog(_("Creating HDD file"), _("Creating HDD file"), neededSize, nullptr, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
|
progressDialog = new wxProgressDialog(_("Creating HDD file"), _("Creating HDD file"), reqMiB, nullptr, wxPD_APP_MODAL | wxPD_AUTO_HIDE | wxPD_CAN_ABORT | wxPD_ELAPSED_TIME | wxPD_REMAINING_TIME);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fileThread = std::thread(&HddCreate::WriteImage, this, filePath, neededSize);
|
fileThread = std::thread(&HddCreate::WriteImage, this, filePath, neededSize);
|
||||||
|
@ -45,9 +50,9 @@ void HddCreate::Start()
|
||||||
//Instead, loop here to update UI
|
//Instead, loop here to update UI
|
||||||
wxString msg;
|
wxString msg;
|
||||||
int currentSize;
|
int currentSize;
|
||||||
while ((currentSize = written.load()) != neededSize && !errored.load())
|
while ((currentSize = written.load()) != reqMiB && !errored.load())
|
||||||
{
|
{
|
||||||
msg.Printf(_("%i / %i MiB"), written.load(), neededSize);
|
msg.Printf(_("%i / %i MiB"), written.load(), reqMiB);
|
||||||
|
|
||||||
#ifndef PCSX2_CORE
|
#ifndef PCSX2_CORE
|
||||||
if (!progressDialog->Update(currentSize, msg))
|
if (!progressDialog->Update(currentSize, msg))
|
||||||
|
@ -78,7 +83,7 @@ void HddCreate::Start()
|
||||||
completedCV.notify_all();
|
completedCV.notify_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HddCreate::WriteImage(fs::path hddPath, int reqSizeMiB)
|
void HddCreate::WriteImage(fs::path hddPath, u64 reqSizeBytes)
|
||||||
{
|
{
|
||||||
constexpr int buffsize = 4 * 1024;
|
constexpr int buffsize = 4 * 1024;
|
||||||
u8 buff[buffsize] = {0}; //4kb
|
u8 buff[buffsize] = {0}; //4kb
|
||||||
|
@ -98,7 +103,7 @@ void HddCreate::WriteImage(fs::path hddPath, int reqSizeMiB)
|
||||||
}
|
}
|
||||||
|
|
||||||
//Size file
|
//Size file
|
||||||
newImage.seekp(((u64)reqSizeMiB) * 1024 * 1024 - 1, std::ios::beg);
|
newImage.seekp(reqSizeBytes - 1, std::ios::beg);
|
||||||
const char zero = 0;
|
const char zero = 0;
|
||||||
newImage.write(&zero, 1);
|
newImage.write(&zero, 1);
|
||||||
|
|
||||||
|
@ -114,9 +119,13 @@ void HddCreate::WriteImage(fs::path hddPath, int reqSizeMiB)
|
||||||
|
|
||||||
newImage.seekp(0, std::ios::beg);
|
newImage.seekp(0, std::ios::beg);
|
||||||
|
|
||||||
for (int iMiB = 0; iMiB < reqSizeMiB; iMiB++)
|
//Round up
|
||||||
|
const s32 reqMiB = (reqSizeBytes + ((1024 * 1024) - 1)) / (1024 * 1024);
|
||||||
|
for (s32 iMiB = 0; iMiB < reqMiB; iMiB++)
|
||||||
{
|
{
|
||||||
for (int i4kb = 0; i4kb < 256; i4kb++)
|
//Round down
|
||||||
|
const s32 req4Kib = std::min<s32>(1024, (reqSizeBytes / 1024) - (u64)iMiB * 1024) / 4;
|
||||||
|
for (s32 i4kb = 0; i4kb < req4Kib; i4kb++)
|
||||||
{
|
{
|
||||||
newImage.write((char*)buff, buffsize);
|
newImage.write((char*)buff, buffsize);
|
||||||
if (newImage.fail())
|
if (newImage.fail())
|
||||||
|
@ -128,8 +137,21 @@ void HddCreate::WriteImage(fs::path hddPath, int reqSizeMiB)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req4Kib != 256)
|
||||||
|
{
|
||||||
|
const s32 remainingBytes = reqSizeBytes - (((u64)iMiB) * (1024 * 1024) + req4Kib * 4096);
|
||||||
|
newImage.write((char*)buff, remainingBytes);
|
||||||
|
if (newImage.fail())
|
||||||
|
{
|
||||||
|
newImage.close();
|
||||||
|
fs::remove(filePath);
|
||||||
|
SetError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
const std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
||||||
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - lastUpdate).count() >= 100 || (iMiB + 1) == neededSize)
|
if (std::chrono::duration_cast<std::chrono::milliseconds>(now - lastUpdate).count() >= 100 || (iMiB + 1) == reqMiB)
|
||||||
{
|
{
|
||||||
lastUpdate = now;
|
lastUpdate = now;
|
||||||
SetFileProgress(iMiB + 1);
|
SetFileProgress(iMiB + 1);
|
||||||
|
|
|
@ -29,7 +29,7 @@ class HddCreate
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
fs::path filePath;
|
fs::path filePath;
|
||||||
int neededSize;
|
u64 neededSize;
|
||||||
|
|
||||||
std::atomic_bool errored{false};
|
std::atomic_bool errored{false};
|
||||||
|
|
||||||
|
@ -55,5 +55,5 @@ public:
|
||||||
private:
|
private:
|
||||||
void SetFileProgress(int currentSize);
|
void SetFileProgress(int currentSize);
|
||||||
void SetError();
|
void SetError();
|
||||||
void WriteImage(fs::path hddPath, int reqSizeMB);
|
void WriteImage(fs::path hddPath, u64 reqSizeBytes);
|
||||||
};
|
};
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
#include "common/StringUtil.h"
|
#include "common/StringUtil.h"
|
||||||
|
|
||||||
#include "DEV9Config.h"
|
#include "Config.h"
|
||||||
#include "DEV9.h"
|
#include "DEV9.h"
|
||||||
#include "pcap_io.h"
|
#include "pcap_io.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
@ -81,7 +81,7 @@ class DEV9Dialog : public wxDialog
|
||||||
IPControl_SetValue(m_ip, ip);
|
IPControl_SetValue(m_ip, ip);
|
||||||
m_auto->SetValue(is_auto);
|
m_auto->SetValue(is_auto);
|
||||||
}
|
}
|
||||||
void save(IP_Address& ip, int& is_auto)
|
void save(IP_Address& ip, bool& is_auto)
|
||||||
{
|
{
|
||||||
ip = IPControl_GetValue(m_ip);
|
ip = IPControl_GetValue(m_ip);
|
||||||
is_auto = m_auto->GetValue();
|
is_auto = m_auto->GetValue();
|
||||||
|
@ -90,7 +90,7 @@ class DEV9Dialog : public wxDialog
|
||||||
wxCheckBox* m_eth_enable;
|
wxCheckBox* m_eth_enable;
|
||||||
wxChoice* m_eth_adapter_api;
|
wxChoice* m_eth_adapter_api;
|
||||||
wxChoice* m_eth_adapter;
|
wxChoice* m_eth_adapter;
|
||||||
std::vector<NetApi> m_api_list;
|
std::vector<Pcsx2Config::DEV9Options::NetApi> m_api_list;
|
||||||
std::vector<std::vector<AdapterEntry>> m_adapter_list;
|
std::vector<std::vector<AdapterEntry>> m_adapter_list;
|
||||||
wxCheckBox* m_intercept_dhcp;
|
wxCheckBox* m_intercept_dhcp;
|
||||||
wxTextCtrl* m_ps2_address;
|
wxTextCtrl* m_ps2_address;
|
||||||
|
@ -143,8 +143,8 @@ public:
|
||||||
std::sort(list.begin(), list.end(), [](const AdapterEntry& a, AdapterEntry& b){ return a.name < b.name; });
|
std::sort(list.begin(), list.end(), [](const AdapterEntry& a, AdapterEntry& b){ return a.name < b.name; });
|
||||||
wxArrayString adapter_api_name_list;
|
wxArrayString adapter_api_name_list;
|
||||||
adapter_api_name_list.Add("");
|
adapter_api_name_list.Add("");
|
||||||
for (const NetApi& type : m_api_list)
|
for (const Pcsx2Config::DEV9Options::NetApi& type : m_api_list)
|
||||||
adapter_api_name_list.Add(NetApiToWxString(type));
|
adapter_api_name_list.Add(Pcsx2Config::DEV9Options::NetApiNames[(int)type]);
|
||||||
|
|
||||||
auto* eth_adapter_api_label = new wxStaticText(this, wxID_ANY, _("Ethernet Device Type:"));
|
auto* eth_adapter_api_label = new wxStaticText(this, wxID_ANY, _("Ethernet Device Type:"));
|
||||||
auto* eth_adapter_label = new wxStaticText(this, wxID_ANY, _("Ethernet Device:"));
|
auto* eth_adapter_label = new wxStaticText(this, wxID_ANY, _("Ethernet Device:"));
|
||||||
|
@ -218,9 +218,9 @@ public:
|
||||||
Bind(wxEVT_BUTTON, &DEV9Dialog::OnOK, this, wxID_OK);
|
Bind(wxEVT_BUTTON, &DEV9Dialog::OnOK, this, wxID_OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Load(const ConfigDEV9& config)
|
void Load(const Pcsx2Config::DEV9Options& config)
|
||||||
{
|
{
|
||||||
m_eth_enable->SetValue(config.ethEnable);
|
m_eth_enable->SetValue(config.EthEnable);
|
||||||
m_eth_adapter_api->SetSelection(0);
|
m_eth_adapter_api->SetSelection(0);
|
||||||
for (size_t i = 0; i < m_api_list.size(); i++)
|
for (size_t i = 0; i < m_api_list.size(); i++)
|
||||||
{
|
{
|
||||||
|
@ -234,7 +234,7 @@ public:
|
||||||
const auto& list = m_adapter_list[static_cast<u32>(config.EthApi)];
|
const auto& list = m_adapter_list[static_cast<u32>(config.EthApi)];
|
||||||
for (size_t i = 0; i < list.size(); i++)
|
for (size_t i = 0; i < list.size(); i++)
|
||||||
{
|
{
|
||||||
if (list[i].guid == config.Eth)
|
if (list[i].guid == config.EthDevice)
|
||||||
{
|
{
|
||||||
m_eth_adapter->SetSelection(i + 1);
|
m_eth_adapter->SetSelection(i + 1);
|
||||||
break;
|
break;
|
||||||
|
@ -242,47 +242,48 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
m_intercept_dhcp->SetValue(config.InterceptDHCP);
|
m_intercept_dhcp->SetValue(config.InterceptDHCP);
|
||||||
IPControl_SetValue(m_ps2_address, config.PS2IP);
|
IPControl_SetValue(m_ps2_address, *(IP_Address*)config.PS2IP);
|
||||||
m_subnet_mask .load(config.Mask, config.AutoMask);
|
m_subnet_mask .load(*(IP_Address*)config.Mask, config.AutoMask);
|
||||||
m_gateway_address.load(config.Gateway, config.AutoGateway);
|
m_gateway_address.load(*(IP_Address*)config.Gateway, config.AutoGateway);
|
||||||
m_dns1_address .load(config.DNS1, config.AutoDNS1);
|
m_dns1_address .load(*(IP_Address*)config.DNS1, config.AutoDNS1);
|
||||||
m_dns2_address .load(config.DNS2, config.AutoDNS2);
|
m_dns2_address .load(*(IP_Address*)config.DNS2, config.AutoDNS2);
|
||||||
|
|
||||||
m_hdd_enable->SetValue(config.hddEnable);
|
m_hdd_enable->SetValue(config.HddEnable);
|
||||||
m_hdd_file->SetInitialDirectory(config.Hdd);
|
wxString wxHddFile = StringUtil::UTF8StringToWxString(config.HddFile);
|
||||||
m_hdd_file->SetPath(config.Hdd);
|
m_hdd_file->SetInitialDirectory(wxHddFile);
|
||||||
m_hdd_size_spin->SetValue(config.HddSize / 1024);
|
m_hdd_file->SetPath(wxHddFile);
|
||||||
m_hdd_size_slider->SetValue(config.HddSize / 1024);
|
m_hdd_size_spin->SetValue((u64)config.HddSizeSectors * 512 / (1024 * 1024 * 1024));
|
||||||
|
m_hdd_size_slider->SetValue((u64)config.HddSizeSectors * 512 / (1024 * 1024 * 1024));
|
||||||
|
|
||||||
UpdateEnable();
|
UpdateEnable();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Save(ConfigDEV9& config)
|
void Save(Pcsx2Config::DEV9Options& config)
|
||||||
{
|
{
|
||||||
config.ethEnable = m_eth_enable->GetValue();
|
config.EthEnable = m_eth_enable->GetValue();
|
||||||
int api = m_eth_adapter_api->GetSelection();
|
int api = m_eth_adapter_api->GetSelection();
|
||||||
int eth = m_eth_adapter->GetSelection();
|
int eth = m_eth_adapter->GetSelection();
|
||||||
if (api && eth)
|
if (api && eth)
|
||||||
{
|
{
|
||||||
const AdapterEntry& adapter = m_adapter_list[static_cast<u32>(m_api_list[api - 1])][eth - 1];
|
const AdapterEntry& adapter = m_adapter_list[static_cast<u32>(m_api_list[api - 1])][eth - 1];
|
||||||
wxStrncpy(config.Eth, adapter.guid, std::size(config.Eth) - 1);
|
config.EthDevice = adapter.guid;
|
||||||
config.EthApi = adapter.type;
|
config.EthApi = adapter.type;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
config.Eth[0] = 0;
|
config.EthDevice = "";
|
||||||
config.EthApi = NetApi::Unset;
|
config.EthApi = Pcsx2Config::DEV9Options::NetApi::Unset;
|
||||||
}
|
}
|
||||||
config.InterceptDHCP = m_intercept_dhcp->GetValue();
|
config.InterceptDHCP = m_intercept_dhcp->GetValue();
|
||||||
config.PS2IP = IPControl_GetValue(m_ps2_address);
|
*(IP_Address*)&config.PS2IP = IPControl_GetValue(m_ps2_address);
|
||||||
m_subnet_mask .save(config.Mask, config.AutoMask);
|
m_subnet_mask .save(*(IP_Address*)config.Mask, config.AutoMask);
|
||||||
m_gateway_address.save(config.Gateway, config.AutoGateway);
|
m_gateway_address.save(*(IP_Address*)config.Gateway, config.AutoGateway);
|
||||||
m_dns1_address .save(config.DNS1, config.AutoDNS1);
|
m_dns1_address .save(*(IP_Address*)config.DNS1, config.AutoDNS1);
|
||||||
m_dns2_address .save(config.DNS2, config.AutoDNS2);
|
m_dns2_address .save(*(IP_Address*)config.DNS2, config.AutoDNS2);
|
||||||
|
|
||||||
config.hddEnable = m_hdd_enable->GetValue();
|
config.HddEnable = m_hdd_enable->GetValue();
|
||||||
wxStrncpy(config.Hdd, m_hdd_file->GetPath(), std::size(config.Hdd) - 1);
|
config.HddFile = StringUtil::wxStringToUTF8String(m_hdd_file->GetPath());
|
||||||
config.HddSize = m_hdd_size_spin->GetValue() * 1024;
|
config.HddSizeSectors = (u64)m_hdd_size_spin->GetValue() * 1024 * 1024 * 1024 / 512;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdateEnable()
|
void UpdateEnable()
|
||||||
|
@ -317,7 +318,7 @@ public:
|
||||||
if (m_eth_adapter->GetCount())
|
if (m_eth_adapter->GetCount())
|
||||||
current = m_eth_adapter->GetString(m_eth_adapter->GetSelection());
|
current = m_eth_adapter->GetString(m_eth_adapter->GetSelection());
|
||||||
if (current.empty())
|
if (current.empty())
|
||||||
current = config.Eth;
|
current = StringUtil::UTF8StringToWxString(g_Conf->EmuOptions.DEV9.EthDevice);
|
||||||
for (size_t i = 0; i < list.size(); i++)
|
for (size_t i = 0; i < list.size(); i++)
|
||||||
{
|
{
|
||||||
wxString wxAdapterName = StringUtil::UTF8StringToWxString(list[i].name);
|
wxString wxAdapterName = StringUtil::UTF8StringToWxString(list[i].name);
|
||||||
|
@ -375,14 +376,12 @@ void DEV9configure()
|
||||||
ScopedCoreThreadPause paused_core;
|
ScopedCoreThreadPause paused_core;
|
||||||
|
|
||||||
DEV9Dialog dialog;
|
DEV9Dialog dialog;
|
||||||
LoadConf();
|
dialog.Load(g_Conf->EmuOptions.DEV9);
|
||||||
dialog.Load(config);
|
|
||||||
if (dialog.ShowModal() == wxID_OK)
|
if (dialog.ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
ConfigDEV9 oldConfig = config;
|
dialog.Save(g_Conf->EmuOptions.DEV9);
|
||||||
dialog.Save(config);
|
|
||||||
|
|
||||||
fs::path hddPath(config.Hdd);
|
fs::path hddPath(g_Conf->EmuOptions.DEV9.HddFile);
|
||||||
|
|
||||||
if (hddPath.is_relative())
|
if (hddPath.is_relative())
|
||||||
{
|
{
|
||||||
|
@ -391,17 +390,15 @@ void DEV9configure()
|
||||||
hddPath = path / hddPath;
|
hddPath = path / hddPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.hddEnable && !fs::exists(hddPath))
|
if (g_Conf->EmuOptions.DEV9.HddEnable && !fs::exists(hddPath))
|
||||||
{
|
{
|
||||||
HddCreate hddCreator;
|
HddCreate hddCreator;
|
||||||
hddCreator.filePath = hddPath;
|
hddCreator.filePath = hddPath;
|
||||||
hddCreator.neededSize = config.HddSize;
|
hddCreator.neededSize = ((u64)g_Conf->EmuOptions.DEV9.HddSizeSectors) * 512;
|
||||||
hddCreator.Start();
|
hddCreator.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
SaveConf();
|
AppSaveSettings();
|
||||||
|
|
||||||
ApplyConfigIfRunning(oldConfig);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
paused_core.AllowResume();
|
paused_core.AllowResume();
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#define EXTERN
|
#define EXTERN
|
||||||
#include "DEV9.h"
|
#include "DEV9.h"
|
||||||
#undef EXTERN
|
#undef EXTERN
|
||||||
|
#include "Config.h"
|
||||||
#include "DEV9Config.h"
|
#include "DEV9Config.h"
|
||||||
#include "smap.h"
|
#include "smap.h"
|
||||||
|
|
||||||
|
@ -94,10 +95,10 @@ bool isRunning = false;
|
||||||
fs::path GetHDDPath()
|
fs::path GetHDDPath()
|
||||||
{
|
{
|
||||||
//GHC uses UTF8 on all platforms
|
//GHC uses UTF8 on all platforms
|
||||||
fs::path hddPath(config.Hdd);
|
fs::path hddPath(EmuConfig.DEV9.HddFile);
|
||||||
|
|
||||||
if (hddPath.empty())
|
if (hddPath.empty())
|
||||||
config.hddEnable = false;
|
EmuConfig.DEV9.HddEnable = false;
|
||||||
|
|
||||||
if (hddPath.is_relative())
|
if (hddPath.is_relative())
|
||||||
{
|
{
|
||||||
|
@ -198,25 +199,18 @@ void DEV9shutdown()
|
||||||
s32 DEV9open()
|
s32 DEV9open()
|
||||||
{
|
{
|
||||||
DevCon.WriteLn("DEV9: DEV9open");
|
DevCon.WriteLn("DEV9: DEV9open");
|
||||||
LoadConf();
|
LoadDnsHosts();
|
||||||
#ifdef _WIN32
|
DevCon.WriteLn("DEV9: open r+: %s", EmuConfig.DEV9.HddFile.c_str());
|
||||||
//Convert to utf8
|
|
||||||
char mbHdd[sizeof(config.Hdd)] = {0};
|
|
||||||
WideCharToMultiByte(CP_UTF8, 0, config.Hdd, -1, mbHdd, sizeof(mbHdd) - 1, nullptr, nullptr);
|
|
||||||
DevCon.WriteLn("DEV9: open r+: %s", mbHdd);
|
|
||||||
#else
|
|
||||||
DevCon.WriteLn("DEV9: open r+: %s", config.Hdd);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
fs::path hddPath = GetHDDPath();
|
fs::path hddPath = GetHDDPath();
|
||||||
|
|
||||||
if (config.hddEnable)
|
if (EmuConfig.DEV9.HddEnable)
|
||||||
{
|
{
|
||||||
if (dev9.ata->Open(hddPath) != 0)
|
if (dev9.ata->Open(hddPath) != 0)
|
||||||
config.hddEnable = false;
|
EmuConfig.DEV9.HddEnable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config.ethEnable)
|
if (EmuConfig.DEV9.EthEnable)
|
||||||
InitNet();
|
InitNet();
|
||||||
|
|
||||||
isRunning = true;
|
isRunning = true;
|
||||||
|
@ -316,7 +310,7 @@ void FIFOIntr()
|
||||||
|
|
||||||
u8 DEV9read8(u32 addr)
|
u8 DEV9read8(u32 addr)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u8 hard;
|
u8 hard;
|
||||||
|
@ -382,7 +376,7 @@ u8 DEV9read8(u32 addr)
|
||||||
|
|
||||||
u16 DEV9read16(u32 addr)
|
u16 DEV9read16(u32 addr)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u16 hard;
|
u16 hard;
|
||||||
|
@ -458,9 +452,9 @@ u16 DEV9read16(u32 addr)
|
||||||
|
|
||||||
case SPD_R_REV_3:
|
case SPD_R_REV_3:
|
||||||
hard = 0;
|
hard = 0;
|
||||||
if (config.hddEnable)
|
if (EmuConfig.DEV9.HddEnable)
|
||||||
hard |= SPD_CAPS_ATA;
|
hard |= SPD_CAPS_ATA;
|
||||||
if (config.ethEnable)
|
if (EmuConfig.DEV9.EthEnable)
|
||||||
hard |= SPD_CAPS_SMAP;
|
hard |= SPD_CAPS_SMAP;
|
||||||
hard |= SPD_CAPS_FLASH;
|
hard |= SPD_CAPS_FLASH;
|
||||||
//DevCon.WriteLn("DEV9: SPD_R_REV_3 16bit read %x", hard);
|
//DevCon.WriteLn("DEV9: SPD_R_REV_3 16bit read %x", hard);
|
||||||
|
@ -522,7 +516,7 @@ u16 DEV9read16(u32 addr)
|
||||||
|
|
||||||
u32 DEV9read32(u32 addr)
|
u32 DEV9read32(u32 addr)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
u32 hard;
|
u32 hard;
|
||||||
|
@ -548,7 +542,7 @@ u32 DEV9read32(u32 addr)
|
||||||
|
|
||||||
void DEV9write8(u32 addr, u8 value)
|
void DEV9write8(u32 addr, u8 value)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||||
|
@ -660,7 +654,7 @@ void DEV9write8(u32 addr, u8 value)
|
||||||
|
|
||||||
void DEV9write16(u32 addr, u16 value)
|
void DEV9write16(u32 addr, u16 value)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||||
|
@ -970,7 +964,7 @@ void DEV9write16(u32 addr, u16 value)
|
||||||
|
|
||||||
void DEV9write32(u32 addr, u32 value)
|
void DEV9write32(u32 addr, u32 value)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
if (addr >= ATA_DEV9_HDD_BASE && addr < ATA_DEV9_HDD_END)
|
||||||
|
@ -1006,7 +1000,7 @@ void DEV9write32(u32 addr, u32 value)
|
||||||
|
|
||||||
void DEV9readDMA8Mem(u32* pMem, int size)
|
void DEV9readDMA8Mem(u32* pMem, int size)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size >>= 1;
|
size >>= 1;
|
||||||
|
@ -1032,7 +1026,7 @@ void DEV9readDMA8Mem(u32* pMem, int size)
|
||||||
|
|
||||||
void DEV9writeDMA8Mem(u32* pMem, int size)
|
void DEV9writeDMA8Mem(u32* pMem, int size)
|
||||||
{
|
{
|
||||||
if (!config.ethEnable & !config.hddEnable)
|
if (!EmuConfig.DEV9.EthEnable && !EmuConfig.DEV9.HddEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
size >>= 1;
|
size >>= 1;
|
||||||
|
@ -1062,44 +1056,36 @@ void DEV9async(u32 cycles)
|
||||||
dev9.ata->Async(cycles);
|
dev9.ata->Async(cycles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyConfigIfRunning(ConfigDEV9 oldConfig)
|
void DEV9CheckChanges(const Pcsx2Config& old_config)
|
||||||
{
|
{
|
||||||
if (!isRunning)
|
if (!isRunning)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//Eth
|
//Eth
|
||||||
ReconfigureLiveNet(&oldConfig);
|
ReconfigureLiveNet(old_config);
|
||||||
|
|
||||||
//Hdd
|
//Hdd
|
||||||
//Hdd Validate Path
|
//Hdd Validate Path
|
||||||
fs::path hddPath = GetHDDPath();
|
fs::path hddPath = GetHDDPath();
|
||||||
|
|
||||||
//Hdd Compare with old config
|
//Hdd Compare with old config
|
||||||
if (config.hddEnable)
|
if (EmuConfig.DEV9.HddEnable)
|
||||||
{
|
{
|
||||||
if (oldConfig.hddEnable)
|
if (old_config.DEV9.HddEnable)
|
||||||
{
|
{
|
||||||
//ATA::Open/Close dosn't set any regs
|
//ATA::Open/Close dosn't set any regs
|
||||||
//So we can close/open to apply settings
|
//So we can close/open to apply settings
|
||||||
#ifdef _WIN32
|
if (EmuConfig.DEV9.HddFile != old_config.DEV9.HddFile ||
|
||||||
if (wcscmp(config.Hdd, oldConfig.Hdd))
|
EmuConfig.DEV9.HddSizeSectors != old_config.DEV9.HddSizeSectors)
|
||||||
#else
|
|
||||||
if (strcmp(config.Hdd, oldConfig.Hdd))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
dev9.ata->Close();
|
dev9.ata->Close();
|
||||||
if (dev9.ata->Open(hddPath) != 0)
|
if (dev9.ata->Open(hddPath) != 0)
|
||||||
config.hddEnable = false;
|
EmuConfig.DEV9.HddEnable = false;
|
||||||
}
|
|
||||||
|
|
||||||
if (config.HddSize != oldConfig.HddSize)
|
|
||||||
{
|
|
||||||
dev9.ata->Close();
|
|
||||||
if (dev9.ata->Open(hddPath) != 0)
|
|
||||||
config.hddEnable = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (dev9.ata->Open(hddPath) != 0)
|
||||||
|
EmuConfig.DEV9.HddEnable = false;
|
||||||
}
|
}
|
||||||
else if (oldConfig.hddEnable)
|
else if (old_config.DEV9.HddEnable)
|
||||||
dev9.ata->Close();
|
dev9.ata->Close();
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,29 +65,7 @@ struct ConfigHost
|
||||||
|
|
||||||
struct ConfigDEV9
|
struct ConfigDEV9
|
||||||
{
|
{
|
||||||
char Eth[256];
|
|
||||||
NetApi EthApi;
|
|
||||||
bool InterceptDHCP;
|
|
||||||
PacketReader::IP::IP_Address PS2IP;
|
|
||||||
PacketReader::IP::IP_Address Mask;
|
|
||||||
PacketReader::IP::IP_Address Gateway;
|
|
||||||
PacketReader::IP::IP_Address DNS1;
|
|
||||||
PacketReader::IP::IP_Address DNS2;
|
|
||||||
int AutoMask;
|
|
||||||
int AutoGateway;
|
|
||||||
int AutoDNS1;
|
|
||||||
int AutoDNS2;
|
|
||||||
int EthLogDNS;
|
|
||||||
std::vector<ConfigHost> EthHosts;
|
std::vector<ConfigHost> EthHosts;
|
||||||
#ifdef _WIN32
|
|
||||||
wchar_t Hdd[256];
|
|
||||||
#else
|
|
||||||
char Hdd[256];
|
|
||||||
#endif
|
|
||||||
int HddSize;
|
|
||||||
|
|
||||||
int hddEnable;
|
|
||||||
int ethEnable;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -738,7 +716,7 @@ u32 DEV9read32(u32 addr);
|
||||||
void DEV9write8(u32 addr, u8 value);
|
void DEV9write8(u32 addr, u8 value);
|
||||||
void DEV9write16(u32 addr, u16 value);
|
void DEV9write16(u32 addr, u16 value);
|
||||||
void DEV9write32(u32 addr, u32 value);
|
void DEV9write32(u32 addr, u32 value);
|
||||||
void ApplyConfigIfRunning(ConfigDEV9 oldConfig);
|
void DEV9CheckChanges(const Pcsx2Config& old_config);
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#pragma warning(error : 4013)
|
#pragma warning(error : 4013)
|
||||||
|
|
|
@ -70,7 +70,7 @@ void LoadDnsHosts()
|
||||||
{
|
{
|
||||||
wxFileName iniPath = EmuFolders::Settings.Combine(wxString("DEV9Hosts.ini"));
|
wxFileName iniPath = EmuFolders::Settings.Combine(wxString("DEV9Hosts.ini"));
|
||||||
config.EthHosts.clear();
|
config.EthHosts.clear();
|
||||||
//If no file exists, create one to provice an example config
|
//If no file exists, create one to provide an example config
|
||||||
if (!iniPath.FileExists())
|
if (!iniPath.FileExists())
|
||||||
{
|
{
|
||||||
//Load Default settings
|
//Load Default settings
|
||||||
|
@ -120,7 +120,7 @@ void LoadDnsHosts()
|
||||||
else
|
else
|
||||||
ini.Entry(L"Enabled", entry.Enabled, false);
|
ini.Entry(L"Enabled", entry.Enabled, false);
|
||||||
|
|
||||||
if (config.EthLogDNS && entry.Enabled)
|
if (EmuConfig.DEV9.EthLogDNS && entry.Enabled)
|
||||||
Console.WriteLn("DEV9: Host entry %i: url %s mapped to %s", i, entry.Url.c_str(), tmp.ToStdString().c_str());
|
Console.WriteLn("DEV9: Host entry %i: url %s mapped to %s", i, entry.Url.c_str(), tmp.ToStdString().c_str());
|
||||||
|
|
||||||
config.EthHosts.push_back(entry);
|
config.EthHosts.push_back(entry);
|
||||||
|
|
|
@ -13,8 +13,5 @@
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void SaveConf();
|
|
||||||
void LoadConf();
|
|
||||||
|
|
||||||
void SaveDnsHosts();
|
void SaveDnsHosts();
|
||||||
void LoadDnsHosts();
|
void LoadDnsHosts();
|
||||||
|
|
|
@ -52,30 +52,30 @@ namespace InternalServers
|
||||||
void DHCP_Server::Init(ifaddrs* adapter)
|
void DHCP_Server::Init(ifaddrs* adapter)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
ps2IP = config.PS2IP;
|
ps2IP = *(IP_Address*)&EmuConfig.DEV9.PS2IP;
|
||||||
netmask = {0};
|
netmask = {0};
|
||||||
gateway = {0};
|
gateway = {0};
|
||||||
dns1 = {0};
|
dns1 = {0};
|
||||||
dns2 = {0};
|
dns2 = {0};
|
||||||
broadcastIP = {0};
|
broadcastIP = {0};
|
||||||
|
|
||||||
if (config.AutoMask)
|
if (EmuConfig.DEV9.AutoMask)
|
||||||
AutoNetmask(adapter);
|
AutoNetmask(adapter);
|
||||||
else
|
else
|
||||||
netmask = config.Mask;
|
netmask = *(IP_Address*)EmuConfig.DEV9.Mask;
|
||||||
|
|
||||||
if (config.AutoGateway)
|
if (EmuConfig.DEV9.AutoGateway)
|
||||||
AutoGateway(adapter);
|
AutoGateway(adapter);
|
||||||
else
|
else
|
||||||
gateway = config.Gateway;
|
gateway = *(IP_Address*)EmuConfig.DEV9.Gateway;
|
||||||
|
|
||||||
if (!config.AutoDNS1)
|
if (!EmuConfig.DEV9.AutoDNS1)
|
||||||
dns1 = config.DNS1;
|
dns1 = *(IP_Address*)EmuConfig.DEV9.DNS1;
|
||||||
|
|
||||||
if (!config.AutoDNS2)
|
if (!EmuConfig.DEV9.AutoDNS2)
|
||||||
dns2 = config.DNS2;
|
dns2 = *(IP_Address*)EmuConfig.DEV9.DNS2;
|
||||||
|
|
||||||
AutoDNS(adapter, config.AutoDNS1, config.AutoDNS2);
|
AutoDNS(adapter, EmuConfig.DEV9.AutoDNS1, EmuConfig.DEV9.AutoDNS2);
|
||||||
AutoBroadcast(ps2IP, netmask);
|
AutoBroadcast(ps2IP, netmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,240 +0,0 @@
|
||||||
/* PCSX2 - PS2 Emulator for PCs
|
|
||||||
* Copyright (C) 2002-2020 PCSX2 Dev Team
|
|
||||||
*
|
|
||||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <arpa/inet.h>
|
|
||||||
|
|
||||||
#include "DEV9/DEV9.h"
|
|
||||||
#include "DEV9/Config.h"
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <libxml/parser.h>
|
|
||||||
#include <libxml/tree.h>
|
|
||||||
|
|
||||||
#if defined(__FreeBSD__)
|
|
||||||
#include <sys/socket.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void SaveConf()
|
|
||||||
{
|
|
||||||
xmlDocPtr doc = NULL; /* document pointer */
|
|
||||||
xmlNodePtr root_node = NULL;
|
|
||||||
char buff[256];
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Creates a new document, a node and set it as a root node
|
|
||||||
*/
|
|
||||||
doc = xmlNewDoc(BAD_CAST "1.0");
|
|
||||||
root_node = xmlNewNode(NULL, BAD_CAST "dev9");
|
|
||||||
xmlDocSetRootElement(doc, root_node);
|
|
||||||
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "Eth",
|
|
||||||
BAD_CAST config.Eth);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", (int)config.EthApi);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "EthApi",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.InterceptDHCP);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "InterceptDHCP",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
inet_ntop(AF_INET, &config.PS2IP, buff, 256);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "PS2IP",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
inet_ntop(AF_INET, &config.Mask, buff, 256);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "Subnet",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.AutoMask);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "AutoSubnet",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
inet_ntop(AF_INET, &config.Gateway, buff, 256);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "Gateway",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.AutoGateway);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "AutoGateway",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
inet_ntop(AF_INET, &config.DNS1, buff, 256);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "DNS1",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.AutoDNS1);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "AutoDNS1",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
inet_ntop(AF_INET, &config.DNS2, buff, 256);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "DNS2",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.AutoDNS2);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "AutoDNS2",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.EthLogDNS);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "EthLogDNS",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "Hdd",
|
|
||||||
BAD_CAST config.Hdd);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.HddSize);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "HddSize",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.ethEnable);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "ethEnable",
|
|
||||||
BAD_CAST buff);
|
|
||||||
|
|
||||||
sprintf(buff, "%d", config.hddEnable);
|
|
||||||
xmlNewChild(root_node, NULL, BAD_CAST "hddEnable",
|
|
||||||
BAD_CAST buff);
|
|
||||||
/*
|
|
||||||
* Dumping document to stdio or file
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
const std::string file(EmuFolders::Settings.Combine(wxString("DEV9.cfg")).GetFullPath());
|
|
||||||
|
|
||||||
Console.WriteLn("DEV9: CONF: %s", file.c_str());
|
|
||||||
|
|
||||||
xmlSaveFormatFileEnc(file.c_str(), doc, "UTF-8", 1);
|
|
||||||
// free(configFile);
|
|
||||||
|
|
||||||
/*free the document */
|
|
||||||
xmlFreeDoc(doc);
|
|
||||||
|
|
||||||
/*
|
|
||||||
*Free the global variables that may
|
|
||||||
*have been allocated by the parser.
|
|
||||||
*/
|
|
||||||
xmlCleanupParser();
|
|
||||||
|
|
||||||
SaveDnsHosts();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadConf()
|
|
||||||
{
|
|
||||||
const std::string file(EmuFolders::Settings.Combine(wxString("DEV9.cfg")).GetFullPath());
|
|
||||||
if (-1 == access(file.c_str(), F_OK))
|
|
||||||
return;
|
|
||||||
|
|
||||||
memset(&config, 0, sizeof(config));
|
|
||||||
config.EthApi = NetApi::PCAP_Switched;
|
|
||||||
|
|
||||||
// Read the files
|
|
||||||
xmlDoc* doc = NULL;
|
|
||||||
xmlNode* cur_node = NULL;
|
|
||||||
|
|
||||||
doc = xmlReadFile(file.c_str(), NULL, 0);
|
|
||||||
|
|
||||||
if (doc == NULL)
|
|
||||||
{
|
|
||||||
Console.Error("Unable to parse configuration file! Suggest deleting it and starting over.");
|
|
||||||
}
|
|
||||||
|
|
||||||
for (cur_node = xmlDocGetRootElement(doc)->children; cur_node; cur_node = cur_node->next)
|
|
||||||
{
|
|
||||||
if (cur_node->type == XML_ELEMENT_NODE)
|
|
||||||
{
|
|
||||||
// printf("node type: Element, name: %s\n", cur_node->name);
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "Eth"))
|
|
||||||
{
|
|
||||||
strcpy(config.Eth, (const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "EthApi"))
|
|
||||||
{
|
|
||||||
config.EthApi = (NetApi)atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "InterceptDHCP"))
|
|
||||||
{
|
|
||||||
config.InterceptDHCP = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "PS2IP"))
|
|
||||||
{
|
|
||||||
inet_pton(AF_INET, (const char*)xmlNodeGetContent(cur_node), &config.PS2IP);
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "Subnet"))
|
|
||||||
{
|
|
||||||
inet_pton(AF_INET, (const char*)xmlNodeGetContent(cur_node), &config.Mask);
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "AutoSubnet"))
|
|
||||||
{
|
|
||||||
config.AutoMask = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "Gateway"))
|
|
||||||
{
|
|
||||||
inet_pton(AF_INET, (const char*)xmlNodeGetContent(cur_node), &config.Gateway);
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "AutoGateway"))
|
|
||||||
{
|
|
||||||
config.AutoGateway = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "DNS1"))
|
|
||||||
{
|
|
||||||
inet_pton(AF_INET, (const char*)xmlNodeGetContent(cur_node), &config.DNS1);
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "AutoDNS1"))
|
|
||||||
{
|
|
||||||
config.AutoDNS1 = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "DNS2"))
|
|
||||||
{
|
|
||||||
inet_pton(AF_INET, (const char*)xmlNodeGetContent(cur_node), &config.DNS2);
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "AutoDNS2"))
|
|
||||||
{
|
|
||||||
config.AutoDNS2 = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "EthLogDNS"))
|
|
||||||
{
|
|
||||||
config.EthLogDNS = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "Hdd"))
|
|
||||||
{
|
|
||||||
strcpy(config.Hdd, (const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "HddSize"))
|
|
||||||
{
|
|
||||||
config.HddSize = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "ethEnable"))
|
|
||||||
{
|
|
||||||
config.ethEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
if (0 == strcmp((const char*)cur_node->name, "hddEnable"))
|
|
||||||
{
|
|
||||||
config.hddEnable = atoi((const char*)xmlNodeGetContent(cur_node));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// free(configFile);
|
|
||||||
xmlFreeDoc(doc);
|
|
||||||
xmlCleanupParser();
|
|
||||||
|
|
||||||
LoadDnsHosts();
|
|
||||||
}
|
|
|
@ -1,136 +0,0 @@
|
||||||
/* PCSX2 - PS2 Emulator for PCs
|
|
||||||
* Copyright (C) 2002-2020 PCSX2 Dev Team
|
|
||||||
*
|
|
||||||
* PCSX2 is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU Lesser General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* PCSX2 is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with PCSX2.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "DEV9/DEV9.h"
|
|
||||||
#include "DEV9/DEV9Config.h"
|
|
||||||
#include "Config.h"
|
|
||||||
|
|
||||||
#include "ws2tcpip.h"
|
|
||||||
|
|
||||||
BOOL WritePrivateProfileInt(LPCWSTR lpAppName, LPCWSTR lpKeyName, int intvar, LPCWSTR lpFileName)
|
|
||||||
{
|
|
||||||
return WritePrivateProfileString(lpAppName, lpKeyName, std::to_wstring(intvar).c_str(), lpFileName);
|
|
||||||
}
|
|
||||||
bool FileExists(std::wstring szPath)
|
|
||||||
{
|
|
||||||
DWORD dwAttrib = GetFileAttributes(szPath.c_str());
|
|
||||||
return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
|
|
||||||
!(dwAttrib & FILE_ATTRIBUTE_DIRECTORY));
|
|
||||||
}
|
|
||||||
|
|
||||||
void SaveConf()
|
|
||||||
{
|
|
||||||
const std::wstring file(EmuFolders::Settings.Combine(wxString("DEV9.cfg")).GetFullPath());
|
|
||||||
DeleteFile(file.c_str());
|
|
||||||
|
|
||||||
//Create file with UT16 BOM to allow PrivateProfile to save unicode data
|
|
||||||
int bom = 0xFEFF;
|
|
||||||
std::fstream nfile = std::fstream(file, std::ios::out | std::ios::binary);
|
|
||||||
nfile.write((char*)&bom, 2);
|
|
||||||
//Write header to avoid empty line
|
|
||||||
nfile.write((char*)L"[DEV9]", 14);
|
|
||||||
nfile.close();
|
|
||||||
|
|
||||||
wchar_t addrBuff[INET_ADDRSTRLEN] = {0};
|
|
||||||
wchar_t wEth[sizeof(config.Eth)] = {0};
|
|
||||||
mbstowcs(wEth, config.Eth, sizeof(config.Eth) - 1);
|
|
||||||
WritePrivateProfileString(L"DEV9", L"Eth", wEth, file.c_str());
|
|
||||||
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"EthApi", (int)config.EthApi, file.c_str());
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"InterceptDHCP", config.InterceptDHCP, file.c_str());
|
|
||||||
|
|
||||||
InetNtop(AF_INET, &config.PS2IP, addrBuff, INET_ADDRSTRLEN);
|
|
||||||
WritePrivateProfileString(L"DEV9", L"PS2IP", addrBuff, file.c_str());
|
|
||||||
|
|
||||||
InetNtop(AF_INET, &config.Mask, addrBuff, INET_ADDRSTRLEN);
|
|
||||||
WritePrivateProfileString(L"DEV9", L"Subnet", addrBuff, file.c_str());
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"AutoSubnet", config.AutoMask, file.c_str());
|
|
||||||
|
|
||||||
InetNtop(AF_INET, &config.Gateway, addrBuff, INET_ADDRSTRLEN);
|
|
||||||
WritePrivateProfileString(L"DEV9", L"Gateway", addrBuff, file.c_str());
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"AutoGateway", config.AutoGateway, file.c_str());
|
|
||||||
|
|
||||||
InetNtop(AF_INET, &config.DNS1, addrBuff, INET_ADDRSTRLEN);
|
|
||||||
WritePrivateProfileString(L"DEV9", L"DNS1", addrBuff, file.c_str());
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"AutoDNS1", config.AutoDNS1, file.c_str());
|
|
||||||
|
|
||||||
InetNtop(AF_INET, &config.DNS2, addrBuff, INET_ADDRSTRLEN);
|
|
||||||
WritePrivateProfileString(L"DEV9", L"DNS2", addrBuff, file.c_str());
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"AutoDNS2", config.AutoDNS2, file.c_str());
|
|
||||||
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"EthLogDNS", config.EthLogDNS, file.c_str());
|
|
||||||
|
|
||||||
WritePrivateProfileString(L"DEV9", L"Hdd", config.Hdd, file.c_str());
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"HddSize", config.HddSize, file.c_str());
|
|
||||||
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"ethEnable", config.ethEnable, file.c_str());
|
|
||||||
WritePrivateProfileInt(L"DEV9", L"hddEnable", config.hddEnable, file.c_str());
|
|
||||||
|
|
||||||
SaveDnsHosts();
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadConf()
|
|
||||||
{
|
|
||||||
const std::wstring file(EmuFolders::Settings.Combine(wxString("DEV9.cfg")).GetFullPath());
|
|
||||||
if (FileExists(file.c_str()) == false)
|
|
||||||
{
|
|
||||||
LoadDnsHosts();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wchar_t addrBuff[INET_ADDRSTRLEN] = {0};
|
|
||||||
wchar_t wEth[sizeof(config.Eth)] = {0};
|
|
||||||
mbstowcs(wEth, ETH_DEF, sizeof(config.Eth) - 1);
|
|
||||||
GetPrivateProfileString(L"DEV9", L"Eth", wEth, wEth, sizeof(config.Eth), file.c_str());
|
|
||||||
wcstombs(config.Eth, wEth, sizeof(config.Eth) - 1);
|
|
||||||
|
|
||||||
config.EthApi = (NetApi)GetPrivateProfileInt(L"DEV9", L"EthApi", (int)NetApi::TAP, file.c_str());
|
|
||||||
config.InterceptDHCP = GetPrivateProfileInt(L"DEV9", L"InterceptDHCP", config.InterceptDHCP, file.c_str());
|
|
||||||
|
|
||||||
GetPrivateProfileString(L"DEV9", L"PS2IP", L"0.0.0.0", addrBuff, INET_ADDRSTRLEN, file.c_str());
|
|
||||||
InetPton(AF_INET, addrBuff, &config.PS2IP);
|
|
||||||
|
|
||||||
GetPrivateProfileString(L"DEV9", L"Subnet", L"0.0.0.0", addrBuff, INET_ADDRSTRLEN, file.c_str());
|
|
||||||
InetPton(AF_INET, addrBuff, &config.Mask);
|
|
||||||
config.AutoMask = GetPrivateProfileInt(L"DEV9", L"AutoSubnet", config.AutoMask, file.c_str());
|
|
||||||
|
|
||||||
GetPrivateProfileString(L"DEV9", L"Gateway", L"0.0.0.0", addrBuff, INET_ADDRSTRLEN, file.c_str());
|
|
||||||
InetPton(AF_INET, addrBuff, &config.Gateway);
|
|
||||||
config.AutoGateway = GetPrivateProfileInt(L"DEV9", L"AutoGateway", config.AutoGateway, file.c_str());
|
|
||||||
|
|
||||||
GetPrivateProfileString(L"DEV9", L"DNS1", L"0.0.0.0", addrBuff, INET_ADDRSTRLEN, file.c_str());
|
|
||||||
InetPton(AF_INET, addrBuff, &config.DNS1);
|
|
||||||
config.AutoDNS1 = GetPrivateProfileInt(L"DEV9", L"AutoDNS1", config.AutoDNS1, file.c_str());
|
|
||||||
|
|
||||||
GetPrivateProfileString(L"DEV9", L"DNS2", L"0.0.0.0", addrBuff, INET_ADDRSTRLEN, file.c_str());
|
|
||||||
InetPton(AF_INET, addrBuff, &config.DNS2);
|
|
||||||
config.AutoDNS2 = GetPrivateProfileInt(L"DEV9", L"AutoDNS2", config.AutoDNS2, file.c_str());
|
|
||||||
|
|
||||||
config.EthLogDNS = GetPrivateProfileInt(L"DEV9", L"EthLogDNS", config.EthLogDNS, file.c_str());
|
|
||||||
|
|
||||||
GetPrivateProfileString(L"DEV9", L"Hdd", HDD_DEF, config.Hdd, sizeof(config.Hdd), file.c_str());
|
|
||||||
config.HddSize = GetPrivateProfileInt(L"DEV9", L"HddSize", config.HddSize, file.c_str());
|
|
||||||
|
|
||||||
config.ethEnable = GetPrivateProfileInt(L"DEV9", L"ethEnable", config.ethEnable, file.c_str());
|
|
||||||
config.hddEnable = GetPrivateProfileInt(L"DEV9", L"hddEnable", config.hddEnable, file.c_str());
|
|
||||||
|
|
||||||
LoadDnsHosts();
|
|
||||||
}
|
|
|
@ -218,10 +218,8 @@ static int TAPSetStatus(HANDLE handle, int status)
|
||||||
&status, sizeof(status), &len, NULL);
|
&status, sizeof(status), &len, NULL);
|
||||||
}
|
}
|
||||||
//Open the TAP adapter and set the connection to enabled :)
|
//Open the TAP adapter and set the connection to enabled :)
|
||||||
HANDLE TAPOpen(const char* device_guid)
|
HANDLE TAPOpen(const std::string& device_guid)
|
||||||
{
|
{
|
||||||
char device_path[256];
|
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
unsigned long major;
|
unsigned long major;
|
||||||
|
@ -230,13 +228,10 @@ HANDLE TAPOpen(const char* device_guid)
|
||||||
} version;
|
} version;
|
||||||
LONG version_len;
|
LONG version_len;
|
||||||
|
|
||||||
sprintf_s(device_path, "%s%s%s",
|
std::string device_path = USERMODEDEVICEDIR + device_guid + TAPSUFFIX;
|
||||||
USERMODEDEVICEDIR,
|
|
||||||
device_guid,
|
|
||||||
TAPSUFFIX);
|
|
||||||
|
|
||||||
wil::unique_hfile handle(CreateFileA(
|
wil::unique_hfile handle(CreateFileA(
|
||||||
device_path,
|
device_path.c_str(),
|
||||||
GENERIC_READ | GENERIC_WRITE,
|
GENERIC_READ | GENERIC_WRITE,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
|
@ -282,7 +277,7 @@ PIP_ADAPTER_ADDRESSES FindAdapterViaIndex(PIP_ADAPTER_ADDRESSES adapterList, int
|
||||||
//IP_ADAPTER_ADDRESSES is a structure that contains ptrs to data in other regions
|
//IP_ADAPTER_ADDRESSES is a structure that contains ptrs to data in other regions
|
||||||
//of the buffer, se we need to return both so the caller can free the buffer
|
//of the buffer, se we need to return both so the caller can free the buffer
|
||||||
//after it's finished reading the needed data from IP_ADAPTER_ADDRESSES
|
//after it's finished reading the needed data from IP_ADAPTER_ADDRESSES
|
||||||
bool TAPGetWin32Adapter(const char* name, PIP_ADAPTER_ADDRESSES adapter, std::unique_ptr<IP_ADAPTER_ADDRESSES[]>* buffer)
|
bool TAPGetWin32Adapter(const std::string& name, PIP_ADAPTER_ADDRESSES adapter, std::unique_ptr<IP_ADAPTER_ADDRESSES[]>* buffer)
|
||||||
{
|
{
|
||||||
int neededSize = 256;
|
int neededSize = 256;
|
||||||
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> AdapterInfo = std::make_unique<IP_ADAPTER_ADDRESSES[]>(neededSize);
|
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> AdapterInfo = std::make_unique<IP_ADAPTER_ADDRESSES[]>(neededSize);
|
||||||
|
@ -322,7 +317,7 @@ bool TAPGetWin32Adapter(const char* name, PIP_ADAPTER_ADDRESSES adapter, std::un
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (0 == strcmp(pAdapterInfo->AdapterName, name))
|
if (0 == strcmp(pAdapterInfo->AdapterName, name.c_str()))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pAdapterInfo = pAdapterInfo->Next;
|
pAdapterInfo = pAdapterInfo->Next;
|
||||||
|
@ -535,9 +530,9 @@ bool TAPGetWin32Adapter(const char* name, PIP_ADAPTER_ADDRESSES adapter, std::un
|
||||||
TAPAdapter::TAPAdapter()
|
TAPAdapter::TAPAdapter()
|
||||||
: NetAdapter()
|
: NetAdapter()
|
||||||
{
|
{
|
||||||
if (config.ethEnable == 0)
|
if (!EmuConfig.DEV9.EthEnable)
|
||||||
return;
|
return;
|
||||||
htap = TAPOpen(config.Eth);
|
htap = TAPOpen(EmuConfig.DEV9.EthDevice);
|
||||||
|
|
||||||
read.Offset = 0;
|
read.Offset = 0;
|
||||||
read.OffsetHigh = 0;
|
read.OffsetHigh = 0;
|
||||||
|
@ -563,7 +558,7 @@ TAPAdapter::TAPAdapter()
|
||||||
|
|
||||||
IP_ADAPTER_ADDRESSES adapter;
|
IP_ADAPTER_ADDRESSES adapter;
|
||||||
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
||||||
if (TAPGetWin32Adapter(config.Eth, &adapter, &buffer))
|
if (TAPGetWin32Adapter(EmuConfig.DEV9.EthDevice, &adapter, &buffer))
|
||||||
InitInternalServer(&adapter);
|
InitInternalServer(&adapter);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -658,7 +653,7 @@ void TAPAdapter::reloadSettings()
|
||||||
{
|
{
|
||||||
IP_ADAPTER_ADDRESSES adapter;
|
IP_ADAPTER_ADDRESSES adapter;
|
||||||
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
||||||
if (TAPGetWin32Adapter(config.Eth, &adapter, &buffer))
|
if (TAPGetWin32Adapter(EmuConfig.DEV9.EthDevice, &adapter, &buffer))
|
||||||
ReloadInternalServer(&adapter);
|
ReloadInternalServer(&adapter);
|
||||||
else
|
else
|
||||||
ReloadInternalServer(nullptr);
|
ReloadInternalServer(nullptr);
|
||||||
|
|
|
@ -71,15 +71,15 @@ NetAdapter* GetNetAdapter()
|
||||||
{
|
{
|
||||||
NetAdapter* na = nullptr;
|
NetAdapter* na = nullptr;
|
||||||
|
|
||||||
switch (config.EthApi)
|
switch (EmuConfig.DEV9.EthApi)
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
case NetApi::TAP:
|
case Pcsx2Config::DEV9Options::NetApi::TAP:
|
||||||
na = static_cast<NetAdapter*>(new TAPAdapter());
|
na = static_cast<NetAdapter*>(new TAPAdapter());
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case NetApi::PCAP_Bridged:
|
case Pcsx2Config::DEV9Options::NetApi::PCAP_Bridged:
|
||||||
case NetApi::PCAP_Switched:
|
case Pcsx2Config::DEV9Options::NetApi::PCAP_Switched:
|
||||||
na = static_cast<NetAdapter*>(new PCAPAdapter());
|
na = static_cast<NetAdapter*>(new PCAPAdapter());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -101,7 +101,7 @@ void InitNet()
|
||||||
if (!na)
|
if (!na)
|
||||||
{
|
{
|
||||||
Console.Error("DEV9: Failed to GetNetAdapter()");
|
Console.Error("DEV9: Failed to GetNetAdapter()");
|
||||||
config.ethEnable = false;
|
EmuConfig.DEV9.EthEnable = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,16 +123,16 @@ void InitNet()
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void ReconfigureLiveNet(ConfigDEV9* oldConfig)
|
void ReconfigureLiveNet(const Pcsx2Config& old_config)
|
||||||
{
|
{
|
||||||
//Eth
|
//Eth
|
||||||
if (config.ethEnable)
|
if (EmuConfig.DEV9.EthEnable)
|
||||||
{
|
{
|
||||||
if (oldConfig->ethEnable)
|
if (old_config.DEV9.EthEnable)
|
||||||
{
|
{
|
||||||
//Reload Net if adapter changed
|
//Reload Net if adapter changed
|
||||||
if (strcmp(oldConfig->Eth, config.Eth) != 0 ||
|
if (EmuConfig.DEV9.EthDevice != old_config.DEV9.EthDevice ||
|
||||||
oldConfig->EthApi != config.EthApi)
|
EmuConfig.DEV9.EthApi != old_config.DEV9.EthApi)
|
||||||
{
|
{
|
||||||
TermNet();
|
TermNet();
|
||||||
InitNet();
|
InitNet();
|
||||||
|
@ -144,7 +144,7 @@ void ReconfigureLiveNet(ConfigDEV9* oldConfig)
|
||||||
else
|
else
|
||||||
InitNet();
|
InitNet();
|
||||||
}
|
}
|
||||||
else if (oldConfig->ethEnable)
|
else if (old_config.DEV9.EthEnable)
|
||||||
TermNet();
|
TermNet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,21 +163,6 @@ void TermNet()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const wxChar* NetApiToWxString(NetApi api)
|
|
||||||
{
|
|
||||||
switch (api)
|
|
||||||
{
|
|
||||||
case NetApi::PCAP_Bridged:
|
|
||||||
return _("PCAP Bridged");
|
|
||||||
case NetApi::PCAP_Switched:
|
|
||||||
return _("PCAP Switched");
|
|
||||||
case NetApi::TAP:
|
|
||||||
return _("TAP");
|
|
||||||
default:
|
|
||||||
return _("UNK");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
using namespace PacketReader;
|
using namespace PacketReader;
|
||||||
using namespace PacketReader::IP;
|
using namespace PacketReader::IP;
|
||||||
using namespace PacketReader::IP::UDP;
|
using namespace PacketReader::IP::UDP;
|
||||||
|
@ -224,7 +209,7 @@ NetAdapter::~NetAdapter()
|
||||||
|
|
||||||
void NetAdapter::InspectSend(NetPacket* pkt)
|
void NetAdapter::InspectSend(NetPacket* pkt)
|
||||||
{
|
{
|
||||||
if (config.EthLogDNS)
|
if (EmuConfig.DEV9.EthLogDNS)
|
||||||
{
|
{
|
||||||
EthernetFrame frame(pkt);
|
EthernetFrame frame(pkt);
|
||||||
if (frame.protocol == (u16)EtherType::IPv4)
|
if (frame.protocol == (u16)EtherType::IPv4)
|
||||||
|
@ -249,7 +234,7 @@ void NetAdapter::InspectSend(NetPacket* pkt)
|
||||||
}
|
}
|
||||||
void NetAdapter::InspectRecv(NetPacket* pkt)
|
void NetAdapter::InspectRecv(NetPacket* pkt)
|
||||||
{
|
{
|
||||||
if (config.EthLogDNS)
|
if (EmuConfig.DEV9.EthLogDNS)
|
||||||
{
|
{
|
||||||
EthernetFrame frame(pkt);
|
EthernetFrame frame(pkt);
|
||||||
if (frame.protocol == (u16)EtherType::IPv4)
|
if (frame.protocol == (u16)EtherType::IPv4)
|
||||||
|
@ -313,7 +298,7 @@ void NetAdapter::InitInternalServer(ifaddrs* adapter)
|
||||||
if (adapter == nullptr)
|
if (adapter == nullptr)
|
||||||
Console.Error("DEV9: InitInternalServer() got nullptr for adapter");
|
Console.Error("DEV9: InitInternalServer() got nullptr for adapter");
|
||||||
|
|
||||||
if (config.InterceptDHCP)
|
if (EmuConfig.DEV9.InterceptDHCP)
|
||||||
dhcpServer.Init(adapter);
|
dhcpServer.Init(adapter);
|
||||||
|
|
||||||
dnsServer.Init(adapter);
|
dnsServer.Init(adapter);
|
||||||
|
@ -334,7 +319,7 @@ void NetAdapter::ReloadInternalServer(ifaddrs* adapter)
|
||||||
if (adapter == nullptr)
|
if (adapter == nullptr)
|
||||||
Console.Error("DEV9: ReloadInternalServer() got nullptr for adapter");
|
Console.Error("DEV9: ReloadInternalServer() got nullptr for adapter");
|
||||||
|
|
||||||
if (config.InterceptDHCP)
|
if (EmuConfig.DEV9.InterceptDHCP)
|
||||||
dhcpServer.Init(adapter);
|
dhcpServer.Init(adapter);
|
||||||
|
|
||||||
dnsServer.Init(adapter);
|
dnsServer.Init(adapter);
|
||||||
|
@ -391,7 +376,7 @@ bool NetAdapter::InternalServerSend(NetPacket* pkt)
|
||||||
if (udppkt.destinationPort == 67)
|
if (udppkt.destinationPort == 67)
|
||||||
{
|
{
|
||||||
//Send DHCP
|
//Send DHCP
|
||||||
if (config.InterceptDHCP)
|
if (EmuConfig.DEV9.InterceptDHCP)
|
||||||
return dhcpServer.Send(&udppkt);
|
return dhcpServer.Send(&udppkt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,17 +58,9 @@ extern mtfifo<NetPacket*> rx_fifo;
|
||||||
extern mtfifo<NetPacket*> tx_fifo;
|
extern mtfifo<NetPacket*> tx_fifo;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum struct NetApi : int
|
|
||||||
{
|
|
||||||
Unset = 0,
|
|
||||||
PCAP_Bridged = 1,
|
|
||||||
PCAP_Switched = 2,
|
|
||||||
TAP = 3,
|
|
||||||
};
|
|
||||||
|
|
||||||
struct AdapterEntry
|
struct AdapterEntry
|
||||||
{
|
{
|
||||||
NetApi type;
|
Pcsx2Config::DEV9Options::NetApi type;
|
||||||
//UTF8
|
//UTF8
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string guid;
|
std::string guid;
|
||||||
|
@ -133,7 +125,5 @@ private:
|
||||||
|
|
||||||
void tx_put(NetPacket* ptr);
|
void tx_put(NetPacket* ptr);
|
||||||
void InitNet();
|
void InitNet();
|
||||||
void ReconfigureLiveNet(ConfigDEV9* oldConfig);
|
void ReconfigureLiveNet(const Pcsx2Config& old_config);
|
||||||
void TermNet();
|
void TermNet();
|
||||||
|
|
||||||
const wxChar* NetApiToWxString(NetApi api);
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ mac_address host_mac;
|
||||||
//IP_ADAPTER_ADDRESSES is a structure that contains ptrs to data in other regions
|
//IP_ADAPTER_ADDRESSES is a structure that contains ptrs to data in other regions
|
||||||
//of the buffer, se we need to return both so the caller can free the buffer
|
//of the buffer, se we need to return both so the caller can free the buffer
|
||||||
//after it's finished reading the needed data from IP_ADAPTER_ADDRESSES
|
//after it's finished reading the needed data from IP_ADAPTER_ADDRESSES
|
||||||
bool PCAPGetWin32Adapter(const char* name, PIP_ADAPTER_ADDRESSES adapter, std::unique_ptr<IP_ADAPTER_ADDRESSES[]>* buffer)
|
bool PCAPGetWin32Adapter(const std::string& name, PIP_ADAPTER_ADDRESSES adapter, std::unique_ptr<IP_ADAPTER_ADDRESSES[]>* buffer)
|
||||||
{
|
{
|
||||||
const int guidindex = strlen("\\Device\\NPF_");
|
const int guidindex = strlen("\\Device\\NPF_");
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ bool PCAPGetWin32Adapter(const char* name, PIP_ADAPTER_ADDRESSES adapter, std::u
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (0 == strcmp(pAdapterInfo->AdapterName, &name[guidindex]))
|
if (0 == strcmp(pAdapterInfo->AdapterName, &name.c_str()[guidindex]))
|
||||||
{
|
{
|
||||||
*adapter = *pAdapterInfo;
|
*adapter = *pAdapterInfo;
|
||||||
buffer->swap(AdapterInfo);
|
buffer->swap(AdapterInfo);
|
||||||
|
@ -112,7 +112,7 @@ bool PCAPGetWin32Adapter(const char* name, PIP_ADAPTER_ADDRESSES adapter, std::u
|
||||||
}
|
}
|
||||||
#elif defined(__POSIX__)
|
#elif defined(__POSIX__)
|
||||||
//getifaddrs is not POSIX, but is supported on MAC & Linux
|
//getifaddrs is not POSIX, but is supported on MAC & Linux
|
||||||
bool PCAPGetIfAdapter(char* name, ifaddrs* adapter, ifaddrs** buffer)
|
bool PCAPGetIfAdapter(const std::string& name, ifaddrs* adapter, ifaddrs** buffer)
|
||||||
{
|
{
|
||||||
//Note, we don't support "any" adapter, but that also fails in pcap_io_init()
|
//Note, we don't support "any" adapter, but that also fails in pcap_io_init()
|
||||||
ifaddrs* adapterInfo;
|
ifaddrs* adapterInfo;
|
||||||
|
@ -126,7 +126,7 @@ bool PCAPGetIfAdapter(char* name, ifaddrs* adapter, ifaddrs** buffer)
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (pAdapter->ifa_addr != nullptr && pAdapter->ifa_addr->sa_family == AF_INET && strcmp(pAdapter->ifa_name, name) == 0)
|
if (pAdapter->ifa_addr != nullptr && pAdapter->ifa_addr->sa_family == AF_INET && strcmp(pAdapter->ifa_name, name.c_str()) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
pAdapter = pAdapter->ifa_next;
|
pAdapter = pAdapter->ifa_next;
|
||||||
|
@ -145,7 +145,7 @@ bool PCAPGetIfAdapter(char* name, ifaddrs* adapter, ifaddrs** buffer)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Fetches the MAC address and prints it
|
// Fetches the MAC address and prints it
|
||||||
int GetMACAddress(char* adapter, mac_address* addr)
|
int GetMACAddress(const std::string& adapter, mac_address* addr)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -161,7 +161,7 @@ int GetMACAddress(char* adapter, mac_address* addr)
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int fd = socket(AF_INET, SOCK_DGRAM, 0);
|
int fd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
strcpy(ifr.ifr_name, adapter);
|
strcpy(ifr.ifr_name, adapter.c_str());
|
||||||
if (0 == ioctl(fd, SIOCGIFHWADDR, &ifr))
|
if (0 == ioctl(fd, SIOCGIFHWADDR, &ifr))
|
||||||
{
|
{
|
||||||
retval = 1;
|
retval = 1;
|
||||||
|
@ -169,7 +169,7 @@ int GetMACAddress(char* adapter, mac_address* addr)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.Error("Could not get MAC address for adapter: %s", adapter);
|
Console.Error("Could not get MAC address for adapter: %s", adapter.c_str());
|
||||||
}
|
}
|
||||||
close(fd);
|
close(fd);
|
||||||
#else
|
#else
|
||||||
|
@ -178,18 +178,18 @@ int GetMACAddress(char* adapter, mac_address* addr)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pcap_io_init(char* adapter, bool switched, mac_address virtual_mac)
|
int pcap_io_init(const std::string& adapter, bool switched, mac_address virtual_mac)
|
||||||
{
|
{
|
||||||
struct bpf_program fp;
|
struct bpf_program fp;
|
||||||
char filter[1024] = "ether broadcast or ether dst ";
|
char filter[1024] = "ether broadcast or ether dst ";
|
||||||
int dlt;
|
int dlt;
|
||||||
char* dlt_name;
|
char* dlt_name;
|
||||||
Console.WriteLn("DEV9: Opening adapter '%s'...", adapter);
|
Console.WriteLn("DEV9: Opening adapter '%s'...", adapter.c_str());
|
||||||
|
|
||||||
pcap_io_switched = switched;
|
pcap_io_switched = switched;
|
||||||
|
|
||||||
/* Open the adapter */
|
/* Open the adapter */
|
||||||
if ((adhandle = pcap_open_live(adapter, // name of the device
|
if ((adhandle = pcap_open_live(adapter.c_str(), // name of the device
|
||||||
65536, // portion of the packet to capture.
|
65536, // portion of the packet to capture.
|
||||||
// 65536 grants that the whole packet will be captured on all the MACs.
|
// 65536 grants that the whole packet will be captured on all the MACs.
|
||||||
switched ? 1 : 0,
|
switched ? 1 : 0,
|
||||||
|
@ -198,7 +198,7 @@ int pcap_io_init(char* adapter, bool switched, mac_address virtual_mac)
|
||||||
)) == NULL)
|
)) == NULL)
|
||||||
{
|
{
|
||||||
Console.Error("DEV9: %s", errbuf);
|
Console.Error("DEV9: %s", errbuf);
|
||||||
Console.Error("DEV9: Unable to open the adapter. %s is not supported by pcap", adapter);
|
Console.Error("DEV9: Unable to open the adapter. %s is not supported by pcap", adapter.c_str());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (switched)
|
if (switched)
|
||||||
|
@ -358,9 +358,8 @@ void pcap_io_close()
|
||||||
PCAPAdapter::PCAPAdapter()
|
PCAPAdapter::PCAPAdapter()
|
||||||
: NetAdapter()
|
: NetAdapter()
|
||||||
{
|
{
|
||||||
if (config.ethEnable == 0)
|
if (!EmuConfig.DEV9.EthEnable)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
if (!load_pcap())
|
if (!load_pcap())
|
||||||
return;
|
return;
|
||||||
|
@ -369,7 +368,7 @@ PCAPAdapter::PCAPAdapter()
|
||||||
mac_address hostMAC;
|
mac_address hostMAC;
|
||||||
mac_address newMAC;
|
mac_address newMAC;
|
||||||
|
|
||||||
GetMACAddress(config.Eth, &hostMAC);
|
GetMACAddress(EmuConfig.DEV9.EthDevice, &hostMAC);
|
||||||
memcpy(&newMAC, ps2MAC, 6);
|
memcpy(&newMAC, ps2MAC, 6);
|
||||||
|
|
||||||
//Lets take the hosts last 2 bytes to make it unique on Xlink
|
//Lets take the hosts last 2 bytes to make it unique on Xlink
|
||||||
|
@ -380,16 +379,16 @@ PCAPAdapter::PCAPAdapter()
|
||||||
host_mac = hostMAC;
|
host_mac = hostMAC;
|
||||||
ps2_mac = newMAC; //Needed outside of this class
|
ps2_mac = newMAC; //Needed outside of this class
|
||||||
|
|
||||||
if (pcap_io_init(config.Eth, config.EthApi == NetApi::PCAP_Switched, newMAC) == -1)
|
if (pcap_io_init(EmuConfig.DEV9.EthDevice, EmuConfig.DEV9.EthApi == Pcsx2Config::DEV9Options::NetApi::PCAP_Switched, newMAC) == -1)
|
||||||
{
|
{
|
||||||
Console.Error("DEV9: Can't open Device '%s'", config.Eth);
|
Console.Error("DEV9: Can't open Device '%s'", EmuConfig.DEV9.EthDevice.c_str());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
IP_ADAPTER_ADDRESSES adapter;
|
IP_ADAPTER_ADDRESSES adapter;
|
||||||
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
||||||
if (PCAPGetWin32Adapter(config.Eth, &adapter, &buffer))
|
if (PCAPGetWin32Adapter(EmuConfig.DEV9.EthDevice, &adapter, &buffer))
|
||||||
InitInternalServer(&adapter);
|
InitInternalServer(&adapter);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -399,7 +398,7 @@ PCAPAdapter::PCAPAdapter()
|
||||||
#elif defined(__POSIX__)
|
#elif defined(__POSIX__)
|
||||||
ifaddrs adapter;
|
ifaddrs adapter;
|
||||||
ifaddrs* buffer;
|
ifaddrs* buffer;
|
||||||
if (PCAPGetIfAdapter(config.Eth, &adapter, &buffer))
|
if (PCAPGetIfAdapter(EmuConfig.DEV9.EthDevice, &adapter, &buffer))
|
||||||
{
|
{
|
||||||
InitInternalServer(&adapter);
|
InitInternalServer(&adapter);
|
||||||
freeifaddrs(buffer);
|
freeifaddrs(buffer);
|
||||||
|
@ -457,14 +456,14 @@ void PCAPAdapter::reloadSettings()
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
IP_ADAPTER_ADDRESSES adapter;
|
IP_ADAPTER_ADDRESSES adapter;
|
||||||
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
std::unique_ptr<IP_ADAPTER_ADDRESSES[]> buffer;
|
||||||
if (PCAPGetWin32Adapter(config.Eth, &adapter, &buffer))
|
if (PCAPGetWin32Adapter(EmuConfig.DEV9.EthDevice, &adapter, &buffer))
|
||||||
ReloadInternalServer(&adapter);
|
ReloadInternalServer(&adapter);
|
||||||
else
|
else
|
||||||
ReloadInternalServer(nullptr);
|
ReloadInternalServer(nullptr);
|
||||||
#elif defined(__POSIX__)
|
#elif defined(__POSIX__)
|
||||||
ifaddrs adapter;
|
ifaddrs adapter;
|
||||||
ifaddrs* buffer;
|
ifaddrs* buffer;
|
||||||
if (PCAPGetIfAdapter(config.Eth, &adapter, &buffer))
|
if (PCAPGetIfAdapter(EmuConfig.DEV9.EthDevice, &adapter, &buffer))
|
||||||
{
|
{
|
||||||
ReloadInternalServer(&adapter);
|
ReloadInternalServer(&adapter);
|
||||||
freeifaddrs(buffer);
|
freeifaddrs(buffer);
|
||||||
|
@ -500,7 +499,7 @@ std::vector<AdapterEntry> PCAPAdapter::GetAdapters()
|
||||||
while (d != NULL)
|
while (d != NULL)
|
||||||
{
|
{
|
||||||
AdapterEntry entry;
|
AdapterEntry entry;
|
||||||
entry.type = NetApi::PCAP_Switched;
|
entry.type = Pcsx2Config::DEV9Options::NetApi::PCAP_Switched;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
//guid
|
//guid
|
||||||
entry.guid = std::string(d->name);
|
entry.guid = std::string(d->name);
|
||||||
|
@ -531,7 +530,7 @@ std::vector<AdapterEntry> PCAPAdapter::GetAdapters()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nic.push_back(entry);
|
nic.push_back(entry);
|
||||||
entry.type = NetApi::PCAP_Bridged;
|
entry.type = Pcsx2Config::DEV9Options::NetApi::PCAP_Bridged;
|
||||||
nic.push_back(entry);
|
nic.push_back(entry);
|
||||||
d = d->next;
|
d = d->next;
|
||||||
}
|
}
|
||||||
|
|
|
@ -651,6 +651,78 @@ void Pcsx2Config::SPU2Options::LoadSave(SettingsWrapper& wrap)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Pcsx2Config::DEV9Options::NetApiNames[] = {
|
||||||
|
"Unset",
|
||||||
|
"PCAP Bridged",
|
||||||
|
"PCAP Switched",
|
||||||
|
"TAP",
|
||||||
|
nullptr};
|
||||||
|
|
||||||
|
Pcsx2Config::DEV9Options::DEV9Options()
|
||||||
|
{
|
||||||
|
HddFile = "DEV9hdd.raw";
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pcsx2Config::DEV9Options::LoadSave(SettingsWrapper& wrap)
|
||||||
|
{
|
||||||
|
{
|
||||||
|
SettingsWrapSection("DEV9/Eth");
|
||||||
|
SettingsWrapEntry(EthEnable);
|
||||||
|
SettingsWrapEnumEx(EthApi, "EthApi", NetApiNames);
|
||||||
|
SettingsWrapEntry(EthDevice);
|
||||||
|
SettingsWrapEntry(EthLogDNS);
|
||||||
|
|
||||||
|
SettingsWrapEntry(InterceptDHCP);
|
||||||
|
|
||||||
|
std::string ps2IPStr = "0.0.0.0";
|
||||||
|
std::string gatewayStr = "0.0.0.0";
|
||||||
|
std::string dns1Str = "0.0.0.0";
|
||||||
|
std::string dns2Str = "0.0.0.0";
|
||||||
|
if (wrap.IsSaving())
|
||||||
|
{
|
||||||
|
ps2IPStr = SaveIPHelper(PS2IP);
|
||||||
|
gatewayStr = SaveIPHelper(Gateway);
|
||||||
|
dns1Str = SaveIPHelper(DNS1);
|
||||||
|
dns2Str = SaveIPHelper(DNS2);
|
||||||
|
}
|
||||||
|
SettingsWrapEntryEx(ps2IPStr, "PS2IP");
|
||||||
|
SettingsWrapEntryEx(gatewayStr, "Gateway");
|
||||||
|
SettingsWrapEntryEx(dns1Str, "DNS1");
|
||||||
|
SettingsWrapEntryEx(dns2Str, "DNS2");
|
||||||
|
if (wrap.IsLoading())
|
||||||
|
{
|
||||||
|
LoadIPHelper(PS2IP, ps2IPStr);
|
||||||
|
LoadIPHelper(Gateway, gatewayStr);
|
||||||
|
LoadIPHelper(DNS1, dns1Str);
|
||||||
|
LoadIPHelper(DNS1, dns1Str);
|
||||||
|
}
|
||||||
|
|
||||||
|
SettingsWrapEntry(AutoMask);
|
||||||
|
SettingsWrapEntry(AutoGateway);
|
||||||
|
SettingsWrapEntry(AutoDNS1);
|
||||||
|
SettingsWrapEntry(AutoDNS2);
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
SettingsWrapSection("DEV9/Hdd");
|
||||||
|
SettingsWrapEntry(HddEnable);
|
||||||
|
SettingsWrapEntry(HddFile);
|
||||||
|
SettingsWrapEntry(HddSizeSectors);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Pcsx2Config::DEV9Options::LoadIPHelper(u8* field, const std::string& setting)
|
||||||
|
{
|
||||||
|
if (4 == sscanf(setting.c_str(), "%hhu.%hhu.%hhu.%hhu", &field[0], &field[1], &field[2], &field[3]))
|
||||||
|
return;
|
||||||
|
Console.Error("Invalid IP address in settings file");
|
||||||
|
std::fill(field, field + 4, 0);
|
||||||
|
}
|
||||||
|
std::string Pcsx2Config::DEV9Options::SaveIPHelper(u8* field)
|
||||||
|
{
|
||||||
|
return StringUtil::StdStringFromFormat("%u.%u.%u.%u", field[0], field[1], field[2], field[3]);
|
||||||
|
}
|
||||||
|
|
||||||
static const char* const tbl_GamefixNames[] =
|
static const char* const tbl_GamefixNames[] =
|
||||||
{
|
{
|
||||||
"FpuMul",
|
"FpuMul",
|
||||||
|
@ -947,6 +1019,7 @@ void Pcsx2Config::LoadSave(SettingsWrapper& wrap)
|
||||||
// SPU2 is in a separate ini in wx.
|
// SPU2 is in a separate ini in wx.
|
||||||
SPU2.LoadSave(wrap);
|
SPU2.LoadSave(wrap);
|
||||||
#endif
|
#endif
|
||||||
|
DEV9.LoadSave(wrap);
|
||||||
Gamefixes.LoadSave(wrap);
|
Gamefixes.LoadSave(wrap);
|
||||||
Profiler.LoadSave(wrap);
|
Profiler.LoadSave(wrap);
|
||||||
|
|
||||||
|
@ -1021,6 +1094,7 @@ bool Pcsx2Config::operator==(const Pcsx2Config& right) const
|
||||||
OpEqu(bitset) &&
|
OpEqu(bitset) &&
|
||||||
OpEqu(Cpu) &&
|
OpEqu(Cpu) &&
|
||||||
OpEqu(GS) &&
|
OpEqu(GS) &&
|
||||||
|
OpEqu(DEV9) &&
|
||||||
OpEqu(Speedhacks) &&
|
OpEqu(Speedhacks) &&
|
||||||
OpEqu(Gamefixes) &&
|
OpEqu(Gamefixes) &&
|
||||||
OpEqu(Profiler) &&
|
OpEqu(Profiler) &&
|
||||||
|
@ -1042,6 +1116,7 @@ void Pcsx2Config::CopyConfig(const Pcsx2Config& cfg)
|
||||||
{
|
{
|
||||||
Cpu = cfg.Cpu;
|
Cpu = cfg.Cpu;
|
||||||
GS = cfg.GS;
|
GS = cfg.GS;
|
||||||
|
DEV9 = cfg.DEV9;
|
||||||
Speedhacks = cfg.Speedhacks;
|
Speedhacks = cfg.Speedhacks;
|
||||||
Gamefixes = cfg.Gamefixes;
|
Gamefixes = cfg.Gamefixes;
|
||||||
Profiler = cfg.Profiler;
|
Profiler = cfg.Profiler;
|
||||||
|
|
|
@ -187,8 +187,13 @@ void SysCoreThread::ApplySettings(const Pcsx2Config& src)
|
||||||
|
|
||||||
const bool gs_settings_changed = !src.GS.OptionsAreEqual(EmuConfig.GS);
|
const bool gs_settings_changed = !src.GS.OptionsAreEqual(EmuConfig.GS);
|
||||||
|
|
||||||
|
Pcsx2Config old_config;
|
||||||
|
old_config.CopyConfig(EmuConfig);
|
||||||
EmuConfig.CopyConfig(src);
|
EmuConfig.CopyConfig(src);
|
||||||
|
|
||||||
|
// handle DEV9 setting changes
|
||||||
|
DEV9CheckChanges(old_config);
|
||||||
|
|
||||||
// handle GS setting changes
|
// handle GS setting changes
|
||||||
if (GetMTGS().IsOpen() && gs_settings_changed)
|
if (GetMTGS().IsOpen() && gs_settings_changed)
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
#include "PerformanceMetrics.h"
|
#include "PerformanceMetrics.h"
|
||||||
#include "R5900.h"
|
#include "R5900.h"
|
||||||
#include "SPU2/spu2.h"
|
#include "SPU2/spu2.h"
|
||||||
|
#include "DEV9/DEV9.h"
|
||||||
#include "System/SysThreads.h"
|
#include "System/SysThreads.h"
|
||||||
#include "USB/USB.h"
|
#include "USB/USB.h"
|
||||||
#include "PAD/Host/PAD.h"
|
#include "PAD/Host/PAD.h"
|
||||||
|
@ -71,6 +72,7 @@ namespace VMManager
|
||||||
static void CheckForFramerateConfigChanges(const Pcsx2Config& old_config);
|
static void CheckForFramerateConfigChanges(const Pcsx2Config& old_config);
|
||||||
static void CheckForPatchConfigChanges(const Pcsx2Config& old_config);
|
static void CheckForPatchConfigChanges(const Pcsx2Config& old_config);
|
||||||
static void CheckForSPU2ConfigChanges(const Pcsx2Config& old_config);
|
static void CheckForSPU2ConfigChanges(const Pcsx2Config& old_config);
|
||||||
|
static void CheckForDEV9ConfigChanges(const Pcsx2Config& old_config);
|
||||||
static void CheckForMemoryCardConfigChanges(const Pcsx2Config& old_config);
|
static void CheckForMemoryCardConfigChanges(const Pcsx2Config& old_config);
|
||||||
static void UpdateRunningGame(bool force);
|
static void UpdateRunningGame(bool force);
|
||||||
|
|
||||||
|
@ -1074,6 +1076,14 @@ void VMManager::CheckForSPU2ConfigChanges(const Pcsx2Config& old_config)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VMManager::CheckForDEV9ConfigChanges(const Pcsx2Config& old_config)
|
||||||
|
{
|
||||||
|
if (EmuConfig.DEV9 == old_config.DEV9)
|
||||||
|
return;
|
||||||
|
|
||||||
|
DEV9CheckChanges(old_config);
|
||||||
|
}
|
||||||
|
|
||||||
void VMManager::CheckForMemoryCardConfigChanges(const Pcsx2Config& old_config)
|
void VMManager::CheckForMemoryCardConfigChanges(const Pcsx2Config& old_config)
|
||||||
{
|
{
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
@ -1118,6 +1128,7 @@ void VMManager::CheckForConfigChanges(const Pcsx2Config& old_config)
|
||||||
CheckForFramerateConfigChanges(old_config);
|
CheckForFramerateConfigChanges(old_config);
|
||||||
CheckForPatchConfigChanges(old_config);
|
CheckForPatchConfigChanges(old_config);
|
||||||
CheckForSPU2ConfigChanges(old_config);
|
CheckForSPU2ConfigChanges(old_config);
|
||||||
|
CheckForDEV9ConfigChanges(old_config);
|
||||||
CheckForMemoryCardConfigChanges(old_config);
|
CheckForMemoryCardConfigChanges(old_config);
|
||||||
|
|
||||||
if (EmuConfig.EnableCheats != old_config.EnableCheats || EmuConfig.EnableWideScreenPatches != old_config.EnableWideScreenPatches)
|
if (EmuConfig.EnableCheats != old_config.EnableCheats || EmuConfig.EnableWideScreenPatches != old_config.EnableWideScreenPatches)
|
||||||
|
|
|
@ -304,7 +304,6 @@
|
||||||
<ClCompile Include="DEV9\pcap_io.cpp" />
|
<ClCompile Include="DEV9\pcap_io.cpp" />
|
||||||
<ClCompile Include="DEV9\Win32\pcap_io_win32.cpp" />
|
<ClCompile Include="DEV9\Win32\pcap_io_win32.cpp" />
|
||||||
<ClCompile Include="DEV9\smap.cpp" />
|
<ClCompile Include="DEV9\smap.cpp" />
|
||||||
<ClCompile Include="DEV9\Win32\DEV9WinConfig.cpp" />
|
|
||||||
<ClCompile Include="DEV9\net.cpp" />
|
<ClCompile Include="DEV9\net.cpp" />
|
||||||
<ClCompile Include="DEV9\Win32\tap-win32.cpp" />
|
<ClCompile Include="DEV9\Win32\tap-win32.cpp" />
|
||||||
<ClCompile Include="Frontend\D3D11HostDisplay.cpp" />
|
<ClCompile Include="Frontend\D3D11HostDisplay.cpp" />
|
||||||
|
|
|
@ -1262,9 +1262,6 @@
|
||||||
<ClCompile Include="DEV9\Win32\tap-win32.cpp">
|
<ClCompile Include="DEV9\Win32\tap-win32.cpp">
|
||||||
<Filter>System\Ps2\DEV9</Filter>
|
<Filter>System\Ps2\DEV9</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="DEV9\Win32\DEV9WinConfig.cpp">
|
|
||||||
<Filter>System\Ps2\DEV9</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="USB\configuration.cpp">
|
<ClCompile Include="USB\configuration.cpp">
|
||||||
<Filter>System\Ps2\USB</Filter>
|
<Filter>System\Ps2\USB</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
|
@ -169,7 +169,6 @@
|
||||||
<ClCompile Include="DEV9\pcap_io.cpp" />
|
<ClCompile Include="DEV9\pcap_io.cpp" />
|
||||||
<ClCompile Include="DEV9\Win32\pcap_io_win32.cpp" />
|
<ClCompile Include="DEV9\Win32\pcap_io_win32.cpp" />
|
||||||
<ClCompile Include="DEV9\smap.cpp" />
|
<ClCompile Include="DEV9\smap.cpp" />
|
||||||
<ClCompile Include="DEV9\Win32\DEV9WinConfig.cpp" />
|
|
||||||
<ClCompile Include="DEV9\net.cpp" />
|
<ClCompile Include="DEV9\net.cpp" />
|
||||||
<ClCompile Include="DEV9\Win32\tap-win32.cpp" />
|
<ClCompile Include="DEV9\Win32\tap-win32.cpp" />
|
||||||
<ClCompile Include="Frontend\D3D11HostDisplay.cpp" />
|
<ClCompile Include="Frontend\D3D11HostDisplay.cpp" />
|
||||||
|
|
|
@ -923,9 +923,6 @@
|
||||||
<ClCompile Include="DEV9\Win32\tap-win32.cpp">
|
<ClCompile Include="DEV9\Win32\tap-win32.cpp">
|
||||||
<Filter>System\Ps2\DEV9</Filter>
|
<Filter>System\Ps2\DEV9</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="DEV9\Win32\DEV9WinConfig.cpp">
|
|
||||||
<Filter>System\Ps2\DEV9</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="GS\GS.cpp">
|
<ClCompile Include="GS\GS.cpp">
|
||||||
<Filter>System\Ps2\GS</Filter>
|
<Filter>System\Ps2\GS</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|
Loading…
Reference in New Issue