2
0
mirror of https://github.com/boostorg/asio.git synced 2026-01-27 18:42:07 +00:00

Allow everything to compile on platforms where IPV6_V6ONLY is not defined

(such as Linux distros with a 2.4 kernel), but make any use of ip::v6_only
fail at runtime.


[SVN r37681]
This commit is contained in:
Christopher Kohlhoff
2007-05-13 08:18:09 +00:00
parent f811170a32
commit 899d252fb9
3 changed files with 18 additions and 1 deletions

View File

@@ -319,6 +319,12 @@ inline socket_type socket(int af, int type, int protocol,
inline int setsockopt(socket_type s, int level, int optname,
const void* optval, size_t optlen, boost::system::error_code& ec)
{
if (level == custom_socket_option_level && optname == always_fail_option)
{
ec = boost::asio::error::invalid_argument;
return -1;
}
clear_error(ec);
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
return error_wrapper(::setsockopt(s, level, optname,
@@ -332,6 +338,12 @@ inline int setsockopt(socket_type s, int level, int optname,
inline int getsockopt(socket_type s, int level, int optname, void* optval,
size_t* optlen, boost::system::error_code& ec)
{
if (level == custom_socket_option_level && optname == always_fail_option)
{
ec = boost::asio::error::invalid_argument;
return -1;
}
clear_error(ec);
#if defined(BOOST_WINDOWS) || defined(__CYGWIN__)
int tmp_optlen = static_cast<int>(*optlen);

View File

@@ -170,6 +170,7 @@ const int message_do_not_route = MSG_DONTROUTE;
#endif
const int custom_socket_option_level = 0xA5100000;
const int enable_connection_aborted_option = 1;
const int always_fail_option = 2;
} // namespace detail
} // namespace asio

View File

@@ -52,9 +52,13 @@ namespace ip {
*/
#if defined(GENERATING_DOCUMENTATION)
typedef implementation_defined v6_only;
#else
#elif defined(IPV6_V6ONLY)
typedef boost::asio::detail::socket_option::boolean<
IPPROTO_IPV6, IPV6_V6ONLY> v6_only;
#else
typedef boost::asio::detail::socket_option::boolean<
boost::asio::detail::custom_socket_option_level,
boost::asio::detail::always_fail_option> v6_only;
#endif
} // namespace ip