From 40b934496bde7b71d87bcdff3fd461c68be07dbd Mon Sep 17 00:00:00 2001 From: "Mike Stepanek (mstepane)" Date: Mon, 3 Feb 2020 15:21:20 +0000 Subject: [PATCH] Merge pull request #1977 in SNORT/snort3 from ~THOPETER/snort3:nhttp131 to master Squashed commit of the following: commit 4202f01e2fdc2a3e0fb5178ecb6de438b264a5e6 Author: Tom Peters Date: Fri Jan 31 13:59:15 2020 -0500 http_inspect: refactoring --- .../http_inspect/http_context_data.cc | 21 +++---------------- .../http_inspect/http_context_data.h | 3 ++- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/service_inspectors/http_inspect/http_context_data.cc b/src/service_inspectors/http_inspect/http_context_data.cc index e9b912a60..bb6abb3ce 100644 --- a/src/service_inspectors/http_inspect/http_context_data.cc +++ b/src/service_inspectors/http_inspect/http_context_data.cc @@ -34,25 +34,10 @@ unsigned HttpContextData::ips_id = 0; HttpMsgSection* HttpContextData::get_snapshot(const Packet* p) { assert(p != nullptr); - - if (Http2FlowData::inspector_id != 0) - { - const Http2FlowData* const h2i_flow_data = - (Http2FlowData*)p->flow->get_flow_data(Http2FlowData::inspector_id); - if (h2i_flow_data != nullptr) - return h2i_flow_data->get_hi_msg_section(); - } - - HttpContextData* hcd = (HttpContextData*)DetectionEngine::get_data(HttpContextData::ips_id, - p->context); - - if ( !hcd ) - return nullptr; - - return hcd->current_section; + return get_snapshot(p->flow, p->context); } -HttpMsgSection* HttpContextData::get_snapshot(const Flow* flow) +HttpMsgSection* HttpContextData::get_snapshot(const Flow* flow, IpsContext* context) { assert(flow != nullptr); @@ -65,7 +50,7 @@ HttpMsgSection* HttpContextData::get_snapshot(const Flow* flow) } HttpContextData* hcd = (HttpContextData*)DetectionEngine::get_data(HttpContextData::ips_id, - nullptr); + context); if ( !hcd ) return nullptr; diff --git a/src/service_inspectors/http_inspect/http_context_data.h b/src/service_inspectors/http_inspect/http_context_data.h index 0114d73dd..2ade57f15 100644 --- a/src/service_inspectors/http_inspect/http_context_data.h +++ b/src/service_inspectors/http_inspect/http_context_data.h @@ -33,7 +33,8 @@ public: static void init() { ips_id = IpsContextData::get_ips_id(); } static HttpMsgSection* get_snapshot(const snort::Packet* p); - static HttpMsgSection* get_snapshot(const snort::Flow* flow); + static HttpMsgSection* get_snapshot(const snort::Flow* flow, + snort::IpsContext* context = nullptr); static void save_snapshot(HttpMsgSection* section); static HttpMsgSection* clear_snapshot(snort::IpsContext* context); static unsigned ips_id; -- 2.47.3