5 // Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
7 // Distributed under the Boost Software License, Version 1.0. (See accompanying
8 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
11 #ifndef BOOST_ASIO_IP_ICMP_HPP
12 #define BOOST_ASIO_IP_ICMP_HPP
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
18 #include <boost/asio/detail/config.hpp>
19 #include <boost/asio/detail/socket_types.hpp>
20 #include <boost/asio/basic_raw_socket.hpp>
21 #include <boost/asio/ip/basic_endpoint.hpp>
22 #include <boost/asio/ip/basic_resolver.hpp>
23 #include <boost/asio/ip/basic_resolver_iterator.hpp>
24 #include <boost/asio/ip/basic_resolver_query.hpp>
26 #include <boost/asio/detail/push_options.hpp>
32 /// Encapsulates the flags needed for ICMP.
34 * The boost::asio::ip::icmp class contains flags necessary for ICMP sockets.
37 * @e Distinct @e objects: Safe.@n
38 * @e Shared @e objects: Safe.
41 * Protocol, InternetProtocol.
46 /// The type of a ICMP endpoint.
47 typedef basic_endpoint<icmp> endpoint;
49 /// Construct to represent the IPv4 ICMP protocol.
52 return icmp(BOOST_ASIO_OS_DEF(IPPROTO_ICMP),
53 BOOST_ASIO_OS_DEF(AF_INET));
56 /// Construct to represent the IPv6 ICMP protocol.
59 return icmp(BOOST_ASIO_OS_DEF(IPPROTO_ICMPV6),
60 BOOST_ASIO_OS_DEF(AF_INET6));
63 /// Obtain an identifier for the type of the protocol.
66 return BOOST_ASIO_OS_DEF(SOCK_RAW);
69 /// Obtain an identifier for the protocol.
75 /// Obtain an identifier for the protocol family.
81 /// The ICMP socket type.
82 typedef basic_raw_socket<icmp> socket;
84 /// The ICMP resolver type.
85 typedef basic_resolver<icmp> resolver;
87 /// Compare two protocols for equality.
88 friend bool operator==(const icmp& p1, const icmp& p2)
90 return p1.protocol_ == p2.protocol_ && p1.family_ == p2.family_;
93 /// Compare two protocols for inequality.
94 friend bool operator!=(const icmp& p1, const icmp& p2)
96 return p1.protocol_ != p2.protocol_ || p1.family_ != p2.family_;
100 // Construct with a specific family.
101 explicit icmp(int protocol_id, int protocol_family)
102 : protocol_(protocol_id),
103 family_(protocol_family)
115 #include <boost/asio/detail/pop_options.hpp>
117 #endif // BOOST_ASIO_IP_ICMP_HPP