summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/ldn/ldn.cpp76
-rw-r--r--src/core/hle/service/ldn/ldn.h1
-rw-r--r--src/core/hle/service/ldn/ldn_results.h5
-rw-r--r--src/core/hle/service/ldn/ldn_types.h20
4 files changed, 46 insertions, 56 deletions
diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp
index c8e1898f4..ff4169f8e 100644
--- a/src/core/hle/service/ldn/ldn.cpp
+++ b/src/core/hle/service/ldn/ldn.cpp
@@ -8,6 +8,7 @@
8#include "core/internal_network/network.h" 8#include "core/internal_network/network.h"
9#include "core/internal_network/network_interface.h" 9#include "core/internal_network/network_interface.h"
10 10
11// This is defined by synchapi.h and conflicts with ServiceContext::CreateEvent
11#undef CreateEvent 12#undef CreateEvent
12 13
13namespace Service::LDN { 14namespace Service::LDN {
@@ -168,7 +169,7 @@ void IUserLocalCommunicationService::GetNetworkInfo(Kernel::HLERequestContext& c
168 return; 169 return;
169 } 170 }
170 171
171 NetworkInfo networkInfo{}; 172 NetworkInfo network_info{};
172 const auto rc = ResultSuccess; 173 const auto rc = ResultSuccess;
173 if (rc.IsError()) { 174 if (rc.IsError()) {
174 LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); 175 LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw);
@@ -178,9 +179,9 @@ void IUserLocalCommunicationService::GetNetworkInfo(Kernel::HLERequestContext& c
178 } 179 }
179 180
180 LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", 181 LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}",
181 networkInfo.common.ssid.GetStringValue(), networkInfo.ldn.node_count); 182 network_info.common.ssid.GetStringValue(), network_info.ldn.node_count);
182 183
183 ctx.WriteBuffer<NetworkInfo>(networkInfo); 184 ctx.WriteBuffer<NetworkInfo>(network_info);
184 IPC::ResponseBuilder rb{ctx, 2}; 185 IPC::ResponseBuilder rb{ctx, 2};
185 rb.Push(rc); 186 rb.Push(rc);
186} 187}
@@ -267,8 +268,7 @@ void IUserLocalCommunicationService::GetNetworkInfoLatestUpdate(Kernel::HLEReque
267 } 268 }
268 269
269 NetworkInfo info; 270 NetworkInfo info;
270 std::vector<NodeLatestUpdate> latest_update{}; 271 std::vector<NodeLatestUpdate> latest_update(node_buffer_count);
271 latest_update.resize(node_buffer_count);
272 272
273 const auto rc = ResultSuccess; 273 const auto rc = ResultSuccess;
274 if (rc.IsError()) { 274 if (rc.IsError()) {
@@ -311,14 +311,13 @@ void IUserLocalCommunicationService::ScanImpl(Kernel::HLERequestContext& ctx, bo
311 } 311 }
312 312
313 u16 count = 0; 313 u16 count = 0;
314 std::vector<NetworkInfo> networks_info{}; 314 std::vector<NetworkInfo> network_infos(network_info_size);
315 networks_info.resize(network_info_size);
316 315
317 LOG_WARNING(Service_LDN, 316 LOG_WARNING(Service_LDN,
318 "(STUBBED) called, channel={}, filter_scan_flag={}, filter_network_type={}", 317 "(STUBBED) called, channel={}, filter_scan_flag={}, filter_network_type={}",
319 channel, scan_filter.flag, scan_filter.network_type); 318 channel, scan_filter.flag, scan_filter.network_type);
320 319
321 ctx.WriteBuffer(networks_info); 320 ctx.WriteBuffer(network_infos);
322 321
323 IPC::ResponseBuilder rb{ctx, 3}; 322 IPC::ResponseBuilder rb{ctx, 3};
324 rb.Push(ResultSuccess); 323 rb.Push(ResultSuccess);
@@ -340,31 +339,39 @@ void IUserLocalCommunicationService::CloseAccessPoint(Kernel::HLERequestContext&
340} 339}
341 340
342void IUserLocalCommunicationService::CreateNetwork(Kernel::HLERequestContext& ctx) { 341void IUserLocalCommunicationService::CreateNetwork(Kernel::HLERequestContext& ctx) {
343 LOG_WARNING(Service_LDN, "(STUBBED) called"); 342 IPC::RequestParser rp{ctx};
344 343 struct Parameters {
345 CreateNetworkImpl(ctx, false); 344 SecurityConfig security_config;
346} 345 UserConfig user_config;
346 INSERT_PADDING_WORDS_NOINIT(1);
347 NetworkConfig network_config;
348 };
349 static_assert(sizeof(Parameters) == 0x98, "Parameters has incorrect size.");
347 350
348void IUserLocalCommunicationService::CreateNetworkPrivate(Kernel::HLERequestContext& ctx) {
349 LOG_WARNING(Service_LDN, "(STUBBED) called"); 351 LOG_WARNING(Service_LDN, "(STUBBED) called");
350 352
351 CreateNetworkImpl(ctx, true); 353 IPC::ResponseBuilder rb{ctx, 2};
354 rb.Push(ResultSuccess);
352} 355}
353 356
354void IUserLocalCommunicationService::CreateNetworkImpl(Kernel::HLERequestContext& ctx, 357void IUserLocalCommunicationService::CreateNetworkPrivate(Kernel::HLERequestContext& ctx) {
355 bool is_private) {
356 IPC::RequestParser rp{ctx}; 358 IPC::RequestParser rp{ctx};
359 struct Parameters {
360 SecurityConfig security_config;
361 SecurityParameter security_parameter;
362 UserConfig user_config;
363 NetworkConfig network_config;
364 };
365 static_assert(sizeof(Parameters) == 0xB8, "Parameters has incorrect size.");
357 366
358 const auto security_config{rp.PopRaw<SecurityConfig>()}; 367 const auto parameters{rp.PopRaw<Parameters>()};
359 [[maybe_unused]] const auto security_parameter{is_private ? rp.PopRaw<SecurityParameter>() 368
360 : SecurityParameter{}}; 369 LOG_WARNING(Service_LDN, "(STUBBED) called");
361 const auto user_config{rp.PopRaw<UserConfig>()};
362 rp.Pop<u32>(); // Padding
363 const auto network_Config{rp.PopRaw<NetworkConfig>()};
364 370
365 IPC::ResponseBuilder rb{ctx, 2}; 371 IPC::ResponseBuilder rb{ctx, 2};
366 rb.Push(ResultSuccess); 372 rb.Push(ResultSuccess);
367} 373}
374
368void IUserLocalCommunicationService::DestroyNetwork(Kernel::HLERequestContext& ctx) { 375void IUserLocalCommunicationService::DestroyNetwork(Kernel::HLERequestContext& ctx) {
369 LOG_WARNING(Service_LDN, "(STUBBED) called"); 376 LOG_WARNING(Service_LDN, "(STUBBED) called");
370 377
@@ -413,14 +420,18 @@ void IUserLocalCommunicationService::Connect(Kernel::HLERequestContext& ctx) {
413 LOG_WARNING(Service_LDN, "(STUBBED) called"); 420 LOG_WARNING(Service_LDN, "(STUBBED) called");
414 421
415 IPC::RequestParser rp{ctx}; 422 IPC::RequestParser rp{ctx};
423 struct Parameters {
424 SecurityConfig security_config;
425 UserConfig user_config;
426 u32 local_communication_version;
427 u32 option;
428 };
429 static_assert(sizeof(Parameters) == 0x7C, "Parameters has incorrect size.");
416 430
417 [[maybe_unused]] const auto securityConfig{rp.PopRaw<SecurityConfig>()}; 431 const auto parameters{rp.PopRaw<Parameters>()};
418 const auto user_config{rp.PopRaw<UserConfig>()};
419 const auto local_communication_version{rp.Pop<u32>()};
420 [[maybe_unused]] const auto option{rp.Pop<u32>()};
421 432
422 std::vector<u8> read_buffer = ctx.ReadBuffer(); 433 const std::vector<u8> read_buffer = ctx.ReadBuffer();
423 NetworkInfo networkInfo{}; 434 NetworkInfo network_info{};
424 435
425 if (read_buffer.size() != sizeof(NetworkInfo)) { 436 if (read_buffer.size() != sizeof(NetworkInfo)) {
426 LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!"); 437 LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!");
@@ -429,7 +440,7 @@ void IUserLocalCommunicationService::Connect(Kernel::HLERequestContext& ctx) {
429 return; 440 return;
430 } 441 }
431 442
432 std::memcpy(&networkInfo, read_buffer.data(), read_buffer.size()); 443 std::memcpy(&network_info, read_buffer.data(), read_buffer.size());
433 444
434 IPC::ResponseBuilder rb{ctx, 2}; 445 IPC::ResponseBuilder rb{ctx, 2};
435 rb.Push(ResultSuccess); 446 rb.Push(ResultSuccess);
@@ -445,9 +456,6 @@ void IUserLocalCommunicationService::Initialize(Kernel::HLERequestContext& ctx)
445 LOG_WARNING(Service_LDN, "(STUBBED) called"); 456 LOG_WARNING(Service_LDN, "(STUBBED) called");
446 457
447 const auto rc = InitializeImpl(ctx); 458 const auto rc = InitializeImpl(ctx);
448 if (rc.IsError()) {
449 LOG_ERROR(Service_LDN, "Network isn't initialized, rc={}", rc.raw);
450 }
451 459
452 IPC::ResponseBuilder rb{ctx, 2}; 460 IPC::ResponseBuilder rb{ctx, 2};
453 rb.Push(rc); 461 rb.Push(rc);
@@ -466,9 +474,6 @@ void IUserLocalCommunicationService::Initialize2(Kernel::HLERequestContext& ctx)
466 LOG_WARNING(Service_LDN, "(STUBBED) called"); 474 LOG_WARNING(Service_LDN, "(STUBBED) called");
467 475
468 const auto rc = InitializeImpl(ctx); 476 const auto rc = InitializeImpl(ctx);
469 if (rc.IsError()) {
470 LOG_ERROR(Service_LDN, "Network isn't initialized, rc={}", rc.raw);
471 }
472 477
473 IPC::ResponseBuilder rb{ctx, 2}; 478 IPC::ResponseBuilder rb{ctx, 2};
474 rb.Push(rc); 479 rb.Push(rc);
@@ -477,6 +482,7 @@ void IUserLocalCommunicationService::Initialize2(Kernel::HLERequestContext& ctx)
477Result IUserLocalCommunicationService::InitializeImpl(Kernel::HLERequestContext& ctx) { 482Result IUserLocalCommunicationService::InitializeImpl(Kernel::HLERequestContext& ctx) {
478 const auto network_interface = Network::GetSelectedNetworkInterface(); 483 const auto network_interface = Network::GetSelectedNetworkInterface();
479 if (!network_interface) { 484 if (!network_interface) {
485 LOG_ERROR(Service_LDN, "No network interface is set");
480 return ResultAirplaneModeEnabled; 486 return ResultAirplaneModeEnabled;
481 } 487 }
482 488
diff --git a/src/core/hle/service/ldn/ldn.h b/src/core/hle/service/ldn/ldn.h
index 331455e3f..4ab8f7a9b 100644
--- a/src/core/hle/service/ldn/ldn.h
+++ b/src/core/hle/service/ldn/ldn.h
@@ -54,7 +54,6 @@ public:
54 54
55 void CreateNetwork(Kernel::HLERequestContext& ctx); 55 void CreateNetwork(Kernel::HLERequestContext& ctx);
56 void CreateNetworkPrivate(Kernel::HLERequestContext& ctx); 56 void CreateNetworkPrivate(Kernel::HLERequestContext& ctx);
57 void CreateNetworkImpl(Kernel::HLERequestContext& ctx, bool is_private);
58 57
59 void DestroyNetwork(Kernel::HLERequestContext& ctx); 58 void DestroyNetwork(Kernel::HLERequestContext& ctx);
60 59
diff --git a/src/core/hle/service/ldn/ldn_results.h b/src/core/hle/service/ldn/ldn_results.h
index 8b6b436b7..f340bda42 100644
--- a/src/core/hle/service/ldn/ldn_results.h
+++ b/src/core/hle/service/ldn/ldn_results.h
@@ -1,6 +1,5 @@
1// Copyright 2022 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-3.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
diff --git a/src/core/hle/service/ldn/ldn_types.h b/src/core/hle/service/ldn/ldn_types.h
index 1132b2eb6..0c07a7397 100644
--- a/src/core/hle/service/ldn/ldn_types.h
+++ b/src/core/hle/service/ldn/ldn_types.h
@@ -1,6 +1,5 @@
1// Copyright 2022 yuzu emulator team 1// SPDX-FileCopyrightText: Copyright 2022 yuzu Emulator Project
2// Licensed under GPLv2 or any later version 2// SPDX-License-Identifier: GPL-3.0-or-later
3// Refer to the license.txt file included.
4 3
5#pragma once 4#pragma once
6 5
@@ -32,14 +31,6 @@ enum class NodeStateChange : u8 {
32 DisconnectAndConnect, 31 DisconnectAndConnect,
33}; 32};
34 33
35inline NodeStateChange operator|(NodeStateChange a, NodeStateChange b) {
36 return static_cast<NodeStateChange>(static_cast<u8>(a) | static_cast<u8>(b));
37}
38
39inline NodeStateChange operator|=(NodeStateChange& a, NodeStateChange b) {
40 return a = a | b;
41}
42
43enum class ScanFilterFlag : u32 { 34enum class ScanFilterFlag : u32 {
44 None = 0, 35 None = 0,
45 LocalCommunicationId = 1 << 0, 36 LocalCommunicationId = 1 << 0,
@@ -135,10 +126,7 @@ struct SessionId {
135 u64 high; 126 u64 high;
136 u64 low; 127 u64 low;
137 128
138public: 129 bool operator==(const SessionId&) const = default;
139 bool operator==(const SessionId& b) const {
140 return (low == b.low) && (high == b.high);
141 }
142}; 130};
143static_assert(sizeof(SessionId) == 0x10, "SessionId is an invalid size"); 131static_assert(sizeof(SessionId) == 0x10, "SessionId is an invalid size");
144 132
@@ -160,7 +148,6 @@ struct Ssid {
160 u8 length; 148 u8 length;
161 std::array<char, SsidLengthMax + 1> raw; 149 std::array<char, SsidLengthMax + 1> raw;
162 150
163public:
164 std::string GetStringValue() const { 151 std::string GetStringValue() const {
165 return std::string(raw.data(), length); 152 return std::string(raw.data(), length);
166 } 153 }
@@ -173,7 +160,6 @@ struct Ipv4Address {
173 std::array<u8, 4> bytes; 160 std::array<u8, 4> bytes;
174 }; 161 };
175 162
176public:
177 std::string GetStringValue() const { 163 std::string GetStringValue() const {
178 return fmt::format("{}.{}.{}.{}", bytes[3], bytes[2], bytes[1], bytes[0]); 164 return fmt::format("{}.{}.{}.{}", bytes[3], bytes[2], bytes[1], bytes[0]);
179 } 165 }