sockets.h 1.7 KB

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