rust/detect: replace rs_ naming with SC

pull/13152/head
Jason Ish 4 months ago committed by Victor Julien
parent 713034d0dd
commit 1c580f9001

@ -229,7 +229,7 @@ fn detect_parse_float_notending<T: DetectFloatType>(i: &str) -> IResult<&str, De
}
#[no_mangle]
pub unsafe extern "C" fn rs_detect_f64_parse(
pub unsafe extern "C" fn SCDetectF64Parse(
ustr: *const std::os::raw::c_char,
) -> *mut DetectFloatData<f64> {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -243,7 +243,7 @@ pub unsafe extern "C" fn rs_detect_f64_parse(
}
#[no_mangle]
pub unsafe extern "C" fn rs_detect_f64_match(
pub unsafe extern "C" fn SCDetectF64Match(
arg: f64, ctx: &DetectFloatData<f64>,
) -> std::os::raw::c_int {
if detect_match_float::<f64>(ctx, arg) {
@ -253,7 +253,7 @@ pub unsafe extern "C" fn rs_detect_f64_match(
}
#[no_mangle]
pub unsafe extern "C" fn rs_detect_f64_free(ctx: &mut DetectFloatData<f64>) {
pub unsafe extern "C" fn SCDetectF64Free(ctx: &mut DetectFloatData<f64>) {
// Just unbox...
std::mem::drop(Box::from_raw(ctx));
}
@ -441,7 +441,7 @@ mod tests {
fn do_match_test(val: &str, arg1: f64, arg1_cmp: f64, arg2: f64, mode: DetectFloatMode) {
let c_string = CString::new(val).expect("CString::new failed");
unsafe {
let val = rs_detect_f64_parse(c_string.as_ptr());
let val = SCDetectF64Parse(c_string.as_ptr());
let str_arg_a = format!("{:.3}", (*val).arg1);
let str_arg_b = format!("{:.3}", arg1);
assert_eq!(str_arg_a, str_arg_b);
@ -450,7 +450,7 @@ mod tests {
assert_eq!(str_arg_a, str_arg_b);
assert_eq!((*val).mode, mode);
assert_eq!(1, rs_detect_f64_match(arg1_cmp, &*val));
assert_eq!(1, SCDetectF64Match(arg1_cmp, &*val));
}
}
@ -461,7 +461,7 @@ mod tests {
fn do_parse_test(val: &str, arg1: f64, arg2: f64, mode: DetectFloatMode) {
let c_string = CString::new(val).expect("CString::new failed");
unsafe {
let val = rs_detect_f64_parse(c_string.as_ptr());
let val = SCDetectF64Parse(c_string.as_ptr());
let str_arg_a = format!("{:.3}", (*val).arg1);
let str_arg_b = format!("{:.3}", arg1);
assert_eq!(str_arg_a, str_arg_b);
@ -478,7 +478,7 @@ mod tests {
}
#[test]
fn test_rs_detect_match_valid() {
fn test_ffi_detect_match_valid() {
do_match_test_arg1("1.0", 1.0, 1.0, DetectFloatMode::DetectFloatModeEqual);
do_match_test_arg1("> 1.0", 1.0, 1.1, DetectFloatMode::DetectFloatModeGt);
do_match_test_arg1(">= 1.0", 1.0, 1.0, DetectFloatMode::DetectFloatModeGte);
@ -515,7 +515,7 @@ mod tests {
}
#[test]
fn test_rs_detect_parse_valid() {
fn test_ffi_detect_parse_valid() {
do_parse_test_arg1("1.0", 1.0, DetectFloatMode::DetectFloatModeEqual);
do_parse_test_arg1("> 1.0", 1.0, DetectFloatMode::DetectFloatModeGt);
do_parse_test_arg1(">= 1.0", 1.0, DetectFloatMode::DetectFloatModeGte);

@ -78,7 +78,7 @@ pub fn detect_parse_stream_size(i: &str) -> IResult<&str, DetectStreamSizeData>
}
#[no_mangle]
pub unsafe extern "C" fn rs_detect_stream_size_parse(
pub unsafe extern "C" fn SCDetectStreamSizeParse(
ustr: *const std::os::raw::c_char,
) -> *mut DetectStreamSizeData {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -92,7 +92,7 @@ pub unsafe extern "C" fn rs_detect_stream_size_parse(
}
#[no_mangle]
pub unsafe extern "C" fn rs_detect_stream_size_free(ctx: &mut DetectStreamSizeData) {
pub unsafe extern "C" fn SCDetectStreamSizeFree(ctx: &mut DetectStreamSizeData) {
// Just unbox...
std::mem::drop(Box::from_raw(ctx));
}

@ -58,7 +58,7 @@ pub fn detect_parse_urilen(i: &str) -> IResult<&str, DetectUrilenData> {
}
#[no_mangle]
pub unsafe extern "C" fn rs_detect_urilen_parse(
pub unsafe extern "C" fn SCDetectUrilenParse(
ustr: *const std::os::raw::c_char,
) -> *mut DetectUrilenData {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -72,7 +72,7 @@ pub unsafe extern "C" fn rs_detect_urilen_parse(
}
#[no_mangle]
pub unsafe extern "C" fn rs_detect_urilen_free(ctx: &mut DetectUrilenData) {
pub unsafe extern "C" fn SCDetectUrilenFree(ctx: &mut DetectUrilenData) {
// Just unbox...
std::mem::drop(Box::from_raw(ctx));
}

@ -142,7 +142,7 @@ static int DetectStreamSizeMatch(
*/
static int DetectStreamSizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *streamstr)
{
DetectStreamSizeData *sd = rs_detect_stream_size_parse(streamstr);
DetectStreamSizeData *sd = SCDetectStreamSizeParse(streamstr);
if (sd == NULL)
return -1;
@ -161,7 +161,7 @@ static int DetectStreamSizeSetup (DetectEngineCtx *de_ctx, Signature *s, const c
*/
void DetectStreamSizeFree(DetectEngineCtx *de_ctx, void *ptr)
{
rs_detect_stream_size_free(ptr);
SCDetectStreamSizeFree(ptr);
}
/* prefilter code */
@ -238,7 +238,7 @@ static int DetectStreamSizeParseTest01 (void)
{
int result = 0;
DetectStreamSizeData *sd = NULL;
sd = rs_detect_stream_size_parse("server,<,6");
sd = SCDetectStreamSizeParse("server,<,6");
if (sd != NULL) {
if (sd->flags & StreamSizeServer && sd->du32.mode == DETECT_UINT_LT && sd->du32.arg1 == 6)
result = 1;
@ -257,7 +257,7 @@ static int DetectStreamSizeParseTest02 (void)
{
int result = 1;
DetectStreamSizeData *sd = NULL;
sd = rs_detect_stream_size_parse("invalidoption,<,6");
sd = SCDetectStreamSizeParse("invalidoption,<,6");
if (sd != NULL) {
printf("expected: NULL got 0x%02X %" PRIu32 ": ", sd->flags, sd->du32.arg1);
result = 0;
@ -298,7 +298,7 @@ static int DetectStreamSizeParseTest03 (void)
memset(&f, 0, sizeof(Flow));
memset(&tcph, 0, sizeof(TCPHdr));
sd = rs_detect_stream_size_parse("client,>,8");
sd = SCDetectStreamSizeParse("client,>,8");
if (sd != NULL) {
if (!(sd->flags & StreamSizeClient)) {
printf("sd->flags not STREAM_SIZE_CLIENT: ");
@ -374,7 +374,7 @@ static int DetectStreamSizeParseTest04 (void)
memset(&f, 0, sizeof(Flow));
memset(&ip4h, 0, sizeof(IPV4Hdr));
sd = rs_detect_stream_size_parse(" client , > , 8 ");
sd = SCDetectStreamSizeParse(" client , > , 8 ");
if (sd != NULL) {
if (!(sd->flags & StreamSizeClient) && sd->du32.mode != DETECT_UINT_GT &&
sd->du32.arg1 != 8) {

@ -85,7 +85,7 @@ void DetectUrilenRegister(void)
static DetectUrilenData *DetectUrilenParse (const char *urilenstr)
{
return rs_detect_urilen_parse(urilenstr);
return SCDetectUrilenParse(urilenstr);
}
/**
@ -140,7 +140,7 @@ static void DetectUrilenFree(DetectEngineCtx *de_ctx, void *ptr)
return;
DetectUrilenData *urilend = (DetectUrilenData *)ptr;
rs_detect_urilen_free(urilend);
SCDetectUrilenFree(urilend);
}
/** \brief set prefilter dsize pair

Loading…
Cancel
Save