#include "host/pingerfactory.h"
+#include <boost/asio/ip/tcp_raw_protocol.hpp>
+
#include "icmp/icmppinger.h"
#include "tcp/tcppinger.h"
using boost::shared_ptr;
using boost::asio::io_service;
using boost::asio::ip::icmp;
+using boost::asio::ip::tcp_raw_protocol;
//-----------------------------------------------------------------------------
// PingerFactory
//-----------------------------------------------------------------------------
+/**
+ * @brief Default constructor.
+ */
PingerFactory::PingerFactory()
{
}
+/**
+ * @brief Destructor.
+ */
PingerFactory::~PingerFactory()
{
}
* @brief Create a Pinger object suitable to the given protocol.
*
* @param protocol One of the available ping protocols.
- * @param io_serv The io_service object.
+ * @param io_serv The @c io_service object.
* @param network_interface The network interface name from where the ping
* packet will be sent.
* @return a Pinger object to able to ping using the given protocol.
);
case PingProtocol_TCP:
return shared_ptr<Pinger>(
- new TcpPinger( io_serv, network_interface, ping_reply_timeout_in_sec )
+ new TcpPinger( io_serv, tcp_raw_protocol::v4(), network_interface, ping_reply_timeout_in_sec )
);
default:
BOOST_ASSERT( !"Try to create a pinger from an invalid protocol" );
// TcpPinger
//-----------------------------------------------------------------------------
+/**
+ * @brief Parameterized constructor.
+ *
+ * @param io_serv The @c io_service object to control this object.
+ * @param protocol The network layer protocol to use.
+ * @param source_network_interface The network interface name from where to
+ * send the segments.
+ * @param echo_reply_timeout_in_sec The amount of time to wait for a reply.
+ */
TcpPinger::TcpPinger(
io_service &io_serv,
+ const tcp_raw_protocol::socket::protocol_type &protocol,
const string &source_network_interface_name,
const int rst_reply_timeout_in_sec
) :
IoService( io_serv ),
DestinationEndpoint(),
- Socket( IoService, tcp_raw_protocol::v4() ),
+ Socket( IoService, protocol ),
NetInterface( source_network_interface_name, Socket ),
TcpSegmentReceiveTimer( IoService ),
Identifier( 0 ),
{
++SequenceNumber;
- // Create an TCP header for an ACK request.
+ // Create a TCP header for an ACK request.
address source_address = get_source_address();
address destination_address = get_destination_address();
uint16_t source_port = get_source_port();
public:
TcpPinger(
boost::asio::io_service &io_service,
+ const boost::asio::ip::tcp_raw_protocol::socket::protocol_type &protocol,
const std::string &source_network_interface_name,
const int rst_reply_timeout_in_sec
);