summaryrefslogtreecommitdiff
path: root/ACE/ace/ICMP_Socket.h
blob: ab3f549cf17f1f62611de09456a15e46320bbb13 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// -*- C++ -*-

//=============================================================================
/**
 *  @file    ICMP_Socket.h
 *
 *  @author Robert S. Iakobashvili <coroberti@gmail.com> <coroberti@walla.co.il>
 *  @author Gonzalo A. Diethelm <gonzalo.diethelm@aditiva.com>
 */
//=============================================================================

#ifndef ACE_ICMP_SOCKET_H
#define ACE_ICMP_SOCKET_H

#include /**/ "ace/pre.h"

#include /**/ "ace/ACE_export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#if defined (ACE_HAS_ICMP_SUPPORT) && (ACE_HAS_ICMP_SUPPORT == 1)

#include "ace/SOCK.h"
#include "ace/Time_Value.h"
#include "ace/os_include/netinet/os_in.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

/**
 * @class ACE_ICMP_Socket
 *
 * @brief An abstract class that forms the basis for usage of the ICMP
 * protocol (that is, support for things such as ping).
 */
class ACE_Export ACE_ICMP_Socket : public ACE_SOCK
{
public:
  /**
   * @name Data transfer routines.
   *
   * Data transfer routines.
   */
  //@{

  /// Send an @a n byte @a buf to the datagram socket (uses
  /// @c sendto(3) ).
  ssize_t send (void const * buf,
                size_t n,
                ACE_Addr const & addr,
                int flags = 0) const;

  /// Receive an @a n byte @a buf from the datagram socket
  /// (uses @c recvfrom(3) ).
  ssize_t recv (void * buf,
                size_t n,
                ACE_Addr & addr,
                int flags = 0) const;

  /// TODO: comment
  ssize_t recv (void * buf,
                size_t n,
                int flags,
                ACE_Time_Value const * timeout) const;

  //@}

  /// Wrapper around the BSD-style @c socket system call (no QoS).
  int open (ACE_Addr const & local = ACE_Addr::sap_any,
            int protocol = IPPROTO_ICMP,
            int reuse_addr = 0);

  /// Dump the state of object.
  void dump (void) const;

  /// Declare the dynamic allocation hooks.
  ACE_ALLOC_HOOK_DECLARE;

protected:

  // Protected constructors, so the class can only be derived from.

  /// Default constructor.
  ACE_ICMP_Socket (void);

  /// Constructor that takes a local listening address.
  ACE_ICMP_Socket (ACE_Addr const & local,
                   int protocol = IPPROTO_ICMP,
                   int reuse_addr = 0);

  /// Wrapper around BSD-style @c bind system call.
  int shared_open (ACE_Addr const & local);

  /// Calculates check-sum.
  unsigned short calculate_checksum (unsigned short* paddress,
                                     int len);
};

ACE_END_VERSIONED_NAMESPACE_DECL

#endif  /* ACE_HAS_ICMP_SUPPORT == 1 */

#include /**/ "ace/post.h"

#endif /* ACE_ICMP_SOCKET_H */