Squashed commit of the following:
commit
acbf1f541bffec35d3d63a779c515287bd43255f
Author: Serhii Lysenko <selysenk@cisco.com>
Date: Thu Jan 23 16:16:20 2020 +0200
loggers: update vlan logging in csv and json loggers
Log vlan id 0 if vlan_agnostic or untagged, use flow vlan id or packet
vid otherwise.
static void ff_vlan(const Args& a)
{
- uint16_t vid;
-
- if (a.pkt->flow)
- vid = a.pkt->flow->key->vlan_tag;
-
- else if ( a.pkt->proto_bits & PROTO_BIT__VLAN )
- vid = layer::get_vlan_layer(a.pkt)->vid();
-
- else
- return;
-
- TextLog_Print(csv_log, "%hu", vid);
+ TextLog_Print(csv_log, "%hu", a.pkt->get_flow_vlan_id());
}
//-------------------------------------------------------------------------
static bool ff_vlan(const Args& a)
{
- uint16_t vid;
-
- if (a.pkt->flow)
- vid = a.pkt->flow->key->vlan_tag;
-
- else if ( a.pkt->proto_bits & PROTO_BIT__VLAN )
- vid = layer::get_vlan_layer(a.pkt)->vid();
-
- else
- return false;
-
print_label(a, "vlan");
- TextLog_Print(json_log, "%hu", vid);
+ TextLog_Print(json_log, "%hu", a.pkt->get_flow_vlan_id());
return true;
}
#include "managers/codec_manager.h"
#include "packet_manager.h"
+#include "vlan.h"
namespace snort
{
return flow ? flow->ssn_state.snort_protocol_id : UNKNOWN_PROTOCOL_ID;
}
+uint16_t Packet::get_flow_vlan_id() const
+{
+ uint16_t vid = 0;
+
+ if (flow)
+ vid = flow->key->vlan_tag;
+ else if ( !SnortConfig::get_vlan_agnostic() and (proto_bits & PROTO_BIT__VLAN) )
+ vid = layer::get_vlan_layer(this)->vid();
+
+ return vid;
+}
+
} // namespace snort
flow->ssn_state.snort_protocol_id = proto_id;
}
+ uint16_t get_flow_vlan_id() const;
+
private:
bool allocated;
};