diff options
Diffstat (limited to '3rdParty/Boost/src/boost/asio/ip/impl')
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/ip/impl/address.ipp | 40 | ||||
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/ip/impl/address_v4.ipp | 24 | ||||
-rw-r--r-- | 3rdParty/Boost/src/boost/asio/ip/impl/address_v6.ipp | 89 |
3 files changed, 110 insertions, 43 deletions
diff --git a/3rdParty/Boost/src/boost/asio/ip/impl/address.ipp b/3rdParty/Boost/src/boost/asio/ip/impl/address.ipp index 11f06fc..4bf959c 100644 --- a/3rdParty/Boost/src/boost/asio/ip/impl/address.ipp +++ b/3rdParty/Boost/src/boost/asio/ip/impl/address.ipp @@ -57,6 +57,15 @@ address::address(const address& other) { } +#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_; @@ -65,6 +74,16 @@ address& address::operator=(const address& other) 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; @@ -159,6 +178,27 @@ address address::from_string(const std::string& str, 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_) diff --git a/3rdParty/Boost/src/boost/asio/ip/impl/address_v4.ipp b/3rdParty/Boost/src/boost/asio/ip/impl/address_v4.ipp index 8bdef19..3d24dd9 100644 --- a/3rdParty/Boost/src/boost/asio/ip/impl/address_v4.ipp +++ b/3rdParty/Boost/src/boost/asio/ip/impl/address_v4.ipp @@ -42,7 +42,7 @@ address_v4::address_v4(const address_v4::bytes_type& bytes) #endif // UCHAR_MAX > 0xFF using namespace std; // For memcpy. - memcpy(&addr_.s_addr, bytes.elems, 4); + memcpy(&addr_.s_addr, bytes.data(), 4); } address_v4::address_v4(unsigned long addr) @@ -62,7 +62,11 @@ 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; } @@ -119,24 +123,34 @@ address_v4 address_v4::from_string( 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 IN_CLASSA(to_ulong()); + return (to_ulong() & 0x80000000) == 0; } bool address_v4::is_class_b() const { - return IN_CLASSB(to_ulong()); + return (to_ulong() & 0xC0000000) == 0x80000000; } bool address_v4::is_class_c() const { - return IN_CLASSC(to_ulong()); + return (to_ulong() & 0xE0000000) == 0xC0000000; } bool address_v4::is_multicast() const { - return IN_MULTICAST(to_ulong()); + return (to_ulong() & 0xF0000000) == 0xE0000000; } address_v4 address_v4::broadcast(const address_v4& addr, const address_v4& mask) diff --git a/3rdParty/Boost/src/boost/asio/ip/impl/address_v6.ipp b/3rdParty/Boost/src/boost/asio/ip/impl/address_v6.ipp index 5a3dddd..898f922 100644 --- a/3rdParty/Boost/src/boost/asio/ip/impl/address_v6.ipp +++ b/3rdParty/Boost/src/boost/asio/ip/impl/address_v6.ipp @@ -32,15 +32,14 @@ namespace asio { namespace ip { address_v6::address_v6() - : scope_id_(0) + : addr_(), + scope_id_(0) { - boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_ANY_INIT; - addr_ = tmp_addr; } address_v6::address_v6(const address_v6::bytes_type& bytes, - unsigned long scope_id) - : scope_id_(scope_id) + unsigned long scope) + : scope_id_(scope) { #if UCHAR_MAX > 0xFF for (std::size_t i = 0; i < bytes.size(); ++i) @@ -54,7 +53,7 @@ address_v6::address_v6(const address_v6::bytes_type& bytes, #endif // UCHAR_MAX > 0xFF using namespace std; // For memcpy. - memcpy(addr_.s6_addr, bytes.elems, 16); + memcpy(addr_.s6_addr, bytes.data(), 16); } address_v6::address_v6(const address_v6& other) @@ -63,6 +62,14 @@ address_v6::address_v6(const address_v6& other) { } +#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_; @@ -70,11 +77,24 @@ address_v6& address_v6::operator=(const address_v6& other) 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; } @@ -141,7 +161,6 @@ address_v4 address_v6::to_v4() const bool address_v6::is_loopback() const { -#if defined(__BORLANDC__) 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) @@ -150,15 +169,10 @@ bool address_v6::is_loopback() const && (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)); -#else - using namespace boost::asio::detail; - return IN6_IS_ADDR_LOOPBACK(&addr_) != 0; -#endif } bool address_v6::is_unspecified() const { -#if defined(__BORLANDC__) 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) @@ -167,70 +181,70 @@ bool address_v6::is_unspecified() const && (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)); -#else - using namespace boost::asio::detail; - return IN6_IS_ADDR_UNSPECIFIED(&addr_) != 0; -#endif } bool address_v6::is_link_local() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_LINKLOCAL(&addr_) != 0; + return ((addr_.s6_addr[0] == 0xfe) && ((addr_.s6_addr[1] & 0xc0) == 0x80)); } bool address_v6::is_site_local() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_SITELOCAL(&addr_) != 0; + return ((addr_.s6_addr[0] == 0xfe) && ((addr_.s6_addr[1] & 0xc0) == 0xc0)); } bool address_v6::is_v4_mapped() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_V4MAPPED(&addr_) != 0; + 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 { - using namespace boost::asio::detail; - return IN6_IS_ADDR_V4COMPAT(&addr_) != 0; + 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 { - using namespace boost::asio::detail; - return IN6_IS_ADDR_MULTICAST(&addr_) != 0; + return (addr_.s6_addr[0] == 0xff); } bool address_v6::is_multicast_global() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_MC_GLOBAL(&addr_) != 0; + return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x0e)); } bool address_v6::is_multicast_link_local() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_MC_LINKLOCAL(&addr_) != 0; + return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x02)); } bool address_v6::is_multicast_node_local() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_MC_NODELOCAL(&addr_) != 0; + return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x01)); } bool address_v6::is_multicast_org_local() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_MC_ORGLOCAL(&addr_) != 0; + return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x08)); } bool address_v6::is_multicast_site_local() const { - using namespace boost::asio::detail; - return IN6_IS_ADDR_MC_SITELOCAL(&addr_) != 0; + return ((addr_.s6_addr[0] == 0xff) && ((addr_.s6_addr[1] & 0x0f) == 0x05)); } bool operator==(const address_v6& a1, const address_v6& a2) @@ -256,8 +270,7 @@ bool operator<(const address_v6& a1, const address_v6& a2) address_v6 address_v6::loopback() { address_v6 tmp; - boost::asio::detail::in6_addr_type tmp_addr = IN6ADDR_LOOPBACK_INIT; - tmp.addr_ = tmp_addr; + tmp.addr_.s6_addr[15] = 1; return tmp; } |