|
|
|
@ -26,7 +26,7 @@ use crate::filecontainer::*;
|
|
|
|
|
use crate::filetracker::*;
|
|
|
|
|
use nom;
|
|
|
|
|
use std;
|
|
|
|
|
use std::ffi::{CStr, CString};
|
|
|
|
|
use std::ffi::CString;
|
|
|
|
|
use std::fmt;
|
|
|
|
|
use std::io;
|
|
|
|
|
|
|
|
|
@ -299,9 +299,9 @@ impl Drop for HTTP2Transaction {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[repr(u32)]
|
|
|
|
|
#[derive(AppLayerEvent)]
|
|
|
|
|
pub enum HTTP2Event {
|
|
|
|
|
InvalidFrameHeader = 0,
|
|
|
|
|
InvalidFrameHeader,
|
|
|
|
|
InvalidClientMagic,
|
|
|
|
|
InvalidFrameData,
|
|
|
|
|
InvalidHeader,
|
|
|
|
@ -313,24 +313,6 @@ pub enum HTTP2Event {
|
|
|
|
|
FailedDecompression,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl HTTP2Event {
|
|
|
|
|
fn from_i32(value: i32) -> Option<HTTP2Event> {
|
|
|
|
|
match value {
|
|
|
|
|
0 => Some(HTTP2Event::InvalidFrameHeader),
|
|
|
|
|
1 => Some(HTTP2Event::InvalidClientMagic),
|
|
|
|
|
2 => Some(HTTP2Event::InvalidFrameData),
|
|
|
|
|
3 => Some(HTTP2Event::InvalidHeader),
|
|
|
|
|
4 => Some(HTTP2Event::InvalidFrameLength),
|
|
|
|
|
5 => Some(HTTP2Event::ExtraHeaderData),
|
|
|
|
|
6 => Some(HTTP2Event::LongFrameData),
|
|
|
|
|
7 => Some(HTTP2Event::StreamIdReuse),
|
|
|
|
|
8 => Some(HTTP2Event::InvalidHTTP1Settings),
|
|
|
|
|
9 => Some(HTTP2Event::FailedDecompression),
|
|
|
|
|
_ => None,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct HTTP2DynTable {
|
|
|
|
|
pub table: Vec<parser::HTTP2FrameHeaderBlock>,
|
|
|
|
|
pub current_size: usize,
|
|
|
|
@ -1095,63 +1077,6 @@ pub unsafe extern "C" fn rs_http2_state_get_events(
|
|
|
|
|
return tx.events;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub unsafe extern "C" fn rs_http2_state_get_event_info(
|
|
|
|
|
event_name: *const std::os::raw::c_char, event_id: *mut std::os::raw::c_int,
|
|
|
|
|
event_type: *mut core::AppLayerEventType,
|
|
|
|
|
) -> std::os::raw::c_int {
|
|
|
|
|
if event_name == std::ptr::null() {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
let c_event_name: &CStr = CStr::from_ptr(event_name);
|
|
|
|
|
let event = match c_event_name.to_str() {
|
|
|
|
|
Ok(s) => {
|
|
|
|
|
match s {
|
|
|
|
|
"invalid_frame_header" => HTTP2Event::InvalidFrameHeader as i32,
|
|
|
|
|
"invalid_client_magic" => HTTP2Event::InvalidClientMagic as i32,
|
|
|
|
|
"invalid_frame_data" => HTTP2Event::InvalidFrameData as i32,
|
|
|
|
|
"invalid_header" => HTTP2Event::InvalidHeader as i32,
|
|
|
|
|
"invalid_frame_length" => HTTP2Event::InvalidFrameLength as i32,
|
|
|
|
|
"extra_header_data" => HTTP2Event::ExtraHeaderData as i32,
|
|
|
|
|
"long_frame_data" => HTTP2Event::LongFrameData as i32,
|
|
|
|
|
"stream_id_reuse" => HTTP2Event::StreamIdReuse as i32,
|
|
|
|
|
"invalid_http1_settings" => HTTP2Event::InvalidHTTP1Settings as i32,
|
|
|
|
|
"failed_decompression" => HTTP2Event::FailedDecompression as i32,
|
|
|
|
|
_ => -1, // unknown event
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Err(_) => -1, // UTF-8 conversion failed
|
|
|
|
|
};
|
|
|
|
|
*event_type = core::APP_LAYER_EVENT_TYPE_TRANSACTION;
|
|
|
|
|
*event_id = event as std::os::raw::c_int;
|
|
|
|
|
0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub unsafe extern "C" fn rs_http2_state_get_event_info_by_id(
|
|
|
|
|
event_id: std::os::raw::c_int, event_name: *mut *const std::os::raw::c_char,
|
|
|
|
|
event_type: *mut core::AppLayerEventType,
|
|
|
|
|
) -> i8 {
|
|
|
|
|
if let Some(e) = HTTP2Event::from_i32(event_id as i32) {
|
|
|
|
|
let estr = match e {
|
|
|
|
|
HTTP2Event::InvalidFrameHeader => "invalid_frame_header\0",
|
|
|
|
|
HTTP2Event::InvalidClientMagic => "invalid_client_magic\0",
|
|
|
|
|
HTTP2Event::InvalidFrameData => "invalid_frame_data\0",
|
|
|
|
|
HTTP2Event::InvalidHeader => "invalid_header\0",
|
|
|
|
|
HTTP2Event::InvalidFrameLength => "invalid_frame_length\0",
|
|
|
|
|
HTTP2Event::ExtraHeaderData => "extra_header_data\0",
|
|
|
|
|
HTTP2Event::LongFrameData => "long_frame_data\0",
|
|
|
|
|
HTTP2Event::StreamIdReuse => "stream_id_reuse\0",
|
|
|
|
|
HTTP2Event::InvalidHTTP1Settings => "invalid_http1_settings\0",
|
|
|
|
|
HTTP2Event::FailedDecompression => "failed_decompression\0",
|
|
|
|
|
};
|
|
|
|
|
*event_name = estr.as_ptr() as *const std::os::raw::c_char;
|
|
|
|
|
*event_type = core::APP_LAYER_EVENT_TYPE_TRANSACTION;
|
|
|
|
|
0
|
|
|
|
|
} else {
|
|
|
|
|
-1
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#[no_mangle]
|
|
|
|
|
pub unsafe extern "C" fn rs_http2_state_get_tx_iterator(
|
|
|
|
|
_ipproto: u8, _alproto: AppProto, state: *mut std::os::raw::c_void, min_tx_id: u64,
|
|
|
|
@ -1209,8 +1134,8 @@ pub unsafe extern "C" fn rs_http2_register_parser() {
|
|
|
|
|
get_de_state: rs_http2_tx_get_detect_state,
|
|
|
|
|
set_de_state: rs_http2_tx_set_detect_state,
|
|
|
|
|
get_events: Some(rs_http2_state_get_events),
|
|
|
|
|
get_eventinfo: Some(rs_http2_state_get_event_info),
|
|
|
|
|
get_eventinfo_byid: Some(rs_http2_state_get_event_info_by_id),
|
|
|
|
|
get_eventinfo: Some(HTTP2Event::get_event_info),
|
|
|
|
|
get_eventinfo_byid: Some(HTTP2Event::get_event_info_by_id),
|
|
|
|
|
localstorage_new: None,
|
|
|
|
|
localstorage_free: None,
|
|
|
|
|
get_files: Some(rs_http2_getfiles),
|
|
|
|
|