2
0

strerror_defs.cpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. WARNING: Generated from ../scripts/generate-error-types.tcl
  3. DO NOT MODIFY.
  4. Copyright applies as per the generator script.
  5. */
  6. #include <cstddef>
  7. namespace srt
  8. {
  9. // MJ_SUCCESS 'Success'
  10. const char* strerror_msgs_success [] = {
  11. "Success", // MN_NONE = 0
  12. ""
  13. };
  14. // MJ_SETUP 'Connection setup failure'
  15. const char* strerror_msgs_setup [] = {
  16. "Connection setup failure", // MN_NONE = 0
  17. "Connection setup failure: connection timed out", // MN_TIMEOUT = 1
  18. "Connection setup failure: connection rejected", // MN_REJECTED = 2
  19. "Connection setup failure: unable to create/configure SRT socket", // MN_NORES = 3
  20. "Connection setup failure: aborted for security reasons", // MN_SECURITY = 4
  21. "Connection setup failure: socket closed during operation", // MN_CLOSED = 5
  22. ""
  23. };
  24. // MJ_CONNECTION ''
  25. const char* strerror_msgs_connection [] = {
  26. "", // MN_NONE = 0
  27. "Connection was broken", // MN_CONNLOST = 1
  28. "Connection does not exist", // MN_NOCONN = 2
  29. ""
  30. };
  31. // MJ_SYSTEMRES 'System resource failure'
  32. const char* strerror_msgs_systemres [] = {
  33. "System resource failure", // MN_NONE = 0
  34. "System resource failure: unable to create new threads", // MN_THREAD = 1
  35. "System resource failure: unable to allocate buffers", // MN_MEMORY = 2
  36. "System resource failure: unable to allocate a system object", // MN_OBJECT = 3
  37. ""
  38. };
  39. // MJ_FILESYSTEM 'File system failure'
  40. const char* strerror_msgs_filesystem [] = {
  41. "File system failure", // MN_NONE = 0
  42. "File system failure: cannot seek read position", // MN_SEEKGFAIL = 1
  43. "File system failure: failure in read", // MN_READFAIL = 2
  44. "File system failure: cannot seek write position", // MN_SEEKPFAIL = 3
  45. "File system failure: failure in write", // MN_WRITEFAIL = 4
  46. ""
  47. };
  48. // MJ_NOTSUP 'Operation not supported'
  49. const char* strerror_msgs_notsup [] = {
  50. "Operation not supported", // MN_NONE = 0
  51. "Operation not supported: Cannot do this operation on a BOUND socket", // MN_ISBOUND = 1
  52. "Operation not supported: Cannot do this operation on a CONNECTED socket", // MN_ISCONNECTED = 2
  53. "Operation not supported: Bad parameters", // MN_INVAL = 3
  54. "Operation not supported: Invalid socket ID", // MN_SIDINVAL = 4
  55. "Operation not supported: Cannot do this operation on an UNBOUND socket", // MN_ISUNBOUND = 5
  56. "Operation not supported: Socket is not in listening state", // MN_NOLISTEN = 6
  57. "Operation not supported: Listen/accept is not supported in rendezvous connection setup", // MN_ISRENDEZVOUS = 7
  58. "Operation not supported: Cannot call connect on UNBOUND socket in rendezvous connection setup", // MN_ISRENDUNBOUND = 8
  59. "Operation not supported: Incorrect use of Message API (sendmsg/recvmsg)", // MN_INVALMSGAPI = 9
  60. "Operation not supported: Incorrect use of Buffer API (send/recv) or File API (sendfile/recvfile)", // MN_INVALBUFFERAPI = 10
  61. "Operation not supported: Another socket is already listening on the same port", // MN_BUSY = 11
  62. "Operation not supported: Message is too large to send", // MN_XSIZE = 12
  63. "Operation not supported: Invalid epoll ID", // MN_EIDINVAL = 13
  64. "Operation not supported: All sockets removed from epoll, waiting would deadlock", // MN_EEMPTY = 14
  65. "Operation not supported: Another socket is bound to that port and is not reusable for requested settings", // MN_BUSYPORT = 15
  66. ""
  67. };
  68. // MJ_AGAIN 'Non-blocking call failure'
  69. const char* strerror_msgs_again [] = {
  70. "Non-blocking call failure", // MN_NONE = 0
  71. "Non-blocking call failure: no buffer available for sending", // MN_WRAVAIL = 1
  72. "Non-blocking call failure: no data available for reading", // MN_RDAVAIL = 2
  73. "Non-blocking call failure: transmission timed out", // MN_XMTIMEOUT = 3
  74. "Non-blocking call failure: early congestion notification", // MN_CONGESTION = 4
  75. ""
  76. };
  77. // MJ_PEERERROR 'The peer side has signaled an error'
  78. const char* strerror_msgs_peererror [] = {
  79. "The peer side has signaled an error", // MN_NONE = 0
  80. ""
  81. };
  82. const char** strerror_array_major [] = {
  83. strerror_msgs_success, // MJ_SUCCESS = 0
  84. strerror_msgs_setup, // MJ_SETUP = 1
  85. strerror_msgs_connection, // MJ_CONNECTION = 2
  86. strerror_msgs_systemres, // MJ_SYSTEMRES = 3
  87. strerror_msgs_filesystem, // MJ_FILESYSTEM = 4
  88. strerror_msgs_notsup, // MJ_NOTSUP = 5
  89. strerror_msgs_again, // MJ_AGAIN = 6
  90. strerror_msgs_peererror, // MJ_PEERERROR = 7
  91. NULL
  92. };
  93. #define SRT_ARRAY_SIZE(ARR) sizeof(ARR) / sizeof(ARR[0])
  94. const size_t strerror_array_sizes [] = {
  95. SRT_ARRAY_SIZE(strerror_msgs_success) - 1,
  96. SRT_ARRAY_SIZE(strerror_msgs_setup) - 1,
  97. SRT_ARRAY_SIZE(strerror_msgs_connection) - 1,
  98. SRT_ARRAY_SIZE(strerror_msgs_systemres) - 1,
  99. SRT_ARRAY_SIZE(strerror_msgs_filesystem) - 1,
  100. SRT_ARRAY_SIZE(strerror_msgs_notsup) - 1,
  101. SRT_ARRAY_SIZE(strerror_msgs_again) - 1,
  102. SRT_ARRAY_SIZE(strerror_msgs_peererror) - 1,
  103. 0
  104. };
  105. const char* strerror_get_message(size_t major, size_t minor)
  106. {
  107. static const char* const undefined = "UNDEFINED ERROR";
  108. // Extract the major array
  109. if (major >= sizeof(strerror_array_major)/sizeof(const char**))
  110. {
  111. return undefined;
  112. }
  113. const char** array = strerror_array_major[major];
  114. const size_t size = strerror_array_sizes[major];
  115. if (minor >= size)
  116. {
  117. return undefined;
  118. }
  119. return array[minor];
  120. }
  121. } // namespace srt