summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/core/hle/service/nifm/nifm.cpp87
1 files changed, 56 insertions, 31 deletions
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index 4fa9f51a6..1990e3a46 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -22,15 +22,19 @@ namespace {
22 22
23namespace Service::NIFM { 23namespace Service::NIFM {
24 24
25// This is nn::nifm::RequestState
25enum class RequestState : u32 { 26enum class RequestState : u32 {
26 NotSubmitted = 1, 27 NotSubmitted = 1,
27 Error = 1, ///< The duplicate 1 is intentional; it means both not submitted and error on HW. 28 Invalid = 1, ///< The duplicate 1 is intentional; it means both not submitted and error on HW.
28 Pending = 2, 29 OnHold = 2,
29 Connected = 3, 30 Accepted = 3,
31 Blocking = 4,
30}; 32};
31 33
32enum class InternetConnectionType : u8 { 34// This is nn::nifm::NetworkInterfaceType
33 WiFi = 1, 35enum class NetworkInterfaceType : u32 {
36 Invalid = 0,
37 WiFi_Ieee80211 = 1,
34 Ethernet = 2, 38 Ethernet = 2,
35}; 39};
36 40
@@ -42,14 +46,23 @@ enum class InternetConnectionStatus : u8 {
42 Connected, 46 Connected,
43}; 47};
44 48
49// This is nn::nifm::NetworkProfileType
50enum class NetworkProfileType : u32 {
51 User,
52 SsidList,
53 Temporary,
54};
55
56// This is nn::nifm::IpAddressSetting
45struct IpAddressSetting { 57struct IpAddressSetting {
46 bool is_automatic{}; 58 bool is_automatic{};
47 Network::IPv4Address current_address{}; 59 Network::IPv4Address ip_address{};
48 Network::IPv4Address subnet_mask{}; 60 Network::IPv4Address subnet_mask{};
49 Network::IPv4Address gateway{}; 61 Network::IPv4Address default_gateway{};
50}; 62};
51static_assert(sizeof(IpAddressSetting) == 0xD, "IpAddressSetting has incorrect size."); 63static_assert(sizeof(IpAddressSetting) == 0xD, "IpAddressSetting has incorrect size.");
52 64
65// This is nn::nifm::DnsSetting
53struct DnsSetting { 66struct DnsSetting {
54 bool is_automatic{}; 67 bool is_automatic{};
55 Network::IPv4Address primary_dns{}; 68 Network::IPv4Address primary_dns{};
@@ -57,18 +70,26 @@ struct DnsSetting {
57}; 70};
58static_assert(sizeof(DnsSetting) == 0x9, "DnsSetting has incorrect size."); 71static_assert(sizeof(DnsSetting) == 0x9, "DnsSetting has incorrect size.");
59 72
73// This is nn::nifm::AuthenticationSetting
74struct AuthenticationSetting {
75 bool is_enabled{};
76 std::array<char, 0x20> user{};
77 std::array<char, 0x20> password{};
78};
79static_assert(sizeof(AuthenticationSetting) == 0x41, "AuthenticationSetting has incorrect size.");
80
81// This is nn::nifm::ProxySetting
60struct ProxySetting { 82struct ProxySetting {
61 bool enabled{}; 83 bool is_enabled{};
62 INSERT_PADDING_BYTES(1); 84 INSERT_PADDING_BYTES(1);
63 u16 port{}; 85 u16 port{};
64 std::array<char, 0x64> proxy_server{}; 86 std::array<char, 0x64> proxy_server{};
65 bool automatic_auth_enabled{}; 87 AuthenticationSetting authentication{};
66 std::array<char, 0x20> user{};
67 std::array<char, 0x20> password{};
68 INSERT_PADDING_BYTES(1); 88 INSERT_PADDING_BYTES(1);
69}; 89};
70static_assert(sizeof(ProxySetting) == 0xAA, "ProxySetting has incorrect size."); 90static_assert(sizeof(ProxySetting) == 0xAA, "ProxySetting has incorrect size.");
71 91
92// This is nn::nifm::IpSettingData
72struct IpSettingData { 93struct IpSettingData {
73 IpAddressSetting ip_address_setting{}; 94 IpAddressSetting ip_address_setting{};
74 DnsSetting dns_setting{}; 95 DnsSetting dns_setting{};
@@ -101,6 +122,7 @@ static_assert(sizeof(NifmWirelessSettingData) == 0x70,
101 "NifmWirelessSettingData has incorrect size."); 122 "NifmWirelessSettingData has incorrect size.");
102 123
103#pragma pack(push, 1) 124#pragma pack(push, 1)
125// This is nn::nifm::detail::sf::NetworkProfileData
104struct SfNetworkProfileData { 126struct SfNetworkProfileData {
105 IpSettingData ip_setting_data{}; 127 IpSettingData ip_setting_data{};
106 u128 uuid{}; 128 u128 uuid{};
@@ -114,13 +136,14 @@ struct SfNetworkProfileData {
114}; 136};
115static_assert(sizeof(SfNetworkProfileData) == 0x17C, "SfNetworkProfileData has incorrect size."); 137static_assert(sizeof(SfNetworkProfileData) == 0x17C, "SfNetworkProfileData has incorrect size.");
116 138
139// This is nn::nifm::NetworkProfileData
117struct NifmNetworkProfileData { 140struct NifmNetworkProfileData {
118 u128 uuid{}; 141 u128 uuid{};
119 std::array<char, 0x40> network_name{}; 142 std::array<char, 0x40> network_name{};
120 u32 unknown_1{}; 143 NetworkProfileType network_profile_type{};
121 u32 unknown_2{}; 144 NetworkInterfaceType network_interface_type{};
122 u8 unknown_3{}; 145 bool is_auto_connect{};
123 u8 unknown_4{}; 146 bool is_large_capacity{};
124 INSERT_PADDING_BYTES(2); 147 INSERT_PADDING_BYTES(2);
125 NifmWirelessSettingData wireless_setting_data{}; 148 NifmWirelessSettingData wireless_setting_data{};
126 IpSettingData ip_setting_data{}; 149 IpSettingData ip_setting_data{};
@@ -196,7 +219,7 @@ private:
196 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 219 LOG_WARNING(Service_NIFM, "(STUBBED) called");
197 220
198 if (state == RequestState::NotSubmitted) { 221 if (state == RequestState::NotSubmitted) {
199 UpdateState(RequestState::Pending); 222 UpdateState(RequestState::OnHold);
200 } 223 }
201 224
202 IPC::ResponseBuilder rb{ctx, 2}; 225 IPC::ResponseBuilder rb{ctx, 2};
@@ -219,14 +242,14 @@ private:
219 switch (state) { 242 switch (state) {
220 case RequestState::NotSubmitted: 243 case RequestState::NotSubmitted:
221 return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled; 244 return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled;
222 case RequestState::Pending: 245 case RequestState::OnHold:
223 if (has_connection) { 246 if (has_connection) {
224 UpdateState(RequestState::Connected); 247 UpdateState(RequestState::Accepted);
225 } else { 248 } else {
226 UpdateState(RequestState::Error); 249 UpdateState(RequestState::Invalid);
227 } 250 }
228 return ResultPendingConnection; 251 return ResultPendingConnection;
229 case RequestState::Connected: 252 case RequestState::Accepted:
230 default: 253 default:
231 return ResultSuccess; 254 return ResultSuccess;
232 } 255 }
@@ -338,9 +361,9 @@ void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
338 .ip_setting_data{ 361 .ip_setting_data{
339 .ip_address_setting{ 362 .ip_address_setting{
340 .is_automatic{true}, 363 .is_automatic{true},
341 .current_address{Network::TranslateIPv4(net_iface->ip_address)}, 364 .ip_address{Network::TranslateIPv4(net_iface->ip_address)},
342 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)}, 365 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
343 .gateway{Network::TranslateIPv4(net_iface->gateway)}, 366 .default_gateway{Network::TranslateIPv4(net_iface->gateway)},
344 }, 367 },
345 .dns_setting{ 368 .dns_setting{
346 .is_automatic{true}, 369 .is_automatic{true},
@@ -348,12 +371,14 @@ void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
348 .secondary_dns{1, 0, 0, 1}, 371 .secondary_dns{1, 0, 0, 1},
349 }, 372 },
350 .proxy_setting{ 373 .proxy_setting{
351 .enabled{false}, 374 .is_enabled{false},
352 .port{}, 375 .port{},
353 .proxy_server{}, 376 .proxy_server{},
354 .automatic_auth_enabled{}, 377 .authentication{
355 .user{}, 378 .is_enabled{},
356 .password{}, 379 .user{},
380 .password{},
381 },
357 }, 382 },
358 .mtu{1500}, 383 .mtu{1500},
359 }, 384 },
@@ -370,7 +395,7 @@ void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
370 // When we're connected to a room, spoof the hosts IP address 395 // When we're connected to a room, spoof the hosts IP address
371 if (auto room_member = network.GetRoomMember().lock()) { 396 if (auto room_member = network.GetRoomMember().lock()) {
372 if (room_member->IsConnected()) { 397 if (room_member->IsConnected()) {
373 network_profile_data.ip_setting_data.ip_address_setting.current_address = 398 network_profile_data.ip_setting_data.ip_address_setting.ip_address =
374 room_member->GetFakeIpAddress(); 399 room_member->GetFakeIpAddress();
375 } 400 }
376 } 401 }
@@ -444,9 +469,9 @@ void IGeneralService::GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
444 return IpConfigInfo{ 469 return IpConfigInfo{
445 .ip_address_setting{ 470 .ip_address_setting{
446 .is_automatic{true}, 471 .is_automatic{true},
447 .current_address{Network::TranslateIPv4(net_iface->ip_address)}, 472 .ip_address{Network::TranslateIPv4(net_iface->ip_address)},
448 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)}, 473 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
449 .gateway{Network::TranslateIPv4(net_iface->gateway)}, 474 .default_gateway{Network::TranslateIPv4(net_iface->gateway)},
450 }, 475 },
451 .dns_setting{ 476 .dns_setting{
452 .is_automatic{true}, 477 .is_automatic{true},
@@ -459,7 +484,7 @@ void IGeneralService::GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
459 // When we're connected to a room, spoof the hosts IP address 484 // When we're connected to a room, spoof the hosts IP address
460 if (auto room_member = network.GetRoomMember().lock()) { 485 if (auto room_member = network.GetRoomMember().lock()) {
461 if (room_member->IsConnected()) { 486 if (room_member->IsConnected()) {
462 ip_config_info.ip_address_setting.current_address = room_member->GetFakeIpAddress(); 487 ip_config_info.ip_address_setting.ip_address = room_member->GetFakeIpAddress();
463 } 488 }
464 } 489 }
465 490
@@ -480,7 +505,7 @@ void IGeneralService::GetInternetConnectionStatus(Kernel::HLERequestContext& ctx
480 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 505 LOG_WARNING(Service_NIFM, "(STUBBED) called");
481 506
482 struct Output { 507 struct Output {
483 InternetConnectionType type{InternetConnectionType::WiFi}; 508 u8 type{static_cast<u8>(NetworkInterfaceType::WiFi_Ieee80211)};
484 u8 wifi_strength{3}; 509 u8 wifi_strength{3};
485 InternetConnectionStatus state{InternetConnectionStatus::Connected}; 510 InternetConnectionStatus state{InternetConnectionStatus::Connected};
486 }; 511 };