summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nifm/nifm.cpp88
1 files changed, 57 insertions, 31 deletions
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index 4fa9f51a6..5d32adf64 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{};
@@ -184,6 +207,7 @@ public:
184 207
185 event1 = CreateKEvent(service_context, "IRequest:Event1"); 208 event1 = CreateKEvent(service_context, "IRequest:Event1");
186 event2 = CreateKEvent(service_context, "IRequest:Event2"); 209 event2 = CreateKEvent(service_context, "IRequest:Event2");
210 state = RequestState::NotSubmitted;
187 } 211 }
188 212
189 ~IRequest() override { 213 ~IRequest() override {
@@ -196,7 +220,7 @@ private:
196 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 220 LOG_WARNING(Service_NIFM, "(STUBBED) called");
197 221
198 if (state == RequestState::NotSubmitted) { 222 if (state == RequestState::NotSubmitted) {
199 UpdateState(RequestState::Pending); 223 UpdateState(RequestState::OnHold);
200 } 224 }
201 225
202 IPC::ResponseBuilder rb{ctx, 2}; 226 IPC::ResponseBuilder rb{ctx, 2};
@@ -219,14 +243,14 @@ private:
219 switch (state) { 243 switch (state) {
220 case RequestState::NotSubmitted: 244 case RequestState::NotSubmitted:
221 return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled; 245 return has_connection ? ResultSuccess : ResultNetworkCommunicationDisabled;
222 case RequestState::Pending: 246 case RequestState::OnHold:
223 if (has_connection) { 247 if (has_connection) {
224 UpdateState(RequestState::Connected); 248 UpdateState(RequestState::Accepted);
225 } else { 249 } else {
226 UpdateState(RequestState::Error); 250 UpdateState(RequestState::Invalid);
227 } 251 }
228 return ResultPendingConnection; 252 return ResultPendingConnection;
229 case RequestState::Connected: 253 case RequestState::Accepted:
230 default: 254 default:
231 return ResultSuccess; 255 return ResultSuccess;
232 } 256 }
@@ -338,9 +362,9 @@ void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
338 .ip_setting_data{ 362 .ip_setting_data{
339 .ip_address_setting{ 363 .ip_address_setting{
340 .is_automatic{true}, 364 .is_automatic{true},
341 .current_address{Network::TranslateIPv4(net_iface->ip_address)}, 365 .ip_address{Network::TranslateIPv4(net_iface->ip_address)},
342 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)}, 366 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
343 .gateway{Network::TranslateIPv4(net_iface->gateway)}, 367 .default_gateway{Network::TranslateIPv4(net_iface->gateway)},
344 }, 368 },
345 .dns_setting{ 369 .dns_setting{
346 .is_automatic{true}, 370 .is_automatic{true},
@@ -348,12 +372,14 @@ void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
348 .secondary_dns{1, 0, 0, 1}, 372 .secondary_dns{1, 0, 0, 1},
349 }, 373 },
350 .proxy_setting{ 374 .proxy_setting{
351 .enabled{false}, 375 .is_enabled{false},
352 .port{}, 376 .port{},
353 .proxy_server{}, 377 .proxy_server{},
354 .automatic_auth_enabled{}, 378 .authentication{
355 .user{}, 379 .is_enabled{},
356 .password{}, 380 .user{},
381 .password{},
382 },
357 }, 383 },
358 .mtu{1500}, 384 .mtu{1500},
359 }, 385 },
@@ -370,7 +396,7 @@ void IGeneralService::GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
370 // When we're connected to a room, spoof the hosts IP address 396 // When we're connected to a room, spoof the hosts IP address
371 if (auto room_member = network.GetRoomMember().lock()) { 397 if (auto room_member = network.GetRoomMember().lock()) {
372 if (room_member->IsConnected()) { 398 if (room_member->IsConnected()) {
373 network_profile_data.ip_setting_data.ip_address_setting.current_address = 399 network_profile_data.ip_setting_data.ip_address_setting.ip_address =
374 room_member->GetFakeIpAddress(); 400 room_member->GetFakeIpAddress();
375 } 401 }
376 } 402 }
@@ -444,9 +470,9 @@ void IGeneralService::GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
444 return IpConfigInfo{ 470 return IpConfigInfo{
445 .ip_address_setting{ 471 .ip_address_setting{
446 .is_automatic{true}, 472 .is_automatic{true},
447 .current_address{Network::TranslateIPv4(net_iface->ip_address)}, 473 .ip_address{Network::TranslateIPv4(net_iface->ip_address)},
448 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)}, 474 .subnet_mask{Network::TranslateIPv4(net_iface->subnet_mask)},
449 .gateway{Network::TranslateIPv4(net_iface->gateway)}, 475 .default_gateway{Network::TranslateIPv4(net_iface->gateway)},
450 }, 476 },
451 .dns_setting{ 477 .dns_setting{
452 .is_automatic{true}, 478 .is_automatic{true},
@@ -459,7 +485,7 @@ void IGeneralService::GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
459 // When we're connected to a room, spoof the hosts IP address 485 // When we're connected to a room, spoof the hosts IP address
460 if (auto room_member = network.GetRoomMember().lock()) { 486 if (auto room_member = network.GetRoomMember().lock()) {
461 if (room_member->IsConnected()) { 487 if (room_member->IsConnected()) {
462 ip_config_info.ip_address_setting.current_address = room_member->GetFakeIpAddress(); 488 ip_config_info.ip_address_setting.ip_address = room_member->GetFakeIpAddress();
463 } 489 }
464 } 490 }
465 491
@@ -480,7 +506,7 @@ void IGeneralService::GetInternetConnectionStatus(Kernel::HLERequestContext& ctx
480 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 506 LOG_WARNING(Service_NIFM, "(STUBBED) called");
481 507
482 struct Output { 508 struct Output {
483 InternetConnectionType type{InternetConnectionType::WiFi}; 509 u8 type{static_cast<u8>(NetworkInterfaceType::WiFi_Ieee80211)};
484 u8 wifi_strength{3}; 510 u8 wifi_strength{3};
485 InternetConnectionStatus state{InternetConnectionStatus::Connected}; 511 InternetConnectionStatus state{InternetConnectionStatus::Connected};
486 }; 512 };