diff --git a/src/iosource/Packet.cc b/src/iosource/Packet.cc index e9edcab241..0a17a78968 100644 --- a/src/iosource/Packet.cc +++ b/src/iosource/Packet.cc @@ -67,7 +67,7 @@ void Packet::Init(int arg_link_type, pkt_timeval* arg_ts, uint32_t arg_caplen, u ip_hdr.reset(); proto = -1; - tunnel_type = BifEnum::Tunnel::IP; + tunnel_type = BifEnum::Tunnel::NONE; gre_version = -1; gre_link_type = DLT_RAW; diff --git a/src/iosource/Packet.h b/src/iosource/Packet.h index 2719047415..bf5c221bd9 100644 --- a/src/iosource/Packet.h +++ b/src/iosource/Packet.h @@ -250,7 +250,7 @@ public: * the type of tunnel. It is used to pass the tunnel type between the * packet analyzers during analysis. */ - BifEnum::Tunnel::Type tunnel_type = BifEnum::Tunnel::IP; + BifEnum::Tunnel::Type tunnel_type = BifEnum::Tunnel::NONE; /** * If the packet contains a GRE tunnel, this field will contain the diff --git a/src/packet_analysis/protocol/ip/IP.cc b/src/packet_analysis/protocol/ip/IP.cc index ec2c6dcdc0..0fd7537197 100644 --- a/src/packet_analysis/protocol/ip/IP.cc +++ b/src/packet_analysis/protocol/ip/IP.cc @@ -2,6 +2,8 @@ #include "zeek/packet_analysis/protocol/ip/IP.h" +#include + #include "zeek/Discard.h" #include "zeek/Event.h" #include "zeek/Frag.h" @@ -269,6 +271,11 @@ bool IPAnalyzer::AnalyzePacket(size_t len, const uint8_t* data, Packet* packet) return false; } + // If the next protocol is a tunneled type, set the tunnel_type field in the packet to IP + // so that it gets handled correctly. + if ( proto == IPPROTO_IPV4 || proto == IPPROTO_IPV6 ) + packet->tunnel_type = BifEnum::Tunnel::IP; + switch ( proto ) { case IPPROTO_NONE: