diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/service/ldn/ldn.cpp | 565 | ||||
| -rw-r--r-- | src/core/hle/service/ldn/ldn.h | 66 |
2 files changed, 297 insertions, 334 deletions
diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index ff4169f8e..c11daff54 100644 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp | |||
| @@ -5,6 +5,8 @@ | |||
| 5 | 5 | ||
| 6 | #include "core/core.h" | 6 | #include "core/core.h" |
| 7 | #include "core/hle/service/ldn/ldn.h" | 7 | #include "core/hle/service/ldn/ldn.h" |
| 8 | #include "core/hle/service/ldn/ldn_results.h" | ||
| 9 | #include "core/hle/service/ldn/ldn_types.h" | ||
| 8 | #include "core/internal_network/network.h" | 10 | #include "core/internal_network/network.h" |
| 9 | #include "core/internal_network/network_interface.h" | 11 | #include "core/internal_network/network_interface.h" |
| 10 | 12 | ||
| @@ -98,11 +100,14 @@ public: | |||
| 98 | } | 100 | } |
| 99 | }; | 101 | }; |
| 100 | 102 | ||
| 101 | IUserLocalCommunicationService::IUserLocalCommunicationService(Core::System& system_) | 103 | class IUserLocalCommunicationService final |
| 102 | : ServiceFramework{system_, "IUserLocalCommunicationService", ServiceThreadType::CreateNew}, | 104 | : public ServiceFramework<IUserLocalCommunicationService> { |
| 103 | service_context{system, "IUserLocalCommunicationService"}, room_network{ | 105 | public: |
| 104 | system_.GetRoomNetwork()} { | 106 | explicit IUserLocalCommunicationService(Core::System& system_) |
| 105 | // clang-format off | 107 | : ServiceFramework{system_, "IUserLocalCommunicationService", ServiceThreadType::CreateNew}, |
| 108 | service_context{system, "IUserLocalCommunicationService"}, room_network{ | ||
| 109 | system_.GetRoomNetwork()} { | ||
| 110 | // clang-format off | ||
| 106 | static const FunctionInfo functions[] = { | 111 | static const FunctionInfo functions[] = { |
| 107 | {0, &IUserLocalCommunicationService::GetState, "GetState"}, | 112 | {0, &IUserLocalCommunicationService::GetState, "GetState"}, |
| 108 | {1, &IUserLocalCommunicationService::GetNetworkInfo, "GetNetworkInfo"}, | 113 | {1, &IUserLocalCommunicationService::GetNetworkInfo, "GetNetworkInfo"}, |
| @@ -134,362 +139,386 @@ IUserLocalCommunicationService::IUserLocalCommunicationService(Core::System& sys | |||
| 134 | {401, &IUserLocalCommunicationService::Finalize, "Finalize"}, | 139 | {401, &IUserLocalCommunicationService::Finalize, "Finalize"}, |
| 135 | {402, &IUserLocalCommunicationService::Initialize2, "Initialize2"}, | 140 | {402, &IUserLocalCommunicationService::Initialize2, "Initialize2"}, |
| 136 | }; | 141 | }; |
| 137 | // clang-format on | 142 | // clang-format on |
| 138 | |||
| 139 | RegisterHandlers(functions); | ||
| 140 | |||
| 141 | state_change_event = | ||
| 142 | service_context.CreateEvent("IUserLocalCommunicationService:StateChangeEvent"); | ||
| 143 | } | ||
| 144 | 143 | ||
| 145 | IUserLocalCommunicationService::~IUserLocalCommunicationService() { | 144 | RegisterHandlers(functions); |
| 146 | service_context.CloseEvent(state_change_event); | ||
| 147 | } | ||
| 148 | 145 | ||
| 149 | void IUserLocalCommunicationService::OnEventFired() { | 146 | state_change_event = |
| 150 | state_change_event->GetWritableEvent().Signal(); | 147 | service_context.CreateEvent("IUserLocalCommunicationService:StateChangeEvent"); |
| 151 | } | 148 | } |
| 152 | 149 | ||
| 153 | void IUserLocalCommunicationService::GetState(Kernel::HLERequestContext& ctx) { | 150 | ~IUserLocalCommunicationService() { |
| 154 | State state = State::Error; | 151 | service_context.CloseEvent(state_change_event); |
| 155 | LOG_WARNING(Service_LDN, "(STUBBED) called, state = {}", state); | 152 | } |
| 156 | 153 | ||
| 157 | IPC::ResponseBuilder rb{ctx, 3}; | 154 | void OnEventFired() { |
| 158 | rb.Push(ResultSuccess); | 155 | state_change_event->GetWritableEvent().Signal(); |
| 159 | rb.PushEnum(state); | 156 | } |
| 160 | } | ||
| 161 | 157 | ||
| 162 | void IUserLocalCommunicationService::GetNetworkInfo(Kernel::HLERequestContext& ctx) { | 158 | void GetState(Kernel::HLERequestContext& ctx) { |
| 163 | const auto write_buffer_size = ctx.GetWriteBufferSize(); | 159 | State state = State::Error; |
| 160 | LOG_WARNING(Service_LDN, "(STUBBED) called, state = {}", state); | ||
| 164 | 161 | ||
| 165 | if (write_buffer_size != sizeof(NetworkInfo)) { | 162 | IPC::ResponseBuilder rb{ctx, 3}; |
| 166 | LOG_ERROR(Service_LDN, "Invalid buffer size {}", write_buffer_size); | 163 | rb.Push(ResultSuccess); |
| 167 | IPC::ResponseBuilder rb{ctx, 2}; | 164 | rb.PushEnum(state); |
| 168 | rb.Push(ResultBadInput); | ||
| 169 | return; | ||
| 170 | } | 165 | } |
| 171 | 166 | ||
| 172 | NetworkInfo network_info{}; | 167 | void GetNetworkInfo(Kernel::HLERequestContext& ctx) { |
| 173 | const auto rc = ResultSuccess; | 168 | const auto write_buffer_size = ctx.GetWriteBufferSize(); |
| 174 | if (rc.IsError()) { | 169 | |
| 175 | LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); | 170 | if (write_buffer_size != sizeof(NetworkInfo)) { |
| 171 | LOG_ERROR(Service_LDN, "Invalid buffer size {}", write_buffer_size); | ||
| 172 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 173 | rb.Push(ResultBadInput); | ||
| 174 | return; | ||
| 175 | } | ||
| 176 | |||
| 177 | NetworkInfo network_info{}; | ||
| 178 | const auto rc = ResultSuccess; | ||
| 179 | if (rc.IsError()) { | ||
| 180 | LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); | ||
| 181 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 182 | rb.Push(rc); | ||
| 183 | return; | ||
| 184 | } | ||
| 185 | |||
| 186 | LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", | ||
| 187 | network_info.common.ssid.GetStringValue(), network_info.ldn.node_count); | ||
| 188 | |||
| 189 | ctx.WriteBuffer<NetworkInfo>(network_info); | ||
| 176 | IPC::ResponseBuilder rb{ctx, 2}; | 190 | IPC::ResponseBuilder rb{ctx, 2}; |
| 177 | rb.Push(rc); | 191 | rb.Push(rc); |
| 178 | return; | ||
| 179 | } | 192 | } |
| 180 | 193 | ||
| 181 | LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", | 194 | void GetDisconnectReason(Kernel::HLERequestContext& ctx) { |
| 182 | network_info.common.ssid.GetStringValue(), network_info.ldn.node_count); | 195 | const auto disconnect_reason = DisconnectReason::None; |
| 183 | 196 | ||
| 184 | ctx.WriteBuffer<NetworkInfo>(network_info); | 197 | LOG_WARNING(Service_LDN, "(STUBBED) called, disconnect_reason={}", disconnect_reason); |
| 185 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 186 | rb.Push(rc); | ||
| 187 | } | ||
| 188 | 198 | ||
| 189 | void IUserLocalCommunicationService::GetDisconnectReason(Kernel::HLERequestContext& ctx) { | 199 | IPC::ResponseBuilder rb{ctx, 3}; |
| 190 | const auto disconnect_reason = DisconnectReason::None; | 200 | rb.Push(ResultSuccess); |
| 201 | rb.PushEnum(disconnect_reason); | ||
| 202 | } | ||
| 191 | 203 | ||
| 192 | LOG_WARNING(Service_LDN, "(STUBBED) called, disconnect_reason={}", disconnect_reason); | 204 | void GetSecurityParameter(Kernel::HLERequestContext& ctx) { |
| 205 | SecurityParameter security_parameter{}; | ||
| 206 | NetworkInfo info{}; | ||
| 207 | const Result rc = ResultSuccess; | ||
| 193 | 208 | ||
| 194 | IPC::ResponseBuilder rb{ctx, 3}; | 209 | if (rc.IsError()) { |
| 195 | rb.Push(ResultSuccess); | 210 | LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); |
| 196 | rb.PushEnum(disconnect_reason); | 211 | IPC::ResponseBuilder rb{ctx, 2}; |
| 197 | } | 212 | rb.Push(rc); |
| 213 | return; | ||
| 214 | } | ||
| 198 | 215 | ||
| 199 | void IUserLocalCommunicationService::GetSecurityParameter(Kernel::HLERequestContext& ctx) { | 216 | security_parameter.session_id = info.network_id.session_id; |
| 200 | SecurityParameter security_parameter; | 217 | std::memcpy(security_parameter.data.data(), info.ldn.security_parameter.data(), |
| 201 | NetworkInfo info; | 218 | sizeof(SecurityParameter::data)); |
| 202 | const Result rc = ResultSuccess; | ||
| 203 | 219 | ||
| 204 | if (rc.IsError()) { | 220 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 205 | LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); | 221 | |
| 206 | IPC::ResponseBuilder rb{ctx, 2}; | 222 | IPC::ResponseBuilder rb{ctx, 10}; |
| 207 | rb.Push(rc); | 223 | rb.Push(rc); |
| 208 | return; | 224 | rb.PushRaw<SecurityParameter>(security_parameter); |
| 209 | } | 225 | } |
| 210 | 226 | ||
| 211 | security_parameter.session_id = info.network_id.session_id; | 227 | void GetNetworkConfig(Kernel::HLERequestContext& ctx) { |
| 212 | std::memcpy(security_parameter.data.data(), info.ldn.security_parameter.data(), | 228 | NetworkConfig config{}; |
| 213 | sizeof(SecurityParameter::data)); | 229 | NetworkInfo info{}; |
| 214 | 230 | const Result rc = ResultSuccess; | |
| 215 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 231 | |
| 216 | 232 | if (rc.IsError()) { | |
| 217 | IPC::ResponseBuilder rb{ctx, 10}; | 233 | LOG_ERROR(Service_LDN, "NetworkConfig is not valid {}", rc.raw); |
| 218 | rb.Push(rc); | 234 | IPC::ResponseBuilder rb{ctx, 2}; |
| 219 | rb.PushRaw<SecurityParameter>(security_parameter); | 235 | rb.Push(rc); |
| 220 | } | 236 | return; |
| 237 | } | ||
| 238 | |||
| 239 | config.intent_id = info.network_id.intent_id; | ||
| 240 | config.channel = info.common.channel; | ||
| 241 | config.node_count_max = info.ldn.node_count_max; | ||
| 242 | config.local_communication_version = info.ldn.nodes[0].local_communication_version; | ||
| 243 | |||
| 244 | LOG_WARNING(Service_LDN, | ||
| 245 | "(STUBBED) called, intent_id={}/{}, channel={}, node_count_max={}, " | ||
| 246 | "local_communication_version={}", | ||
| 247 | config.intent_id.local_communication_id, config.intent_id.scene_id, | ||
| 248 | config.channel, config.node_count_max, config.local_communication_version); | ||
| 249 | |||
| 250 | IPC::ResponseBuilder rb{ctx, 10}; | ||
| 251 | rb.Push(rc); | ||
| 252 | rb.PushRaw<NetworkConfig>(config); | ||
| 253 | } | ||
| 221 | 254 | ||
| 222 | void IUserLocalCommunicationService::GetNetworkConfig(Kernel::HLERequestContext& ctx) { | 255 | void AttachStateChangeEvent(Kernel::HLERequestContext& ctx) { |
| 223 | NetworkConfig config; | 256 | LOG_INFO(Service_LDN, "called"); |
| 224 | NetworkInfo info; | ||
| 225 | const Result rc = ResultSuccess; | ||
| 226 | 257 | ||
| 227 | if (rc.IsError()) { | 258 | IPC::ResponseBuilder rb{ctx, 2, 1}; |
| 228 | LOG_ERROR(Service_LDN, "NetworkConfig is not valid {}", rc.raw); | 259 | rb.Push(ResultSuccess); |
| 229 | IPC::ResponseBuilder rb{ctx, 2}; | 260 | rb.PushCopyObjects(state_change_event->GetReadableEvent()); |
| 230 | rb.Push(rc); | ||
| 231 | return; | ||
| 232 | } | 261 | } |
| 233 | 262 | ||
| 234 | config.intent_id = info.network_id.intent_id; | 263 | void GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx) { |
| 235 | config.channel = info.common.channel; | 264 | const std::size_t network_buffer_size = ctx.GetWriteBufferSize(0); |
| 236 | config.node_count_max = info.ldn.node_count_max; | 265 | const std::size_t node_buffer_count = ctx.GetWriteBufferSize(1) / sizeof(NodeLatestUpdate); |
| 237 | config.local_communication_version = info.ldn.nodes[0].local_communication_version; | ||
| 238 | 266 | ||
| 239 | LOG_WARNING(Service_LDN, | 267 | if (node_buffer_count == 0 || network_buffer_size != sizeof(NetworkInfo)) { |
| 240 | "(STUBBED) called, intent_id={}/{}, channel={}, node_count_max={}, " | 268 | LOG_ERROR(Service_LDN, "Invalid buffer size {}, {}", network_buffer_size, |
| 241 | "local_communication_version={}", | 269 | node_buffer_count); |
| 242 | config.intent_id.local_communication_id, config.intent_id.scene_id, config.channel, | 270 | IPC::ResponseBuilder rb{ctx, 2}; |
| 243 | config.node_count_max, config.local_communication_version); | 271 | rb.Push(ResultBadInput); |
| 272 | return; | ||
| 273 | } | ||
| 244 | 274 | ||
| 245 | IPC::ResponseBuilder rb{ctx, 10}; | 275 | NetworkInfo info; |
| 246 | rb.Push(rc); | 276 | std::vector<NodeLatestUpdate> latest_update(node_buffer_count); |
| 247 | rb.PushRaw<NetworkConfig>(config); | ||
| 248 | } | ||
| 249 | 277 | ||
| 250 | void IUserLocalCommunicationService::AttachStateChangeEvent(Kernel::HLERequestContext& ctx) { | 278 | const auto rc = ResultSuccess; |
| 251 | LOG_INFO(Service_LDN, "called"); | 279 | if (rc.IsError()) { |
| 280 | LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); | ||
| 281 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 282 | rb.Push(rc); | ||
| 283 | return; | ||
| 284 | } | ||
| 252 | 285 | ||
| 253 | IPC::ResponseBuilder rb{ctx, 2, 1}; | 286 | LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", |
| 254 | rb.Push(ResultSuccess); | 287 | info.common.ssid.GetStringValue(), info.ldn.node_count); |
| 255 | rb.PushCopyObjects(state_change_event->GetReadableEvent()); | ||
| 256 | } | ||
| 257 | 288 | ||
| 258 | void IUserLocalCommunicationService::GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx) { | 289 | ctx.WriteBuffer(info, 0); |
| 259 | const std::size_t network_buffer_size = ctx.GetWriteBufferSize(0); | 290 | ctx.WriteBuffer(latest_update, 1); |
| 260 | const std::size_t node_buffer_count = ctx.GetWriteBufferSize(1) / sizeof(NodeLatestUpdate); | ||
| 261 | 291 | ||
| 262 | if (node_buffer_count == 0 || network_buffer_size != sizeof(NetworkInfo)) { | ||
| 263 | LOG_ERROR(Service_LDN, "Invalid buffer size {}, {}", network_buffer_size, | ||
| 264 | node_buffer_count); | ||
| 265 | IPC::ResponseBuilder rb{ctx, 2}; | 292 | IPC::ResponseBuilder rb{ctx, 2}; |
| 266 | rb.Push(ResultBadInput); | 293 | rb.Push(ResultSuccess); |
| 267 | return; | ||
| 268 | } | 294 | } |
| 269 | 295 | ||
| 270 | NetworkInfo info; | 296 | void Scan(Kernel::HLERequestContext& ctx) { |
| 271 | std::vector<NodeLatestUpdate> latest_update(node_buffer_count); | 297 | ScanImpl(ctx); |
| 272 | |||
| 273 | const auto rc = ResultSuccess; | ||
| 274 | if (rc.IsError()) { | ||
| 275 | LOG_ERROR(Service_LDN, "NetworkInfo is not valid {}", rc.raw); | ||
| 276 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 277 | rb.Push(rc); | ||
| 278 | return; | ||
| 279 | } | 298 | } |
| 280 | 299 | ||
| 281 | LOG_WARNING(Service_LDN, "(STUBBED) called, ssid='{}', nodes={}", | 300 | void ScanPrivate(Kernel::HLERequestContext& ctx) { |
| 282 | info.common.ssid.GetStringValue(), info.ldn.node_count); | 301 | ScanImpl(ctx, true); |
| 302 | } | ||
| 283 | 303 | ||
| 284 | ctx.WriteBuffer(info, 0); | 304 | void ScanImpl(Kernel::HLERequestContext& ctx, bool is_private = false) { |
| 285 | ctx.WriteBuffer(latest_update, 1); | 305 | IPC::RequestParser rp{ctx}; |
| 306 | const auto channel{rp.PopEnum<WifiChannel>()}; | ||
| 307 | const auto scan_filter{rp.PopRaw<ScanFilter>()}; | ||
| 286 | 308 | ||
| 287 | IPC::ResponseBuilder rb{ctx, 2}; | 309 | const std::size_t network_info_size = ctx.GetWriteBufferSize() / sizeof(NetworkInfo); |
| 288 | rb.Push(ResultSuccess); | ||
| 289 | } | ||
| 290 | 310 | ||
| 291 | void IUserLocalCommunicationService::Scan(Kernel::HLERequestContext& ctx) { | 311 | if (network_info_size == 0) { |
| 292 | ScanImpl(ctx); | 312 | LOG_ERROR(Service_LDN, "Invalid buffer size {}", network_info_size); |
| 293 | } | 313 | IPC::ResponseBuilder rb{ctx, 2}; |
| 314 | rb.Push(ResultBadInput); | ||
| 315 | return; | ||
| 316 | } | ||
| 294 | 317 | ||
| 295 | void IUserLocalCommunicationService::ScanPrivate(Kernel::HLERequestContext& ctx) { | 318 | u16 count = 0; |
| 296 | ScanImpl(ctx, true); | 319 | std::vector<NetworkInfo> network_infos(network_info_size); |
| 297 | } | ||
| 298 | 320 | ||
| 299 | void IUserLocalCommunicationService::ScanImpl(Kernel::HLERequestContext& ctx, bool is_private) { | 321 | LOG_WARNING(Service_LDN, |
| 300 | IPC::RequestParser rp{ctx}; | 322 | "(STUBBED) called, channel={}, filter_scan_flag={}, filter_network_type={}", |
| 301 | const auto channel{rp.PopEnum<WifiChannel>()}; | 323 | channel, scan_filter.flag, scan_filter.network_type); |
| 302 | const auto scan_filter{rp.PopRaw<ScanFilter>()}; | ||
| 303 | 324 | ||
| 304 | const std::size_t network_info_size = ctx.GetWriteBufferSize() / sizeof(NetworkInfo); | 325 | ctx.WriteBuffer(network_infos); |
| 305 | 326 | ||
| 306 | if (network_info_size == 0) { | 327 | IPC::ResponseBuilder rb{ctx, 3}; |
| 307 | LOG_ERROR(Service_LDN, "Invalid buffer size {}", network_info_size); | 328 | rb.Push(ResultSuccess); |
| 308 | IPC::ResponseBuilder rb{ctx, 2}; | 329 | rb.Push<u32>(count); |
| 309 | rb.Push(ResultBadInput); | ||
| 310 | return; | ||
| 311 | } | 330 | } |
| 312 | 331 | ||
| 313 | u16 count = 0; | 332 | void OpenAccessPoint(Kernel::HLERequestContext& ctx) { |
| 314 | std::vector<NetworkInfo> network_infos(network_info_size); | 333 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 315 | |||
| 316 | LOG_WARNING(Service_LDN, | ||
| 317 | "(STUBBED) called, channel={}, filter_scan_flag={}, filter_network_type={}", | ||
| 318 | channel, scan_filter.flag, scan_filter.network_type); | ||
| 319 | 334 | ||
| 320 | ctx.WriteBuffer(network_infos); | 335 | IPC::ResponseBuilder rb{ctx, 2}; |
| 336 | rb.Push(ResultSuccess); | ||
| 337 | } | ||
| 321 | 338 | ||
| 322 | IPC::ResponseBuilder rb{ctx, 3}; | 339 | void CloseAccessPoint(Kernel::HLERequestContext& ctx) { |
| 323 | rb.Push(ResultSuccess); | 340 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 324 | rb.Push<u32>(count); | ||
| 325 | } | ||
| 326 | 341 | ||
| 327 | void IUserLocalCommunicationService::OpenAccessPoint(Kernel::HLERequestContext& ctx) { | 342 | IPC::ResponseBuilder rb{ctx, 2}; |
| 328 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 343 | rb.Push(ResultSuccess); |
| 344 | } | ||
| 329 | 345 | ||
| 330 | IPC::ResponseBuilder rb{ctx, 2}; | 346 | void CreateNetwork(Kernel::HLERequestContext& ctx) { |
| 331 | rb.Push(ResultSuccess); | 347 | IPC::RequestParser rp{ctx}; |
| 332 | } | 348 | struct Parameters { |
| 349 | SecurityConfig security_config; | ||
| 350 | UserConfig user_config; | ||
| 351 | INSERT_PADDING_WORDS_NOINIT(1); | ||
| 352 | NetworkConfig network_config; | ||
| 353 | }; | ||
| 354 | static_assert(sizeof(Parameters) == 0x98, "Parameters has incorrect size."); | ||
| 333 | 355 | ||
| 334 | void IUserLocalCommunicationService::CloseAccessPoint(Kernel::HLERequestContext& ctx) { | 356 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 335 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | ||
| 336 | 357 | ||
| 337 | IPC::ResponseBuilder rb{ctx, 2}; | 358 | LOG_WARNING(Service_LDN, |
| 338 | rb.Push(ResultSuccess); | 359 | "(STUBBED) called, passphrase_size={}, security_mode={}, " |
| 339 | } | 360 | "local_communication_version={}", |
| 361 | parameters.security_config.passphrase_size, | ||
| 362 | parameters.security_config.security_mode, | ||
| 363 | parameters.network_config.local_communication_version); | ||
| 340 | 364 | ||
| 341 | void IUserLocalCommunicationService::CreateNetwork(Kernel::HLERequestContext& ctx) { | 365 | IPC::ResponseBuilder rb{ctx, 2}; |
| 342 | IPC::RequestParser rp{ctx}; | 366 | rb.Push(ResultSuccess); |
| 343 | struct Parameters { | 367 | } |
| 344 | SecurityConfig security_config; | ||
| 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."); | ||
| 350 | 368 | ||
| 351 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 369 | void CreateNetworkPrivate(Kernel::HLERequestContext& ctx) { |
| 370 | IPC::RequestParser rp{ctx}; | ||
| 371 | struct Parameters { | ||
| 372 | SecurityConfig security_config; | ||
| 373 | SecurityParameter security_parameter; | ||
| 374 | UserConfig user_config; | ||
| 375 | NetworkConfig network_config; | ||
| 376 | }; | ||
| 377 | static_assert(sizeof(Parameters) == 0xB8, "Parameters has incorrect size."); | ||
| 352 | 378 | ||
| 353 | IPC::ResponseBuilder rb{ctx, 2}; | 379 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 354 | rb.Push(ResultSuccess); | ||
| 355 | } | ||
| 356 | 380 | ||
| 357 | void IUserLocalCommunicationService::CreateNetworkPrivate(Kernel::HLERequestContext& ctx) { | 381 | LOG_WARNING(Service_LDN, |
| 358 | IPC::RequestParser rp{ctx}; | 382 | "(STUBBED) called, passphrase_size={}, security_mode={}, " |
| 359 | struct Parameters { | 383 | "local_communication_version={}", |
| 360 | SecurityConfig security_config; | 384 | parameters.security_config.passphrase_size, |
| 361 | SecurityParameter security_parameter; | 385 | parameters.security_config.security_mode, |
| 362 | UserConfig user_config; | 386 | parameters.network_config.local_communication_version); |
| 363 | NetworkConfig network_config; | ||
| 364 | }; | ||
| 365 | static_assert(sizeof(Parameters) == 0xB8, "Parameters has incorrect size."); | ||
| 366 | 387 | ||
| 367 | const auto parameters{rp.PopRaw<Parameters>()}; | 388 | IPC::ResponseBuilder rb{ctx, 2}; |
| 389 | rb.Push(ResultSuccess); | ||
| 390 | } | ||
| 368 | 391 | ||
| 369 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 392 | void DestroyNetwork(Kernel::HLERequestContext& ctx) { |
| 393 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | ||
| 370 | 394 | ||
| 371 | IPC::ResponseBuilder rb{ctx, 2}; | 395 | IPC::ResponseBuilder rb{ctx, 2}; |
| 372 | rb.Push(ResultSuccess); | 396 | rb.Push(ResultSuccess); |
| 373 | } | 397 | } |
| 374 | 398 | ||
| 375 | void IUserLocalCommunicationService::DestroyNetwork(Kernel::HLERequestContext& ctx) { | 399 | void SetAdvertiseData(Kernel::HLERequestContext& ctx) { |
| 376 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 400 | std::vector<u8> read_buffer = ctx.ReadBuffer(); |
| 377 | 401 | ||
| 378 | IPC::ResponseBuilder rb{ctx, 2}; | 402 | LOG_WARNING(Service_LDN, "(STUBBED) called, size {}", read_buffer.size()); |
| 379 | rb.Push(ResultSuccess); | ||
| 380 | } | ||
| 381 | 403 | ||
| 382 | void IUserLocalCommunicationService::SetAdvertiseData(Kernel::HLERequestContext& ctx) { | 404 | IPC::ResponseBuilder rb{ctx, 2}; |
| 383 | std::vector<u8> read_buffer = ctx.ReadBuffer(); | 405 | rb.Push(ResultSuccess); |
| 406 | } | ||
| 384 | 407 | ||
| 385 | LOG_WARNING(Service_LDN, "(STUBBED) called, size {}", read_buffer.size()); | 408 | void SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) { |
| 409 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | ||
| 386 | 410 | ||
| 387 | IPC::ResponseBuilder rb{ctx, 2}; | 411 | IPC::ResponseBuilder rb{ctx, 2}; |
| 388 | rb.Push(ResultSuccess); | 412 | rb.Push(ResultSuccess); |
| 389 | } | 413 | } |
| 390 | 414 | ||
| 391 | void IUserLocalCommunicationService::SetStationAcceptPolicy(Kernel::HLERequestContext& ctx) { | 415 | void AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) { |
| 392 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 416 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 393 | 417 | ||
| 394 | IPC::ResponseBuilder rb{ctx, 2}; | 418 | IPC::ResponseBuilder rb{ctx, 2}; |
| 395 | rb.Push(ResultSuccess); | 419 | rb.Push(ResultSuccess); |
| 396 | } | 420 | } |
| 397 | 421 | ||
| 398 | void IUserLocalCommunicationService::AddAcceptFilterEntry(Kernel::HLERequestContext& ctx) { | 422 | void OpenStation(Kernel::HLERequestContext& ctx) { |
| 399 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 423 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 400 | 424 | ||
| 401 | IPC::ResponseBuilder rb{ctx, 2}; | 425 | IPC::ResponseBuilder rb{ctx, 2}; |
| 402 | rb.Push(ResultSuccess); | 426 | rb.Push(ResultSuccess); |
| 403 | } | 427 | } |
| 404 | 428 | ||
| 405 | void IUserLocalCommunicationService::OpenStation(Kernel::HLERequestContext& ctx) { | 429 | void CloseStation(Kernel::HLERequestContext& ctx) { |
| 406 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 430 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 407 | 431 | ||
| 408 | IPC::ResponseBuilder rb{ctx, 2}; | 432 | IPC::ResponseBuilder rb{ctx, 2}; |
| 409 | rb.Push(ResultSuccess); | 433 | rb.Push(ResultSuccess); |
| 410 | } | 434 | } |
| 411 | 435 | ||
| 412 | void IUserLocalCommunicationService::CloseStation(Kernel::HLERequestContext& ctx) { | 436 | void Connect(Kernel::HLERequestContext& ctx) { |
| 413 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 437 | IPC::RequestParser rp{ctx}; |
| 438 | struct Parameters { | ||
| 439 | SecurityConfig security_config; | ||
| 440 | UserConfig user_config; | ||
| 441 | u32 local_communication_version; | ||
| 442 | u32 option; | ||
| 443 | }; | ||
| 444 | static_assert(sizeof(Parameters) == 0x7C, "Parameters has incorrect size."); | ||
| 414 | 445 | ||
| 415 | IPC::ResponseBuilder rb{ctx, 2}; | 446 | const auto parameters{rp.PopRaw<Parameters>()}; |
| 416 | rb.Push(ResultSuccess); | ||
| 417 | } | ||
| 418 | 447 | ||
| 419 | void IUserLocalCommunicationService::Connect(Kernel::HLERequestContext& ctx) { | 448 | LOG_WARNING(Service_LDN, |
| 420 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 449 | "(STUBBED) called, passphrase_size={}, security_mode={}, " |
| 450 | "local_communication_version={}", | ||
| 451 | parameters.security_config.passphrase_size, | ||
| 452 | parameters.security_config.security_mode, | ||
| 453 | parameters.local_communication_version); | ||
| 421 | 454 | ||
| 422 | IPC::RequestParser rp{ctx}; | 455 | const std::vector<u8> read_buffer = ctx.ReadBuffer(); |
| 423 | struct Parameters { | 456 | NetworkInfo network_info{}; |
| 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."); | ||
| 430 | 457 | ||
| 431 | const auto parameters{rp.PopRaw<Parameters>()}; | 458 | if (read_buffer.size() != sizeof(NetworkInfo)) { |
| 459 | LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!"); | ||
| 460 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 461 | rb.Push(ResultBadInput); | ||
| 462 | return; | ||
| 463 | } | ||
| 432 | 464 | ||
| 433 | const std::vector<u8> read_buffer = ctx.ReadBuffer(); | 465 | std::memcpy(&network_info, read_buffer.data(), read_buffer.size()); |
| 434 | NetworkInfo network_info{}; | ||
| 435 | 466 | ||
| 436 | if (read_buffer.size() != sizeof(NetworkInfo)) { | ||
| 437 | LOG_ERROR(Frontend, "NetworkInfo doesn't match read_buffer size!"); | ||
| 438 | IPC::ResponseBuilder rb{ctx, 2}; | 467 | IPC::ResponseBuilder rb{ctx, 2}; |
| 439 | rb.Push(ResultBadInput); | 468 | rb.Push(ResultSuccess); |
| 440 | return; | ||
| 441 | } | 469 | } |
| 442 | 470 | ||
| 443 | std::memcpy(&network_info, read_buffer.data(), read_buffer.size()); | 471 | void Disconnect(Kernel::HLERequestContext& ctx) { |
| 444 | 472 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | |
| 445 | IPC::ResponseBuilder rb{ctx, 2}; | ||
| 446 | rb.Push(ResultSuccess); | ||
| 447 | } | ||
| 448 | 473 | ||
| 449 | void IUserLocalCommunicationService::Disconnect(Kernel::HLERequestContext& ctx) { | 474 | IPC::ResponseBuilder rb{ctx, 2}; |
| 450 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | 475 | rb.Push(ResultSuccess); |
| 476 | } | ||
| 477 | void Initialize(Kernel::HLERequestContext& ctx) { | ||
| 478 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | ||
| 451 | 479 | ||
| 452 | IPC::ResponseBuilder rb{ctx, 2}; | 480 | const auto rc = InitializeImpl(ctx); |
| 453 | rb.Push(ResultSuccess); | ||
| 454 | } | ||
| 455 | void IUserLocalCommunicationService::Initialize(Kernel::HLERequestContext& ctx) { | ||
| 456 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | ||
| 457 | 481 | ||
| 458 | const auto rc = InitializeImpl(ctx); | 482 | IPC::ResponseBuilder rb{ctx, 2}; |
| 483 | rb.Push(rc); | ||
| 484 | } | ||
| 459 | 485 | ||
| 460 | IPC::ResponseBuilder rb{ctx, 2}; | 486 | void Finalize(Kernel::HLERequestContext& ctx) { |
| 461 | rb.Push(rc); | 487 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 462 | } | ||
| 463 | 488 | ||
| 464 | void IUserLocalCommunicationService::Finalize(Kernel::HLERequestContext& ctx) { | 489 | is_initialized = false; |
| 465 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | ||
| 466 | 490 | ||
| 467 | is_initialized = false; | 491 | IPC::ResponseBuilder rb{ctx, 2}; |
| 492 | rb.Push(ResultSuccess); | ||
| 493 | } | ||
| 468 | 494 | ||
| 469 | IPC::ResponseBuilder rb{ctx, 2}; | 495 | void Initialize2(Kernel::HLERequestContext& ctx) { |
| 470 | rb.Push(ResultSuccess); | 496 | LOG_WARNING(Service_LDN, "(STUBBED) called"); |
| 471 | } | ||
| 472 | 497 | ||
| 473 | void IUserLocalCommunicationService::Initialize2(Kernel::HLERequestContext& ctx) { | 498 | const auto rc = InitializeImpl(ctx); |
| 474 | LOG_WARNING(Service_LDN, "(STUBBED) called"); | ||
| 475 | 499 | ||
| 476 | const auto rc = InitializeImpl(ctx); | 500 | IPC::ResponseBuilder rb{ctx, 2}; |
| 501 | rb.Push(rc); | ||
| 502 | } | ||
| 477 | 503 | ||
| 478 | IPC::ResponseBuilder rb{ctx, 2}; | 504 | Result InitializeImpl(Kernel::HLERequestContext& ctx) { |
| 479 | rb.Push(rc); | 505 | const auto network_interface = Network::GetSelectedNetworkInterface(); |
| 480 | } | 506 | if (!network_interface) { |
| 507 | LOG_ERROR(Service_LDN, "No network interface is set"); | ||
| 508 | return ResultAirplaneModeEnabled; | ||
| 509 | } | ||
| 481 | 510 | ||
| 482 | Result IUserLocalCommunicationService::InitializeImpl(Kernel::HLERequestContext& ctx) { | 511 | is_initialized = true; |
| 483 | const auto network_interface = Network::GetSelectedNetworkInterface(); | 512 | // TODO (flTobi): Change this to ResultSuccess when LDN is fully implemented |
| 484 | if (!network_interface) { | ||
| 485 | LOG_ERROR(Service_LDN, "No network interface is set"); | ||
| 486 | return ResultAirplaneModeEnabled; | 513 | return ResultAirplaneModeEnabled; |
| 487 | } | 514 | } |
| 488 | 515 | ||
| 489 | is_initialized = true; | 516 | KernelHelpers::ServiceContext service_context; |
| 490 | // TODO (flTobi): Change this to ResultSuccess when LDN is fully implemented | 517 | Kernel::KEvent* state_change_event; |
| 491 | return ResultAirplaneModeEnabled; | 518 | Network::RoomNetwork& room_network; |
| 492 | } | 519 | |
| 520 | bool is_initialized{}; | ||
| 521 | }; | ||
| 493 | 522 | ||
| 494 | class LDNS final : public ServiceFramework<LDNS> { | 523 | class LDNS final : public ServiceFramework<LDNS> { |
| 495 | public: | 524 | public: |
diff --git a/src/core/hle/service/ldn/ldn.h b/src/core/hle/service/ldn/ldn.h index 4ab8f7a9b..6afe2ea6f 100644 --- a/src/core/hle/service/ldn/ldn.h +++ b/src/core/hle/service/ldn/ldn.h | |||
| @@ -7,8 +7,6 @@ | |||
| 7 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/kernel/k_event.h" |
| 8 | #include "core/hle/result.h" | 8 | #include "core/hle/result.h" |
| 9 | #include "core/hle/service/kernel_helpers.h" | 9 | #include "core/hle/service/kernel_helpers.h" |
| 10 | #include "core/hle/service/ldn/ldn_results.h" | ||
| 11 | #include "core/hle/service/ldn/ldn_types.h" | ||
| 12 | #include "core/hle/service/sm/sm.h" | 10 | #include "core/hle/service/sm/sm.h" |
| 13 | 11 | ||
| 14 | namespace Core { | 12 | namespace Core { |
| @@ -24,68 +22,4 @@ namespace Service::LDN { | |||
| 24 | /// Registers all LDN services with the specified service manager. | 22 | /// Registers all LDN services with the specified service manager. |
| 25 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 23 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); |
| 26 | 24 | ||
| 27 | class IUserLocalCommunicationService final | ||
| 28 | : public ServiceFramework<IUserLocalCommunicationService> { | ||
| 29 | public: | ||
| 30 | explicit IUserLocalCommunicationService(Core::System& system_); | ||
| 31 | ~IUserLocalCommunicationService() override; | ||
| 32 | |||
| 33 | void GetState(Kernel::HLERequestContext& ctx); | ||
| 34 | |||
| 35 | void GetNetworkInfo(Kernel::HLERequestContext& ctx); | ||
| 36 | |||
| 37 | void GetDisconnectReason(Kernel::HLERequestContext& ctx); | ||
| 38 | |||
| 39 | void GetSecurityParameter(Kernel::HLERequestContext& ctx); | ||
| 40 | |||
| 41 | void GetNetworkConfig(Kernel::HLERequestContext& ctx); | ||
| 42 | |||
| 43 | void AttachStateChangeEvent(Kernel::HLERequestContext& ctx); | ||
| 44 | |||
| 45 | void GetNetworkInfoLatestUpdate(Kernel::HLERequestContext& ctx); | ||
| 46 | |||
| 47 | void Scan(Kernel::HLERequestContext& ctx); | ||
| 48 | void ScanPrivate(Kernel::HLERequestContext& ctx); | ||
| 49 | void ScanImpl(Kernel::HLERequestContext& ctx, bool is_private = false); | ||
| 50 | |||
| 51 | void OpenAccessPoint(Kernel::HLERequestContext& ctx); | ||
| 52 | |||
| 53 | void CloseAccessPoint(Kernel::HLERequestContext& ctx); | ||
| 54 | |||
| 55 | void CreateNetwork(Kernel::HLERequestContext& ctx); | ||
| 56 | void CreateNetworkPrivate(Kernel::HLERequestContext& ctx); | ||
| 57 | |||
| 58 | void DestroyNetwork(Kernel::HLERequestContext& ctx); | ||
| 59 | |||
| 60 | void SetAdvertiseData(Kernel::HLERequestContext& ctx); | ||
| 61 | |||
| 62 | void SetStationAcceptPolicy(Kernel::HLERequestContext& ctx); | ||
| 63 | |||
| 64 | void AddAcceptFilterEntry(Kernel::HLERequestContext& ctx); | ||
| 65 | |||
| 66 | void OpenStation(Kernel::HLERequestContext& ctx); | ||
| 67 | |||
| 68 | void CloseStation(Kernel::HLERequestContext& ctx); | ||
| 69 | |||
| 70 | void Disconnect(Kernel::HLERequestContext& ctx); | ||
| 71 | |||
| 72 | void Connect(Kernel::HLERequestContext& ctx); | ||
| 73 | |||
| 74 | void Initialize(Kernel::HLERequestContext& ctx); | ||
| 75 | |||
| 76 | void Finalize(Kernel::HLERequestContext& ctx); | ||
| 77 | |||
| 78 | void Initialize2(Kernel::HLERequestContext& ctx); | ||
| 79 | Result InitializeImpl(Kernel::HLERequestContext& ctx); | ||
| 80 | |||
| 81 | private: | ||
| 82 | void OnEventFired(); | ||
| 83 | |||
| 84 | KernelHelpers::ServiceContext service_context; | ||
| 85 | Kernel::KEvent* state_change_event; | ||
| 86 | Network::RoomNetwork& room_network; | ||
| 87 | |||
| 88 | bool is_initialized{}; | ||
| 89 | }; | ||
| 90 | |||
| 91 | } // namespace Service::LDN | 25 | } // namespace Service::LDN |