// we never increase, only trim, but daq doesn't support resizing wire packet
PacketManager::encode_update(p);
- if ( p->daq_instance->inject(p->daq_msg, 0, p->pkt, p->pktlen) == DAQ_SUCCESS )
+ if ( p->inject() == DAQ_SUCCESS )
verdict = DAQ_VERDICT_BLOCK;
// FIXIT-M X Should we be blocking the wire packet even if the injection fails?
}
PacketTracer::log("Verdict: Queuing for Retry\n");
else if (msg_was_held)
PacketTracer::log("Verdict: Holding for Detection\n");
+ else if (verdict == DAQ_VERDICT_BLOCK and p->is_pkt_injected())
+ PacketTracer::log("Verdict: Inject, original packet dropped\n");
else
PacketTracer::log("Verdict: %s\n", SFDAQ::verdict_to_string(verdict));
PacketTracer::dump(p);
packet_flags = PKT_FROM_CLIENT;
}
Packet::~Packet() = default;
+int Packet::inject() { return 0; }
IpsPolicy* get_ips_policy() { return nullptr; }
void DataBus::publish(unsigned, unsigned, Packet*, Flow*) { }
void DataBus::publish(unsigned, unsigned, DataEvent&, Flow*) { }
#include "log/obfuscator.h"
#include "main/snort_config.h"
#include "packet_io/active.h"
+#include "packet_io/sfdaq_instance.h"
#include "packet_manager.h"
#include "vlan.h"
return is_from_server();
}
+int Packet::inject()
+{
+ set_pkt_injected();
+ return daq_instance->inject(daq_msg, 0, pkt, pktlen);
+}
+
} // namespace snort
#define PKT_TCP_PSEUDO_EST 0x80000000 // A one-sided or bidirectional without LWS TCP session was detected
#define TS_PKT_OFFLOADED 0x01
+#define TS_PKT_INJECT 0x02
#define PKT_PDU_FULL (PKT_PDU_HEAD | PKT_PDU_TAIL)
void clear_offloaded()
{ ts_packet_flags &= (~TS_PKT_OFFLOADED); }
+ bool is_pkt_injected() const
+ { return (ts_packet_flags & TS_PKT_INJECT) != 0; }
+
+ void set_pkt_injected()
+ { ts_packet_flags |= TS_PKT_INJECT; }
+
bool has_parent() const
{ return (packet_flags & PKT_HAS_PARENT) != 0; }
void set_pdu_section(PduSection pdu_sect)
{ sect = pdu_sect; }
+ int inject();
+
private:
bool allocated;
};
#include "managers/codec_manager.h"
#include "packet_io/packet_tracer.h"
#include "packet_io/sfdaq.h"
+#include "packet_io/sfdaq_instance.h"
#include "profiler/profiler_defs.h"
#include "stream/stream.h"
#include "trace/trace_api.h"
int layer::get_inner_ip6_frag_index(const Packet* const) { return 0; }
uint8_t Stream::get_flow_ttl(Flow*, char, bool) { return 0; }
bool SFDAQ::forwarding_packet(const DAQ_PktHdr_t*) { return false; }
+int SFDAQInstance::inject(_daq_msg const*, int, unsigned char const*, unsigned int) { return -1; }
void sum_stats(PegCount*, PegCount*, unsigned, bool) {}
IpsContext::IpsContext(unsigned):
packet(nullptr), encode_packet(nullptr), pkth (nullptr), buf(nullptr),
#include "flow/expect_flow.h"
#include "framework/api_options.h"
+#include "packet_io/sfdaq_instance.h"
#include "protocols/packet.h"
#include "protocols/packet_manager.h"
const vlan::VlanTagHdr* layer::get_vlan_layer(const Packet*) { return nullptr; }
const geneve::GeneveLyr* layer::get_geneve_layer(const Packet*, bool) { return nullptr; }
void ip::IpApi::reset() {}
+int SFDAQInstance::inject(_daq_msg const*, int, unsigned char const*, unsigned int) { return -1; }
uint8_t PacketManager::max_layers = DEFAULT_LAYERMAX;
using namespace Http2Enums;
#include "../http2_hpack_int_decode.h"
#include "../http2_varlen_int_decode_impl.h"
+#include "packet_io/sfdaq_instance.h"
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/TestHarness.h>
{
// Stubs whose sole purpose is to make the test code link
int DetectionEngine::queue_event(unsigned int, unsigned int) { return 0; }
+int SFDAQInstance::inject(_daq_msg const*, int, unsigned char const*, unsigned int) { return -1; }
}
#include "../http2_varlen_string_decode_impl.h"
#include "../../http_inspect/http_common.h"
#include "../../http_inspect/http_enum.h"
+#include "packet_io/sfdaq_instance.h"
#include <CppUTest/CommandLineTestRunner.h>
#include <CppUTest/TestHarness.h>
{
// Stubs whose sole purpose is to make the test code link
int DetectionEngine::queue_event(unsigned int, unsigned int) { return 0; }
+int SFDAQInstance::inject(_daq_msg const*, int, unsigned char const*, unsigned int) { return -1; }
}
using namespace HttpCommon;
#include "log/messages.h"
#include "main/thread_config.h"
+#include "packet_io/sfdaq_instance.h"
#include "service_inspectors/http_inspect/http_js_norm.h"
#include "service_inspectors/http_inspect/http_uri_norm.h"
void DecodeConfig::set_decompress_swf(bool) {}
void DecodeConfig::set_decompress_zip(bool) {}
void DecodeConfig::set_decompress_vba(bool) {}
+int SFDAQInstance::inject(_daq_msg const*, int, unsigned char const*, unsigned int) { return -1; }
SearchTool::~SearchTool() {}
unsigned get_instance_id()
{ return 0; }
tsd.set_len(max);
tsd.set_packet_flags(PKT_RESIZED);
tsd.set_end_seq(tsd.get_end_seq() - fat);
+ if (stream_tcp_trace_enabled)
+ trace_logf(TRACE_WARNING_LEVEL, stream_tcp_trace, DEFAULT_TRACE_OPTION_ID, \
+ tsd.get_pkt(), "stream_tcp: Packet resized, length set to %u bytes", max);
return true;
}
return false;