bsd.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. static const FunctionInfo functions[] = {
  53. {0, &BSD::RegisterClient, "RegisterClient"},
  54. {1, &BSD::StartMonitoring, "StartMonitoring"},
  55. {2, &BSD::Socket, "Socket"},
  56. {3, nullptr, "SocketExempt"},
  57. {4, nullptr, "Open"},
  58. {5, nullptr, "Select"},
  59. {6, nullptr, "Poll"},
  60. {7, nullptr, "Sysctl"},
  61. {8, nullptr, "Recv"},
  62. {9, nullptr, "RecvFrom"},
  63. {10, nullptr, "Send"},
  64. {11, &BSD::SendTo, "SendTo"},
  65. {12, nullptr, "Accept"},
  66. {13, nullptr, "Bind"},
  67. {14, &BSD::Connect, "Connect"},
  68. {15, nullptr, "GetPeerName"},
  69. {16, nullptr, "GetSockName"},
  70. {17, nullptr, "GetSockOpt"},
  71. {18, nullptr, "Listen"},
  72. {19, nullptr, "Ioctl"},
  73. {20, nullptr, "Fcntl"},
  74. {21, nullptr, "SetSockOpt"},
  75. {22, nullptr, "Shutdown"},
  76. {23, nullptr, "ShutdownAllSockets"},
  77. {24, nullptr, "Write"},
  78. {25, nullptr, "Read"},
  79. {26, &BSD::Close, "Close"},
  80. {27, nullptr, "DuplicateSocket"},
  81. {28, nullptr, "GetResourceStatistics"},
  82. {29, nullptr, "RecvMMsg"},
  83. {30, nullptr, "SendMMsg"},
  84. };
  85. RegisterHandlers(functions);
  86. }
  87. } // namespace Service::Sockets