00001 // 00002 // icmp.hpp 00003 // ~~~~~~~~ 00004 // 00005 // Copyright (c) 2003-2008 Christopher M. Kohlhoff (chris at kohlhoff dot com) 00006 // 00007 // Distributed under the Boost Software License, Version 1.0. (See accompanying 00008 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 00009 // 00010 00011 #ifndef ASIO_IP_ICMP_HPP 00012 #define ASIO_IP_ICMP_HPP 00013 00014 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 00015 # pragma once 00016 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 00017 00018 #include "asio/detail/push_options.hpp" 00019 00020 #include "asio/basic_raw_socket.hpp" 00021 #include "asio/ip/basic_endpoint.hpp" 00022 #include "asio/ip/basic_resolver.hpp" 00023 #include "asio/ip/basic_resolver_iterator.hpp" 00024 #include "asio/ip/basic_resolver_query.hpp" 00025 #include "asio/detail/socket_types.hpp" 00026 00027 namespace asio { 00028 namespace ip { 00029 00031 00041 class icmp 00042 { 00043 public: 00045 typedef basic_endpoint<icmp> endpoint; 00046 00048 typedef basic_resolver_query<icmp> resolver_query; 00049 00051 typedef basic_resolver_iterator<icmp> resolver_iterator; 00052 00054 static icmp v4() 00055 { 00056 return icmp(IPPROTO_ICMP, PF_INET); 00057 } 00058 00060 static icmp v6() 00061 { 00062 return icmp(IPPROTO_ICMPV6, PF_INET6); 00063 } 00064 00066 int type() const 00067 { 00068 return SOCK_RAW; 00069 } 00070 00072 int protocol() const 00073 { 00074 return protocol_; 00075 } 00076 00078 int family() const 00079 { 00080 return family_; 00081 } 00082 00084 typedef basic_raw_socket<icmp> socket; 00085 00087 typedef basic_resolver<icmp> resolver; 00088 00090 friend bool operator==(const icmp& p1, const icmp& p2) 00091 { 00092 return p1.protocol_ == p2.protocol_ && p1.family_ == p2.family_; 00093 } 00094 00096 friend bool operator!=(const icmp& p1, const icmp& p2) 00097 { 00098 return p1.protocol_ != p2.protocol_ || p1.family_ != p2.family_; 00099 } 00100 00101 private: 00102 // Construct with a specific family. 00103 explicit icmp(int protocol, int family) 00104 : protocol_(protocol), 00105 family_(family) 00106 { 00107 } 00108 00109 int protocol_; 00110 int family_; 00111 }; 00112 00113 } // namespace ip 00114 } // namespace asio 00115 00116 #include "asio/detail/pop_options.hpp" 00117 00118 #endif // ASIO_IP_ICMP_HPP