Added boost header
This commit is contained in:
55
test/external/boost/asio/ip/impl/address.hpp
vendored
Normal file
55
test/external/boost/asio/ip/impl/address.hpp
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ip/impl/address.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_ADDRESS_HPP
|
||||
#define BOOST_ASIO_IP_IMPL_ADDRESS_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
template <typename Elem, typename Traits>
|
||||
std::basic_ostream<Elem, Traits>& operator<<(
|
||||
std::basic_ostream<Elem, Traits>& os, const address& addr)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::string s = addr.to_string(ec);
|
||||
if (ec)
|
||||
{
|
||||
if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit)
|
||||
boost::asio::detail::throw_error(ec);
|
||||
else
|
||||
os.setstate(std::basic_ostream<Elem, Traits>::failbit);
|
||||
}
|
||||
else
|
||||
for (std::string::iterator i = s.begin(); i != s.end(); ++i)
|
||||
os << os.widen(*i);
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_ADDRESS_HPP
|
||||
228
test/external/boost/asio/ip/impl/address.ipp
vendored
Normal file
228
test/external/boost/asio/ip/impl/address.ipp
vendored
Normal file
@@ -0,0 +1,228 @@
|
||||
//
|
||||
// ip/impl/address.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_ADDRESS_IPP
|
||||
#define BOOST_ASIO_IP_IMPL_ADDRESS_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <typeinfo>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/ip/address.hpp>
|
||||
#include <boost/system/system_error.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
address::address()
|
||||
: type_(ipv4),
|
||||
ipv4_address_(),
|
||||
ipv6_address_()
|
||||
{
|
||||
}
|
||||
|
||||
address::address(const boost::asio::ip::address_v4& ipv4_address)
|
||||
: type_(ipv4),
|
||||
ipv4_address_(ipv4_address),
|
||||
ipv6_address_()
|
||||
{
|
||||
}
|
||||
|
||||
address::address(const boost::asio::ip::address_v6& ipv6_address)
|
||||
: type_(ipv6),
|
||||
ipv4_address_(),
|
||||
ipv6_address_(ipv6_address)
|
||||
{
|
||||
}
|
||||
|
||||
address::address(const address& other)
|
||||
: type_(other.type_),
|
||||
ipv4_address_(other.ipv4_address_),
|
||||
ipv6_address_(other.ipv6_address_)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
address::address(address&& other)
|
||||
: type_(other.type_),
|
||||
ipv4_address_(other.ipv4_address_),
|
||||
ipv6_address_(other.ipv6_address_)
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
address& address::operator=(const address& other)
|
||||
{
|
||||
type_ = other.type_;
|
||||
ipv4_address_ = other.ipv4_address_;
|
||||
ipv6_address_ = other.ipv6_address_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
address& address::operator=(address&& other)
|
||||
{
|
||||
type_ = other.type_;
|
||||
ipv4_address_ = other.ipv4_address_;
|
||||
ipv6_address_ = other.ipv6_address_;
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
address& address::operator=(const boost::asio::ip::address_v4& ipv4_address)
|
||||
{
|
||||
type_ = ipv4;
|
||||
ipv4_address_ = ipv4_address;
|
||||
ipv6_address_ = boost::asio::ip::address_v6();
|
||||
return *this;
|
||||
}
|
||||
|
||||
address& address::operator=(const boost::asio::ip::address_v6& ipv6_address)
|
||||
{
|
||||
type_ = ipv6;
|
||||
ipv4_address_ = boost::asio::ip::address_v4();
|
||||
ipv6_address_ = ipv6_address;
|
||||
return *this;
|
||||
}
|
||||
|
||||
boost::asio::ip::address_v4 address::to_v4() const
|
||||
{
|
||||
if (type_ != ipv4)
|
||||
{
|
||||
std::bad_cast ex;
|
||||
boost::throw_exception(ex);
|
||||
}
|
||||
return ipv4_address_;
|
||||
}
|
||||
|
||||
boost::asio::ip::address_v6 address::to_v6() const
|
||||
{
|
||||
if (type_ != ipv6)
|
||||
{
|
||||
std::bad_cast ex;
|
||||
boost::throw_exception(ex);
|
||||
}
|
||||
return ipv6_address_;
|
||||
}
|
||||
|
||||
std::string address::to_string() const
|
||||
{
|
||||
if (type_ == ipv6)
|
||||
return ipv6_address_.to_string();
|
||||
return ipv4_address_.to_string();
|
||||
}
|
||||
|
||||
std::string address::to_string(boost::system::error_code& ec) const
|
||||
{
|
||||
if (type_ == ipv6)
|
||||
return ipv6_address_.to_string(ec);
|
||||
return ipv4_address_.to_string(ec);
|
||||
}
|
||||
|
||||
address address::from_string(const char* str)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
address addr = from_string(str, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return addr;
|
||||
}
|
||||
|
||||
address address::from_string(const char* str, boost::system::error_code& ec)
|
||||
{
|
||||
boost::asio::ip::address_v6 ipv6_address =
|
||||
boost::asio::ip::address_v6::from_string(str, ec);
|
||||
if (!ec)
|
||||
{
|
||||
address tmp;
|
||||
tmp.type_ = ipv6;
|
||||
tmp.ipv6_address_ = ipv6_address;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
boost::asio::ip::address_v4 ipv4_address =
|
||||
boost::asio::ip::address_v4::from_string(str, ec);
|
||||
if (!ec)
|
||||
{
|
||||
address tmp;
|
||||
tmp.type_ = ipv4;
|
||||
tmp.ipv4_address_ = ipv4_address;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
return address();
|
||||
}
|
||||
|
||||
address address::from_string(const std::string& str)
|
||||
{
|
||||
return from_string(str.c_str());
|
||||
}
|
||||
|
||||
address address::from_string(const std::string& str,
|
||||
boost::system::error_code& ec)
|
||||
{
|
||||
return from_string(str.c_str(), ec);
|
||||
}
|
||||
|
||||
bool address::is_loopback() const
|
||||
{
|
||||
return (type_ == ipv4)
|
||||
? ipv4_address_.is_loopback()
|
||||
: ipv6_address_.is_loopback();
|
||||
}
|
||||
|
||||
bool address::is_unspecified() const
|
||||
{
|
||||
return (type_ == ipv4)
|
||||
? ipv4_address_.is_unspecified()
|
||||
: ipv6_address_.is_unspecified();
|
||||
}
|
||||
|
||||
bool address::is_multicast() const
|
||||
{
|
||||
return (type_ == ipv4)
|
||||
? ipv4_address_.is_multicast()
|
||||
: ipv6_address_.is_multicast();
|
||||
}
|
||||
|
||||
bool operator==(const address& a1, const address& a2)
|
||||
{
|
||||
if (a1.type_ != a2.type_)
|
||||
return false;
|
||||
if (a1.type_ == address::ipv6)
|
||||
return a1.ipv6_address_ == a2.ipv6_address_;
|
||||
return a1.ipv4_address_ == a2.ipv4_address_;
|
||||
}
|
||||
|
||||
bool operator<(const address& a1, const address& a2)
|
||||
{
|
||||
if (a1.type_ < a2.type_)
|
||||
return true;
|
||||
if (a1.type_ > a2.type_)
|
||||
return false;
|
||||
if (a1.type_ == address::ipv6)
|
||||
return a1.ipv6_address_ < a2.ipv6_address_;
|
||||
return a1.ipv4_address_ < a2.ipv4_address_;
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_ADDRESS_IPP
|
||||
55
test/external/boost/asio/ip/impl/address_v4.hpp
vendored
Normal file
55
test/external/boost/asio/ip/impl/address_v4.hpp
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ip/impl/address_v4.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_ADDRESS_V4_HPP
|
||||
#define BOOST_ASIO_IP_IMPL_ADDRESS_V4_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
template <typename Elem, typename Traits>
|
||||
std::basic_ostream<Elem, Traits>& operator<<(
|
||||
std::basic_ostream<Elem, Traits>& os, const address_v4& addr)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::string s = addr.to_string(ec);
|
||||
if (ec)
|
||||
{
|
||||
if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit)
|
||||
boost::asio::detail::throw_error(ec);
|
||||
else
|
||||
os.setstate(std::basic_ostream<Elem, Traits>::failbit);
|
||||
}
|
||||
else
|
||||
for (std::string::iterator i = s.begin(); i != s.end(); ++i)
|
||||
os << os.widen(*i);
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_ADDRESS_V4_HPP
|
||||
178
test/external/boost/asio/ip/impl/address_v4.ipp
vendored
Normal file
178
test/external/boost/asio/ip/impl/address_v4.ipp
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
//
|
||||
// ip/impl/address_v4.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_ADDRESS_V4_IPP
|
||||
#define BOOST_ASIO_IP_IMPL_ADDRESS_V4_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <climits>
|
||||
#include <stdexcept>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/detail/socket_ops.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/ip/address_v4.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
address_v4::address_v4(const address_v4::bytes_type& bytes)
|
||||
{
|
||||
#if UCHAR_MAX > 0xFF
|
||||
if (bytes[0] > 0xFF || bytes[1] > 0xFF
|
||||
|| bytes[2] > 0xFF || bytes[3] > 0xFF)
|
||||
{
|
||||
std::out_of_range ex("address_v4 from bytes_type");
|
||||
boost::throw_exception(ex);
|
||||
}
|
||||
#endif // UCHAR_MAX > 0xFF
|
||||
|
||||
using namespace std; // For memcpy.
|
||||
memcpy(&addr_.s_addr, bytes.data(), 4);
|
||||
}
|
||||
|
||||
address_v4::address_v4(unsigned long addr)
|
||||
{
|
||||
#if ULONG_MAX > 0xFFFFFFFF
|
||||
if (addr > 0xFFFFFFFF)
|
||||
{
|
||||
std::out_of_range ex("address_v4 from unsigned long");
|
||||
boost::throw_exception(ex);
|
||||
}
|
||||
#endif // ULONG_MAX > 0xFFFFFFFF
|
||||
|
||||
addr_.s_addr = boost::asio::detail::socket_ops::host_to_network_long(addr);
|
||||
}
|
||||
|
||||
address_v4::bytes_type address_v4::to_bytes() const
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
bytes_type bytes;
|
||||
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
memcpy(bytes.data(), &addr_.s_addr, 4);
|
||||
#else // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
memcpy(bytes.elems, &addr_.s_addr, 4);
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
return bytes;
|
||||
}
|
||||
|
||||
unsigned long address_v4::to_ulong() const
|
||||
{
|
||||
return boost::asio::detail::socket_ops::network_to_host_long(addr_.s_addr);
|
||||
}
|
||||
|
||||
std::string address_v4::to_string() const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::string addr = to_string(ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return addr;
|
||||
}
|
||||
|
||||
std::string address_v4::to_string(boost::system::error_code& ec) const
|
||||
{
|
||||
char addr_str[boost::asio::detail::max_addr_v4_str_len];
|
||||
const char* addr =
|
||||
boost::asio::detail::socket_ops::inet_ntop(AF_INET, &addr_, addr_str,
|
||||
boost::asio::detail::max_addr_v4_str_len, 0, ec);
|
||||
if (addr == 0)
|
||||
return std::string();
|
||||
return addr;
|
||||
}
|
||||
|
||||
address_v4 address_v4::from_string(const char* str)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
address_v4 addr = from_string(str, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return addr;
|
||||
}
|
||||
|
||||
address_v4 address_v4::from_string(
|
||||
const char* str, boost::system::error_code& ec)
|
||||
{
|
||||
address_v4 tmp;
|
||||
if (boost::asio::detail::socket_ops::inet_pton(
|
||||
AF_INET, str, &tmp.addr_, 0, ec) <= 0)
|
||||
return address_v4();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
address_v4 address_v4::from_string(const std::string& str)
|
||||
{
|
||||
return from_string(str.c_str());
|
||||
}
|
||||
|
||||
address_v4 address_v4::from_string(
|
||||
const std::string& str, boost::system::error_code& ec)
|
||||
{
|
||||
return from_string(str.c_str(), ec);
|
||||
}
|
||||
|
||||
bool address_v4::is_loopback() const
|
||||
{
|
||||
return (to_ulong() & 0xFF000000) == 0x7F000000;
|
||||
}
|
||||
|
||||
bool address_v4::is_unspecified() const
|
||||
{
|
||||
return to_ulong() == 0;
|
||||
}
|
||||
|
||||
bool address_v4::is_class_a() const
|
||||
{
|
||||
return (to_ulong() & 0x80000000) == 0;
|
||||
}
|
||||
|
||||
bool address_v4::is_class_b() const
|
||||
{
|
||||
return (to_ulong() & 0xC0000000) == 0x80000000;
|
||||
}
|
||||
|
||||
bool address_v4::is_class_c() const
|
||||
{
|
||||
return (to_ulong() & 0xE0000000) == 0xC0000000;
|
||||
}
|
||||
|
||||
bool address_v4::is_multicast() const
|
||||
{
|
||||
return (to_ulong() & 0xF0000000) == 0xE0000000;
|
||||
}
|
||||
|
||||
address_v4 address_v4::broadcast(const address_v4& addr, const address_v4& mask)
|
||||
{
|
||||
return address_v4(addr.to_ulong() | (mask.to_ulong() ^ 0xFFFFFFFF));
|
||||
}
|
||||
|
||||
address_v4 address_v4::netmask(const address_v4& addr)
|
||||
{
|
||||
if (addr.is_class_a())
|
||||
return address_v4(0xFF000000);
|
||||
if (addr.is_class_b())
|
||||
return address_v4(0xFFFF0000);
|
||||
if (addr.is_class_c())
|
||||
return address_v4(0xFFFFFF00);
|
||||
return address_v4(0xFFFFFFFF);
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_ADDRESS_V4_IPP
|
||||
55
test/external/boost/asio/ip/impl/address_v6.hpp
vendored
Normal file
55
test/external/boost/asio/ip/impl/address_v6.hpp
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
//
|
||||
// ip/impl/address_v6.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_ADDRESS_V6_HPP
|
||||
#define BOOST_ASIO_IP_IMPL_ADDRESS_V6_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
template <typename Elem, typename Traits>
|
||||
std::basic_ostream<Elem, Traits>& operator<<(
|
||||
std::basic_ostream<Elem, Traits>& os, const address_v6& addr)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::string s = addr.to_string(ec);
|
||||
if (ec)
|
||||
{
|
||||
if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit)
|
||||
boost::asio::detail::throw_error(ec);
|
||||
else
|
||||
os.setstate(std::basic_ostream<Elem, Traits>::failbit);
|
||||
}
|
||||
else
|
||||
for (std::string::iterator i = s.begin(); i != s.end(); ++i)
|
||||
os << os.widen(*i);
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_ADDRESS_V6_HPP
|
||||
299
test/external/boost/asio/ip/impl/address_v6.ipp
vendored
Normal file
299
test/external/boost/asio/ip/impl/address_v6.ipp
vendored
Normal file
@@ -0,0 +1,299 @@
|
||||
//
|
||||
// ip/impl/address_v6.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_ADDRESS_V6_IPP
|
||||
#define BOOST_ASIO_IP_IMPL_ADDRESS_V6_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <cstring>
|
||||
#include <stdexcept>
|
||||
#include <typeinfo>
|
||||
#include <boost/throw_exception.hpp>
|
||||
#include <boost/asio/detail/socket_ops.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/error.hpp>
|
||||
#include <boost/asio/ip/address_v6.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
address_v6::address_v6()
|
||||
: addr_(),
|
||||
scope_id_(0)
|
||||
{
|
||||
}
|
||||
|
||||
address_v6::address_v6(const address_v6::bytes_type& bytes,
|
||||
unsigned long scope)
|
||||
: scope_id_(scope)
|
||||
{
|
||||
#if UCHAR_MAX > 0xFF
|
||||
for (std::size_t i = 0; i < bytes.size(); ++i)
|
||||
{
|
||||
if (bytes[i] > 0xFF)
|
||||
{
|
||||
std::out_of_range ex("address_v6 from bytes_type");
|
||||
boost::throw_exception(ex);
|
||||
}
|
||||
}
|
||||
#endif // UCHAR_MAX > 0xFF
|
||||
|
||||
using namespace std; // For memcpy.
|
||||
memcpy(addr_.s6_addr, bytes.data(), 16);
|
||||
}
|
||||
|
||||
address_v6::address_v6(const address_v6& other)
|
||||
: addr_(other.addr_),
|
||||
scope_id_(other.scope_id_)
|
||||
{
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
address_v6::address_v6(address_v6&& other)
|
||||
: addr_(other.addr_),
|
||||
scope_id_(other.scope_id_)
|
||||
{
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
address_v6& address_v6::operator=(const address_v6& other)
|
||||
{
|
||||
addr_ = other.addr_;
|
||||
scope_id_ = other.scope_id_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined(BOOST_ASIO_HAS_MOVE)
|
||||
address_v6& address_v6::operator=(address_v6&& other)
|
||||
{
|
||||
addr_ = other.addr_;
|
||||
scope_id_ = other.scope_id_;
|
||||
return *this;
|
||||
}
|
||||
#endif // defined(BOOST_ASIO_HAS_MOVE)
|
||||
|
||||
address_v6::bytes_type address_v6::to_bytes() const
|
||||
{
|
||||
using namespace std; // For memcpy.
|
||||
bytes_type bytes;
|
||||
#if defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
memcpy(bytes.data(), addr_.s6_addr, 16);
|
||||
#else // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
memcpy(bytes.elems, addr_.s6_addr, 16);
|
||||
#endif // defined(BOOST_ASIO_HAS_STD_ARRAY)
|
||||
return bytes;
|
||||
}
|
||||
|
||||
std::string address_v6::to_string() const
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
std::string addr = to_string(ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return addr;
|
||||
}
|
||||
|
||||
std::string address_v6::to_string(boost::system::error_code& ec) const
|
||||
{
|
||||
char addr_str[boost::asio::detail::max_addr_v6_str_len];
|
||||
const char* addr =
|
||||
boost::asio::detail::socket_ops::inet_ntop(AF_INET6, &addr_, addr_str,
|
||||
boost::asio::detail::max_addr_v6_str_len, scope_id_, ec);
|
||||
if (addr == 0)
|
||||
return std::string();
|
||||
return addr;
|
||||
}
|
||||
|
||||
address_v6 address_v6::from_string(const char* str)
|
||||
{
|
||||
boost::system::error_code ec;
|
||||
address_v6 addr = from_string(str, ec);
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return addr;
|
||||
}
|
||||
|
||||
address_v6 address_v6::from_string(
|
||||
const char* str, boost::system::error_code& ec)
|
||||
{
|
||||
address_v6 tmp;
|
||||
if (boost::asio::detail::socket_ops::inet_pton(
|
||||
AF_INET6, str, &tmp.addr_, &tmp.scope_id_, ec) <= 0)
|
||||
return address_v6();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
address_v6 address_v6::from_string(const std::string& str)
|
||||
{
|
||||
return from_string(str.c_str());
|
||||
}
|
||||
|
||||
address_v6 address_v6::from_string(
|
||||
const std::string& str, boost::system::error_code& ec)
|
||||
{
|
||||
return from_string(str.c_str(), ec);
|
||||
}
|
||||
|
||||
address_v4 address_v6::to_v4() const
|
||||
{
|
||||
if (!is_v4_mapped() && !is_v4_compatible())
|
||||
{
|
||||
std::bad_cast ex;
|
||||
boost::throw_exception(ex);
|
||||
}
|
||||
|
||||
address_v4::bytes_type v4_bytes = { { addr_.s6_addr[12],
|
||||
addr_.s6_addr[13], addr_.s6_addr[14], addr_.s6_addr[15] } };
|
||||
return address_v4(v4_bytes);
|
||||
}
|
||||
|
||||
bool address_v6::is_loopback() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
|
||||
&& (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
|
||||
&& (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
|
||||
&& (addr_.s6_addr[6] == 0) && (addr_.s6_addr[7] == 0)
|
||||
&& (addr_.s6_addr[8] == 0) && (addr_.s6_addr[9] == 0)
|
||||
&& (addr_.s6_addr[10] == 0) && (addr_.s6_addr[11] == 0)
|
||||
&& (addr_.s6_addr[12] == 0) && (addr_.s6_addr[13] == 0)
|
||||
&& (addr_.s6_addr[14] == 0) && (addr_.s6_addr[15] == 1));
|
||||
}
|
||||
|
||||
bool address_v6::is_unspecified() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
|
||||
&& (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
|
||||
&& (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
|
||||
&& (addr_.s6_addr[6] == 0) && (addr_.s6_addr[7] == 0)
|
||||
&& (addr_.s6_addr[8] == 0) && (addr_.s6_addr[9] == 0)
|
||||
&& (addr_.s6_addr[10] == 0) && (addr_.s6_addr[11] == 0)
|
||||
&& (addr_.s6_addr[12] == 0) && (addr_.s6_addr[13] == 0)
|
||||
&& (addr_.s6_addr[14] == 0) && (addr_.s6_addr[15] == 0));
|
||||
}
|
||||
|
||||
bool address_v6::is_link_local() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0xfe) && ((addr_.s6_addr[1] & 0xc0) == 0x80));
|
||||
}
|
||||
|
||||
bool address_v6::is_site_local() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0xfe) && ((addr_.s6_addr[1] & 0xc0) == 0xc0));
|
||||
}
|
||||
|
||||
bool address_v6::is_v4_mapped() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
|
||||
&& (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
|
||||
&& (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
|
||||
&& (addr_.s6_addr[6] == 0) && (addr_.s6_addr[7] == 0)
|
||||
&& (addr_.s6_addr[8] == 0) && (addr_.s6_addr[9] == 0)
|
||||
&& (addr_.s6_addr[10] == 0xff) && (addr_.s6_addr[11] == 0xff));
|
||||
}
|
||||
|
||||
bool address_v6::is_v4_compatible() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0) && (addr_.s6_addr[1] == 0)
|
||||
&& (addr_.s6_addr[2] == 0) && (addr_.s6_addr[3] == 0)
|
||||
&& (addr_.s6_addr[4] == 0) && (addr_.s6_addr[5] == 0)
|
||||
&& (addr_.s6_addr[6] == 0) && (addr_.s6_addr[7] == 0)
|
||||
&& (addr_.s6_addr[8] == 0) && (addr_.s6_addr[9] == 0)
|
||||
&& (addr_.s6_addr[10] == 0) && (addr_.s6_addr[11] == 0)
|
||||
&& !((addr_.s6_addr[12] == 0)
|
||||
&& (addr_.s6_addr[13] == 0)
|
||||
&& (addr_.s6_addr[14] == 0)
|
||||
&& ((addr_.s6_addr[15] == 0) || (addr_.s6_addr[15] == 1))));
|
||||
}
|
||||
|
||||
bool address_v6::is_multicast() const
|
||||
{
|
||||
return (addr_.s6_addr[0] == 0xff);
|
||||
}
|
||||
|
||||
bool address_v6::is_multicast_global() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x0e));
|
||||
}
|
||||
|
||||
bool address_v6::is_multicast_link_local() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x02));
|
||||
}
|
||||
|
||||
bool address_v6::is_multicast_node_local() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x01));
|
||||
}
|
||||
|
||||
bool address_v6::is_multicast_org_local() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x08));
|
||||
}
|
||||
|
||||
bool address_v6::is_multicast_site_local() const
|
||||
{
|
||||
return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x05));
|
||||
}
|
||||
|
||||
bool operator==(const address_v6& a1, const address_v6& a2)
|
||||
{
|
||||
using namespace std; // For memcmp.
|
||||
return memcmp(&a1.addr_, &a2.addr_,
|
||||
sizeof(boost::asio::detail::in6_addr_type)) == 0
|
||||
&& a1.scope_id_ == a2.scope_id_;
|
||||
}
|
||||
|
||||
bool operator<(const address_v6& a1, const address_v6& a2)
|
||||
{
|
||||
using namespace std; // For memcmp.
|
||||
int memcmp_result = memcmp(&a1.addr_, &a2.addr_,
|
||||
sizeof(boost::asio::detail::in6_addr_type));
|
||||
if (memcmp_result < 0)
|
||||
return true;
|
||||
if (memcmp_result > 0)
|
||||
return false;
|
||||
return a1.scope_id_ < a2.scope_id_;
|
||||
}
|
||||
|
||||
address_v6 address_v6::loopback()
|
||||
{
|
||||
address_v6 tmp;
|
||||
tmp.addr_.s6_addr[15] = 1;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
address_v6 address_v6::v4_mapped(const address_v4& addr)
|
||||
{
|
||||
address_v4::bytes_type v4_bytes = addr.to_bytes();
|
||||
bytes_type v6_bytes = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFF, 0xFF,
|
||||
v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] } };
|
||||
return address_v6(v6_bytes);
|
||||
}
|
||||
|
||||
address_v6 address_v6::v4_compatible(const address_v4& addr)
|
||||
{
|
||||
address_v4::bytes_type v4_bytes = addr.to_bytes();
|
||||
bytes_type v6_bytes = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
v4_bytes[0], v4_bytes[1], v4_bytes[2], v4_bytes[3] } };
|
||||
return address_v6(v6_bytes);
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_ADDRESS_V6_IPP
|
||||
57
test/external/boost/asio/ip/impl/basic_endpoint.hpp
vendored
Normal file
57
test/external/boost/asio/ip/impl/basic_endpoint.hpp
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
//
|
||||
// ip/impl/basic_endpoint.hpp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_BASIC_ENDPOINT_HPP
|
||||
#define BOOST_ASIO_IP_IMPL_BASIC_ENDPOINT_HPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#if !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
template <typename Elem, typename Traits, typename InternetProtocol>
|
||||
std::basic_ostream<Elem, Traits>& operator<<(
|
||||
std::basic_ostream<Elem, Traits>& os,
|
||||
const basic_endpoint<InternetProtocol>& endpoint)
|
||||
{
|
||||
boost::asio::ip::detail::endpoint tmp_ep(endpoint.address(), endpoint.port());
|
||||
boost::system::error_code ec;
|
||||
std::string s = tmp_ep.to_string(ec);
|
||||
if (ec)
|
||||
{
|
||||
if (os.exceptions() & std::basic_ostream<Elem, Traits>::failbit)
|
||||
boost::asio::detail::throw_error(ec);
|
||||
else
|
||||
os.setstate(std::basic_ostream<Elem, Traits>::failbit);
|
||||
}
|
||||
else
|
||||
for (std::string::iterator i = s.begin(); i != s.end(); ++i)
|
||||
os << os.widen(*i);
|
||||
return os;
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // !defined(BOOST_NO_IOSTREAM)
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_BASIC_ENDPOINT_HPP
|
||||
56
test/external/boost/asio/ip/impl/host_name.ipp
vendored
Normal file
56
test/external/boost/asio/ip/impl/host_name.ipp
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
//
|
||||
// ip/impl/host_name.ipp
|
||||
// ~~~~~~~~~~~~~~~~~~~~~
|
||||
//
|
||||
// Copyright (c) 2003-2011 Christopher M. Kohlhoff (chris at kohlhoff dot com)
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
//
|
||||
|
||||
#ifndef BOOST_ASIO_IP_IMPL_HOST_NAME_IPP
|
||||
#define BOOST_ASIO_IP_IMPL_HOST_NAME_IPP
|
||||
|
||||
#if defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
# pragma once
|
||||
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
|
||||
|
||||
#include <boost/asio/detail/config.hpp>
|
||||
#include <boost/asio/detail/socket_ops.hpp>
|
||||
#include <boost/asio/detail/throw_error.hpp>
|
||||
#include <boost/asio/detail/winsock_init.hpp>
|
||||
#include <boost/asio/ip/host_name.hpp>
|
||||
|
||||
#include <boost/asio/detail/push_options.hpp>
|
||||
|
||||
namespace boost {
|
||||
namespace asio {
|
||||
namespace ip {
|
||||
|
||||
std::string host_name()
|
||||
{
|
||||
char name[1024];
|
||||
boost::system::error_code ec;
|
||||
if (boost::asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
|
||||
{
|
||||
boost::asio::detail::throw_error(ec);
|
||||
return std::string();
|
||||
}
|
||||
return std::string(name);
|
||||
}
|
||||
|
||||
std::string host_name(boost::system::error_code& ec)
|
||||
{
|
||||
char name[1024];
|
||||
if (boost::asio::detail::socket_ops::gethostname(name, sizeof(name), ec) != 0)
|
||||
return std::string();
|
||||
return std::string(name);
|
||||
}
|
||||
|
||||
} // namespace ip
|
||||
} // namespace asio
|
||||
} // namespace boost
|
||||
|
||||
#include <boost/asio/detail/pop_options.hpp>
|
||||
|
||||
#endif // BOOST_ASIO_IP_IMPL_HOST_NAME_IPP
|
||||
Reference in New Issue
Block a user