From: Guilherme Maciel Ferreira Date: Sat, 24 Dec 2011 13:52:00 +0000 (-0200) Subject: Fix: the TCP's ttl was being printed as a char instead of as a integer. X-Git-Tag: v1.3~23 X-Git-Url: http://developer.intra2net.com/git/?a=commitdiff_plain;h=ffd08e985b5a6f909a66c8fbd04b7e35a56f2d2a;p=pingcheck Fix: the TCP's ttl was being printed as a char instead of as a integer. --- diff --git a/src/tcp/tcpipv4segment.cpp b/src/tcp/tcpipv4segment.cpp index 500421f..8dc663c 100644 --- a/src/tcp/tcpipv4segment.cpp +++ b/src/tcp/tcpipv4segment.cpp @@ -24,6 +24,7 @@ using namespace std; using boost::asio::ip::address; +using boost::date_time::time_resolution_traits_adapted64_impl; using boost::posix_time::ptime; using boost::posix_time::microsec_clock; using I2n::Logger::GlobalLogger; @@ -114,11 +115,16 @@ void TcpIpv4Segment::print_rst_reply( Ipv4Header ipv4_header = get_ip_header(); TcpHeader tcp_header = get_tcp_header(); + uint32_t sequence_number = tcp_header.get_sequence_number(); + int ttl = ipv4_header.get_time_to_live(); ptime now = microsec_clock::universal_time(); + time_resolution_traits_adapted64_impl::int_type elapsed_time = + (now - time_segment_sent).total_milliseconds(); + GlobalLogger.info() << "RST from " << ipv4_header.get_source_address() - << ": tcp_seq=" << tcp_header.get_sequence_number() - << ", ttl=" << ipv4_header.get_time_to_live() - << " time=" << (now - time_segment_sent).total_milliseconds() << " ms" + << ": tcp_seq=" << sequence_number + << ", ttl=" << ttl + << " time=" << elapsed_time << " ms" << endl; } diff --git a/src/tcp/tcpipv6segment.cpp b/src/tcp/tcpipv6segment.cpp index 49593e6..00c9734 100644 --- a/src/tcp/tcpipv6segment.cpp +++ b/src/tcp/tcpipv6segment.cpp @@ -24,6 +24,7 @@ using namespace std; using boost::asio::ip::address; +using boost::date_time::time_resolution_traits_adapted64_impl; using boost::posix_time::ptime; using boost::posix_time::microsec_clock; using I2n::Logger::GlobalLogger; @@ -114,11 +115,16 @@ void TcpIpv6Segment::print_rst_reply( Ipv6Header ipv6_header = get_ip_header(); TcpHeader tcp_header = get_tcp_header(); + uint32_t sequence_number = tcp_header.get_sequence_number(); + int hops = ipv6_header.get_hop_limit(); ptime now = microsec_clock::universal_time(); + time_resolution_traits_adapted64_impl::int_type elapsed_time = + (now - time_segment_sent).total_milliseconds(); + GlobalLogger.info() << "RST from " << ipv6_header.get_source_address() - << ": tcp_seq=" << tcp_header.get_sequence_number() - << ", ttl=" << ipv6_header.get_hop_limit() - << " time=" << (now - time_segment_sent).total_milliseconds() << " ms" + << ": tcp_seq=" << sequence_number + << ", hops=" << hops + << " time=" << elapsed_time << " ms" << endl; }