Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

icmp.hpp 2.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. #ifndef ASIO_IP_ICMP_HPP
  11. #define ASIO_IP_ICMP_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include "asio/detail/config.hpp"
  16. #include "asio/detail/socket_types.hpp"
  17. #include "asio/basic_raw_socket.hpp"
  18. #include "asio/ip/basic_endpoint.hpp"
  19. #include "asio/ip/basic_resolver.hpp"
  20. #include "asio/ip/basic_resolver_iterator.hpp"
  21. #include "asio/ip/basic_resolver_query.hpp"
  22. #include "asio/detail/push_options.hpp"
  23. namespace asio {
  24. namespace ip {
  25. /// Encapsulates the flags needed for ICMP.
  26. /**
  27. * The asio::ip::icmp class contains flags necessary for ICMP sockets.
  28. *
  29. * @par Thread Safety
  30. * @e Distinct @e objects: Safe.@n
  31. * @e Shared @e objects: Safe.
  32. *
  33. * @par Concepts:
  34. * Protocol, InternetProtocol.
  35. */
  36. class icmp
  37. {
  38. public:
  39. /// The type of a ICMP endpoint.
  40. typedef basic_endpoint<icmp> endpoint;
  41. /// Construct to represent the IPv4 ICMP protocol.
  42. static icmp v4()
  43. {
  44. return icmp(ASIO_OS_DEF(IPPROTO_ICMP),
  45. ASIO_OS_DEF(AF_INET));
  46. }
  47. /// Construct to represent the IPv6 ICMP protocol.
  48. static icmp v6()
  49. {
  50. return icmp(ASIO_OS_DEF(IPPROTO_ICMPV6),
  51. ASIO_OS_DEF(AF_INET6));
  52. }
  53. /// Obtain an identifier for the type of the protocol.
  54. int type() const
  55. {
  56. return ASIO_OS_DEF(SOCK_RAW);
  57. }
  58. /// Obtain an identifier for the protocol.
  59. int protocol() const
  60. {
  61. return protocol_;
  62. }
  63. /// Obtain an identifier for the protocol family.
  64. int family() const
  65. {
  66. return family_;
  67. }
  68. /// The ICMP socket type.
  69. typedef basic_raw_socket<icmp> socket;
  70. /// The ICMP resolver type.
  71. typedef basic_resolver<icmp> resolver;
  72. /// Compare two protocols for equality.
  73. friend bool operator==(const icmp& p1, const icmp& p2)
  74. {
  75. return p1.protocol_ == p2.protocol_ && p1.family_ == p2.family_;
  76. }
  77. /// Compare two protocols for inequality.
  78. friend bool operator!=(const icmp& p1, const icmp& p2)
  79. {
  80. return p1.protocol_ != p2.protocol_ || p1.family_ != p2.family_;
  81. }
  82. private:
  83. // Construct with a specific family.
  84. explicit icmp(int protocol_id, int protocol_family)
  85. : protocol_(protocol_id),
  86. family_(protocol_family)
  87. {
  88. }
  89. int protocol_;
  90. int family_;
  91. };
  92. } // namespace ip
  93. } // namespace asio
  94. #include "asio/detail/pop_options.hpp"
  95. #endif // ASIO_IP_ICMP_HPP