diff --git a/src/packet_analysis/protocol/iptunnel/IPTunnel.cc b/src/packet_analysis/protocol/iptunnel/IPTunnel.cc index f1e44b19a4..4730e13f79 100644 --- a/src/packet_analysis/protocol/iptunnel/IPTunnel.cc +++ b/src/packet_analysis/protocol/iptunnel/IPTunnel.cc @@ -172,17 +172,25 @@ bool IPTunnelAnalyzer::ProcessEncapsulatedPacket(double t, const Packet* pkt, ui std::unique_ptr build_inner_packet(Packet* outer_pkt, int* encap_index, std::shared_ptr encap_stack, - uint32_t len, const u_char* data, int link_type, - BifEnum::Tunnel::Type tunnel_type, + uint32_t inner_cap_len, const u_char* data, + int link_type, BifEnum::Tunnel::Type tunnel_type, const Tag& analyzer_tag) { auto inner_pkt = std::make_unique(); + assert(outer_pkt->cap_len >= inner_cap_len); + assert(outer_pkt->len >= outer_pkt->cap_len - inner_cap_len); + + // Compute the wire length of the inner packet based on the wire length of + // the outer and the difference in cap len's. + uint32_t consumed_len = outer_pkt->cap_len - inner_cap_len; + uint32_t inner_wire_len = outer_pkt->len - consumed_len; + pkt_timeval ts; ts.tv_sec = static_cast(run_state::current_timestamp); ts.tv_usec = static_cast( (run_state::current_timestamp - static_cast(ts.tv_sec)) * 1000000); - inner_pkt->Init(link_type, &ts, len, len, data); + inner_pkt->Init(link_type, &ts, inner_cap_len, inner_wire_len, data); *encap_index = 0; if ( outer_pkt->session ) diff --git a/src/packet_analysis/protocol/iptunnel/IPTunnel.h b/src/packet_analysis/protocol/iptunnel/IPTunnel.h index cddd981045..ec91ac605e 100644 --- a/src/packet_analysis/protocol/iptunnel/IPTunnel.h +++ b/src/packet_analysis/protocol/iptunnel/IPTunnel.h @@ -99,8 +99,8 @@ protected: */ extern std::unique_ptr build_inner_packet(Packet* outer_pkt, int* encap_index, std::shared_ptr encap_stack, - uint32_t len, const u_char* data, int link_type, - BifEnum::Tunnel::Type tunnel_type, + uint32_t inner_cap_len, const u_char* data, + int link_type, BifEnum::Tunnel::Type tunnel_type, const Tag& analyzer_tag); namespace detail