ldn.cpp 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include <memory>
  5. #include "core/hle/ipc_helpers.h"
  6. #include "core/hle/result.h"
  7. #include "core/hle/service/ldn/ldn.h"
  8. #include "core/hle/service/sm/sm.h"
  9. namespace Service::LDN {
  10. class IMonitorService final : public ServiceFramework<IMonitorService> {
  11. public:
  12. explicit IMonitorService() : ServiceFramework{"IMonitorService"} {
  13. // clang-format off
  14. static const FunctionInfo functions[] = {
  15. {0, nullptr, "GetStateForMonitor"},
  16. {1, nullptr, "GetNetworkInfoForMonitor"},
  17. {2, nullptr, "GetIpv4AddressForMonitor"},
  18. {3, nullptr, "GetDisconnectReasonForMonitor"},
  19. {4, nullptr, "GetSecurityParameterForMonitor"},
  20. {5, nullptr, "GetNetworkConfigForMonitor"},
  21. {100, nullptr, "InitializeMonitor"},
  22. {101, nullptr, "FinalizeMonitor"},
  23. };
  24. // clang-format on
  25. RegisterHandlers(functions);
  26. }
  27. };
  28. class LDNM final : public ServiceFramework<LDNM> {
  29. public:
  30. explicit LDNM() : ServiceFramework{"ldn:m"} {
  31. // clang-format off
  32. static const FunctionInfo functions[] = {
  33. {0, &LDNM::CreateMonitorService, "CreateMonitorService"}
  34. };
  35. // clang-format on
  36. RegisterHandlers(functions);
  37. }
  38. void CreateMonitorService(Kernel::HLERequestContext& ctx) {
  39. LOG_DEBUG(Service_LDN, "called");
  40. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  41. rb.Push(RESULT_SUCCESS);
  42. rb.PushIpcInterface<IMonitorService>();
  43. }
  44. };
  45. class ISystemLocalCommunicationService final
  46. : public ServiceFramework<ISystemLocalCommunicationService> {
  47. public:
  48. explicit ISystemLocalCommunicationService()
  49. : ServiceFramework{"ISystemLocalCommunicationService"} {
  50. // clang-format off
  51. static const FunctionInfo functions[] = {
  52. {0, nullptr, "GetState"},
  53. {1, nullptr, "GetNetworkInfo"},
  54. {2, nullptr, "GetIpv4Address"},
  55. {3, nullptr, "GetDisconnectReason"},
  56. {4, nullptr, "GetSecurityParameter"},
  57. {5, nullptr, "GetNetworkConfig"},
  58. {100, nullptr, "AttachStateChangeEvent"},
  59. {101, nullptr, "GetNetworkInfoLatestUpdate"},
  60. {102, nullptr, "Scan"},
  61. {103, nullptr, "ScanPrivate"},
  62. {200, nullptr, "OpenAccessPoint"},
  63. {201, nullptr, "CloseAccessPoint"},
  64. {202, nullptr, "CreateNetwork"},
  65. {203, nullptr, "CreateNetworkPrivate"},
  66. {204, nullptr, "DestroyNetwork"},
  67. {205, nullptr, "Reject"},
  68. {206, nullptr, "SetAdvertiseData"},
  69. {207, nullptr, "SetStationAcceptPolicy"},
  70. {208, nullptr, "AddAcceptFilterEntry"},
  71. {209, nullptr, "ClearAcceptFilter"},
  72. {300, nullptr, "OpenStation"},
  73. {301, nullptr, "CloseStation"},
  74. {302, nullptr, "Connect"},
  75. {303, nullptr, "ConnectPrivate"},
  76. {304, nullptr, "Disconnect"},
  77. {400, nullptr, "InitializeSystem"},
  78. {401, nullptr, "FinalizeSystem"},
  79. {402, nullptr, "SetOperationMode"},
  80. {403, nullptr, "InitializeSystem2"},
  81. };
  82. // clang-format on
  83. RegisterHandlers(functions);
  84. }
  85. };
  86. class IUserLocalCommunicationService final
  87. : public ServiceFramework<IUserLocalCommunicationService> {
  88. public:
  89. explicit IUserLocalCommunicationService() : ServiceFramework{"IUserLocalCommunicationService"} {
  90. // clang-format off
  91. static const FunctionInfo functions[] = {
  92. {0, nullptr, "GetState"},
  93. {1, nullptr, "GetNetworkInfo"},
  94. {2, nullptr, "GetIpv4Address"},
  95. {3, nullptr, "GetDisconnectReason"},
  96. {4, nullptr, "GetSecurityParameter"},
  97. {5, nullptr, "GetNetworkConfig"},
  98. {100, nullptr, "AttachStateChangeEvent"},
  99. {101, nullptr, "GetNetworkInfoLatestUpdate"},
  100. {102, nullptr, "Scan"},
  101. {103, nullptr, "ScanPrivate"},
  102. {104, nullptr, "SetWirelessControllerRestriction"},
  103. {200, nullptr, "OpenAccessPoint"},
  104. {201, nullptr, "CloseAccessPoint"},
  105. {202, nullptr, "CreateNetwork"},
  106. {203, nullptr, "CreateNetworkPrivate"},
  107. {204, nullptr, "DestroyNetwork"},
  108. {205, nullptr, "Reject"},
  109. {206, nullptr, "SetAdvertiseData"},
  110. {207, nullptr, "SetStationAcceptPolicy"},
  111. {208, nullptr, "AddAcceptFilterEntry"},
  112. {209, nullptr, "ClearAcceptFilter"},
  113. {300, nullptr, "OpenStation"},
  114. {301, nullptr, "CloseStation"},
  115. {302, nullptr, "Connect"},
  116. {303, nullptr, "ConnectPrivate"},
  117. {304, nullptr, "Disconnect"},
  118. {400, nullptr, "Initialize"},
  119. {401, nullptr, "Finalize"},
  120. {402, &IUserLocalCommunicationService::Initialize2, "Initialize2"}, // 7.0.0+
  121. };
  122. // clang-format on
  123. RegisterHandlers(functions);
  124. }
  125. void Initialize2(Kernel::HLERequestContext& ctx) {
  126. LOG_WARNING(Service_LDN, "(STUBBED) called");
  127. // Result success seem make this services start network and continue.
  128. // If we just pass result error then it will stop and maybe try again and again.
  129. IPC::ResponseBuilder rb{ctx, 2};
  130. rb.Push(RESULT_UNKNOWN);
  131. }
  132. };
  133. class LDNS final : public ServiceFramework<LDNS> {
  134. public:
  135. explicit LDNS() : ServiceFramework{"ldn:s"} {
  136. // clang-format off
  137. static const FunctionInfo functions[] = {
  138. {0, &LDNS::CreateSystemLocalCommunicationService, "CreateSystemLocalCommunicationService"},
  139. };
  140. // clang-format on
  141. RegisterHandlers(functions);
  142. }
  143. void CreateSystemLocalCommunicationService(Kernel::HLERequestContext& ctx) {
  144. LOG_DEBUG(Service_LDN, "called");
  145. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  146. rb.Push(RESULT_SUCCESS);
  147. rb.PushIpcInterface<ISystemLocalCommunicationService>();
  148. }
  149. };
  150. class LDNU final : public ServiceFramework<LDNU> {
  151. public:
  152. explicit LDNU() : ServiceFramework{"ldn:u"} {
  153. // clang-format off
  154. static const FunctionInfo functions[] = {
  155. {0, &LDNU::CreateUserLocalCommunicationService, "CreateUserLocalCommunicationService"},
  156. };
  157. // clang-format on
  158. RegisterHandlers(functions);
  159. }
  160. void CreateUserLocalCommunicationService(Kernel::HLERequestContext& ctx) {
  161. LOG_DEBUG(Service_LDN, "called");
  162. IPC::ResponseBuilder rb{ctx, 2, 0, 1};
  163. rb.Push(RESULT_SUCCESS);
  164. rb.PushIpcInterface<IUserLocalCommunicationService>();
  165. }
  166. };
  167. void InstallInterfaces(SM::ServiceManager& sm) {
  168. std::make_shared<LDNM>()->InstallAsService(sm);
  169. std::make_shared<LDNS>()->InstallAsService(sm);
  170. std::make_shared<LDNU>()->InstallAsService(sm);
  171. }
  172. } // namespace Service::LDN