bsd.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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::Connect(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::SendTo(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::Close(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. BSD::BSD(const char* name) : ServiceFramework(name) {
  52. // clang-format off
  53. static const FunctionInfo functions[] = {
  54. {0, &BSD::RegisterClient, "RegisterClient"},
  55. {1, &BSD::StartMonitoring, "StartMonitoring"},
  56. {2, &BSD::Socket, "Socket"},
  57. {3, nullptr, "SocketExempt"},
  58. {4, nullptr, "Open"},
  59. {5, nullptr, "Select"},
  60. {6, nullptr, "Poll"},
  61. {7, nullptr, "Sysctl"},
  62. {8, nullptr, "Recv"},
  63. {9, nullptr, "RecvFrom"},
  64. {10, nullptr, "Send"},
  65. {11, &BSD::SendTo, "SendTo"},
  66. {12, nullptr, "Accept"},
  67. {13, nullptr, "Bind"},
  68. {14, &BSD::Connect, "Connect"},
  69. {15, nullptr, "GetPeerName"},
  70. {16, nullptr, "GetSockName"},
  71. {17, nullptr, "GetSockOpt"},
  72. {18, nullptr, "Listen"},
  73. {19, nullptr, "Ioctl"},
  74. {20, nullptr, "Fcntl"},
  75. {21, nullptr, "SetSockOpt"},
  76. {22, nullptr, "Shutdown"},
  77. {23, nullptr, "ShutdownAllSockets"},
  78. {24, nullptr, "Write"},
  79. {25, nullptr, "Read"},
  80. {26, &BSD::Close, "Close"},
  81. {27, nullptr, "DuplicateSocket"},
  82. {28, nullptr, "GetResourceStatistics"},
  83. {29, nullptr, "RecvMMsg"},
  84. {30, nullptr, "SendMMsg"},
  85. {31, nullptr, "EventFd"},
  86. {32, nullptr, "RegisterResourceStatisticsName"},
  87. };
  88. // clang-format on
  89. RegisterHandlers(functions);
  90. }
  91. BSD::~BSD() = default;
  92. BSDCFG::BSDCFG() : ServiceFramework{"bsdcfg"} {
  93. // clang-format off
  94. static const FunctionInfo functions[] = {
  95. {0, nullptr, "SetIfUp"},
  96. {1, nullptr, "SetIfUpWithEvent"},
  97. {2, nullptr, "CancelIf"},
  98. {3, nullptr, "SetIfDown"},
  99. {4, nullptr, "GetIfState"},
  100. {5, nullptr, "DhcpRenew"},
  101. {6, nullptr, "AddStaticArpEntry"},
  102. {7, nullptr, "RemoveArpEntry"},
  103. {8, nullptr, "LookupArpEntry"},
  104. {9, nullptr, "LookupArpEntry2"},
  105. {10, nullptr, "ClearArpEntries"},
  106. {11, nullptr, "ClearArpEntries2"},
  107. {12, nullptr, "PrintArpEntries"},
  108. };
  109. // clang-format on
  110. RegisterHandlers(functions);
  111. }
  112. BSDCFG::~BSDCFG() = default;
  113. } // namespace Service::Sockets