Realistic 3D camera system
3D camera system components
icmp.hpp
Go to the documentation of this file.
1 //
2 // ip/icmp.hpp
3 // ~~~~~~~~~~~
4 //
5 // Copyright (c) 2003-2015 Christopher M. Kohlhoff (chris at kohlhoff dot com)
6 //
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)
9 //
10 
11 #ifndef ASIO_IP_ICMP_HPP
12 #define ASIO_IP_ICMP_HPP
13 
14 #if defined(_MSC_VER) && (_MSC_VER >= 1200)
15 # pragma once
16 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
17 
18 #include "asio/detail/config.hpp"
25 
27 
28 namespace asio {
29 namespace ip {
30 
32 
42 class icmp
43 {
44 public:
47 
49  static icmp v4()
50  {
51  return icmp(ASIO_OS_DEF(IPPROTO_ICMP),
52  ASIO_OS_DEF(AF_INET));
53  }
54 
56  static icmp v6()
57  {
58  return icmp(ASIO_OS_DEF(IPPROTO_ICMPV6),
59  ASIO_OS_DEF(AF_INET6));
60  }
61 
63  int type() const
64  {
65  return ASIO_OS_DEF(SOCK_RAW);
66  }
67 
69  int protocol() const
70  {
71  return protocol_;
72  }
73 
75  int family() const
76  {
77  return family_;
78  }
79 
82 
85 
87  friend bool operator==(const icmp& p1, const icmp& p2)
88  {
89  return p1.protocol_ == p2.protocol_ && p1.family_ == p2.family_;
90  }
91 
93  friend bool operator!=(const icmp& p1, const icmp& p2)
94  {
95  return p1.protocol_ != p2.protocol_ || p1.family_ != p2.family_;
96  }
97 
98 private:
99  // Construct with a specific family.
100  explicit icmp(int protocol_id, int protocol_family)
101  : protocol_(protocol_id),
102  family_(protocol_family)
103  {
104  }
105 
106  int protocol_;
107  int family_;
108 };
109 
110 } // namespace ip
111 } // namespace asio
112 
114 
115 #endif // ASIO_IP_ICMP_HPP
Describes an endpoint for a version-independent IP socket.
#define ASIO_OS_DEF(c)
Encapsulates the flags needed for ICMP.
Definition: icmp.hpp:42
friend bool operator!=(const icmp &p1, const icmp &p2)
Compare two protocols for inequality.
Definition: icmp.hpp:93
basic_resolver< icmp > resolver
The ICMP resolver type.
Definition: icmp.hpp:84
int protocol() const
Obtain an identifier for the protocol.
Definition: icmp.hpp:69
basic_raw_socket< icmp > socket
The ICMP socket type.
Definition: icmp.hpp:81
int family() const
Obtain an identifier for the protocol family.
Definition: icmp.hpp:75
static icmp v4()
Construct to represent the IPv4 ICMP protocol.
Definition: icmp.hpp:49
Provides endpoint resolution functionality.
static icmp v6()
Construct to represent the IPv6 ICMP protocol.
Definition: icmp.hpp:56
basic_endpoint< icmp > endpoint
The type of a ICMP endpoint.
Definition: icmp.hpp:46
Provides raw-oriented socket functionality.
friend bool operator==(const icmp &p1, const icmp &p2)
Compare two protocols for equality.
Definition: icmp.hpp:87
int type() const
Obtain an identifier for the type of the protocol.
Definition: icmp.hpp:63