GlobalErrno.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * Copyright: JessMA Open Source (ldcsaa@gmail.com)
  3. *
  4. * Author : Bruce Liang
  5. * Website : https://github.com/ldcsaa
  6. * Project : https://github.com/ldcsaa/HP-Socket
  7. * Blog : http://www.cnblogs.com/ldcsaa
  8. * Wiki : http://www.oschina.net/p/hp-socket
  9. * QQ Group : 44636872, 75375912
  10. *
  11. * Licensed under the Apache License, Version 2.0 (the "License");
  12. * you may not use this file except in compliance with the License.
  13. * You may obtain a copy of the License at
  14. *
  15. * http://www.apache.org/licenses/LICENSE-2.0
  16. *
  17. * Unless required by applicable law or agreed to in writing, software
  18. * distributed under the License is distributed on an "AS IS" BASIS,
  19. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  20. * See the License for the specific language governing permissions and
  21. * limitations under the License.
  22. */
  23. #pragma once
  24. #include "GlobalDef.h"
  25. #include <errno.h>
  26. #include <sysexits.h>
  27. #define ERROR_INVALID_STATE EPERM
  28. #define ERROR_INVALID_PARAMETER EINVAL
  29. #define ERROR_BROKEN_PIPE EPIPE
  30. #define ERROR_AGAIN EAGAIN
  31. #define ERROR_WOULDBLOCK EAGAIN
  32. #define ERROR_READ_FAULT EFAULT
  33. #define ERROR_WRITE_FAULT EFAULT
  34. #define ERROR_HANDLES_CLOSED EBADFD
  35. #define ERROR_IO_PENDING EINPROGRESS
  36. #define ERROR_INTR EINTR
  37. #define ERROR_EMPTY ENODATA
  38. #define ERROR_NO_DATA ENODATA
  39. #define ERROR_FILE_TOO_LARGE EFBIG
  40. #define ERROR_INVALID_OPERATION EPERM
  41. #define ERROR_CANCELLED ECANCELED
  42. #define ERROR_UNKNOWN ENOMSG
  43. #define ERROR_OBJECT_NOT_FOUND EBADSLT
  44. #define ERROR_NOT_FOUND EBADSLT
  45. #define ERROR_INVALID_INDEX ENOANO
  46. #define ERROR_OPERATION_ABORTED ECANCELED
  47. #define ERROR_CONNABORTED ECONNABORTED
  48. #define ERROR_ADDRNOTAVAIL EADDRNOTAVAIL
  49. #define ERROR_INCORRECT_ADDRESS EADDRNOTAVAIL
  50. #define ERROR_PFNOSUPPORT EPFNOSUPPORT
  51. #define ERROR_AFNOSUPPORT EAFNOSUPPORT
  52. #define ERROR_TIMEOUT ETIMEDOUT
  53. #define ERROR_TIMEDOUT ETIMEDOUT
  54. #define ERROR_PROTO EPROTO
  55. #define ERROR_CONNECTION_COUNT_LIMIT ENOSR
  56. #define ERROR_VERIFY_CHECK EBADRQC
  57. #define ERROR_CREATE_FAILED EMFILE
  58. #define ERROR_INVALID_DATA EBADMSG
  59. #define ERROR_BAD_LENGTH EMSGSIZE
  60. #define ERROR_CALL_NOT_IMPLEMENTED EPERM
  61. #define ERROR_INCORRECT_SIZE EMSGSIZE
  62. #define ERROR_CONNRESET ECONNRESET
  63. #define ERROR_CONNREFUSED ECONNREFUSED
  64. #define ERROR_HOSTUNREACH EHOSTUNREACH
  65. #define ERROR_INVALID_NAME ENOENT
  66. #define ERROR_BAD_FILE_TYPE EBADF
  67. #define ERROR_FILE_NOT_FOUND ENOENT
  68. #define ERROR_FUNCTION_FAILED EFAULT
  69. #define ERROR_INVALID_PASSWORD EACCES
  70. #define ERROR_INVALID_ACCESS EACCES
  71. #define ERROR_NOT_READY EPERM
  72. #define ERROR_NOT_SUPPORTED EPERM
  73. #define ERROR_BAD_FORMAT EBADMSG
  74. #define ERROR_BUFFER_OVERFLOW E2BIG
  75. #define ERROR_OUT_OF_RANGE ERANGE
  76. #define ERROR_DESTINATION_ELEMENT_FULL EXFULL
  77. #define ERROR_ALREADY_INITIALIZED EALREADY
  78. #define EXIT_CODE_OK EX_OK
  79. #define EXIT_CODE_CONFIG EX_CONFIG
  80. #define EXIT_CODE_SOFTWARE EX_SOFTWARE
  81. /*
  82. * Socket error codes.
  83. */
  84. #ifndef WSABASEERR
  85. /*
  86. * All Sockets error constants are biased by WSABASEERR from
  87. * the "normal"
  88. */
  89. #define WSABASEERR 10000
  90. /*
  91. * Sockets definitions of regular Microsoft C error constants
  92. */
  93. #define WSAEINTR (WSABASEERR+4)
  94. #define WSAEBADF (WSABASEERR+9)
  95. #define WSAEACCES (WSABASEERR+13)
  96. #define WSAEFAULT (WSABASEERR+14)
  97. #define WSAEINVAL (WSABASEERR+22)
  98. #define WSAEMFILE (WSABASEERR+24)
  99. /*
  100. * Sockets definitions of regular Berkeley error constants
  101. */
  102. #define WSAEWOULDBLOCK (WSABASEERR+35)
  103. #define WSAEINPROGRESS (WSABASEERR+36)
  104. #define WSAEALREADY (WSABASEERR+37)
  105. #define WSAENOTSOCK (WSABASEERR+38)
  106. #define WSAEDESTADDRREQ (WSABASEERR+39)
  107. #define WSAEMSGSIZE (WSABASEERR+40)
  108. #define WSAEPROTOTYPE (WSABASEERR+41)
  109. #define WSAENOPROTOOPT (WSABASEERR+42)
  110. #define WSAEPROTONOSUPPORT (WSABASEERR+43)
  111. #define WSAESOCKTNOSUPPORT (WSABASEERR+44)
  112. #define WSAEOPNOTSUPP (WSABASEERR+45)
  113. #define WSAEPFNOSUPPORT (WSABASEERR+46)
  114. #define WSAEAFNOSUPPORT (WSABASEERR+47)
  115. #define WSAEADDRINUSE (WSABASEERR+48)
  116. #define WSAEADDRNOTAVAIL (WSABASEERR+49)
  117. #define WSAENETDOWN (WSABASEERR+50)
  118. #define WSAENETUNREACH (WSABASEERR+51)
  119. #define WSAENETRESET (WSABASEERR+52)
  120. #define WSAECONNABORTED (WSABASEERR+53)
  121. #define WSAECONNRESET (WSABASEERR+54)
  122. #define WSAENOBUFS (WSABASEERR+55)
  123. #define WSAEISCONN (WSABASEERR+56)
  124. #define WSAENOTCONN (WSABASEERR+57)
  125. #define WSAESHUTDOWN (WSABASEERR+58)
  126. #define WSAETOOMANYREFS (WSABASEERR+59)
  127. #define WSAETIMEDOUT (WSABASEERR+60)
  128. #define WSAECONNREFUSED (WSABASEERR+61)
  129. #define WSAELOOP (WSABASEERR+62)
  130. #define WSAENAMETOOLONG (WSABASEERR+63)
  131. #define WSAEHOSTDOWN (WSABASEERR+64)
  132. #define WSAEHOSTUNREACH (WSABASEERR+65)
  133. #define WSAENOTEMPTY (WSABASEERR+66)
  134. #define WSAEPROCLIM (WSABASEERR+67)
  135. #define WSAEUSERS (WSABASEERR+68)
  136. #define WSAEDQUOT (WSABASEERR+69)
  137. #define WSAESTALE (WSABASEERR+70)
  138. #define WSAEREMOTE (WSABASEERR+71)
  139. /*
  140. * Extended Sockets error constant definitions
  141. */
  142. #define WSASYSNOTREADY (WSABASEERR+91)
  143. #define WSAVERNOTSUPPORTED (WSABASEERR+92)
  144. #define WSANOTINITIALISED (WSABASEERR+93)
  145. #define WSAEDISCON (WSABASEERR+101)
  146. #define WSAENOMORE (WSABASEERR+102)
  147. #define WSAECANCELLED (WSABASEERR+103)
  148. #define WSAEINVALIDPROCTABLE (WSABASEERR+104)
  149. #define WSAEINVALIDPROVIDER (WSABASEERR+105)
  150. #define WSAEPROVIDERFAILEDINIT (WSABASEERR+106)
  151. #define WSASYSCALLFAILURE (WSABASEERR+107)
  152. #define WSASERVICE_NOT_FOUND (WSABASEERR+108)
  153. #define WSATYPE_NOT_FOUND (WSABASEERR+109)
  154. #define WSA_E_NO_MORE (WSABASEERR+110)
  155. #define WSA_E_CANCELLED (WSABASEERR+111)
  156. #define WSAEREFUSED (WSABASEERR+112)
  157. /*
  158. * Error return codes from gethostbyname() and gethostbyaddr()
  159. * (when using the resolver). Note that these errors are
  160. * retrieved via WSAGetLastError() and must therefore follow
  161. * the rules for avoiding clashes with error numbers from
  162. * specific implementations or language run-time systems.
  163. * For this reason the codes are based at WSABASEERR+1001.
  164. * Note also that [WSA]NO_ADDRESS is defined only for
  165. * compatibility purposes.
  166. */
  167. /* Authoritative Answer: Host not found */
  168. #define WSAHOST_NOT_FOUND (WSABASEERR+1001)
  169. /* Non-Authoritative: Host not found, or SERVERFAIL */
  170. #define WSATRY_AGAIN (WSABASEERR+1002)
  171. /* Non-recoverable errors, FORMERR, REFUSED, NOTIMP */
  172. #define WSANO_RECOVERY (WSABASEERR+1003)
  173. /* Valid name, no data record of requested type */
  174. #define WSANO_DATA (WSABASEERR+1004)
  175. /*
  176. * Define QOS related error return codes
  177. *
  178. */
  179. #define WSA_QOS_RECEIVERS (WSABASEERR + 1005)
  180. /* at least one Reserve has arrived */
  181. #define WSA_QOS_SENDERS (WSABASEERR + 1006)
  182. /* at least one Path has arrived */
  183. #define WSA_QOS_NO_SENDERS (WSABASEERR + 1007)
  184. /* there are no senders */
  185. #define WSA_QOS_NO_RECEIVERS (WSABASEERR + 1008)
  186. /* there are no receivers */
  187. #define WSA_QOS_REQUEST_CONFIRMED (WSABASEERR + 1009)
  188. /* Reserve has been confirmed */
  189. #define WSA_QOS_ADMISSION_FAILURE (WSABASEERR + 1010)
  190. /* error due to lack of resources */
  191. #define WSA_QOS_POLICY_FAILURE (WSABASEERR + 1011)
  192. /* rejected for administrative reasons - bad credentials */
  193. #define WSA_QOS_BAD_STYLE (WSABASEERR + 1012)
  194. /* unknown or conflicting style */
  195. #define WSA_QOS_BAD_OBJECT (WSABASEERR + 1013)
  196. /* problem with some part of the filterspec or providerspecific
  197. * buffer in general */
  198. #define WSA_QOS_TRAFFIC_CTRL_ERROR (WSABASEERR + 1014)
  199. /* problem with some part of the flowspec */
  200. #define WSA_QOS_GENERIC_ERROR (WSABASEERR + 1015)
  201. /* general error */
  202. #define WSA_QOS_ESERVICETYPE (WSABASEERR + 1016)
  203. /* invalid service type in flowspec */
  204. #define WSA_QOS_EFLOWSPEC (WSABASEERR + 1017)
  205. /* invalid flowspec */
  206. #define WSA_QOS_EPROVSPECBUF (WSABASEERR + 1018)
  207. /* invalid provider specific buffer */
  208. #define WSA_QOS_EFILTERSTYLE (WSABASEERR + 1019)
  209. /* invalid filter style */
  210. #define WSA_QOS_EFILTERTYPE (WSABASEERR + 1020)
  211. /* invalid filter type */
  212. #define WSA_QOS_EFILTERCOUNT (WSABASEERR + 1021)
  213. /* incorrect number of filters */
  214. #define WSA_QOS_EOBJLENGTH (WSABASEERR + 1022)
  215. /* invalid object length */
  216. #define WSA_QOS_EFLOWCOUNT (WSABASEERR + 1023)
  217. /* incorrect number of flows */
  218. #define WSA_QOS_EUNKOWNPSOBJ (WSABASEERR + 1024)
  219. /* unknown object in provider specific buffer */
  220. #define WSA_QOS_EPOLICYOBJ (WSABASEERR + 1025)
  221. /* invalid policy object in provider specific buffer */
  222. #define WSA_QOS_EFLOWDESC (WSABASEERR + 1026)
  223. /* invalid flow descriptor in the list */
  224. #define WSA_QOS_EPSFLOWSPEC (WSABASEERR + 1027)
  225. /* inconsistent flow spec in provider specific buffer */
  226. #define WSA_QOS_EPSFILTERSPEC (WSABASEERR + 1028)
  227. /* invalid filter spec in provider specific buffer */
  228. #define WSA_QOS_ESDMODEOBJ (WSABASEERR + 1029)
  229. /* invalid shape discard mode object in provider specific buffer */
  230. #define WSA_QOS_ESHAPERATEOBJ (WSABASEERR + 1030)
  231. /* invalid shaping rate object in provider specific buffer */
  232. #define WSA_QOS_RESERVED_PETYPE (WSABASEERR + 1031)
  233. /* reserved policy element in provider specific buffer */
  234. #endif /* ifdef WSABASEERR */