mirror of
https://github.com/Lime3DS/Lime3DS.git
synced 2024-11-11 12:45:05 +01:00
Service/NWM: convert to ServiceFramwework
This commit is contained in:
parent
64adf94ef2
commit
7471373058
@ -2,7 +2,6 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include <cryptopp/osrng.h>
|
|
||||||
#include "core/hle/service/nwm/nwm.h"
|
#include "core/hle/service/nwm/nwm.h"
|
||||||
#include "core/hle/service/nwm/nwm_cec.h"
|
#include "core/hle/service/nwm/nwm_cec.h"
|
||||||
#include "core/hle/service/nwm/nwm_ext.h"
|
#include "core/hle/service/nwm/nwm_ext.h"
|
||||||
@ -11,35 +10,17 @@
|
|||||||
#include "core/hle/service/nwm/nwm_soc.h"
|
#include "core/hle/service/nwm/nwm_soc.h"
|
||||||
#include "core/hle/service/nwm/nwm_tst.h"
|
#include "core/hle/service/nwm/nwm_tst.h"
|
||||||
#include "core/hle/service/nwm/nwm_uds.h"
|
#include "core/hle/service/nwm/nwm_uds.h"
|
||||||
#include "core/hle/shared_page.h"
|
|
||||||
#include "network/network.h"
|
|
||||||
|
|
||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
void Init() {
|
|
||||||
AddService(new NWM_CEC);
|
|
||||||
AddService(new NWM_EXT);
|
|
||||||
AddService(new NWM_INF);
|
|
||||||
AddService(new NWM_SAP);
|
|
||||||
AddService(new NWM_SOC);
|
|
||||||
AddService(new NWM_TST);
|
|
||||||
|
|
||||||
CryptoPP::AutoSeededRandomPool rng;
|
|
||||||
auto mac = SharedPage::DefaultMac;
|
|
||||||
// Keep the Nintendo 3DS MAC header and randomly generate the last 3 bytes
|
|
||||||
rng.GenerateBlock(static_cast<CryptoPP::byte*>(mac.data() + 3), 3);
|
|
||||||
|
|
||||||
if (auto room_member = Network::GetRoomMember().lock()) {
|
|
||||||
if (room_member->IsConnected()) {
|
|
||||||
mac = room_member->GetMacAddress();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
SharedPage::SetMacAddress(mac);
|
|
||||||
SharedPage::SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST);
|
|
||||||
}
|
|
||||||
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
||||||
|
std::make_shared<NWM_CEC>()->InstallAsService(service_manager);
|
||||||
|
std::make_shared<NWM_EXT>()->InstallAsService(service_manager);
|
||||||
|
std::make_shared<NWM_INF>()->InstallAsService(service_manager);
|
||||||
|
std::make_shared<NWM_SAP>()->InstallAsService(service_manager);
|
||||||
|
std::make_shared<NWM_SOC>()->InstallAsService(service_manager);
|
||||||
|
std::make_shared<NWM_TST>()->InstallAsService(service_manager);
|
||||||
std::make_shared<NWM_UDS>()->InstallAsService(service_manager);
|
std::make_shared<NWM_UDS>()->InstallAsService(service_manager);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,6 @@ namespace Service {
|
|||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
/// Initialize all NWM services
|
/// Initialize all NWM services
|
||||||
void Init();
|
|
||||||
void InstallInterfaces(SM::ServiceManager& service_manager);
|
void InstallInterfaces(SM::ServiceManager& service_manager);
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -7,12 +7,11 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
NWM_CEC::NWM_CEC() : ServiceFramework("nwm::CEC") {
|
||||||
{0x000D0082, nullptr, "SendProbeRequest"},
|
static const FunctionInfo functions[] = {
|
||||||
};
|
{0x000D0082, nullptr, "SendProbeRequest"},
|
||||||
|
};
|
||||||
NWM_CEC::NWM_CEC() {
|
RegisterHandlers(functions);
|
||||||
Register(FunctionTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -9,13 +9,9 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
class NWM_CEC final : public Interface {
|
class NWM_CEC final : public ServiceFramework<NWM_CEC> {
|
||||||
public:
|
public:
|
||||||
NWM_CEC();
|
NWM_CEC();
|
||||||
|
|
||||||
std::string GetPortName() const override {
|
|
||||||
return "nwm::CEC";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -7,12 +7,11 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
NWM_EXT::NWM_EXT() : ServiceFramework("nwm::EXT") {
|
||||||
{0x00080040, nullptr, "ControlWirelessEnabled"},
|
static const FunctionInfo functions[] = {
|
||||||
};
|
{0x00080040, nullptr, "ControlWirelessEnabled"},
|
||||||
|
};
|
||||||
NWM_EXT::NWM_EXT() {
|
RegisterHandlers(functions);
|
||||||
Register(FunctionTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -9,13 +9,9 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
class NWM_EXT final : public Interface {
|
class NWM_EXT final : public ServiceFramework<NWM_EXT> {
|
||||||
public:
|
public:
|
||||||
NWM_EXT();
|
NWM_EXT();
|
||||||
|
|
||||||
std::string GetPortName() const override {
|
|
||||||
return "nwm::EXT";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -7,14 +7,13 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
NWM_INF::NWM_INF() : ServiceFramework("nwm::INF") {
|
||||||
{0x000603C4, nullptr, "RecvBeaconBroadcastData"},
|
static const FunctionInfo functions[] = {
|
||||||
{0x00070742, nullptr, "ConnectToEncryptedAP"},
|
{0x000603C4, nullptr, "RecvBeaconBroadcastData"},
|
||||||
{0x00080302, nullptr, "ConnectToAP"},
|
{0x00070742, nullptr, "ConnectToEncryptedAP"},
|
||||||
};
|
{0x00080302, nullptr, "ConnectToAP"},
|
||||||
|
};
|
||||||
NWM_INF::NWM_INF() {
|
RegisterHandlers(functions);
|
||||||
Register(FunctionTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -9,13 +9,9 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
class NWM_INF final : public Interface {
|
class NWM_INF final : public ServiceFramework<NWM_INF> {
|
||||||
public:
|
public:
|
||||||
NWM_INF();
|
NWM_INF();
|
||||||
|
|
||||||
std::string GetPortName() const override {
|
|
||||||
return "nwm::INF";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -7,13 +7,12 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
/*
|
NWM_SAP::NWM_SAP() : ServiceFramework("nwm::SAP") {
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
/*
|
||||||
};
|
static const FunctionInfo functions[] = {
|
||||||
*/
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
NWM_SAP::NWM_SAP() {
|
*/
|
||||||
// Register(FunctionTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -9,13 +9,9 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
class NWM_SAP final : public Interface {
|
class NWM_SAP final : public ServiceFramework<NWM_SAP> {
|
||||||
public:
|
public:
|
||||||
NWM_SAP();
|
NWM_SAP();
|
||||||
|
|
||||||
std::string GetPortName() const override {
|
|
||||||
return "nwm::SAP";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -7,13 +7,12 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
/*
|
NWM_SOC::NWM_SOC() : ServiceFramework("nwm::SOC") {
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
/*
|
||||||
};
|
static const FunctionInfo functions[] = {
|
||||||
*/
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
NWM_SOC::NWM_SOC() {
|
*/
|
||||||
// Register(FunctionTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -9,13 +9,9 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
class NWM_SOC final : public Interface {
|
class NWM_SOC final : public ServiceFramework<NWM_SOC> {
|
||||||
public:
|
public:
|
||||||
NWM_SOC();
|
NWM_SOC();
|
||||||
|
|
||||||
std::string GetPortName() const override {
|
|
||||||
return "nwm::SOC";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -7,13 +7,12 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
/*
|
NWM_TST::NWM_TST() : ServiceFramework("nwm::TST") {
|
||||||
const Interface::FunctionInfo FunctionTable[] = {
|
/*
|
||||||
};
|
static const FunctionInfo functions[] = {
|
||||||
*/
|
};
|
||||||
|
RegisterHandlers(functions);
|
||||||
NWM_TST::NWM_TST() {
|
*/
|
||||||
// Register(FunctionTable);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -9,13 +9,9 @@
|
|||||||
namespace Service {
|
namespace Service {
|
||||||
namespace NWM {
|
namespace NWM {
|
||||||
|
|
||||||
class NWM_TST final : public Interface {
|
class NWM_TST final : public ServiceFramework<NWM_TST> {
|
||||||
public:
|
public:
|
||||||
NWM_TST();
|
NWM_TST();
|
||||||
|
|
||||||
std::string GetPortName() const override {
|
|
||||||
return "nwm::TST";
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace NWM
|
} // namespace NWM
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <mutex>
|
#include <mutex>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <cryptopp/osrng.h>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "common/logging/log.h"
|
#include "common/logging/log.h"
|
||||||
#include "core/core_timing.h"
|
#include "core/core_timing.h"
|
||||||
@ -23,6 +24,7 @@
|
|||||||
#include "core/hle/service/nwm/uds_beacon.h"
|
#include "core/hle/service/nwm/uds_beacon.h"
|
||||||
#include "core/hle/service/nwm/uds_connection.h"
|
#include "core/hle/service/nwm/uds_connection.h"
|
||||||
#include "core/hle/service/nwm/uds_data.h"
|
#include "core/hle/service/nwm/uds_data.h"
|
||||||
|
#include "core/hle/shared_page.h"
|
||||||
#include "core/memory.h"
|
#include "core/memory.h"
|
||||||
#include "network/network.h"
|
#include "network/network.h"
|
||||||
|
|
||||||
@ -1320,6 +1322,19 @@ NWM_UDS::NWM_UDS() : ServiceFramework("nwm::UDS") {
|
|||||||
|
|
||||||
beacon_broadcast_event =
|
beacon_broadcast_event =
|
||||||
CoreTiming::RegisterEvent("UDS::BeaconBroadcastCallback", BeaconBroadcastCallback);
|
CoreTiming::RegisterEvent("UDS::BeaconBroadcastCallback", BeaconBroadcastCallback);
|
||||||
|
|
||||||
|
CryptoPP::AutoSeededRandomPool rng;
|
||||||
|
auto mac = SharedPage::DefaultMac;
|
||||||
|
// Keep the Nintendo 3DS MAC header and randomly generate the last 3 bytes
|
||||||
|
rng.GenerateBlock(static_cast<CryptoPP::byte*>(mac.data() + 3), 3);
|
||||||
|
|
||||||
|
if (auto room_member = Network::GetRoomMember().lock()) {
|
||||||
|
if (room_member->IsConnected()) {
|
||||||
|
mac = room_member->GetMacAddress();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
SharedPage::SetMacAddress(mac);
|
||||||
|
SharedPage::SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
NWM_UDS::~NWM_UDS() {
|
NWM_UDS::~NWM_UDS() {
|
||||||
|
@ -252,7 +252,6 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) {
|
|||||||
NEWS::InstallInterfaces(*sm);
|
NEWS::InstallInterfaces(*sm);
|
||||||
NFC::InstallInterfaces(*sm);
|
NFC::InstallInterfaces(*sm);
|
||||||
NIM::InstallInterfaces(*sm);
|
NIM::InstallInterfaces(*sm);
|
||||||
NWM::Init();
|
|
||||||
PTM::InstallInterfaces(*sm);
|
PTM::InstallInterfaces(*sm);
|
||||||
QTM::Init();
|
QTM::Init();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user