From: Mike Stepanek (mstepane) Date: Tue, 24 Mar 2020 14:01:40 +0000 (+0000) Subject: Merge pull request #2100 in SNORT/snort3 from ~KATHARVE/snort3:nhi_refactor_print_bod... X-Git-Tag: 3.0.0-270~6 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0ef96b29bd977a7e2582f26a7124529a042d930;p=thirdparty%2Fsnort3.git Merge pull request #2100 in SNORT/snort3 from ~KATHARVE/snort3:nhi_refactor_print_body_section to master Squashed commit of the following: commit 9c9226cea9e366bfd8be4da464ba1428497c9221 Author: Katura Harvey Date: Mon Mar 23 16:54:22 2020 -0400 http_inspect: refactor print_section for message bodies --- diff --git a/src/service_inspectors/http_inspect/http_msg_body.cc b/src/service_inspectors/http_inspect/http_msg_body.cc index 0f35cf857..c3cdba2a6 100644 --- a/src/service_inspectors/http_inspect/http_msg_body.cc +++ b/src/service_inspectors/http_inspect/http_msg_body.cc @@ -279,8 +279,10 @@ const Field& HttpMsgBody::get_classic_client_body() #ifdef REG_TEST // Common elements of print_section() for body sections -void HttpMsgBody::print_body_section(FILE* output) +void HttpMsgBody::print_body_section(FILE* output, const char* body_type_str) { + HttpMsgSection::print_section_title(output, body_type_str); + fprintf(output, "octets seen %" PRIi64 "\n", body_octets); detect_data.print(output, "Detect data"); get_classic_buffer(HTTP_BUFFER_CLIENT_BODY, 0, 0).print(output, HttpApi::classic_buffer_names[HTTP_BUFFER_CLIENT_BODY-1]); diff --git a/src/service_inspectors/http_inspect/http_msg_body.h b/src/service_inspectors/http_inspect/http_msg_body.h index b086588b7..c84079334 100644 --- a/src/service_inspectors/http_inspect/http_msg_body.h +++ b/src/service_inspectors/http_inspect/http_msg_body.h @@ -51,7 +51,7 @@ protected: bool first_body; #ifdef REG_TEST - void print_body_section(FILE* output); + void print_body_section(FILE* output, const char* body_type_str); #endif private: diff --git a/src/service_inspectors/http_inspect/http_msg_body_chunk.cc b/src/service_inspectors/http_inspect/http_msg_body_chunk.cc index 5acf0dcf2..dc4c1b24f 100644 --- a/src/service_inspectors/http_inspect/http_msg_body_chunk.cc +++ b/src/service_inspectors/http_inspect/http_msg_body_chunk.cc @@ -55,9 +55,7 @@ void HttpMsgBodyChunk::update_flow() #ifdef REG_TEST void HttpMsgBodyChunk::print_section(FILE* output) { - HttpMsgSection::print_section_title(output, "chunked body"); - fprintf(output, "Cumulative octets %" PRIi64 "\n", body_octets); - print_body_section(output); + print_body_section(output, "chunked body"); } #endif diff --git a/src/service_inspectors/http_inspect/http_msg_body_cl.cc b/src/service_inspectors/http_inspect/http_msg_body_cl.cc index 6ac9611d8..1809595bd 100644 --- a/src/service_inspectors/http_inspect/http_msg_body_cl.cc +++ b/src/service_inspectors/http_inspect/http_msg_body_cl.cc @@ -41,9 +41,7 @@ void HttpMsgBodyCl::update_flow() #ifdef REG_TEST void HttpMsgBodyCl::print_section(FILE* output) { - HttpMsgSection::print_section_title(output, "Content-Length body"); - fprintf(output, "octets seen %" PRIi64 "\n", body_octets); - print_body_section(output); + print_body_section(output, "Content-Length body"); } #endif diff --git a/src/service_inspectors/http_inspect/http_msg_body_h2.cc b/src/service_inspectors/http_inspect/http_msg_body_h2.cc index ea0a87551..9911a9b2d 100644 --- a/src/service_inspectors/http_inspect/http_msg_body_h2.cc +++ b/src/service_inspectors/http_inspect/http_msg_body_h2.cc @@ -43,9 +43,7 @@ void HttpMsgBodyH2::update_flow() #ifdef REG_TEST void HttpMsgBodyH2::print_section(FILE* output) { - HttpMsgSection::print_section_title(output, "HTTP/2 body"); - fprintf(output, "octets seen %" PRIi64 "\n", body_octets); - print_body_section(output); + print_body_section(output, "HTTP/2 body"); } #endif diff --git a/src/service_inspectors/http_inspect/http_msg_body_old.cc b/src/service_inspectors/http_inspect/http_msg_body_old.cc index 6e68953c3..102659a7f 100644 --- a/src/service_inspectors/http_inspect/http_msg_body_old.cc +++ b/src/service_inspectors/http_inspect/http_msg_body_old.cc @@ -33,9 +33,7 @@ void HttpMsgBodyOld::update_flow() #ifdef REG_TEST void HttpMsgBodyOld::print_section(FILE* output) { - HttpMsgSection::print_section_title(output, "old-style body"); - fprintf(output, "octets seen %" PRIi64 "\n", body_octets); - print_body_section(output); + print_body_section(output, "old-style body"); } #endif