--- /dev/null
+/*
+The software in this package is distributed under the GNU General
+Public License version 2 (with a special exception described below).
+
+A copy of GNU General Public License (GPL) is included in this distribution,
+in the file COPYING.GPL.
+
+As a special exception, if other files instantiate templates or use macros
+or inline functions from this file, or you compile this file and link it
+with other works to produce a work based on this file, this file
+does not by itself cause the resulting work to be covered
+by the GNU General Public License.
+
+However the source code for this file must still be made available
+in accordance with section (3) of the GNU General Public License.
+
+This exception does not invalidate any other reasons why a work based
+on this file might be covered by the GNU General Public License.
+*/
+
+#ifndef PING_STATUS_H
+#define PING_STATUS_H
+
+enum PingStatus
+{
+ PingStatus_NotSent,
+ PingStatus_SuccessReply,
+ PingStatus_FailureTimeout,
+ PingStatus_FailureDestinationUnreachable
+};
+
+#endif /* PING_STATUS_H */
// Decode the reply packet.
IcmpPacket icmp_packet;
- if (!(is >> icmp_packet))
+ if (! (is >> icmp_packet) )
{
GlobalLogger.notice() << "Warning: ignoring broken ICMP packet"
<< endl;
// We can receive all ICMP packets received by the host, so we need to
// filter out only the echo replies that match the our identifier,
- // expected sequence number, and destination host address (receive just the
- // ICMP packets from the host we had ping).
- if ( icmp_packet.match(
- IcmpType_EchoReply, Identifier, SequenceNumber,
- DestinationEndpoint.address() ) )
+ // expected sequence number, and destination host address (receive just
+ // the ICMP packets from the host we had ping).
+
+ if ( icmp_packet.match( IcmpType_EchoReply,
+ Identifier, SequenceNumber,
+ DestinationEndpoint.address() ) )
{
ReceivedReply = true;
IcmpPacketReceiveTimer.cancel();
}
- else if ( icmp_packet.match(
- IcmpType_DestinationUnreachable, Identifier, SequenceNumber,
- DestinationEndpoint.address() ) )
+ else if ( icmp_packet.match( IcmpType_DestinationUnreachable,
+ Identifier, SequenceNumber,
+ DestinationEndpoint.address() ) )
{
ReceivedReply = true;
IcmpPacketReceiveTimer.cancel();
}
+ // Unknown ICMP reply, start another receive till timeout
else
{
- // Unknown ICMP reply, start another receive till timeout
start_receive();
}
}
catch ( ... )
{
GlobalLogger.notice() << "Warning: exception during ICMP parse. "
- << "Starting another recieve till timeout." << endl;
+ << "Starting another receive till timeout." << endl;
start_receive();
}
}
<< " Destination Net Unreachable" << endl;
}
-void IcmpPinger::set_ping_status( IcmpPinger::PingStatus ping_status )
+void IcmpPinger::set_ping_status( PingStatus ping_status )
{
PingerStatus = ping_status;
}
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
-#ifndef ICMPPINGER_H
-#define ICMPPINGER_H
+#ifndef ICMP_PINGER_H
+#define ICMP_PINGER_H
#include <string>
#include <boost/function.hpp>
#include "host/pinger.h"
+#include "host/pingstatus.h"
class IcmpPacket;
);
private:
- enum PingStatus
- {
- PingStatus_NotSent,
- PingStatus_SuccessReply,
- PingStatus_FailureTimeout,
- PingStatus_FailureDestinationUnreachable
- };
-
-private:
void set_destination_endpoint( const std::string &destination_ip );
void start_send();
const IcmpPacket &icmp_packet
) const;
- void set_ping_status( IcmpPinger::PingStatus ping_status );
+ void set_ping_status( PingStatus ping_status );
bool select_source_network_interface(
const std::string &source_network_interface
/// the amount of time to wait for the reply
int EchoReplyTimeoutInSec;
/// the status of the pinger
- IcmpPinger::PingStatus PingerStatus;
+ PingStatus PingerStatus;
/// Callback to notify when the ping is done (got reply/timeout)
boost::function< void(bool) > PingDoneCallback;
};
-#endif /* ICMPPINGER_H */
+#endif // ICMP_PINGER_H
}
-void TcpPinger::set_ping_status( TcpPinger::PingStatus ping_status )
+void TcpPinger::set_ping_status( PingStatus ping_status )
{
PingerStatus = ping_status;
}
This exception does not invalidate any other reasons why a work based
on this file might be covered by the GNU General Public License.
*/
-#ifndef TCPPINGER_H
-#define TCPPINGER_H
+#ifndef TCP_PINGER_H
+#define TCP_PINGER_H
#include <string>
#include <boost/function.hpp>
#include "host/pinger.h"
+#include "host/pingstatus.h"
#include "ip/ipv4header.h"
#include "tcp/tcpheader.h"
);
private:
- enum PingStatus
- {
- PingStatus_NotSent,
- PingStatus_SuccessReply,
- PingStatus_FailureTimeout,
- PingStatus_FailureDestinationUnreachable
- };
-
-private:
uint32_t get_source_address();
uint32_t get_destination_address() const;
void set_destination_endpoint( const std::string &destination_ip );
const TcpHeader &tcp_header
) const;
- void set_ping_status( TcpPinger::PingStatus ping_status );
+ void set_ping_status( PingStatus ping_status );
bool select_source_network_interface(
const std::string &source_network_interface_name
/// the amount of time to wait for the reply
int RstReplyTimeoutInSec;
/// the status of the pinger
- TcpPinger::PingStatus PingerStatus;
+ PingStatus PingerStatus;
/// Callback to notify when the ping is done (got reply/timeout)
boost::function< void(bool) > PingDoneCallback;
};
-#endif /* TCPPINGER_H */
+#endif // TCP_PINGER_H