• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // detail/socket_types.hpp
3 // ~~~~~~~~~~~~~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
9 //
10 
11 #ifndef ASIO_DETAIL_SOCKET_TYPES_HPP
12 #define ASIO_DETAIL_SOCKET_TYPES_HPP
13 
14 
15 #include "asio/detail/config.hpp"
16 
17 # include <sys/ioctl.h>
18 #  include <sys/poll.h>
19 # include <sys/types.h>
20 # include <sys/stat.h>
21 # include <fcntl.h>
22 # if defined(__hpux)
23 #  include <sys/time.h>
24 # endif
25 # if !defined(__hpux) || defined(__SELECT)
26 #  include <sys/select.h>
27 # endif
28 # include <sys/socket.h>
29 # include <sys/uio.h>
30 # include <sys/un.h>
31 # include <netinet/in.h>
32 #  include <netinet/tcp.h>
33 # include <arpa/inet.h>
34 # include <netdb.h>
35 # include <net/if.h>
36 # include <limits.h>
37 # if defined(__sun)
38 #  include <sys/filio.h>
39 #  include <sys/sockio.h>
40 # endif
41 
42 #include "asio/detail/push_options.hpp"
43 
44 namespace asio {
45 namespace detail {
46 
47 typedef int socket_type;
48 const int invalid_socket = -1;
49 const int socket_error_retval = -1;
50 const int max_addr_v4_str_len = INET_ADDRSTRLEN;
51 #if defined(INET6_ADDRSTRLEN)
52 const int max_addr_v6_str_len = INET6_ADDRSTRLEN + 1 + IF_NAMESIZE;
53 #else // defined(INET6_ADDRSTRLEN)
54 const int max_addr_v6_str_len = 256;
55 #endif // defined(INET6_ADDRSTRLEN)
56 typedef sockaddr socket_addr_type;
57 typedef in_addr in4_addr_type;
58 # if defined(__hpux)
59 // HP-UX doesn't provide ip_mreq when _XOPEN_SOURCE_EXTENDED is defined.
60 struct in4_mreq_type
61 {
62   struct in_addr imr_multiaddr;
63   struct in_addr imr_interface;
64 };
65 # else
66 typedef ip_mreq in4_mreq_type;
67 # endif
68 typedef sockaddr_in sockaddr_in4_type;
69 typedef in6_addr in6_addr_type;
70 typedef ipv6_mreq in6_mreq_type;
71 typedef sockaddr_in6 sockaddr_in6_type;
72 typedef sockaddr_storage sockaddr_storage_type;
73 typedef sockaddr_un sockaddr_un_type;
74 typedef addrinfo addrinfo_type;
75 typedef ::linger linger_type;
76 typedef int ioctl_arg_type;
77 typedef uint32_t u_long_type;
78 typedef uint16_t u_short_type;
79 #if defined(ASIO_HAS_SSIZE_T)
80 typedef ssize_t signed_size_type;
81 #else // defined(ASIO_HAS_SSIZE_T)
82 typedef int signed_size_type;
83 #endif // defined(ASIO_HAS_SSIZE_T)
84 # define ASIO_OS_DEF(c) ASIO_OS_DEF_##c
85 # define ASIO_OS_DEF_AF_UNSPEC AF_UNSPEC
86 # define ASIO_OS_DEF_AF_INET AF_INET
87 # define ASIO_OS_DEF_AF_INET6 AF_INET6
88 # define ASIO_OS_DEF_SOCK_STREAM SOCK_STREAM
89 # define ASIO_OS_DEF_SOCK_DGRAM SOCK_DGRAM
90 # define ASIO_OS_DEF_SOCK_RAW SOCK_RAW
91 # define ASIO_OS_DEF_SOCK_SEQPACKET SOCK_SEQPACKET
92 # define ASIO_OS_DEF_IPPROTO_IP IPPROTO_IP
93 # define ASIO_OS_DEF_IPPROTO_IPV6 IPPROTO_IPV6
94 # define ASIO_OS_DEF_IPPROTO_TCP IPPROTO_TCP
95 # define ASIO_OS_DEF_IPPROTO_UDP IPPROTO_UDP
96 # define ASIO_OS_DEF_IPPROTO_ICMP IPPROTO_ICMP
97 # define ASIO_OS_DEF_IPPROTO_ICMPV6 IPPROTO_ICMPV6
98 # define ASIO_OS_DEF_FIONBIO FIONBIO
99 # define ASIO_OS_DEF_FIONREAD FIONREAD
100 # define ASIO_OS_DEF_INADDR_ANY INADDR_ANY
101 # define ASIO_OS_DEF_MSG_OOB MSG_OOB
102 # define ASIO_OS_DEF_MSG_PEEK MSG_PEEK
103 # define ASIO_OS_DEF_MSG_DONTROUTE MSG_DONTROUTE
104 # define ASIO_OS_DEF_MSG_EOR MSG_EOR
105 # define ASIO_OS_DEF_SHUT_RD SHUT_RD
106 # define ASIO_OS_DEF_SHUT_WR SHUT_WR
107 # define ASIO_OS_DEF_SHUT_RDWR SHUT_RDWR
108 # define ASIO_OS_DEF_SOMAXCONN SOMAXCONN
109 # define ASIO_OS_DEF_SOL_SOCKET SOL_SOCKET
110 # define ASIO_OS_DEF_SO_BROADCAST SO_BROADCAST
111 # define ASIO_OS_DEF_SO_DEBUG SO_DEBUG
112 # define ASIO_OS_DEF_SO_DONTROUTE SO_DONTROUTE
113 # define ASIO_OS_DEF_SO_KEEPALIVE SO_KEEPALIVE
114 # define ASIO_OS_DEF_SO_LINGER SO_LINGER
115 # define ASIO_OS_DEF_SO_SNDBUF SO_SNDBUF
116 # define ASIO_OS_DEF_SO_RCVBUF SO_RCVBUF
117 # define ASIO_OS_DEF_SO_SNDLOWAT SO_SNDLOWAT
118 # define ASIO_OS_DEF_SO_RCVLOWAT SO_RCVLOWAT
119 # define ASIO_OS_DEF_SO_REUSEADDR SO_REUSEADDR
120 # define ASIO_OS_DEF_TCP_NODELAY TCP_NODELAY
121 # define ASIO_OS_DEF_IP_MULTICAST_IF IP_MULTICAST_IF
122 # define ASIO_OS_DEF_IP_MULTICAST_TTL IP_MULTICAST_TTL
123 # define ASIO_OS_DEF_IP_MULTICAST_LOOP IP_MULTICAST_LOOP
124 # define ASIO_OS_DEF_IP_ADD_MEMBERSHIP IP_ADD_MEMBERSHIP
125 # define ASIO_OS_DEF_IP_DROP_MEMBERSHIP IP_DROP_MEMBERSHIP
126 # define ASIO_OS_DEF_IP_TTL IP_TTL
127 # define ASIO_OS_DEF_IPV6_UNICAST_HOPS IPV6_UNICAST_HOPS
128 # define ASIO_OS_DEF_IPV6_MULTICAST_IF IPV6_MULTICAST_IF
129 # define ASIO_OS_DEF_IPV6_MULTICAST_HOPS IPV6_MULTICAST_HOPS
130 # define ASIO_OS_DEF_IPV6_MULTICAST_LOOP IPV6_MULTICAST_LOOP
131 # define ASIO_OS_DEF_IPV6_JOIN_GROUP IPV6_JOIN_GROUP
132 # define ASIO_OS_DEF_IPV6_LEAVE_GROUP IPV6_LEAVE_GROUP
133 # define ASIO_OS_DEF_AI_CANONNAME AI_CANONNAME
134 # define ASIO_OS_DEF_AI_PASSIVE AI_PASSIVE
135 # define ASIO_OS_DEF_AI_NUMERICHOST AI_NUMERICHOST
136 # if defined(AI_NUMERICSERV)
137 #  define ASIO_OS_DEF_AI_NUMERICSERV AI_NUMERICSERV
138 # else
139 #  define ASIO_OS_DEF_AI_NUMERICSERV 0
140 # endif
141 // Note: QNX Neutrino 6.3 defines AI_V4MAPPED, AI_ALL and AI_ADDRCONFIG but
142 // does not implement them. Therefore they are specifically excluded here.
143 # if defined(AI_V4MAPPED) && !defined(__QNXNTO__)
144 #  define ASIO_OS_DEF_AI_V4MAPPED AI_V4MAPPED
145 # else
146 #  define ASIO_OS_DEF_AI_V4MAPPED 0
147 # endif
148 # if defined(AI_ALL) && !defined(__QNXNTO__)
149 #  define ASIO_OS_DEF_AI_ALL AI_ALL
150 # else
151 #  define ASIO_OS_DEF_AI_ALL 0
152 # endif
153 # if defined(AI_ADDRCONFIG) && !defined(__QNXNTO__)
154 #  define ASIO_OS_DEF_AI_ADDRCONFIG AI_ADDRCONFIG
155 # else
156 #  define ASIO_OS_DEF_AI_ADDRCONFIG 0
157 # endif
158 # if defined(IOV_MAX)
159 const int max_iov_len = IOV_MAX;
160 # else
161 // POSIX platforms are not required to define IOV_MAX.
162 const int max_iov_len = 16;
163 # endif
164 const int custom_socket_option_level = 0xA5100000;
165 const int enable_connection_aborted_option = 1;
166 const int always_fail_option = 2;
167 
168 } // namespace detail
169 } // namespace asio
170 
171 #include "asio/detail/pop_options.hpp"
172 
173 #endif // ASIO_DETAIL_SOCKET_TYPES_HPP
174