rust/http2: replace rs_ naming with SC

pull/13152/head
Jason Ish 4 months ago committed by Victor Julien
parent af15986d41
commit 717e06e351

@ -86,6 +86,7 @@ include = [
"FtpRequestCommand",
"FtpStateValues",
"FtpDataStateValues",
"HTTP2TransactionState",
"SCSigTableAppLiteElmt",
"SCTransformTableElmt",
"DataRepType",

@ -48,7 +48,7 @@ fn http2_tx_has_frametype(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_has_frametype(
pub unsafe extern "C" fn SCHttp2TxHasFrametype(
tx: *mut std::os::raw::c_void, direction: u8, value: u8,
) -> std::os::raw::c_int {
let tx = cast_pointer!(tx, HTTP2Transaction);
@ -56,7 +56,7 @@ pub unsafe extern "C" fn rs_http2_tx_has_frametype(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_parse_frametype(
pub unsafe extern "C" fn SCHttp2ParseFrametype(
str: *const std::os::raw::c_char,
) -> std::os::raw::c_int {
let ft_name: &CStr = CStr::from_ptr(str); //unsafe
@ -108,7 +108,7 @@ fn http2_tx_has_errorcode(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_has_errorcode(
pub unsafe extern "C" fn SCHttp2TxHasErrorCode(
tx: *mut std::os::raw::c_void, direction: u8, code: u32,
) -> std::os::raw::c_int {
let tx = cast_pointer!(tx, HTTP2Transaction);
@ -116,7 +116,7 @@ pub unsafe extern "C" fn rs_http2_tx_has_errorcode(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_parse_errorcode(
pub unsafe extern "C" fn SCHttp2ParseErrorCode(
str: *const std::os::raw::c_char,
) -> std::os::raw::c_int {
let ft_name: &CStr = CStr::from_ptr(str); //unsafe
@ -181,7 +181,7 @@ fn http2_tx_get_next_priority(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_next_priority(
pub unsafe extern "C" fn SCHttp2TxGetNextPriority(
tx: *mut std::os::raw::c_void, direction: u8, nb: u32,
) -> std::os::raw::c_int {
let tx = cast_pointer!(tx, HTTP2Transaction);
@ -217,7 +217,7 @@ fn http2_tx_get_next_window(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_next_window(
pub unsafe extern "C" fn SCHttp2TxGetNextWindow(
tx: *mut std::os::raw::c_void, direction: u8, nb: u32,
) -> std::os::raw::c_int {
let tx = cast_pointer!(tx, HTTP2Transaction);
@ -225,7 +225,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_next_window(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_detect_settingsctx_parse(
pub unsafe extern "C" fn SCHttp2DetectSettingsCtxParse(
str: *const std::os::raw::c_char,
) -> *mut std::os::raw::c_void {
let ft_name: &CStr = CStr::from_ptr(str); //unsafe
@ -239,7 +239,7 @@ pub unsafe extern "C" fn rs_http2_detect_settingsctx_parse(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_detect_settingsctx_free(ctx: *mut std::os::raw::c_void) {
pub unsafe extern "C" fn SCHttp2DetectSettingsCtxFree(ctx: *mut std::os::raw::c_void) {
// Just unbox...
std::mem::drop(Box::from_raw(ctx as *mut parser::DetectHTTP2settingsSigCtx));
}
@ -288,7 +288,7 @@ fn http2_detect_settingsctx_match(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_detect_settingsctx_match(
pub unsafe extern "C" fn SCHttp2DetectSettingsCtxMatch(
ctx: *const std::os::raw::c_void, tx: *mut std::os::raw::c_void, direction: u8,
) -> std::os::raw::c_int {
let ctx = cast_pointer!(ctx, parser::DetectHTTP2settingsSigCtx);
@ -349,7 +349,7 @@ fn http2_detect_sizeupdatectx_match(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_detect_sizeupdatectx_match(
pub unsafe extern "C" fn SCHttp2DetectSizeUpdateCtxMatch(
ctx: *const std::os::raw::c_void, tx: *mut std::os::raw::c_void, direction: u8,
) -> std::os::raw::c_int {
let ctx = cast_pointer!(ctx, DetectUintData<u64>);
@ -357,10 +357,10 @@ pub unsafe extern "C" fn rs_http2_detect_sizeupdatectx_match(
return http2_detect_sizeupdatectx_match(ctx, tx, direction.into());
}
//TODOask better syntax between rs_http2_tx_get_header_name in argument
// and rs_http2_detect_sizeupdatectx_match explicitly casting
//TODOask better syntax between SCHttp2TxGetHeaderName in argument
// and SCHttp2DetectSizeUpdateCtxMatch explicitly casting
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_header_name(
pub unsafe extern "C" fn SCHttp2TxGetHeaderName(
_de: *mut DetectEngineThreadCtx, tx: *const c_void, direction: u8, nb: u32,
buffer: *mut *const u8, buffer_len: *mut u32,
) -> bool {
@ -530,7 +530,7 @@ fn http2_tx_get_req_line(tx: &mut HTTP2Transaction) {
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_request_line(
pub unsafe extern "C" fn SCHttp2TxGetRequestLine(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
http2_tx_get_req_line(tx);
@ -559,7 +559,7 @@ fn http2_tx_get_resp_line(tx: &mut HTTP2Transaction) {
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_response_line(
pub unsafe extern "C" fn SCHttp2TxGetResponseLine(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
http2_tx_get_resp_line(tx);
@ -569,7 +569,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_response_line(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_uri(
pub unsafe extern "C" fn SCHttp2TxGetUri(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
if let Ok(value) = http2_frames_get_header_firstvalue(tx, Direction::ToServer, ":path") {
@ -581,7 +581,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_uri(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_method(
pub unsafe extern "C" fn SCHttp2TxGetMethod(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
if let Ok(value) = http2_frames_get_header_firstvalue(tx, Direction::ToServer, ":method") {
@ -593,7 +593,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_method(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_host(
pub unsafe extern "C" fn SCHttp2TxGetHost(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
if let Ok(value) = http2_frames_get_header_value(tx, Direction::ToServer, ":authority") {
@ -645,7 +645,7 @@ fn http2_normalize_host(value: &[u8]) -> &[u8] {
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_host_norm(
pub unsafe extern "C" fn SCHttp2TxGetHostNorm(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
if let Ok(value) = http2_frames_get_header_value(tx, Direction::ToServer, ":authority") {
@ -674,7 +674,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_host_norm(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_useragent(
pub unsafe extern "C" fn SCHttp2TxGetUserAgent(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
if let Ok(value) = http2_frames_get_header_value(tx, Direction::ToServer, "user-agent") {
@ -686,7 +686,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_useragent(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_status(
pub unsafe extern "C" fn SCHttp2TxGetStatus(
tx: &mut HTTP2Transaction, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
if let Ok(value) = http2_frames_get_header_firstvalue(tx, Direction::ToClient, ":status") {
@ -698,7 +698,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_status(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_cookie(
pub unsafe extern "C" fn SCHttp2TxGetCookie(
tx: &mut HTTP2Transaction, direction: u8, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
if direction == u8::from(Direction::ToServer) {
@ -716,7 +716,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_cookie(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_header_value(
pub unsafe extern "C" fn SCHttp2TxGetHeaderValue(
tx: &mut HTTP2Transaction, direction: u8, strname: *const std::os::raw::c_char,
buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
@ -742,7 +742,7 @@ fn http2_escape_header(blocks: &[parser::HTTP2FrameHeaderBlock], i: u32) -> Vec<
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_header_names(
pub unsafe extern "C" fn SCHttp2TxGetHeaderNames(
tx: &mut HTTP2Transaction, direction: u8, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
let mut vec = vec![b'\r', b'\n'];
@ -806,7 +806,7 @@ fn http2_header_trimspaces(value: &[u8]) -> &[u8] {
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_headers(
pub unsafe extern "C" fn SCHttp2TxGetHeaders(
tx: &mut HTTP2Transaction, direction: u8, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
let mut vec = Vec::new();
@ -840,7 +840,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_headers(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_headers_raw(
pub unsafe extern "C" fn SCHttp2TxGetHeadersRaw(
tx: &mut HTTP2Transaction, direction: u8, buffer: *mut *const u8, buffer_len: *mut u32,
) -> u8 {
let mut vec = Vec::new();
@ -872,7 +872,7 @@ pub unsafe extern "C" fn rs_http2_tx_get_headers_raw(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_header(
pub unsafe extern "C" fn SCHttp2TxGetHeader(
_de: *mut DetectEngineThreadCtx, tx: *const c_void, direction: u8, nb: u32,
buffer: *mut *const u8, buffer_len: *mut u32,
) -> bool {
@ -951,7 +951,7 @@ fn http2_tx_set_header(state: &mut HTTP2State, name: &[u8], input: &[u8]) {
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_set_method(
pub unsafe extern "C" fn SCHttp2TxSetMethod(
state: &mut HTTP2State, buffer: *const u8, buffer_len: u32,
) {
let slice = build_slice!(buffer, buffer_len as usize);
@ -959,7 +959,7 @@ pub unsafe extern "C" fn rs_http2_tx_set_method(
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_set_uri(
pub unsafe extern "C" fn SCHttp2TxSetUri(
state: &mut HTTP2State, buffer: *const u8, buffer_len: u32,
) {
let slice = build_slice!(buffer, buffer_len as usize);
@ -1011,7 +1011,7 @@ fn http2_caseinsensitive_cmp(s1: &[u8], s2: &str) -> bool {
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_add_header(
pub unsafe extern "C" fn SCHttp2TxAddHeader(
state: &mut HTTP2State, name: *const u8, name_len: u32, value: *const u8, value_len: u32,
) {
let slice_name = build_slice!(name, name_len as usize);

@ -49,7 +49,7 @@ const HTTP2_MIN_HANDLED_FRAME_SIZE: usize = 256;
pub static mut SURICATA_HTTP2_FILE_CONFIG: Option<&'static SuricataFileContext> = None;
#[no_mangle]
pub extern "C" fn rs_http2_init(context: &'static mut SuricataFileContext) {
pub extern "C" fn SCHttp2Init(context: &'static mut SuricataFileContext) {
unsafe {
SURICATA_HTTP2_FILE_CONFIG = Some(context);
}
@ -1394,8 +1394,7 @@ export_tx_data_get!(http2_get_tx_data, HTTP2Transaction);
export_state_data_get!(http2_get_state_data, HTTP2State);
/// C entry point for a probing parser.
#[no_mangle]
pub unsafe extern "C" fn rs_http2_probing_parser_tc(
unsafe extern "C" fn http2_probing_parser_tc(
_flow: *const Flow, _direction: u8, input: *const u8, input_len: u32, _rdir: *mut u8,
) -> AppProto {
if !input.is_null() {
@ -1431,9 +1430,8 @@ extern "C" {
// Suppress the unsafe warning here as creating a state for an app-layer
// is typically not unsafe.
#[no_mangle]
#[allow(clippy::not_unsafe_ptr_arg_deref)]
pub extern "C" fn rs_http2_state_new(
extern "C" fn http2_state_new(
orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto,
) -> *mut std::os::raw::c_void {
let state = HTTP2State::new();
@ -1448,20 +1446,17 @@ pub extern "C" fn rs_http2_state_new(
return r;
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_state_free(state: *mut std::os::raw::c_void) {
unsafe extern "C" fn http2_state_free(state: *mut std::os::raw::c_void) {
let mut state: Box<HTTP2State> = Box::from_raw(state as _);
state.free();
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) {
unsafe extern "C" fn http2_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) {
let state = cast_pointer!(state, HTTP2State);
state.free_tx(tx_id);
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_parse_ts(
unsafe extern "C" fn http2_parse_ts(
flow: *const Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void,
stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
) -> AppLayerResult {
@ -1469,8 +1464,7 @@ pub unsafe extern "C" fn rs_http2_parse_ts(
return state.parse_ts(flow, stream_slice);
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_parse_tc(
unsafe extern "C" fn http2_parse_tc(
flow: *const Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void,
stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
) -> AppLayerResult {
@ -1478,8 +1472,7 @@ pub unsafe extern "C" fn rs_http2_parse_tc(
return state.parse_tc(flow, stream_slice);
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_state_get_tx(
unsafe extern "C" fn http2_state_get_tx(
state: *mut std::os::raw::c_void, tx_id: u64,
) -> *mut std::os::raw::c_void {
let state = cast_pointer!(state, HTTP2State);
@ -1493,29 +1486,25 @@ pub unsafe extern "C" fn rs_http2_state_get_tx(
}
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 {
unsafe extern "C" fn http2_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 {
let state = cast_pointer!(state, HTTP2State);
return state.tx_id;
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_state(
unsafe extern "C" fn http2_tx_get_state(
tx: *mut std::os::raw::c_void,
) -> HTTP2TransactionState {
let tx = cast_pointer!(tx, HTTP2Transaction);
return tx.state;
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_tx_get_alstate_progress(
unsafe extern "C" fn http2_tx_get_alstate_progress(
tx: *mut std::os::raw::c_void, _direction: u8,
) -> std::os::raw::c_int {
return rs_http2_tx_get_state(tx) as i32;
return http2_tx_get_state(tx) as i32;
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_getfiles(
unsafe extern "C" fn http2_getfiles(
tx: *mut std::os::raw::c_void, direction: u8,
) -> AppLayerGetFileState {
let tx = cast_pointer!(tx, HTTP2Transaction);
@ -1539,31 +1528,31 @@ pub unsafe extern "C" fn rs_http2_getfiles(
const PARSER_NAME: &[u8] = b"http2\0";
#[no_mangle]
pub unsafe extern "C" fn rs_http2_register_parser() {
pub unsafe extern "C" fn SCRegisterHttp2Parser() {
let default_port = CString::new("[80]").unwrap();
let mut parser = RustParser {
name: PARSER_NAME.as_ptr() as *const std::os::raw::c_char,
default_port: default_port.as_ptr(),
ipproto: IPPROTO_TCP,
probe_ts: None, // big magic string should be enough
probe_tc: Some(rs_http2_probing_parser_tc),
probe_tc: Some(http2_probing_parser_tc),
min_depth: HTTP2_FRAME_HEADER_LEN as u16,
max_depth: HTTP2_MAGIC_LEN as u16,
state_new: rs_http2_state_new,
state_free: rs_http2_state_free,
tx_free: rs_http2_state_tx_free,
parse_ts: rs_http2_parse_ts,
parse_tc: rs_http2_parse_tc,
get_tx_count: rs_http2_state_get_tx_count,
get_tx: rs_http2_state_get_tx,
state_new: http2_state_new,
state_free: http2_state_free,
tx_free: http2_state_tx_free,
parse_ts: http2_parse_ts,
parse_tc: http2_parse_tc,
get_tx_count: http2_state_get_tx_count,
get_tx: http2_state_get_tx,
tx_comp_st_ts: HTTP2TransactionState::HTTP2StateClosed as i32,
tx_comp_st_tc: HTTP2TransactionState::HTTP2StateClosed as i32,
tx_get_progress: rs_http2_tx_get_alstate_progress,
tx_get_progress: http2_tx_get_alstate_progress,
get_eventinfo: Some(HTTP2Event::get_event_info),
get_eventinfo_byid: Some(HTTP2Event::get_event_info_by_id),
localstorage_new: None,
localstorage_free: None,
get_tx_files: Some(rs_http2_getfiles),
get_tx_files: Some(http2_getfiles),
get_tx_iterator: Some(applayer::state_get_tx_iterator::<HTTP2State, HTTP2Transaction>),
get_tx_data: http2_get_tx_data,
get_state_data: http2_get_state_data,

@ -285,7 +285,7 @@ fn log_http2(tx: &HTTP2Transaction, js: &mut JsonBuilder) -> Result<bool, JsonEr
}
#[no_mangle]
pub unsafe extern "C" fn rs_http2_log_json(
pub unsafe extern "C" fn SCHttp2LogJson(
tx: *mut std::os::raw::c_void, js: &mut JsonBuilder,
) -> bool {
let tx = cast_pointer!(tx, HTTP2Transaction);

@ -86,7 +86,7 @@ pub fn http2_parse_check_content_range(input: &[u8]) -> IResult<&[u8], HTTPConte
}
#[no_mangle]
pub unsafe extern "C" fn rs_http_parse_content_range(
pub unsafe extern "C" fn SCHttpParseContentRange(
cr: &mut HTTPContentRange, buffer: *const u8, buffer_len: u32,
) -> std::os::raw::c_int {
let slice = build_slice!(buffer, buffer_len as usize);

@ -96,7 +96,7 @@ int HTPFileOpen(HtpState *s, HtpTxUserData *tx, const uint8_t *filename, uint16_
int HTPParseContentRange(const bstr *rawvalue, HTTPContentRange *range)
{
uint32_t len = (uint32_t)bstr_len(rawvalue);
return rs_http_parse_content_range(range, bstr_ptr(rawvalue), len);
return SCHttpParseContentRange(range, bstr_ptr(rawvalue), len);
}
/**

@ -62,8 +62,8 @@ void RegisterHTTP2Parsers(void)
if (HTTP2RegisterPatternsForProtocolDetection() < 0)
return;
rs_http2_init(&sfc);
rs_http2_register_parser();
SCHttp2Init(&sfc);
SCRegisterHttp2Parser();
}
#ifdef UNITTESTS
@ -82,18 +82,18 @@ void HTTP2MimicHttp1Request(void *alstate_orig, void *h2s)
return;
}
// else
rs_http2_tx_set_method(h2s, bstr_ptr(htp_tx_request_method(h1tx)),
SCHttp2TxSetMethod(h2s, bstr_ptr(htp_tx_request_method(h1tx)),
(uint32_t)bstr_len(htp_tx_request_method(h1tx)));
if (htp_tx_request_uri(h1tx) != NULL) {
// A request line without spaces gets interpreted as a request_method
// and has request_uri=NULL
rs_http2_tx_set_uri(h2s, bstr_ptr(htp_tx_request_uri(h1tx)),
SCHttp2TxSetUri(h2s, bstr_ptr(htp_tx_request_uri(h1tx)),
(uint32_t)bstr_len(htp_tx_request_uri(h1tx)));
}
size_t nbheaders = htp_tx_request_headers_size(h1tx);
for (size_t i = 0; i < nbheaders; i++) {
const htp_header_t *h = htp_tx_request_header_index(h1tx, i);
rs_http2_tx_add_header(h2s, htp_header_name_ptr(h), (uint32_t)htp_header_name_len(h),
SCHttp2TxAddHeader(h2s, htp_header_name_ptr(h), (uint32_t)htp_header_name_len(h),
htp_header_value_ptr(h), (uint32_t)htp_header_value_len(h));
}
}

@ -234,7 +234,7 @@ static InspectionBuffer *GetRequestData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_cookie(txv, STREAM_TOSERVER, &b, &b_len) != 1)
if (SCHttp2TxGetCookie(txv, STREAM_TOSERVER, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;
@ -254,7 +254,7 @@ static InspectionBuffer *GetResponseData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_cookie(txv, STREAM_TOCLIENT, &b, &b_len) != 1)
if (SCHttp2TxGetCookie(txv, STREAM_TOCLIENT, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -170,7 +170,7 @@ static InspectionBuffer *GetBuffer2ForTX(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_header_names(txv, flow_flags, &b, &b_len) != 1)
if (SCHttp2TxGetHeaderNames(txv, flow_flags, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -152,7 +152,7 @@ static InspectionBuffer *GetBuffer2ForTX(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_headers(txv, flow_flags, &b, &b_len) != 1)
if (SCHttp2TxGetHeaders(txv, flow_flags, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;
@ -592,7 +592,7 @@ void DetectHttpRequestHeaderRegister(void)
SIGMATCH_NOOPT | SIGMATCH_INFO_STICKY_BUFFER;
DetectAppLayerMultiRegister("http_request_header", ALPROTO_HTTP2, SIG_FLAG_TOSERVER,
HTTP2StateOpen, rs_http2_tx_get_header, 2);
HTTP2StateOpen, SCHttp2TxGetHeader, 2);
DetectAppLayerMultiRegister("http_request_header", ALPROTO_HTTP1, SIG_FLAG_TOSERVER,
HTP_REQUEST_PROGRESS_HEADERS, GetHttp1HeaderData, 2);
@ -625,7 +625,7 @@ void DetectHttpResponseHeaderRegister(void)
SIGMATCH_NOOPT | SIGMATCH_INFO_STICKY_BUFFER;
DetectAppLayerMultiRegister("http_response_header", ALPROTO_HTTP2, SIG_FLAG_TOCLIENT,
HTTP2StateOpen, rs_http2_tx_get_header, 2);
HTTP2StateOpen, SCHttp2TxGetHeader, 2);
DetectAppLayerMultiRegister("http_response_header", ALPROTO_HTTP1, SIG_FLAG_TOCLIENT,
HTP_RESPONSE_PROGRESS_HEADERS, GetHttp1HeaderData, 2);

@ -85,7 +85,7 @@ static InspectionBuffer *GetRequestData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_header_value(txv, STREAM_TOSERVER, HEADER_NAME, &b, &b_len) != 1)
if (SCHttp2TxGetHeaderValue(txv, STREAM_TOSERVER, HEADER_NAME, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;
@ -139,7 +139,7 @@ static InspectionBuffer *GetResponseData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_header_value(txv, STREAM_TOCLIENT, HEADER_NAME, &b, &b_len) != 1)
if (SCHttp2TxGetHeaderValue(txv, STREAM_TOCLIENT, HEADER_NAME, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -270,7 +270,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_host_norm(txv, &b, &b_len) != 1)
if (SCHttp2TxGetHostNorm(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;
@ -290,7 +290,7 @@ static InspectionBuffer *GetRawData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_host(txv, &b, &b_len) != 1)
if (SCHttp2TxGetHost(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -229,7 +229,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_method(txv, &b, &b_len) != 1)
if (SCHttp2TxGetMethod(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -217,7 +217,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_headers_raw(txv, flow_flags, &b, &b_len) != 1)
if (SCHttp2TxGetHeadersRaw(txv, flow_flags, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -82,7 +82,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_request_line(txv, &b, &b_len) != 1)
if (SCHttp2TxGetRequestLine(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -82,7 +82,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_response_line(txv, &b, &b_len) != 1)
if (SCHttp2TxGetResponseLine(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -188,7 +188,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_status(txv, &b, &b_len) != 1)
if (SCHttp2TxGetStatus(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -193,7 +193,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_useragent(txv, &b, &b_len) != 1)
if (SCHttp2TxGetUserAgent(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -242,7 +242,7 @@ static InspectionBuffer *GetData2(DetectEngineThreadCtx *det_ctx,
uint32_t b_len = 0;
const uint8_t *b = NULL;
if (rs_http2_tx_get_uri(txv, &b, &b_len) != 1)
if (SCHttp2TxGetUri(txv, &b, &b_len) != 1)
return NULL;
if (b == NULL || b_len == 0)
return NULL;

@ -175,9 +175,9 @@ void DetectHttp2Register(void)
sigmatch_table[DETECT_HTTP2_HEADERNAME].flags |= SIGMATCH_NOOPT | SIGMATCH_INFO_STICKY_BUFFER;
DetectAppLayerMultiRegister("http2_header_name", ALPROTO_HTTP2, SIG_FLAG_TOCLIENT,
HTTP2StateOpen, rs_http2_tx_get_header_name, 2);
HTTP2StateOpen, SCHttp2TxGetHeaderName, 2);
DetectAppLayerMultiRegister("http2_header_name", ALPROTO_HTTP2, SIG_FLAG_TOSERVER,
HTTP2StateOpen, rs_http2_tx_get_header_name, 2);
HTTP2StateOpen, SCHttp2TxGetHeaderName, 2);
DetectBufferTypeSupportsMultiInstance("http2_header_name");
DetectBufferTypeSetDescriptionByName("http2_header_name",
@ -205,7 +205,7 @@ static int DetectHTTP2frametypeMatch(DetectEngineThreadCtx *det_ctx,
{
uint8_t *detect = (uint8_t *)ctx;
return rs_http2_tx_has_frametype(txv, flags, *detect);
return SCHttp2TxHasFrametype(txv, flags, *detect);
}
static int DetectHTTP2FuncParseFrameType(const char *str, uint8_t *ft)
@ -216,7 +216,7 @@ static int DetectHTTP2FuncParseFrameType(const char *str, uint8_t *ft)
}
// it it failed so far, parse string value from enumeration
int r = rs_http2_parse_frametype(str);
int r = SCHttp2ParseFrametype(str);
if (r >= 0 && r <= UINT8_MAX) {
*ft = (uint8_t)r;
return 1;
@ -284,7 +284,7 @@ static int DetectHTTP2errorcodeMatch(DetectEngineThreadCtx *det_ctx,
{
uint32_t *detect = (uint32_t *)ctx;
return rs_http2_tx_has_errorcode(txv, flags, *detect);
return SCHttp2TxHasErrorCode(txv, flags, *detect);
//TODOask handle negation rules
}
@ -296,7 +296,7 @@ static int DetectHTTP2FuncParseErrorCode(const char *str, uint32_t *ec)
}
// it it failed so far, parse string value from enumeration
int r = rs_http2_parse_errorcode(str);
int r = SCHttp2ParseErrorCode(str);
if (r >= 0) {
*ec = r;
return 1;
@ -363,14 +363,14 @@ static int DetectHTTP2priorityMatch(DetectEngineThreadCtx *det_ctx,
{
uint32_t nb = 0;
int value = rs_http2_tx_get_next_priority(txv, flags, nb);
int value = SCHttp2TxGetNextPriority(txv, flags, nb);
const DetectU8Data *du8 = (const DetectU8Data *)ctx;
while (value >= 0) {
if (DetectU8Match((uint8_t)value, du8)) {
return 1;
}
nb++;
value = rs_http2_tx_get_next_priority(txv, flags, nb);
value = SCHttp2TxGetNextPriority(txv, flags, nb);
}
return 0;
}
@ -425,14 +425,14 @@ static int DetectHTTP2windowMatch(DetectEngineThreadCtx *det_ctx,
{
uint32_t nb = 0;
int value = rs_http2_tx_get_next_window(txv, flags, nb);
int value = SCHttp2TxGetNextWindow(txv, flags, nb);
const DetectU32Data *du32 = (const DetectU32Data *)ctx;
while (value >= 0) {
if (DetectU32Match(value, du32)) {
return 1;
}
nb++;
value = rs_http2_tx_get_next_window(txv, flags, nb);
value = SCHttp2TxGetNextWindow(txv, flags, nb);
}
return 0;
}
@ -486,7 +486,7 @@ static int DetectHTTP2sizeUpdateMatch(DetectEngineThreadCtx *det_ctx,
const SigMatchCtx *ctx)
{
return rs_http2_detect_sizeupdatectx_match(ctx, txv, flags);
return SCHttp2DetectSizeUpdateCtxMatch(ctx, txv, flags);
}
/**
@ -538,7 +538,7 @@ static int DetectHTTP2settingsMatch(DetectEngineThreadCtx *det_ctx,
const SigMatchCtx *ctx)
{
return rs_http2_detect_settingsctx_match(ctx, txv, flags);
return SCHttp2DetectSettingsCtxMatch(ctx, txv, flags);
}
/**
@ -556,7 +556,7 @@ static int DetectHTTP2settingsSetup (DetectEngineCtx *de_ctx, Signature *s, cons
if (DetectSignatureSetAppProto(s, ALPROTO_HTTP2) != 0)
return -1;
void *http2set = rs_http2_detect_settingsctx_parse(str);
void *http2set = SCHttp2DetectSettingsCtxParse(str);
if (http2set == NULL)
return -1;
@ -576,7 +576,7 @@ static int DetectHTTP2settingsSetup (DetectEngineCtx *de_ctx, Signature *s, cons
*/
void DetectHTTP2settingsFree(DetectEngineCtx *de_ctx, void *ptr)
{
rs_http2_detect_settingsctx_free(ptr);
SCHttp2DetectSettingsCtxFree(ptr);
}
static int DetectHTTP2headerNameSetup(DetectEngineCtx *de_ctx, Signature *s, const char *arg)

@ -260,7 +260,7 @@ bool AlertJsonDoh2(void *txptr, SCJsonBuilder *js)
SCJbGetMark(js, &mark);
// first log HTTP2 part
bool r = rs_http2_log_json(txptr, js);
bool r = SCHttp2LogJson(txptr, js);
if (!r) {
SCJbRestoreMark(js, &mark);
}
@ -296,7 +296,7 @@ static int JsonDoh2Logger(ThreadVars *tv, void *thread_data, const Packet *p, Fl
SCJbGetMark(jb, &mark);
// first log HTTP2 part
bool r = rs_http2_log_json(txptr, jb);
bool r = SCHttp2LogJson(txptr, jb);
if (!r) {
SCJbRestoreMark(jb, &mark);
}

@ -932,8 +932,7 @@ void OutputRegisterRootLoggers(void)
ALPROTO_TEMPLATE, (EveJsonSimpleTxLogFunc)rs_template_logger_log, NULL);
RegisterSimpleJsonApplayerLogger(ALPROTO_RDP, (EveJsonSimpleTxLogFunc)SCRdpToJson, NULL);
// special case : http2 is logged in http object
RegisterSimpleJsonApplayerLogger(
ALPROTO_HTTP2, (EveJsonSimpleTxLogFunc)rs_http2_log_json, "http");
RegisterSimpleJsonApplayerLogger(ALPROTO_HTTP2, (EveJsonSimpleTxLogFunc)SCHttp2LogJson, "http");
// underscore instead of dash for bittorrent_dht
RegisterSimpleJsonApplayerLogger(ALPROTO_BITTORRENT_DHT,
(EveJsonSimpleTxLogFunc)SCBittorrentDhtLogger, "bittorrent_dht");

Loading…
Cancel
Save