return current_stream[source_id];
}
+void Http2FlowData::allocate_hi_memory()
+{
+ update_allocations(HttpFlowData::get_memory_usage_estimate());
+}
+
+void Http2FlowData::deallocate_hi_memory()
+{
+ update_deallocations(HttpFlowData::get_memory_usage_estimate());
+}
class Http2Stream* get_stream(uint32_t key);
class Http2Stream* get_hi_stream() const;
class Http2Stream* find_stream(uint32_t key) const;
+
+ // When H2I allocates http_inspect flows, it bypasses the usual FlowData memory allocation
+ // bookkeeping. So H2I needs to update memory allocations and deallocations itself.
+ void allocate_hi_memory();
+ void deallocate_hi_memory();
};
#endif
Http2Stream::~Http2Stream()
{
delete current_frame;
+ if (hi_flow_data)
+ session_data->deallocate_hi_memory();
delete hi_flow_data;
delete data_cutter[SRC_CLIENT];
delete data_cutter[SRC_SERVER];
current_frame = nullptr;
}
+void Http2Stream::set_hi_flow_data(HttpFlowData* flow_data)
+{
+ assert(hi_flow_data == nullptr);
+ hi_flow_data = flow_data;
+ session_data->allocate_hi_memory();
+}
+
const Field& Http2Stream::get_buf(unsigned id)
{
if (current_frame != nullptr)
void clear_frame();
const Field& get_buf(unsigned id);
HttpFlowData* get_hi_flow_data() const { return hi_flow_data; }
- void set_hi_flow_data(HttpFlowData* flow_data)
- { assert(hi_flow_data == nullptr); hi_flow_data = flow_data; }
+ void set_hi_flow_data(HttpFlowData* flow_data);
HttpMsgSection* get_hi_msg_section() const { return hi_msg_section; }
void set_hi_msg_section(HttpMsgSection* section) { hi_msg_section = section; }
uint32_t get_xtradata_mask() { return (current_frame != nullptr) ?
#include "http_common.h"
#include "http_enum.h"
#include "http_module.h"
+#include "http_msg_header.h"
+#include "http_msg_request.h"
+#include "http_msg_status.h"
#include "http_test_manager.h"
#include "http_transaction.h"
+#include "http_uri.h"
using namespace snort;
using namespace HttpCommon;
uint64_t HttpFlowData::instance_count = 0;
#endif
+const uint16_t HttpFlowData::memory_usage_estimate = sizeof(HttpFlowData) + sizeof(HttpTransaction)
+ + sizeof(HttpMsgRequest) + sizeof(HttpMsgStatus) + (2 * sizeof(HttpMsgHeader)) + sizeof(HttpUri)
+ + header_size_estimate + small_things;
+
HttpFlowData::HttpFlowData() : FlowData(inspector_id)
{
#ifdef REG_TEST
return transaction[source_id]->get_infractions(source_id);
}
+uint16_t HttpFlowData::get_memory_usage_estimate()
+{
+ return memory_usage_estimate;
+}
+
#ifdef REG_TEST
void HttpFlowData::show(FILE* out_file) const
{
void reset_partial_flush(HttpCommon::SourceId source_id)
{ partial_flush[source_id] = false; }
+ static uint16_t get_memory_usage_estimate();
+
private:
// HTTP/2 handling
bool for_http2 = false;
// Transactions with uncleared sections awaiting deletion
HttpTransaction* discard_list = nullptr;
+ // Estimates of how much memory http_inspect uses to process a stream for H2I
+ static const uint16_t header_size_estimate = 3000; // combined raw size of request and
+ //response message headers
+ static const uint16_t small_things = 400; // minor memory costs not otherwise accounted for
+ static const uint16_t memory_usage_estimate;
+
#ifdef REG_TEST
static uint64_t instance_count;
uint64_t seq_num;