Warning, file /include/boost/asio/ip/address_v6.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef BOOST_ASIO_IP_ADDRESS_V6_HPP
0012 #define BOOST_ASIO_IP_ADDRESS_V6_HPP
0013
0014 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
0015 # pragma once
0016 #endif
0017
0018 #include <boost/asio/detail/config.hpp>
0019 #include <functional>
0020 #include <string>
0021 #include <boost/asio/detail/array.hpp>
0022 #include <boost/asio/detail/cstdint.hpp>
0023 #include <boost/asio/detail/socket_types.hpp>
0024 #include <boost/asio/detail/string_view.hpp>
0025 #include <boost/asio/detail/winsock_init.hpp>
0026 #include <boost/system/error_code.hpp>
0027 #include <boost/asio/ip/address_v4.hpp>
0028
0029 #if !defined(BOOST_ASIO_NO_IOSTREAM)
0030 # include <iosfwd>
0031 #endif
0032
0033 #include <boost/asio/detail/push_options.hpp>
0034
0035 namespace boost {
0036 namespace asio {
0037 namespace ip {
0038
0039 template <typename> class basic_address_iterator;
0040
0041
0042 typedef uint_least32_t scope_id_type;
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053 class address_v6
0054 {
0055 public:
0056
0057
0058
0059
0060
0061 #if defined(GENERATING_DOCUMENTATION)
0062 typedef array<unsigned char, 16> bytes_type;
0063 #else
0064 typedef boost::asio::detail::array<unsigned char, 16> bytes_type;
0065 #endif
0066
0067
0068
0069
0070
0071
0072
0073 BOOST_ASIO_DECL address_v6() noexcept;
0074
0075
0076
0077
0078
0079
0080
0081
0082
0083
0084
0085 BOOST_ASIO_DECL explicit address_v6(const bytes_type& bytes,
0086 scope_id_type scope_id = 0);
0087
0088
0089 BOOST_ASIO_DECL address_v6(const address_v6& other) noexcept;
0090
0091
0092 BOOST_ASIO_DECL address_v6(address_v6&& other) noexcept;
0093
0094
0095 BOOST_ASIO_DECL address_v6& operator=(
0096 const address_v6& other) noexcept;
0097
0098
0099 BOOST_ASIO_DECL address_v6& operator=(address_v6&& other) noexcept;
0100
0101
0102
0103
0104
0105 scope_id_type scope_id() const noexcept
0106 {
0107 return scope_id_;
0108 }
0109
0110
0111
0112
0113
0114
0115
0116 void scope_id(scope_id_type id) noexcept
0117 {
0118 scope_id_ = id;
0119 }
0120
0121
0122 BOOST_ASIO_DECL bytes_type to_bytes() const noexcept;
0123
0124
0125 BOOST_ASIO_DECL std::string to_string() const;
0126
0127
0128
0129
0130
0131
0132 BOOST_ASIO_DECL bool is_loopback() const noexcept;
0133
0134
0135
0136
0137
0138
0139 BOOST_ASIO_DECL bool is_unspecified() const noexcept;
0140
0141
0142 BOOST_ASIO_DECL bool is_link_local() const noexcept;
0143
0144
0145 BOOST_ASIO_DECL bool is_site_local() const noexcept;
0146
0147
0148 BOOST_ASIO_DECL bool is_v4_mapped() const noexcept;
0149
0150
0151 BOOST_ASIO_DECL bool is_multicast() const noexcept;
0152
0153
0154 BOOST_ASIO_DECL bool is_multicast_global() const noexcept;
0155
0156
0157 BOOST_ASIO_DECL bool is_multicast_link_local() const noexcept;
0158
0159
0160 BOOST_ASIO_DECL bool is_multicast_node_local() const noexcept;
0161
0162
0163 BOOST_ASIO_DECL bool is_multicast_org_local() const noexcept;
0164
0165
0166 BOOST_ASIO_DECL bool is_multicast_site_local() const noexcept;
0167
0168
0169 BOOST_ASIO_DECL friend bool operator==(const address_v6& a1,
0170 const address_v6& a2) noexcept;
0171
0172
0173 friend bool operator!=(const address_v6& a1,
0174 const address_v6& a2) noexcept
0175 {
0176 return !(a1 == a2);
0177 }
0178
0179
0180 BOOST_ASIO_DECL friend bool operator<(const address_v6& a1,
0181 const address_v6& a2) noexcept;
0182
0183
0184 friend bool operator>(const address_v6& a1,
0185 const address_v6& a2) noexcept
0186 {
0187 return a2 < a1;
0188 }
0189
0190
0191 friend bool operator<=(const address_v6& a1,
0192 const address_v6& a2) noexcept
0193 {
0194 return !(a2 < a1);
0195 }
0196
0197
0198 friend bool operator>=(const address_v6& a1,
0199 const address_v6& a2) noexcept
0200 {
0201 return !(a1 < a2);
0202 }
0203
0204
0205
0206
0207
0208
0209
0210
0211 static address_v6 any() noexcept
0212 {
0213 return address_v6();
0214 }
0215
0216
0217
0218
0219
0220
0221 BOOST_ASIO_DECL static address_v6 loopback() noexcept;
0222
0223 private:
0224 friend class basic_address_iterator<address_v6>;
0225
0226
0227 boost::asio::detail::in6_addr_type addr_;
0228
0229
0230 scope_id_type scope_id_;
0231 };
0232
0233
0234
0235
0236
0237 inline address_v6 make_address_v6(const address_v6::bytes_type& bytes,
0238 scope_id_type scope_id = 0)
0239 {
0240 return address_v6(bytes, scope_id);
0241 }
0242
0243
0244
0245
0246
0247 BOOST_ASIO_DECL address_v6 make_address_v6(const char* str);
0248
0249
0250
0251
0252
0253 BOOST_ASIO_DECL address_v6 make_address_v6(const char* str,
0254 boost::system::error_code& ec) noexcept;
0255
0256
0257
0258
0259
0260 BOOST_ASIO_DECL address_v6 make_address_v6(const std::string& str);
0261
0262
0263
0264
0265
0266 BOOST_ASIO_DECL address_v6 make_address_v6(const std::string& str,
0267 boost::system::error_code& ec) noexcept;
0268
0269 #if defined(BOOST_ASIO_HAS_STRING_VIEW) \
0270 || defined(GENERATING_DOCUMENTATION)
0271
0272
0273
0274
0275
0276 BOOST_ASIO_DECL address_v6 make_address_v6(string_view str);
0277
0278
0279
0280
0281
0282 BOOST_ASIO_DECL address_v6 make_address_v6(string_view str,
0283 boost::system::error_code& ec) noexcept;
0284
0285 #endif
0286
0287
0288
0289
0290 enum v4_mapped_t { v4_mapped };
0291
0292
0293
0294
0295
0296 BOOST_ASIO_DECL address_v4 make_address_v4(
0297 v4_mapped_t, const address_v6& v6_addr);
0298
0299
0300
0301
0302
0303 BOOST_ASIO_DECL address_v6 make_address_v6(
0304 v4_mapped_t, const address_v4& v4_addr);
0305
0306 #if !defined(BOOST_ASIO_NO_IOSTREAM)
0307
0308
0309
0310
0311
0312
0313
0314
0315
0316
0317
0318
0319
0320 template <typename Elem, typename Traits>
0321 std::basic_ostream<Elem, Traits>& operator<<(
0322 std::basic_ostream<Elem, Traits>& os, const address_v6& addr);
0323
0324 #endif
0325
0326 }
0327 }
0328 }
0329
0330 namespace std {
0331
0332 template <>
0333 struct hash<boost::asio::ip::address_v6>
0334 {
0335 std::size_t operator()(const boost::asio::ip::address_v6& addr)
0336 const noexcept
0337 {
0338 const boost::asio::ip::address_v6::bytes_type bytes = addr.to_bytes();
0339 std::size_t result = static_cast<std::size_t>(addr.scope_id());
0340 combine_4_bytes(result, &bytes[0]);
0341 combine_4_bytes(result, &bytes[4]);
0342 combine_4_bytes(result, &bytes[8]);
0343 combine_4_bytes(result, &bytes[12]);
0344 return result;
0345 }
0346
0347 private:
0348 static void combine_4_bytes(std::size_t& seed, const unsigned char* bytes)
0349 {
0350 const std::size_t bytes_hash =
0351 (static_cast<std::size_t>(bytes[0]) << 24) |
0352 (static_cast<std::size_t>(bytes[1]) << 16) |
0353 (static_cast<std::size_t>(bytes[2]) << 8) |
0354 (static_cast<std::size_t>(bytes[3]));
0355 seed ^= bytes_hash + 0x9e3779b9 + (seed << 6) + (seed >> 2);
0356 }
0357 };
0358
0359 }
0360
0361 #include <boost/asio/detail/pop_options.hpp>
0362
0363 #include <boost/asio/ip/impl/address_v6.hpp>
0364 #if defined(BOOST_ASIO_HEADER_ONLY)
0365 # include <boost/asio/ip/impl/address_v6.ipp>
0366 #endif
0367
0368 #endif