@@ -424,6 +424,8 @@ static int g_http_request_header_buffer_id = 0;
424424static int g_http_response_header_buffer_id = 0 ;
425425static int g_request_header_thread_id = 0 ;
426426static int g_response_header_thread_id = 0 ;
427+ static int g_h2_request_header_thread_id = 0 ;
428+ static int g_h2_response_header_thread_id = 0 ;
427429
428430typedef struct HttpMultiBufItem {
429431 uint8_t * buffer ;
@@ -462,6 +464,22 @@ static void HttpMultiBufHeaderThreadDataFree(void *data)
462464 SCFree (td );
463465}
464466
467+ static bool GetHttp2HeaderData (DetectEngineThreadCtx * det_ctx , const void * txv , const uint8_t flags ,
468+ uint32_t local_id , const uint8_t * * buf , uint32_t * buf_len )
469+ {
470+ int kw_thread_id ;
471+ if (flags & STREAM_TOSERVER ) {
472+ kw_thread_id = g_h2_request_header_thread_id ;
473+ } else {
474+ kw_thread_id = g_h2_response_header_thread_id ;
475+ }
476+ void * hdr_td = DetectThreadCtxGetGlobalKeywordThreadCtx (det_ctx , kw_thread_id );
477+ if (unlikely (hdr_td == NULL )) {
478+ return false;
479+ }
480+ return SCHttp2TxGetHeader (hdr_td , txv , flags , local_id , buf , buf_len );
481+ }
482+
465483static bool GetHttp1HeaderData (DetectEngineThreadCtx * det_ctx , const void * txv , const uint8_t flags ,
466484 uint32_t local_id , const uint8_t * * buf , uint32_t * buf_len )
467485{
@@ -557,7 +575,7 @@ void DetectHttpRequestHeaderRegister(void)
557575 SIGMATCH_NOOPT | SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_INFO_MULTI_BUFFER ;
558576
559577 DetectAppLayerMultiRegister ("http_request_header" , ALPROTO_HTTP2 , SIG_FLAG_TOSERVER ,
560- HTTP2StateOpen , SCHttp2TxGetHeader , 2 );
578+ HTTP2StateOpen , GetHttp2HeaderData , 2 );
561579 DetectAppLayerMultiRegister ("http_request_header" , ALPROTO_HTTP1 , SIG_FLAG_TOSERVER ,
562580 HTP_REQUEST_PROGRESS_HEADERS , GetHttp1HeaderData , 2 );
563581
@@ -566,6 +584,8 @@ void DetectHttpRequestHeaderRegister(void)
566584 DetectBufferTypeSupportsMultiInstance ("http_request_header" );
567585 g_request_header_thread_id = DetectRegisterThreadCtxGlobalFuncs ("http_request_header" ,
568586 HttpMultiBufHeaderThreadDataInit , NULL , HttpMultiBufHeaderThreadDataFree );
587+ g_h2_request_header_thread_id = DetectRegisterThreadCtxGlobalFuncs ("http2_request_header" ,
588+ SCHttp2ThreadMultiBufDataInit , NULL , SCHttp2ThreadMultiBufDataFree );
569589}
570590
571591static int DetectHTTPResponseHeaderSetup (DetectEngineCtx * de_ctx , Signature * s , const char * arg )
@@ -590,7 +610,7 @@ void DetectHttpResponseHeaderRegister(void)
590610 SIGMATCH_NOOPT | SIGMATCH_INFO_STICKY_BUFFER | SIGMATCH_INFO_MULTI_BUFFER ;
591611
592612 DetectAppLayerMultiRegister ("http_response_header" , ALPROTO_HTTP2 , SIG_FLAG_TOCLIENT ,
593- HTTP2StateOpen , SCHttp2TxGetHeader , 2 );
613+ HTTP2StateOpen , GetHttp2HeaderData , 2 );
594614 DetectAppLayerMultiRegister ("http_response_header" , ALPROTO_HTTP1 , SIG_FLAG_TOCLIENT ,
595615 HTP_RESPONSE_PROGRESS_HEADERS , GetHttp1HeaderData , 2 );
596616
@@ -599,6 +619,8 @@ void DetectHttpResponseHeaderRegister(void)
599619 DetectBufferTypeSupportsMultiInstance ("http_response_header" );
600620 g_response_header_thread_id = DetectRegisterThreadCtxGlobalFuncs ("http_response_header" ,
601621 HttpMultiBufHeaderThreadDataInit , NULL , HttpMultiBufHeaderThreadDataFree );
622+ g_h2_response_header_thread_id = DetectRegisterThreadCtxGlobalFuncs ("http2_response_header" ,
623+ SCHttp2ThreadMultiBufDataInit , NULL , SCHttp2ThreadMultiBufDataFree );
602624}
603625
604626/************************************Unittests*********************************/
0 commit comments