PageRenderTime 49ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/dep/acelite/ace/os_include/sys/os_socket.h

https://bitbucket.org/oregon/oregoncore/
C Header | 305 lines | 214 code | 60 blank | 31 comment | 9 complexity | 173bb9b7286d2a0d62a8184ea9e07197 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, CC-BY-SA-3.0, BSD-2-Clause
  1. // -*- C++ -*-
  2. //=============================================================================
  3. /**
  4. * @file os_socket.h
  5. *
  6. * main sockets header
  7. *
  8. * @author Don Hinton <dhinton@dresystems.com>
  9. * @author This code was originally in various places including ace/OS.h.
  10. */
  11. //=============================================================================
  12. #ifndef ACE_OS_INCLUDE_SYS_OS_SOCKET_H
  13. #define ACE_OS_INCLUDE_SYS_OS_SOCKET_H
  14. #include /**/ "ace/pre.h"
  15. #include /**/ "ace/config-lite.h"
  16. #if !defined (ACE_LACKS_PRAGMA_ONCE)
  17. # pragma once
  18. #endif /* ACE_LACKS_PRAGMA_ONCE */
  19. #include "ace/os_include/sys/os_uio.h"
  20. #if !defined (ACE_LACKS_SYS_SOCKET_H)
  21. # include /**/ <sys/socket.h>
  22. #endif /* !ACE_LACKS_SYS_SOCKET_H */
  23. #if defined (ACE_USES_SOCKLIB_H)
  24. # include /**/ <sockLib.h>
  25. #endif /* ACE_USES_SOCKLIB_H */
  26. // Place all additions (especially function declarations) within extern "C" {}
  27. #ifdef __cplusplus
  28. extern "C"
  29. {
  30. #endif /* __cplusplus */
  31. #if !defined (ACE_HAS_MSG)
  32. struct msghdr {};
  33. #endif /* ACE_HAS_MSG */
  34. #if defined (ACE_HAS_MSG) && defined (ACE_LACKS_MSG_ACCRIGHTS)
  35. # if !defined (msg_accrights)
  36. # undef msg_control
  37. # define msg_accrights msg_control
  38. # endif /* ! msg_accrights */
  39. # if !defined (msg_accrightslen)
  40. # undef msg_controllen
  41. # define msg_accrightslen msg_controllen
  42. # endif /* ! msg_accrightslen */
  43. #endif /* ACE_HAS_MSG && ACE_LACKS_MSG_ACCRIGHTS */
  44. # if defined (ACE_LACKS_SOCKADDR)
  45. struct sockaddr {
  46. u_char sa_len; /* total length */
  47. u_char sa_family; /* address family */
  48. char sa_data[14]; /* actually longer; address value */
  49. };
  50. # endif /* ACE_LACKS_SOCKADDR */
  51. # if defined (ACE_LACKS_LINGER)
  52. struct linger {
  53. int l_onoff; /* option on/off */
  54. int l_linger; /* linger time */
  55. };
  56. # endif /* ACE_LACKS_LINGER */
  57. #if defined (ACE_WIN32)
  58. struct msghdr
  59. {
  60. /// Optional address
  61. sockaddr * msg_name;
  62. /// Size of address
  63. int msg_namelen;
  64. /// Scatter/gather array
  65. iovec *msg_iov;
  66. /// # elements in msg_iov
  67. int msg_iovlen;
  68. /// Access rights sent/received
  69. caddr_t msg_accrights;
  70. int msg_accrightslen;
  71. };
  72. #endif /* ACE_WIN32 */
  73. #if defined (ACE_HAS_4_4BSD_SENDMSG_RECVMSG)
  74. // Control message size to pass a file descriptor.
  75. # define ACE_BSD_CONTROL_MSG_LEN sizeof (struct cmsghdr) + sizeof (ACE_HANDLE)
  76. #endif /* ACE_HAS_4_4BSD_SENDMSG_RECVMSG */
  77. // Increase the range of "address families". Please note that this
  78. // must appear _after_ the include of sys/socket.h, for the AF_FILE
  79. // definition on Linux/glibc2.
  80. #if !defined (AF_ANY)
  81. # define AF_ANY (-1)
  82. #endif /* AF_ANY */
  83. #if !defined (AF_UNSPEC)
  84. # define AF_UNSPEC 0
  85. #endif /* AF_UNSPEC */
  86. #if !defined (AF_LOCAL)
  87. # define AF_LOCAL 1
  88. #endif /* AF_LOCAL */
  89. #if !defined (AF_UNIX)
  90. # define AF_UNIX AF_LOCAL
  91. #endif /* AF_UNIX */
  92. #if !defined (AF_INET)
  93. # define AF_INET 2
  94. #endif /* AF_INET */
  95. #if !defined (PF_INET)
  96. # define PF_INET AF_INET
  97. #endif /* PF_INET */
  98. #if !defined (PF_LOCAL)
  99. # define PF_LOCAL AF_LOCAL
  100. #endif /* PF_LOCAL */
  101. #if !defined (PF_UNIX)
  102. # define PF_UNIX PF_LOCAL
  103. #endif /* PF_UNIX */
  104. #if !defined (AF_MAX)
  105. # define AF_MAX 29
  106. #endif /* AF_MAX */
  107. #if !defined (PF_UNSPEC)
  108. # define PF_UNSPEC 0
  109. #endif /* PF_UNSPEC */
  110. #define AF_SPIPE (AF_MAX + 1)
  111. #if !defined (AF_FILE)
  112. # define AF_FILE (AF_MAX + 2)
  113. #endif /* ! AF_FILE */
  114. #define AF_DEV (AF_MAX + 3)
  115. #define AF_UPIPE (AF_SPIPE)
  116. #if !defined (MSG_OOB)
  117. # define MSG_OOB 0x1
  118. #endif /* MSG_OOB */
  119. #if !defined (MSG_PEEK)
  120. # define MSG_PEEK 0x2
  121. #endif /* MSG_PEEK */
  122. #if !defined (SOCK_STREAM)
  123. # define SOCK_STREAM 1
  124. #endif /* SOCK_STREAM */
  125. #if !defined (SOCK_DGRAM)
  126. # define SOCK_DGRAM 2
  127. #endif /* SOCK_DGRAM */
  128. #if !defined (SOCK_SEQPACKET)
  129. # define SOCK_SEQPACKET 5
  130. #endif /* SOCK_SEQPACKET */
  131. #if !defined (SOL_SOCKET)
  132. # define SOL_SOCKET 0xffff
  133. #endif /* SOL_SOCKET */
  134. #if !defined (SO_REUSEADDR)
  135. # define SO_REUSEADDR 0x0004
  136. #endif /* SO_REUSEADDR */
  137. #if !defined (SO_LINGER)
  138. # define SO_LINGER 0x0080
  139. #endif /* SO_LINGER */
  140. #if !defined (SO_SNDBUF)
  141. # define SO_SNDBUF 0x1001
  142. #endif /* SO_SNDBUF */
  143. #if !defined (SO_RCVBUF)
  144. # define SO_RCVBUF 0x1002
  145. #endif /* SO_RCVBUF */
  146. #if !defined (SO_BROADCAST)
  147. # define SO_BROADCAST 0x0020
  148. #endif /* SO_BROADCAST */
  149. #if !defined (SO_ERROR)
  150. # define SO_ERROR 0x1007
  151. #endif /* SO_ERROR */
  152. #if !defined (SCM_RIGHTS)
  153. # define SCM_RIGHTS 0x01
  154. #endif /* SCM_RIGHTS */
  155. #if defined (ACE_HAS_IPV6)
  156. # if defined (ACE_USES_IPV4_IPV6_MIGRATION)
  157. # define ACE_ADDRESS_FAMILY_INET AF_UNSPEC
  158. # define ACE_PROTOCOL_FAMILY_INET PF_UNSPEC
  159. # else
  160. # define ACE_ADDRESS_FAMILY_INET AF_INET6
  161. # define ACE_PROTOCOL_FAMILY_INET PF_INET6
  162. # endif /* ACE_USES_IPV4_IPV6_MIGRATION */
  163. #else /* !ACE_HAS_IPV6 */
  164. # define ACE_ADDRESS_FAMILY_INET AF_INET
  165. # define ACE_PROTOCOL_FAMILY_INET PF_INET
  166. #endif /* ACE_HAS_IPV6 */
  167. #if !defined (ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE)
  168. #define ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE SSIZE_MAX
  169. #endif /* ACE_HAS_SOCK_BUF_SIZE_MAX_VALUE */
  170. #if defined (ACE_HAS_SOCKLEN_T)
  171. # if defined (__hpux)
  172. /*
  173. ** HP-UX supplies the socklen_t type unless some feature set less than
  174. ** _XOPEN_SOURCE_EXTENDED is specifically requested. However, it only
  175. ** actually uses the socklen_t type in supplied socket functions if
  176. ** _XOPEN_SOURCE_EXTENDED is specifically requested. So, for example,
  177. ** the compile options ACE usually uses (includes -mt) cause _HPUX_SOURCE
  178. ** to be set, which sets _INCLUDE_XOPEN_SOURCE_EXTENDED (causing socklen_t
  179. ** to be defined) but _not_ _XOPEN_SOURCE_EXTENDED (causing socket functions
  180. ** to use int, not socklen_t). React to this situation here...
  181. */
  182. # if defined (_XOPEN_SOURCE_EXTENDED)
  183. typedef socklen_t ACE_SOCKET_LEN;
  184. # else
  185. typedef int ACE_SOCKET_LEN;
  186. # endif /* _XOPEN_SOURCE_EXTENDED */
  187. # else
  188. typedef socklen_t ACE_SOCKET_LEN;
  189. # endif /* __hpux */
  190. #elif defined (ACE_HAS_SIZET_SOCKET_LEN)
  191. typedef size_t ACE_SOCKET_LEN;
  192. #else
  193. typedef int ACE_SOCKET_LEN;
  194. #endif /* ACE_HAS_SIZET_SOCKET_LEN */
  195. #if defined (ACE_HAS_NETLINK)
  196. # include /**/ <asm/types.h>
  197. # include /**/ <linux/netlink.h>
  198. # define ACE_PROTOCOL_FAMILY_NETLINK AF_NETLINK
  199. #endif
  200. #if defined (ACE_HAS_LKSCTP)
  201. extern "C"
  202. {
  203. #include /**/ <netinet/in.h>
  204. #include /**/ <netinet/sctp.h>
  205. }
  206. #endif /* ACE_HAS_LKSCTP */
  207. # if defined (ACE_LACKS_TIMEDWAIT_PROTOTYPES)
  208. ssize_t recv_timedwait (ACE_HANDLE handle,
  209. char *buf,
  210. int len,
  211. int flags,
  212. struct timespec *timeout);
  213. ssize_t recvmsg_timedwait (ACE_HANDLE handle,
  214. struct msghdr *msg,
  215. int flags,
  216. struct timespec *timeout);
  217. ssize_t recvfrom_timedwait (ACE_HANDLE handle,
  218. char *buf,
  219. int len,
  220. int flags,
  221. struct sockaddr *addr,
  222. int *addrlen,
  223. struct timespec *timeout);
  224. ssize_t send_timedwait (ACE_HANDLE handle,
  225. const char *buf,
  226. int len,
  227. int flags,
  228. struct timespec *timeout);
  229. ssize_t sendmsg_timedwait (ACE_HANDLE handle,
  230. const struct msghdr *msg,
  231. int flags,
  232. struct timespec *timeout);
  233. ssize_t sendto_timedwait (ACE_HANDLE handle,
  234. const char *buf,
  235. int len,
  236. int flags,
  237. const struct sockaddr *addr,
  238. int addrlen,
  239. struct timespec *timeout);
  240. # endif /* ACE_LACKS_TIMEDWAIT_PROTOTYPES */
  241. #ifdef __cplusplus
  242. }
  243. #endif /* __cplusplus */
  244. #include /**/ "ace/post.h"
  245. #endif /* ACE_OS_INCLUDE_SYS_OS_SOCKET_H */