From: Tom Peters (thopeter) Date: Fri, 10 Dec 2021 18:28:17 +0000 (+0000) Subject: Pull request #3196: vlan: implement vlan encode function X-Git-Tag: 3.1.19.0~11 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e69c8edf1a4193bc6f62997d97812e7d791a4d7e;p=thirdparty%2Fsnort3.git Pull request #3196: vlan: implement vlan encode function Merge in SNORT/snort3 from ~SBAIGAL/snort3:vlan_encode to master Squashed commit of the following: commit 827bea7bfc67403762cec0424767d822f147419b Author: Steven Baigal (sbaigal) Date: Wed Dec 1 15:32:36 2021 -0500 vlan: implement vlan encode function --- diff --git a/src/codecs/link/cd_vlan.cc b/src/codecs/link/cd_vlan.cc index 1232c08ee..6741edd80 100644 --- a/src/codecs/link/cd_vlan.cc +++ b/src/codecs/link/cd_vlan.cc @@ -58,6 +58,8 @@ public: void get_protocol_ids(std::vector& v) override; bool decode(const RawData&, CodecData&, DecodeData&) override; void log(TextLog* const, const uint8_t* pkt, const uint16_t len) override; + bool encode(const uint8_t* const raw_in, const uint16_t raw_len, EncState&, Buffer&, + Flow*) override; }; constexpr unsigned int ETHERNET_MAX_LEN_ENCAP = 1518; /* 802.3 (+LLC) or ether II ? */ @@ -126,6 +128,20 @@ void VlanCodec::log(TextLog* const text_log, const uint8_t* raw_pkt, TextLog_Print(text_log, " Next:0x%04X", proto); } +bool VlanCodec::encode(const uint8_t* const raw_in, const uint16_t raw_len, EncState& enc, + Buffer& buf, Flow*) +{ + if (!buf.allocate(raw_len)) + return false; + + memcpy(buf.data(), raw_in, raw_len); + + enc.next_ethertype = ProtocolId::ETHERTYPE_NOT_SET; + enc.next_proto = IpProtocol::PROTO_NOT_SET; + + return true; +} + //------------------------------------------------------------------------- // api //-------------------------------------------------------------------------