use super::range;
use crate::applayer::{self, *};
+use crate::conf::conf_get;
use crate::core::*;
use crate::filecontainer::*;
use crate::filetracker::*;
const HTTP2_FRAME_RSTSTREAM_LEN: usize = 4;
const HTTP2_FRAME_PRIORITY_LEN: usize = 5;
const HTTP2_FRAME_WINDOWUPDATE_LEN: usize = 4;
-//TODO make these configurable
-pub const HTTP2_MAX_TABLESIZE: u32 = 0x10000; // 65536
-pub const HTTP2_MAX_STREAMS: usize = 0x1000; // 4096
+pub static mut HTTP2_MAX_TABLESIZE: u32 = 65536; // 0x10000
+static mut HTTP2_MAX_STREAMS: usize = 4096; // 0x1000
#[repr(u8)]
#[derive(Copy, Clone, PartialOrd, PartialEq, Debug)]
tx.stream_id = sid;
tx.state = HTTP2TransactionState::HTTP2StateOpen;
// do not use SETTINGS_MAX_CONCURRENT_STREAMS as it can grow too much
- if self.transactions.len() > HTTP2_MAX_STREAMS {
+ if self.transactions.len() > unsafe { HTTP2_MAX_STREAMS } {
// set at least one another transaction to the drop state
for tx_old in &mut self.transactions {
if tx_old.state != HTTP2TransactionState::HTTP2StateTodrop {
&mut self.dynamic_headers_tc
};
dyn_headers.max_size = set[i].value as usize;
- if set[i].value > HTTP2_MAX_TABLESIZE {
+ if set[i].value > unsafe { HTTP2_MAX_TABLESIZE } {
//mark potential overflow
dyn_headers.overflow = 1;
} else {
if AppLayerParserConfParserEnabled(ip_proto_str.as_ptr(), parser.name) != 0 {
let _ = AppLayerRegisterParser(&parser, alproto);
}
+ if let Some(val) = conf_get("app-layer.protocols.http2.max-streams") {
+ if let Ok(v) = val.parse::<usize>() {
+ HTTP2_MAX_STREAMS = v;
+ } else {
+ SCLogError!("Invalid value for http2.max-streams");
+ }
+ }
+ if let Some(val) = conf_get("app-layer.protocols.http2.max-table-size") {
+ if let Ok(v) = val.parse::<u32>() {
+ HTTP2_MAX_TABLESIZE = v;
+ } else {
+ SCLogError!("Invalid value for http2.max-table-size");
+ }
+ }
SCLogDebug!("Rust http2 parser registered.");
} else {
SCLogNotice!("Protocol detector and parser disabled for HTTP2.");
//in case of overflow, best effort is to keep first headers
if dyn_headers.overflow > 0 {
if dyn_headers.overflow == 1 {
- if dyn_headers.current_size <= (HTTP2_MAX_TABLESIZE as usize) {
+ if dyn_headers.current_size <= (unsafe { HTTP2_MAX_TABLESIZE } as usize) {
//overflow had not yet happened
dyn_headers.table.push(headcopy);
} else if dyn_headers.current_size > dyn_headers.max_size {