bsd.cpp 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #include "core/hle/ipc_helpers.h"
  5. #include "core/hle/service/sockets/bsd.h"
  6. namespace Service::Sockets {
  7. void BSD::RegisterClient(Kernel::HLERequestContext& ctx) {
  8. LOG_WARNING(Service, "(STUBBED) called");
  9. IPC::ResponseBuilder rb{ctx, 3};
  10. rb.Push(RESULT_SUCCESS);
  11. rb.Push<u32>(0); // bsd errno
  12. }
  13. void BSD::StartMonitoring(Kernel::HLERequestContext& ctx) {
  14. LOG_WARNING(Service, "(STUBBED) called");
  15. IPC::ResponseBuilder rb{ctx, 2};
  16. rb.Push(RESULT_SUCCESS);
  17. }
  18. void BSD::Socket(Kernel::HLERequestContext& ctx) {
  19. IPC::RequestParser rp{ctx};
  20. u32 domain = rp.Pop<u32>();
  21. u32 type = rp.Pop<u32>();
  22. u32 protocol = rp.Pop<u32>();
  23. LOG_WARNING(Service, "(STUBBED) called domain={} type={} protocol={}", domain, type, protocol);
  24. u32 fd = next_fd++;
  25. IPC::ResponseBuilder rb{ctx, 4};
  26. rb.Push(RESULT_SUCCESS);
  27. rb.Push<u32>(fd);
  28. rb.Push<u32>(0); // bsd errno
  29. }
  30. void BSD::Select(Kernel::HLERequestContext& ctx) {
  31. LOG_WARNING(Service, "(STUBBED) called");
  32. IPC::ResponseBuilder rb{ctx, 4};
  33. rb.Push(RESULT_SUCCESS);
  34. rb.Push<u32>(0); // ret
  35. rb.Push<u32>(0); // bsd errno
  36. }
  37. void BSD::Bind(Kernel::HLERequestContext& ctx) {
  38. LOG_WARNING(Service, "(STUBBED) called");
  39. IPC::ResponseBuilder rb{ctx, 4};
  40. rb.Push(RESULT_SUCCESS);
  41. rb.Push<u32>(0); // ret
  42. rb.Push<u32>(0); // bsd errno
  43. }
  44. void BSD::Connect(Kernel::HLERequestContext& ctx) {
  45. LOG_WARNING(Service, "(STUBBED) called");
  46. IPC::ResponseBuilder rb{ctx, 4};
  47. rb.Push(RESULT_SUCCESS);
  48. rb.Push<u32>(0); // ret
  49. rb.Push<u32>(0); // bsd errno
  50. }
  51. void BSD::Listen(Kernel::HLERequestContext& ctx) {
  52. LOG_WARNING(Service, "(STUBBED) called");
  53. IPC::ResponseBuilder rb{ctx, 4};
  54. rb.Push(RESULT_SUCCESS);
  55. rb.Push<u32>(0); // ret
  56. rb.Push<u32>(0); // bsd errno
  57. }
  58. void BSD::SetSockOpt(Kernel::HLERequestContext& ctx) {
  59. LOG_WARNING(Service, "(STUBBED) called");
  60. IPC::ResponseBuilder rb{ctx, 4};
  61. rb.Push(RESULT_SUCCESS);
  62. rb.Push<u32>(0); // ret
  63. rb.Push<u32>(0); // bsd errno
  64. }
  65. void BSD::SendTo(Kernel::HLERequestContext& ctx) {
  66. LOG_WARNING(Service, "(STUBBED) called");
  67. IPC::ResponseBuilder rb{ctx, 4};
  68. rb.Push(RESULT_SUCCESS);
  69. rb.Push<u32>(0); // ret
  70. rb.Push<u32>(0); // bsd errno
  71. }
  72. void BSD::Close(Kernel::HLERequestContext& ctx) {
  73. LOG_WARNING(Service, "(STUBBED) called");
  74. IPC::ResponseBuilder rb{ctx, 4};
  75. rb.Push(RESULT_SUCCESS);
  76. rb.Push<u32>(0); // ret
  77. rb.Push<u32>(0); // bsd errno
  78. }
  79. BSD::BSD(const char* name) : ServiceFramework(name) {
  80. // clang-format off
  81. static const FunctionInfo functions[] = {
  82. {0, &BSD::RegisterClient, "RegisterClient"},
  83. {1, &BSD::StartMonitoring, "StartMonitoring"},
  84. {2, &BSD::Socket, "Socket"},
  85. {3, nullptr, "SocketExempt"},
  86. {4, nullptr, "Open"},
  87. {5, &BSD::Select, "Select"},
  88. {6, nullptr, "Poll"},
  89. {7, nullptr, "Sysctl"},
  90. {8, nullptr, "Recv"},
  91. {9, nullptr, "RecvFrom"},
  92. {10, nullptr, "Send"},
  93. {11, &BSD::SendTo, "SendTo"},
  94. {12, nullptr, "Accept"},
  95. {13, &BSD::Bind, "Bind"},
  96. {14, &BSD::Connect, "Connect"},
  97. {15, nullptr, "GetPeerName"},
  98. {16, nullptr, "GetSockName"},
  99. {17, nullptr, "GetSockOpt"},
  100. {18, &BSD::Listen, "Listen"},
  101. {19, nullptr, "Ioctl"},
  102. {20, nullptr, "Fcntl"},
  103. {21, &BSD::SetSockOpt, "SetSockOpt"},
  104. {22, nullptr, "Shutdown"},
  105. {23, nullptr, "ShutdownAllSockets"},
  106. {24, nullptr, "Write"},
  107. {25, nullptr, "Read"},
  108. {26, &BSD::Close, "Close"},
  109. {27, nullptr, "DuplicateSocket"},
  110. {28, nullptr, "GetResourceStatistics"},
  111. {29, nullptr, "RecvMMsg"},
  112. {30, nullptr, "SendMMsg"},
  113. {31, nullptr, "EventFd"},
  114. {32, nullptr, "RegisterResourceStatisticsName"},
  115. };
  116. // clang-format on
  117. RegisterHandlers(functions);
  118. }
  119. BSD::~BSD() = default;
  120. BSDCFG::BSDCFG() : ServiceFramework{"bsdcfg"} {
  121. // clang-format off
  122. static const FunctionInfo functions[] = {
  123. {0, nullptr, "SetIfUp"},
  124. {1, nullptr, "SetIfUpWithEvent"},
  125. {2, nullptr, "CancelIf"},
  126. {3, nullptr, "SetIfDown"},
  127. {4, nullptr, "GetIfState"},
  128. {5, nullptr, "DhcpRenew"},
  129. {6, nullptr, "AddStaticArpEntry"},
  130. {7, nullptr, "RemoveArpEntry"},
  131. {8, nullptr, "LookupArpEntry"},
  132. {9, nullptr, "LookupArpEntry2"},
  133. {10, nullptr, "ClearArpEntries"},
  134. {11, nullptr, "ClearArpEntries2"},
  135. {12, nullptr, "PrintArpEntries"},
  136. };
  137. // clang-format on
  138. RegisterHandlers(functions);
  139. }
  140. BSDCFG::~BSDCFG() = default;
  141. } // namespace Service::Sockets