| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224 |
- // Copyright 2018 yuzu emulator team
- // Licensed under GPLv2 or any later version
- // Refer to the license.txt file included.
- #include <memory>
- #include "core/hle/ipc_helpers.h"
- #include "core/hle/result.h"
- #include "core/hle/service/ldn/errors.h"
- #include "core/hle/service/ldn/ldn.h"
- #include "core/hle/service/sm/sm.h"
- namespace Service::LDN {
- class IMonitorService final : public ServiceFramework<IMonitorService> {
- public:
- explicit IMonitorService(Core::System& system_) : ServiceFramework{system_, "IMonitorService"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, nullptr, "GetStateForMonitor"},
- {1, nullptr, "GetNetworkInfoForMonitor"},
- {2, nullptr, "GetIpv4AddressForMonitor"},
- {3, nullptr, "GetDisconnectReasonForMonitor"},
- {4, nullptr, "GetSecurityParameterForMonitor"},
- {5, nullptr, "GetNetworkConfigForMonitor"},
- {100, nullptr, "InitializeMonitor"},
- {101, nullptr, "FinalizeMonitor"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- };
- class LDNM final : public ServiceFramework<LDNM> {
- public:
- explicit LDNM(Core::System& system_) : ServiceFramework{system_, "ldn:m"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &LDNM::CreateMonitorService, "CreateMonitorService"}
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- void CreateMonitorService(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_LDN, "called");
- IPC::ResponseBuilder rb{ctx, 2, 0, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushIpcInterface<IMonitorService>(system);
- }
- };
- class ISystemLocalCommunicationService final
- : public ServiceFramework<ISystemLocalCommunicationService> {
- public:
- explicit ISystemLocalCommunicationService(Core::System& system_)
- : ServiceFramework{system_, "ISystemLocalCommunicationService"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, nullptr, "GetState"},
- {1, nullptr, "GetNetworkInfo"},
- {2, nullptr, "GetIpv4Address"},
- {3, nullptr, "GetDisconnectReason"},
- {4, nullptr, "GetSecurityParameter"},
- {5, nullptr, "GetNetworkConfig"},
- {100, nullptr, "AttachStateChangeEvent"},
- {101, nullptr, "GetNetworkInfoLatestUpdate"},
- {102, nullptr, "Scan"},
- {103, nullptr, "ScanPrivate"},
- {104, nullptr, "SetWirelessControllerRestriction"},
- {200, nullptr, "OpenAccessPoint"},
- {201, nullptr, "CloseAccessPoint"},
- {202, nullptr, "CreateNetwork"},
- {203, nullptr, "CreateNetworkPrivate"},
- {204, nullptr, "DestroyNetwork"},
- {205, nullptr, "Reject"},
- {206, nullptr, "SetAdvertiseData"},
- {207, nullptr, "SetStationAcceptPolicy"},
- {208, nullptr, "AddAcceptFilterEntry"},
- {209, nullptr, "ClearAcceptFilter"},
- {300, nullptr, "OpenStation"},
- {301, nullptr, "CloseStation"},
- {302, nullptr, "Connect"},
- {303, nullptr, "ConnectPrivate"},
- {304, nullptr, "Disconnect"},
- {400, nullptr, "InitializeSystem"},
- {401, nullptr, "FinalizeSystem"},
- {402, nullptr, "SetOperationMode"},
- {403, nullptr, "InitializeSystem2"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- };
- class IUserLocalCommunicationService final
- : public ServiceFramework<IUserLocalCommunicationService> {
- public:
- explicit IUserLocalCommunicationService(Core::System& system_)
- : ServiceFramework{system_, "IUserLocalCommunicationService"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &IUserLocalCommunicationService::GetState, "GetState"},
- {1, nullptr, "GetNetworkInfo"},
- {2, nullptr, "GetIpv4Address"},
- {3, nullptr, "GetDisconnectReason"},
- {4, nullptr, "GetSecurityParameter"},
- {5, nullptr, "GetNetworkConfig"},
- {100, nullptr, "AttachStateChangeEvent"},
- {101, nullptr, "GetNetworkInfoLatestUpdate"},
- {102, nullptr, "Scan"},
- {103, nullptr, "ScanPrivate"},
- {104, nullptr, "SetWirelessControllerRestriction"},
- {200, nullptr, "OpenAccessPoint"},
- {201, nullptr, "CloseAccessPoint"},
- {202, nullptr, "CreateNetwork"},
- {203, nullptr, "CreateNetworkPrivate"},
- {204, nullptr, "DestroyNetwork"},
- {205, nullptr, "Reject"},
- {206, nullptr, "SetAdvertiseData"},
- {207, nullptr, "SetStationAcceptPolicy"},
- {208, nullptr, "AddAcceptFilterEntry"},
- {209, nullptr, "ClearAcceptFilter"},
- {300, nullptr, "OpenStation"},
- {301, nullptr, "CloseStation"},
- {302, nullptr, "Connect"},
- {303, nullptr, "ConnectPrivate"},
- {304, nullptr, "Disconnect"},
- {400, nullptr, "Initialize"},
- {401, nullptr, "Finalize"},
- {402, &IUserLocalCommunicationService::Initialize2, "Initialize2"}, // 7.0.0+
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- void GetState(Kernel::HLERequestContext& ctx) {
- LOG_WARNING(Service_LDN, "(STUBBED) called");
- IPC::ResponseBuilder rb{ctx, 3};
- // Indicate a network error, as we do not actually emulate LDN
- rb.Push(static_cast<u32>(State::Error));
- rb.Push(RESULT_SUCCESS);
- }
- void Initialize2(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_LDN, "called");
- is_initialized = true;
- IPC::ResponseBuilder rb{ctx, 2};
- rb.Push(ERROR_DISABLED);
- }
- private:
- enum class State {
- None,
- Initialized,
- AccessPointOpened,
- AccessPointCreated,
- StationOpened,
- StationConnected,
- Error,
- };
- bool is_initialized{};
- };
- class LDNS final : public ServiceFramework<LDNS> {
- public:
- explicit LDNS(Core::System& system_) : ServiceFramework{system_, "ldn:s"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &LDNS::CreateSystemLocalCommunicationService, "CreateSystemLocalCommunicationService"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- void CreateSystemLocalCommunicationService(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_LDN, "called");
- IPC::ResponseBuilder rb{ctx, 2, 0, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushIpcInterface<ISystemLocalCommunicationService>(system);
- }
- };
- class LDNU final : public ServiceFramework<LDNU> {
- public:
- explicit LDNU(Core::System& system_) : ServiceFramework{system_, "ldn:u"} {
- // clang-format off
- static const FunctionInfo functions[] = {
- {0, &LDNU::CreateUserLocalCommunicationService, "CreateUserLocalCommunicationService"},
- };
- // clang-format on
- RegisterHandlers(functions);
- }
- void CreateUserLocalCommunicationService(Kernel::HLERequestContext& ctx) {
- LOG_DEBUG(Service_LDN, "called");
- IPC::ResponseBuilder rb{ctx, 2, 0, 1};
- rb.Push(RESULT_SUCCESS);
- rb.PushIpcInterface<IUserLocalCommunicationService>(system);
- }
- };
- void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) {
- std::make_shared<LDNM>(system)->InstallAsService(sm);
- std::make_shared<LDNS>(system)->InstallAsService(sm);
- std::make_shared<LDNU>(system)->InstallAsService(sm);
- }
- } // namespace Service::LDN
|