summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/nifm/nifm.cpp159
1 files changed, 157 insertions, 2 deletions
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp
index b22742148..8372e170c 100644
--- a/src/core/hle/service/nifm/nifm.cpp
+++ b/src/core/hle/service/nifm/nifm.cpp
@@ -21,6 +21,93 @@ enum class RequestState : u32 {
21 Connected = 3, 21 Connected = 3,
22}; 22};
23 23
24struct IpAddressSetting {
25 bool is_automatic{};
26 Network::IPv4Address current_address{};
27 Network::IPv4Address subnet_mask{};
28 Network::IPv4Address gateway{};
29};
30static_assert(sizeof(IpAddressSetting) == 0xD, "IpAddressSetting has incorrect size.");
31
32struct DnsSetting {
33 bool is_automatic{};
34 Network::IPv4Address primary_dns{};
35 Network::IPv4Address secondary_dns{};
36};
37static_assert(sizeof(DnsSetting) == 0x9, "DnsSetting has incorrect size.");
38
39struct ProxySetting {
40 bool enabled{};
41 INSERT_PADDING_BYTES(1);
42 u16 port{};
43 std::array<char, 0x64> proxy_server{};
44 bool automatic_auth_enabled{};
45 std::array<char, 0x20> user{};
46 std::array<char, 0x20> password{};
47 INSERT_PADDING_BYTES(1);
48};
49static_assert(sizeof(ProxySetting) == 0xAA, "ProxySetting has incorrect size.");
50
51struct IpSettingData {
52 IpAddressSetting ip_address_setting{};
53 DnsSetting dns_setting{};
54 ProxySetting proxy_setting{};
55 u16 mtu{};
56};
57static_assert(sizeof(IpSettingData) == 0xC2, "IpSettingData has incorrect size.");
58
59struct SfWirelessSettingData {
60 u8 ssid_length{};
61 std::array<char, 0x20> ssid{};
62 u8 unknown_1{};
63 u8 unknown_2{};
64 u8 unknown_3{};
65 std::array<char, 0x41> passphrase{};
66};
67static_assert(sizeof(SfWirelessSettingData) == 0x65, "SfWirelessSettingData has incorrect size.");
68
69struct NifmWirelessSettingData {
70 u8 ssid_length{};
71 std::array<char, 0x21> ssid{};
72 u8 unknown_1{};
73 INSERT_PADDING_BYTES(1);
74 u32 unknown_2{};
75 u32 unknown_3{};
76 std::array<char, 0x41> passphrase{};
77 INSERT_PADDING_BYTES(3);
78};
79static_assert(sizeof(NifmWirelessSettingData) == 0x70,
80 "NifmWirelessSettingData has incorrect size.");
81
82#pragma pack(push, 1)
83struct SfNetworkProfileData {
84 IpSettingData ip_setting_data{};
85 u128 uuid{};
86 std::array<char, 0x40> network_name{};
87 u8 unknown_1{};
88 u8 unknown_2{};
89 u8 unknown_3{};
90 u8 unknown_4{};
91 SfWirelessSettingData wireless_setting_data{};
92 INSERT_PADDING_BYTES(1);
93};
94static_assert(sizeof(SfNetworkProfileData) == 0x17C, "SfNetworkProfileData has incorrect size.");
95
96struct NifmNetworkProfileData {
97 u128 uuid{};
98 std::array<char, 0x40> network_name{};
99 u32 unknown_1{};
100 u32 unknown_2{};
101 u8 unknown_3{};
102 u8 unknown_4{};
103 INSERT_PADDING_BYTES(2);
104 NifmWirelessSettingData wireless_setting_data{};
105 IpSettingData ip_setting_data{};
106};
107static_assert(sizeof(NifmNetworkProfileData) == 0x18E,
108 "NifmNetworkProfileData has incorrect size.");
109#pragma pack(pop)
110
24class IScanRequest final : public ServiceFramework<IScanRequest> { 111class IScanRequest final : public ServiceFramework<IScanRequest> {
25public: 112public:
26 explicit IScanRequest(Core::System& system_) : ServiceFramework{system_, "IScanRequest"} { 113 explicit IScanRequest(Core::System& system_) : ServiceFramework{system_, "IScanRequest"} {
@@ -183,6 +270,46 @@ private:
183 rb.Push(RESULT_SUCCESS); 270 rb.Push(RESULT_SUCCESS);
184 rb.PushIpcInterface<IRequest>(system); 271 rb.PushIpcInterface<IRequest>(system);
185 } 272 }
273 void GetCurrentNetworkProfile(Kernel::HLERequestContext& ctx) {
274 LOG_WARNING(Service_NIFM, "(STUBBED) called");
275
276 const SfNetworkProfileData network_profile_data{
277 .ip_setting_data{
278 .ip_address_setting{
279 .is_automatic{true},
280 .current_address{192, 168, 1, 100},
281 .subnet_mask{255, 255, 255, 0},
282 .gateway{192, 168, 1, 1},
283 },
284 .dns_setting{
285 .is_automatic{true},
286 .primary_dns{1, 1, 1, 1},
287 .secondary_dns{1, 0, 0, 1},
288 },
289 .proxy_setting{
290 .enabled{false},
291 .port{},
292 .proxy_server{},
293 .automatic_auth_enabled{},
294 .user{},
295 .password{},
296 },
297 .mtu{1500},
298 },
299 .uuid{0xdeadbeef, 0xdeadbeef},
300 .network_name{"yuzu Network"},
301 .wireless_setting_data{
302 .ssid_length{12},
303 .ssid{"yuzu Network"},
304 .passphrase{"yuzupassword"},
305 },
306 };
307
308 ctx.WriteBuffer(network_profile_data);
309
310 IPC::ResponseBuilder rb{ctx, 2};
311 rb.Push(RESULT_SUCCESS);
312 }
186 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) { 313 void RemoveNetworkProfile(Kernel::HLERequestContext& ctx) {
187 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 314 LOG_WARNING(Service_NIFM, "(STUBBED) called");
188 315
@@ -214,6 +341,34 @@ private:
214 rb.PushIpcInterface<INetworkProfile>(system); 341 rb.PushIpcInterface<INetworkProfile>(system);
215 rb.PushRaw<u128>(uuid); 342 rb.PushRaw<u128>(uuid);
216 } 343 }
344 void GetCurrentIpConfigInfo(Kernel::HLERequestContext& ctx) {
345 LOG_WARNING(Service_NIFM, "(STUBBED) called");
346
347 struct IpConfigInfo {
348 IpAddressSetting ip_address_setting;
349 DnsSetting dns_setting;
350 };
351 static_assert(sizeof(IpConfigInfo) == sizeof(IpAddressSetting) + sizeof(DnsSetting),
352 "IpConfigInfo has incorrect size.");
353
354 const IpConfigInfo ip_config_info{
355 .ip_address_setting{
356 .is_automatic{true},
357 .current_address{192, 168, 1, 100},
358 .subnet_mask{255, 255, 255, 0},
359 .gateway{192, 168, 1, 1},
360 },
361 .dns_setting{
362 .is_automatic{true},
363 .primary_dns{1, 1, 1, 1},
364 .secondary_dns{1, 0, 0, 1},
365 },
366 };
367
368 IPC::ResponseBuilder rb{ctx, 2 + sizeof(IpConfigInfo) / sizeof(u32)};
369 rb.Push(RESULT_SUCCESS);
370 rb.PushRaw<IpConfigInfo>(ip_config_info);
371 }
217 void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) { 372 void IsWirelessCommunicationEnabled(Kernel::HLERequestContext& ctx) {
218 LOG_WARNING(Service_NIFM, "(STUBBED) called"); 373 LOG_WARNING(Service_NIFM, "(STUBBED) called");
219 374
@@ -252,7 +407,7 @@ IGeneralService::IGeneralService(Core::System& system_)
252 {1, &IGeneralService::GetClientId, "GetClientId"}, 407 {1, &IGeneralService::GetClientId, "GetClientId"},
253 {2, &IGeneralService::CreateScanRequest, "CreateScanRequest"}, 408 {2, &IGeneralService::CreateScanRequest, "CreateScanRequest"},
254 {4, &IGeneralService::CreateRequest, "CreateRequest"}, 409 {4, &IGeneralService::CreateRequest, "CreateRequest"},
255 {5, nullptr, "GetCurrentNetworkProfile"}, 410 {5, &IGeneralService::GetCurrentNetworkProfile, "GetCurrentNetworkProfile"},
256 {6, nullptr, "EnumerateNetworkInterfaces"}, 411 {6, nullptr, "EnumerateNetworkInterfaces"},
257 {7, nullptr, "EnumerateNetworkProfiles"}, 412 {7, nullptr, "EnumerateNetworkProfiles"},
258 {8, nullptr, "GetNetworkProfile"}, 413 {8, nullptr, "GetNetworkProfile"},
@@ -262,7 +417,7 @@ IGeneralService::IGeneralService(Core::System& system_)
262 {12, &IGeneralService::GetCurrentIpAddress, "GetCurrentIpAddress"}, 417 {12, &IGeneralService::GetCurrentIpAddress, "GetCurrentIpAddress"},
263 {13, nullptr, "GetCurrentAccessPointOld"}, 418 {13, nullptr, "GetCurrentAccessPointOld"},
264 {14, &IGeneralService::CreateTemporaryNetworkProfile, "CreateTemporaryNetworkProfile"}, 419 {14, &IGeneralService::CreateTemporaryNetworkProfile, "CreateTemporaryNetworkProfile"},
265 {15, nullptr, "GetCurrentIpConfigInfo"}, 420 {15, &IGeneralService::GetCurrentIpConfigInfo, "GetCurrentIpConfigInfo"},
266 {16, nullptr, "SetWirelessCommunicationEnabled"}, 421 {16, nullptr, "SetWirelessCommunicationEnabled"},
267 {17, &IGeneralService::IsWirelessCommunicationEnabled, "IsWirelessCommunicationEnabled"}, 422 {17, &IGeneralService::IsWirelessCommunicationEnabled, "IsWirelessCommunicationEnabled"},
268 {18, nullptr, "GetInternetConnectionStatus"}, 423 {18, nullptr, "GetInternetConnectionStatus"},