sockets.h 1.7 KB

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