PageRenderTime 41ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

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

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