sockets.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // Copyright 2018 yuzu emulator team
  2. // Licensed under GPLv2 or any later version
  3. // Refer to the license.txt file included.
  4. #pragma once
  5. #include "common/common_funcs.h"
  6. #include "common/common_types.h"
  7. namespace Core {
  8. class System;
  9. }
  10. namespace Service::SM {
  11. class ServiceManager;
  12. }
  13. namespace Service::Sockets {
  14. enum class Errno : u32 {
  15. SUCCESS = 0,
  16. BADF = 9,
  17. AGAIN = 11,
  18. INVAL = 22,
  19. MFILE = 24,
  20. NOTCONN = 107,
  21. };
  22. enum class Domain : u32 {
  23. INET = 2,
  24. };
  25. enum class Type : u32 {
  26. STREAM = 1,
  27. DGRAM = 2,
  28. RAW = 3,
  29. SEQPACKET = 5,
  30. };
  31. enum class Protocol : u32 {
  32. UNSPECIFIED = 0,
  33. ICMP = 1,
  34. TCP = 6,
  35. UDP = 17,
  36. };
  37. enum class OptName : u32 {
  38. REUSEADDR = 0x4,
  39. BROADCAST = 0x20,
  40. LINGER = 0x80,
  41. SNDBUF = 0x1001,
  42. RCVBUF = 0x1002,
  43. SNDTIMEO = 0x1005,
  44. RCVTIMEO = 0x1006,
  45. };
  46. enum class ShutdownHow : s32 {
  47. RD = 0,
  48. WR = 1,
  49. RDWR = 2,
  50. };
  51. enum class FcntlCmd : s32 {
  52. GETFL = 3,
  53. SETFL = 4,
  54. };
  55. struct SockAddrIn {
  56. u8 len;
  57. u8 family;
  58. u16 portno;
  59. std::array<u8, 4> ip;
  60. std::array<u8, 8> zeroes;
  61. };
  62. enum class PollEvents : u16 {
  63. // Using Pascal case because IN is a macro on Windows.
  64. In = 1 << 0,
  65. Pri = 1 << 1,
  66. Out = 1 << 2,
  67. Err = 1 << 3,
  68. Hup = 1 << 4,
  69. Nval = 1 << 5,
  70. };
  71. DECLARE_ENUM_FLAG_OPERATORS(PollEvents);
  72. struct PollFD {
  73. s32 fd;
  74. PollEvents events;
  75. PollEvents revents;
  76. };
  77. struct Linger {
  78. u32 onoff;
  79. u32 linger;
  80. };
  81. constexpr u32 FLAG_MSG_DONTWAIT = 0x80;
  82. constexpr u32 FLAG_O_NONBLOCK = 0x800;
  83. /// Registers all Sockets services with the specified service manager.
  84. void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system);
  85. } // namespace Service::Sockets