Lime3DS/src/core/hle/service/nwm/nwm.cpp

48 lines
1.5 KiB
C++
Raw Normal View History

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.
#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"
#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);
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 = static_cast<SharedPage::MacAddress>(room_member->GetMacAddress());
}
}
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