mirror of
				https://github.com/PabloMK7/citra.git
				synced 2025-10-31 05:40:04 +00:00 
			
		
		
		
	Merge pull request #3444 from jroweboy/fix-multiplayer
UDS: Add non zero mac address to the shared page
This commit is contained in:
		
						commit
						ce725f24ca
					
				
					 3 changed files with 42 additions and 2 deletions
				
			
		|  | @ -2,6 +2,7 @@ | |||
| // Licensed under GPLv2 or any later version
 | ||||
| // Refer to the license.txt file included.
 | ||||
| 
 | ||||
| #include <cryptopp/osrng.h> | ||||
| #include "core/hle/service/nwm/nwm.h" | ||||
| #include "core/hle/service/nwm/nwm_cec.h" | ||||
| #include "core/hle/service/nwm/nwm_ext.h" | ||||
|  | @ -10,6 +11,8 @@ | |||
| #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" | ||||
| 
 | ||||
| namespace Service { | ||||
| namespace NWM { | ||||
|  | @ -21,6 +24,19 @@ void Init() { | |||
|     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) { | ||||
|  |  | |||
|  | @ -85,4 +85,12 @@ void Init() { | |||
|     CoreTiming::ScheduleEvent(0, update_time_event); | ||||
| } | ||||
| 
 | ||||
| } // namespace
 | ||||
| void SetMacAddress(const MacAddress& addr) { | ||||
|     std::memcpy(shared_page.wifi_macaddr, addr.data(), sizeof(MacAddress)); | ||||
| } | ||||
| 
 | ||||
| void SetWifiLinkLevel(WifiLinkLevel level) { | ||||
|     shared_page.wifi_link_level = static_cast<u8>(level); | ||||
| } | ||||
| 
 | ||||
| } // namespace SharedPage
 | ||||
|  |  | |||
|  | @ -37,6 +37,18 @@ union BatteryState { | |||
|     BitField<2, 3, u8> charge_level; | ||||
| }; | ||||
| 
 | ||||
| using MacAddress = std::array<u8, 6>; | ||||
| 
 | ||||
| // Default MAC address in the Nintendo 3DS range
 | ||||
| constexpr MacAddress DefaultMac = {0x40, 0xF4, 0x07, 0x00, 0x00, 0x00}; | ||||
| 
 | ||||
| enum class WifiLinkLevel : u8 { | ||||
|     OFF = 0, | ||||
|     POOR = 1, | ||||
|     GOOD = 2, | ||||
|     BEST = 3, | ||||
| }; | ||||
| 
 | ||||
| struct SharedPageDef { | ||||
|     // Most of these names are taken from the 3dbrew page linked above.
 | ||||
|     u32_le date_time_counter; // 0
 | ||||
|  | @ -66,4 +78,8 @@ extern SharedPageDef shared_page; | |||
| 
 | ||||
| void Init(); | ||||
| 
 | ||||
| } // namespace
 | ||||
| void SetMacAddress(const MacAddress&); | ||||
| 
 | ||||
| void SetWifiLinkLevel(WifiLinkLevel); | ||||
| 
 | ||||
| } // namespace SharedPage
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue