libDwm-0.6.0
Dwm::PingDestination Class Reference

Common interface for an IPv4 destination we wish to ping with ICMP or TCP. More...

#include <DwmPingDestination.hh>

Collaboration diagram for Dwm::PingDestination:

Public Member Functions

 PingDestination ()
 Constructor.
 
 PingDestination (const std::string &destination)
 Construct from a string of the form 'a.b.c.d:n' where a.b.c.d is the IP address and n is the port number. More...
 
 PingDestination (const Ipv4Address &addr, uint16_t port=0)
 Construct from an IP address (for an ICMP destination), or an IP address and port number (for a TCP destination). More...
 
const Ipv4AddressAddress () const
 Returns the destination IP address.
 
const Ipv4AddressAddress (const Ipv4Address &address)
 Sets and returns the destination IP address.
 
uint16_t Port () const
 Returns the port number (0 for ICMP).
 
const std::string & Hostname () const
 Returns the hostname (an empty string if it was not set).
 
const std::string & Hostname (const std::string &hostname)
 Sets and returns the hostname.
 
bool SendTo (Socket &socket, const Ipv4Address &myAddress, uint16_t identifier) const
 Sends a 'ping' to the destination. More...
 
bool operator< (const PingDestination &pd) const
 operator <
 
bool operator== (const PingDestination &pd) const
 operator ==
 
virtual operator std::string () const
 Returns the destination as a string (IP address in dotted-decimal for an ICMP destination, IP address and port separated by a ':' for a TCP destination). More...
 

Protected Member Functions

void GetPacket (std::string &packet, const Ipv4Address &myAddress, uint16_t identifier) const
 
void GetIcmpPacket (std::string &packet, const Ipv4Address &myAddress, uint16_t identifier) const
 
void GetTcpPacket (std::string &packet, const Ipv4Address &myAddress, uint16_t identifier) const
 

Protected Attributes

Ipv4Address _addr
 
uint16_t _port
 
std::string _hostname
 
bool _primed
 
uint16_t _sequenceNumber
 

Friends

std::ostream & operator<< (std::ostream &os, const PingDestination &pd)
 Prints a PingDestination to an ostream in human-readable form.
 

Detailed Description

Common interface for an IPv4 destination we wish to ping with ICMP or TCP.

Constructor & Destructor Documentation

◆ PingDestination() [1/2]

Dwm::PingDestination::PingDestination ( const std::string &  destination)

Construct from a string of the form 'a.b.c.d:n' where a.b.c.d is the IP address and n is the port number.

If only an IP address is given, we will use ICMP to probe the destination. If a non-zero port number is given, we will use TCP to probe the destination.

◆ PingDestination() [2/2]

Dwm::PingDestination::PingDestination ( const Ipv4Address addr,
uint16_t  port = 0 
)

Construct from an IP address (for an ICMP destination), or an IP address and port number (for a TCP destination).

Member Function Documentation

◆ operator std::string()

virtual Dwm::PingDestination::operator std::string ( ) const
virtual

Returns the destination as a string (IP address in dotted-decimal for an ICMP destination, IP address and port separated by a ':' for a TCP destination).

◆ SendTo()

bool Dwm::PingDestination::SendTo ( Socket socket,
const Ipv4Address myAddress,
uint16_t  identifier 
) const

Sends a 'ping' to the destination.

For ICMP, sends an echo request. For TCP, sends a pure ACK.


The documentation for this class was generated from the following file: