File indexing completed on 2025-01-18 09:29:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #ifndef BOOST_ASIO_IP_NETWORK_V6_HPP
0013 #define BOOST_ASIO_IP_NETWORK_V6_HPP
0014
0015 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0016 # pragma once
0017 #endif
0018
0019 #include <boost/asio/detail/config.hpp>
0020 #include <string>
0021 #include <boost/asio/detail/string_view.hpp>
0022 #include <boost/system/error_code.hpp>
0023 #include <boost/asio/ip/address_v6_range.hpp>
0024
0025 #include <boost/asio/detail/push_options.hpp>
0026
0027 namespace boost {
0028 namespace asio {
0029 namespace ip {
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040 class network_v6
0041 {
0042 public:
0043
0044 network_v6() noexcept
0045 : address_(),
0046 prefix_length_(0)
0047 {
0048 }
0049
0050
0051 BOOST_ASIO_DECL network_v6(const address_v6& addr,
0052 unsigned short prefix_len);
0053
0054
0055 network_v6(const network_v6& other) noexcept
0056 : address_(other.address_),
0057 prefix_length_(other.prefix_length_)
0058 {
0059 }
0060
0061
0062 network_v6(network_v6&& other) noexcept
0063 : address_(static_cast<address_v6&&>(other.address_)),
0064 prefix_length_(other.prefix_length_)
0065 {
0066 }
0067
0068
0069 network_v6& operator=(const network_v6& other) noexcept
0070 {
0071 address_ = other.address_;
0072 prefix_length_ = other.prefix_length_;
0073 return *this;
0074 }
0075
0076
0077 network_v6& operator=(network_v6&& other) noexcept
0078 {
0079 address_ = static_cast<address_v6&&>(other.address_);
0080 prefix_length_ = other.prefix_length_;
0081 return *this;
0082 }
0083
0084
0085 address_v6 address() const noexcept
0086 {
0087 return address_;
0088 }
0089
0090
0091
0092 unsigned short prefix_length() const noexcept
0093 {
0094 return prefix_length_;
0095 }
0096
0097
0098 BOOST_ASIO_DECL address_v6 network() const noexcept;
0099
0100
0101 BOOST_ASIO_DECL address_v6_range hosts() const noexcept;
0102
0103
0104 network_v6 canonical() const noexcept
0105 {
0106 return network_v6(network(), prefix_length());
0107 }
0108
0109
0110 bool is_host() const noexcept
0111 {
0112 return prefix_length_ == 128;
0113 }
0114
0115
0116 BOOST_ASIO_DECL bool is_subnet_of(const network_v6& other) const;
0117
0118
0119 BOOST_ASIO_DECL std::string to_string() const;
0120
0121
0122 BOOST_ASIO_DECL std::string to_string(boost::system::error_code& ec) const;
0123
0124
0125 friend bool operator==(const network_v6& a, const network_v6& b)
0126 {
0127 return a.address_ == b.address_ && a.prefix_length_ == b.prefix_length_;
0128 }
0129
0130
0131 friend bool operator!=(const network_v6& a, const network_v6& b)
0132 {
0133 return !(a == b);
0134 }
0135
0136 private:
0137 address_v6 address_;
0138 unsigned short prefix_length_;
0139 };
0140
0141
0142
0143
0144
0145 inline network_v6 make_network_v6(
0146 const address_v6& addr, unsigned short prefix_len)
0147 {
0148 return network_v6(addr, prefix_len);
0149 }
0150
0151
0152
0153
0154
0155
0156 BOOST_ASIO_DECL network_v6 make_network_v6(const char* str);
0157
0158
0159
0160
0161
0162
0163 BOOST_ASIO_DECL network_v6 make_network_v6(
0164 const char* str, boost::system::error_code& ec);
0165
0166
0167
0168
0169
0170
0171 BOOST_ASIO_DECL network_v6 make_network_v6(const std::string& str);
0172
0173
0174
0175
0176
0177
0178 BOOST_ASIO_DECL network_v6 make_network_v6(
0179 const std::string& str, boost::system::error_code& ec);
0180
0181 #if defined(BOOST_ASIO_HAS_STRING_VIEW) \
0182 || defined(GENERATING_DOCUMENTATION)
0183
0184
0185
0186
0187
0188
0189 BOOST_ASIO_DECL network_v6 make_network_v6(string_view str);
0190
0191
0192
0193
0194
0195
0196 BOOST_ASIO_DECL network_v6 make_network_v6(
0197 string_view str, boost::system::error_code& ec);
0198
0199 #endif
0200
0201
0202 #if !defined(BOOST_ASIO_NO_IOSTREAM)
0203
0204
0205
0206
0207
0208
0209
0210
0211
0212
0213
0214
0215
0216 template <typename Elem, typename Traits>
0217 std::basic_ostream<Elem, Traits>& operator<<(
0218 std::basic_ostream<Elem, Traits>& os, const network_v6& net);
0219
0220 #endif
0221
0222 }
0223 }
0224 }
0225
0226 #include <boost/asio/detail/pop_options.hpp>
0227
0228 #include <boost/asio/ip/impl/network_v6.hpp>
0229 #if defined(BOOST_ASIO_HEADER_ONLY)
0230 # include <boost/asio/ip/impl/network_v6.ipp>
0231 #endif
0232
0233 #endif