From 3d832cc48ec28665d65986e4dcef4962e1600166 Mon Sep 17 00:00:00 2001 From: Matias Fontanini Date: Thu, 13 Nov 2014 22:07:31 -0800 Subject: [PATCH] Replaced calls to PDU::rfind_pdu to find_pdu on TCPStreamFollower. --- include/tins/tcp_stream.h | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/include/tins/tcp_stream.h b/include/tins/tcp_stream.h index 5789afb..9e58a33 100644 --- a/include/tins/tcp_stream.h +++ b/include/tins/tcp_stream.h @@ -340,29 +340,32 @@ void TCPStreamFollower::follow_streams(ForwardIterator start, ForwardIterator en template bool TCPStreamFollower::callback(PDU &pdu, const DataFunctor &data_fun, const EndFunctor &end_fun) { - IP &ip = pdu.rfind_pdu(); - TCP &tcp = pdu.rfind_pdu(); + IP *ip = pdu.find_pdu(); + TCP *tcp = pdu.find_pdu(); + if(!ip || !tcp) { + return true; + } TCPStream::StreamInfo info( - ip.src_addr(), ip.dst_addr(), - tcp.sport(), tcp.dport() + ip->src_addr(), ip->dst_addr(), + tcp->sport(), tcp->dport() ); sessions_type::iterator it = sessions.find(info); if(it == sessions.end()) { std::swap(info.client_addr, info.server_addr); std::swap(info.client_port, info.server_port); if((it = sessions.find(info)) == sessions.end()) { - if(tcp.get_flag(TCP::SYN) && !tcp.get_flag(TCP::ACK)) { + if(tcp->get_flag(TCP::SYN) && !tcp->get_flag(TCP::ACK)) { sessions.insert( std::make_pair( info, - TCPStream(&ip, &tcp, last_identifier++) + TCPStream(ip, tcp, last_identifier++) ) ); } return true; } } - if(it->second.update(&ip, &tcp)) + if(it->second.update(ip, tcp)) data_fun(it->second); // We're done with this stream if(it->second.is_finished()) {