~ubuntu-branches/ubuntu/maverick/libtorrent-rasterbar/maverick

« back to all changes in this revision

Viewing changes to include/libtorrent/asio/ip/icmp.hpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Sauthier
  • Date: 2010-08-10 12:59:37 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20100810125937-jbcmmf17y8yo9hgz
Tags: 0.15.0-0ubuntu1
* New upstream version.
* debian/patches/100_fix_html_docs.patch: refreshed.
* debian/control: bump up standards-version to 3.9.1 (no changes).

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
// icmp.hpp
3
 
// ~~~~~~~~
4
 
//
5
 
// Copyright (c) 2003-2008 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/push_options.hpp"
19
 
 
20
 
#include "asio/basic_raw_socket.hpp"
21
 
#include "asio/ip/basic_endpoint.hpp"
22
 
#include "asio/ip/basic_resolver.hpp"
23
 
#include "asio/ip/basic_resolver_iterator.hpp"
24
 
#include "asio/ip/basic_resolver_query.hpp"
25
 
#include "asio/detail/socket_types.hpp"
26
 
 
27
 
namespace asio {
28
 
namespace ip {
29
 
 
30
 
/// Encapsulates the flags needed for ICMP.
31
 
/**
32
 
 * The asio::ip::icmp class contains flags necessary for ICMP sockets.
33
 
 *
34
 
 * @par Thread Safety
35
 
 * @e Distinct @e objects: Safe.@n
36
 
 * @e Shared @e objects: Safe.
37
 
 *
38
 
 * @par Concepts:
39
 
 * Protocol, InternetProtocol.
40
 
 */
41
 
class icmp
42
 
{
43
 
public:
44
 
  /// The type of a ICMP endpoint.
45
 
  typedef basic_endpoint<icmp> endpoint;
46
 
 
47
 
  /// The type of a resolver query.
48
 
  typedef basic_resolver_query<icmp> resolver_query;
49
 
 
50
 
  /// The type of a resolver iterator.
51
 
  typedef basic_resolver_iterator<icmp> resolver_iterator;
52
 
 
53
 
  /// Construct to represent the IPv4 ICMP protocol.
54
 
  static icmp v4()
55
 
  {
56
 
    return icmp(IPPROTO_ICMP, PF_INET);
57
 
  }
58
 
 
59
 
  /// Construct to represent the IPv6 ICMP protocol.
60
 
  static icmp v6()
61
 
  {
62
 
    return icmp(IPPROTO_ICMPV6, PF_INET6);
63
 
  }
64
 
 
65
 
  /// Obtain an identifier for the type of the protocol.
66
 
  int type() const
67
 
  {
68
 
    return SOCK_RAW;
69
 
  }
70
 
 
71
 
  /// Obtain an identifier for the protocol.
72
 
  int protocol() const
73
 
  {
74
 
    return protocol_;
75
 
  }
76
 
 
77
 
  /// Obtain an identifier for the protocol family.
78
 
  int family() const
79
 
  {
80
 
    return family_;
81
 
  }
82
 
 
83
 
  /// The ICMP socket type.
84
 
  typedef basic_raw_socket<icmp> socket;
85
 
 
86
 
  /// The ICMP resolver type.
87
 
  typedef basic_resolver<icmp> resolver;
88
 
 
89
 
  /// Compare two protocols for equality.
90
 
  friend bool operator==(const icmp& p1, const icmp& p2)
91
 
  {
92
 
    return p1.protocol_ == p2.protocol_ && p1.family_ == p2.family_;
93
 
  }
94
 
 
95
 
  /// Compare two protocols for inequality.
96
 
  friend bool operator!=(const icmp& p1, const icmp& p2)
97
 
  {
98
 
    return p1.protocol_ != p2.protocol_ || p1.family_ != p2.family_;
99
 
  }
100
 
 
101
 
private:
102
 
  // Construct with a specific family.
103
 
  explicit icmp(int protocol, int family)
104
 
    : protocol_(protocol),
105
 
      family_(family)
106
 
  {
107
 
  }
108
 
 
109
 
  int protocol_;
110
 
  int family_;
111
 
};
112
 
 
113
 
} // namespace ip
114
 
} // namespace asio
115
 
 
116
 
#include "asio/detail/pop_options.hpp"
117
 
 
118
 
#endif // ASIO_IP_ICMP_HPP