64 static int g_http_header_buffer_id = 0;
65 static int g_keyword_thread_id = 0;
67 #define BUFFER_SIZE_STEP 1024
70 static uint8_t *GetBufferForTX(
83 if (
flags & STREAM_TOSERVER) {
99 for (; i < no_of_headers; i++) {
104 if (
flags & STREAM_TOSERVER) {
114 size_t size = size1 + size2 + 4;
116 if (i + 1 == no_of_headers)
119 if (size + buf->
len > buf->
size) {
133 #if 0 // looks like this breaks existing rules
134 if (i + 1 == no_of_headers) {
141 *buffer_len = buf->
len;
152 const uint8_t *b = NULL;
154 if (rs_http2_tx_get_headers(txv, flow_flags, &b, &b_len) != 1)
156 if (b == NULL || b_len == 0)
175 const int list_id = engine->
sm_list;
180 SCLogDebug(
"setting up inspect buffer %d", list_id);
188 uint32_t rawdata_len = 0;
189 uint8_t *rawdata = GetBufferForTX(txv, det_ctx, f,
flags, &rawdata_len);
190 if (rawdata_len == 0) {
203 const uint8_t *data = buffer->
inspect;
244 const int list_id =
ctx->list_id;
247 uint32_t rawdata_len = 0;
248 uint8_t *rawdata = GetBufferForTX(txv, det_ctx, f,
flags, &rawdata_len);
249 if (rawdata_len == 0)
258 const uint8_t *data = buffer->
inspect;
263 if (data != NULL && data_len >= mpm_ctx->
minlen) {
265 mpm_ctx, &det_ctx->
mtc, &det_ctx->
pmq, data, data_len);
283 PrefilterMpmHttpHeader(det_ctx, pectx, p, f, txv, idx, _txd,
flags);
287 static void PrefilterMpmHttpHeaderFree(
void *ptr)
313 pectx =
SCCalloc(1,
sizeof(*pectx));
349 pectx =
SCCalloc(1,
sizeof(*pectx));
409 "content modifier to match only on the HTTP header-buffer";
411 "/rules/http-keywords.html#http-header-and-http-raw-header";
459 static int g_http_request_header_buffer_id = 0;
460 static int g_http_response_header_buffer_id = 0;
461 static int g_request_header_thread_id = 0;
462 static int g_response_header_thread_id = 0;
478 static void *HttpMultiBufHeaderThreadDataInit(
void *data)
484 SCLogError(
"failed to allocate %" PRIuMAX
" bytes: %s", (uintmax_t)
sizeof(*td),
491 static void HttpMultiBufHeaderThreadDataFree(
void *data)
494 for (
size_t i = 0; i < td->
cap; i++) {
503 int list_id, uint32_t local_id)
514 const uint8_t *b = NULL;
516 if (rs_http2_tx_get_header(txv,
flags, local_id, &b, &b_len) != 1) {
520 if (b == NULL || b_len == 0) {
533 int list_id, uint32_t local_id)
543 if (
flags & STREAM_TOSERVER) {
544 kw_thread_id = g_request_header_thread_id;
546 kw_thread_id = g_response_header_thread_id;
554 htp_tx_t *tx = (htp_tx_t *)txv;
556 if (
flags & STREAM_TOSERVER) {
566 if (hdr_td->
cap < no_of_headers) {
571 hdr_td->
items = new_buffer;
573 memset(hdr_td->
items + hdr_td->
cap, 0,
575 hdr_td->
cap = no_of_headers;
577 for (
size_t i = 0; i < no_of_headers; i++) {
581 size_t size = size1 + size2 + 2;
596 hdr_td->
len = no_of_headers;
601 if (local_id < hdr_td->
len) {
627 "sticky buffer to match on only one HTTP header name and value";
634 HTTP2StateOpen, GetHttp2HeaderData, 2, HTTP2StateOpen);
642 HttpMultiBufHeaderThreadDataInit, NULL, HttpMultiBufHeaderThreadDataFree);
660 "sticky buffer to match on only one HTTP header name and value";
667 HTTP2StateOpen, GetHttp2HeaderData, 2, HTTP2StateOpen);
675 HttpMultiBufHeaderThreadDataInit, NULL, HttpMultiBufHeaderThreadDataFree);