2016-12-22 09:06:27 +01:00
|
|
|
// Copyright 2016 Citra Emulator Project
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2018-02-23 06:31:58 +01:00
|
|
|
#include <cryptopp/osrng.h>
|
2016-12-22 09:06:27 +01:00
|
|
|
#include "core/hle/service/nwm/nwm.h"
|
|
|
|
#include "core/hle/service/nwm/nwm_cec.h"
|
|
|
|
#include "core/hle/service/nwm/nwm_ext.h"
|
|
|
|
#include "core/hle/service/nwm/nwm_inf.h"
|
|
|
|
#include "core/hle/service/nwm/nwm_sap.h"
|
|
|
|
#include "core/hle/service/nwm/nwm_soc.h"
|
|
|
|
#include "core/hle/service/nwm/nwm_tst.h"
|
|
|
|
#include "core/hle/service/nwm/nwm_uds.h"
|
2018-02-18 06:14:21 +01:00
|
|
|
#include "core/hle/shared_page.h"
|
|
|
|
#include "network/network.h"
|
2016-12-22 09:06:27 +01:00
|
|
|
|
|
|
|
namespace Service {
|
|
|
|
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);
|
2018-02-18 06:14:21 +01:00
|
|
|
|
2018-02-23 06:31:58 +01:00
|
|
|
CryptoPP::AutoSeededRandomPool rng;
|
2018-02-18 06:14:21 +01:00
|
|
|
auto mac = SharedPage::DefaultMac;
|
2018-02-23 06:31:58 +01:00
|
|
|
// Keep the Nintendo 3DS MAC header and randomly generate the last 3 bytes
|
|
|
|
rng.GenerateBlock(static_cast<CryptoPP::byte*>(mac.data() + 3), 3);
|
|
|
|
|
2018-02-18 06:14:21 +01:00
|
|
|
if (auto room_member = Network::GetRoomMember().lock()) {
|
|
|
|
if (room_member->IsConnected()) {
|
2018-03-05 04:16:36 +01:00
|
|
|
mac = room_member->GetMacAddress();
|
2018-02-18 06:14:21 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
SharedPage::SetMacAddress(mac);
|
|
|
|
SharedPage::SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST);
|
2017-11-25 21:08:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void InstallInterfaces(SM::ServiceManager& service_manager) {
|
|
|
|
std::make_shared<NWM_UDS>()->InstallAsService(service_manager);
|
2016-12-22 09:06:27 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace NWM
|
|
|
|
} // namespace Service
|