detect: SC prefix for extern pub Rust functions

Ticket: #7498
pull/12888/head
Jason Ish 4 months ago committed by Victor Julien
parent 27fd2fe74b
commit bfd6c29f5a

@ -384,7 +384,7 @@ pub fn detect_parse_uint_inclusive<T: DetectIntType>(i: &str) -> IResult<&str, D
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u64_parse( pub unsafe extern "C" fn SCDetectU64Parse(
ustr: *const std::os::raw::c_char, ustr: *const std::os::raw::c_char,
) -> *mut DetectUintData<u64> { ) -> *mut DetectUintData<u64> {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -398,7 +398,7 @@ pub unsafe extern "C" fn rs_detect_u64_parse(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u64_match( pub unsafe extern "C" fn SCDetectU64Match(
arg: u64, ctx: &DetectUintData<u64>, arg: u64, ctx: &DetectUintData<u64>,
) -> std::os::raw::c_int { ) -> std::os::raw::c_int {
if detect_match_uint(ctx, arg) { if detect_match_uint(ctx, arg) {
@ -408,13 +408,13 @@ pub unsafe extern "C" fn rs_detect_u64_match(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u64_free(ctx: &mut DetectUintData<u64>) { pub unsafe extern "C" fn SCDetectU64Free(ctx: &mut DetectUintData<u64>) {
// Just unbox... // Just unbox...
std::mem::drop(Box::from_raw(ctx)); std::mem::drop(Box::from_raw(ctx));
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u32_parse( pub unsafe extern "C" fn SCDetectU32Parse(
ustr: *const std::os::raw::c_char, ustr: *const std::os::raw::c_char,
) -> *mut DetectUintData<u32> { ) -> *mut DetectUintData<u32> {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -428,7 +428,7 @@ pub unsafe extern "C" fn rs_detect_u32_parse(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u32_parse_inclusive( pub unsafe extern "C" fn SCDetectU32ParseInclusive(
ustr: *const std::os::raw::c_char, ustr: *const std::os::raw::c_char,
) -> *mut DetectUintData<u32> { ) -> *mut DetectUintData<u32> {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -442,7 +442,7 @@ pub unsafe extern "C" fn rs_detect_u32_parse_inclusive(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u32_match( pub unsafe extern "C" fn SCDetectU32Match(
arg: u32, ctx: &DetectUintData<u32>, arg: u32, ctx: &DetectUintData<u32>,
) -> std::os::raw::c_int { ) -> std::os::raw::c_int {
if detect_match_uint(ctx, arg) { if detect_match_uint(ctx, arg) {
@ -452,13 +452,13 @@ pub unsafe extern "C" fn rs_detect_u32_match(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u32_free(ctx: &mut DetectUintData<u32>) { pub unsafe extern "C" fn SCDetectU32Free(ctx: &mut DetectUintData<u32>) {
// Just unbox... // Just unbox...
std::mem::drop(Box::from_raw(ctx)); std::mem::drop(Box::from_raw(ctx));
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u8_parse( pub unsafe extern "C" fn SCDetectU8Parse(
ustr: *const std::os::raw::c_char, ustr: *const std::os::raw::c_char,
) -> *mut DetectUintData<u8> { ) -> *mut DetectUintData<u8> {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -472,7 +472,7 @@ pub unsafe extern "C" fn rs_detect_u8_parse(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u8_match( pub unsafe extern "C" fn SCDetectU8Match(
arg: u8, ctx: &DetectUintData<u8>, arg: u8, ctx: &DetectUintData<u8>,
) -> std::os::raw::c_int { ) -> std::os::raw::c_int {
if detect_match_uint(ctx, arg) { if detect_match_uint(ctx, arg) {
@ -482,13 +482,13 @@ pub unsafe extern "C" fn rs_detect_u8_match(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u8_free(ctx: &mut DetectUintData<u8>) { pub unsafe extern "C" fn SCDetectU8Free(ctx: &mut DetectUintData<u8>) {
// Just unbox... // Just unbox...
std::mem::drop(Box::from_raw(ctx)); std::mem::drop(Box::from_raw(ctx));
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u16_parse( pub unsafe extern "C" fn SCDetectU16Parse(
ustr: *const std::os::raw::c_char, ustr: *const std::os::raw::c_char,
) -> *mut DetectUintData<u16> { ) -> *mut DetectUintData<u16> {
let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe let ft_name: &CStr = CStr::from_ptr(ustr); //unsafe
@ -502,7 +502,7 @@ pub unsafe extern "C" fn rs_detect_u16_parse(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u16_match( pub unsafe extern "C" fn SCDetectU16Match(
arg: u16, ctx: &DetectUintData<u16>, arg: u16, ctx: &DetectUintData<u16>,
) -> std::os::raw::c_int { ) -> std::os::raw::c_int {
if detect_match_uint(ctx, arg) { if detect_match_uint(ctx, arg) {
@ -512,7 +512,7 @@ pub unsafe extern "C" fn rs_detect_u16_match(
} }
#[no_mangle] #[no_mangle]
pub unsafe extern "C" fn rs_detect_u16_free(ctx: &mut DetectUintData<u16>) { pub unsafe extern "C" fn SCDetectU16Free(ctx: &mut DetectUintData<u16>) {
// Just unbox... // Just unbox...
std::mem::drop(Box::from_raw(ctx)); std::mem::drop(Box::from_raw(ctx));
} }

@ -21,7 +21,7 @@ use super::dhcp::{
}; };
use super::parser::DHCPOptionWrapper; use super::parser::DHCPOptionWrapper;
use crate::detect::uint::{ use crate::detect::uint::{
rs_detect_u64_free, rs_detect_u64_match, rs_detect_u64_parse, DetectUintData, SCDetectU64Free, SCDetectU64Match, SCDetectU64Parse, DetectUintData,
}; };
use crate::detect::{ use crate::detect::{
DetectHelperBufferRegister, DetectHelperKeywordRegister, DetectSignatureSetAppProto, DetectHelperBufferRegister, DetectHelperKeywordRegister, DetectSignatureSetAppProto,
@ -53,7 +53,7 @@ unsafe extern "C" fn dhcp_detect_leasetime_setup(
if DetectSignatureSetAppProto(s, ALPROTO_DHCP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_DHCP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u64_parse(raw) as *mut c_void; let ctx = SCDetectU64Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -79,7 +79,7 @@ unsafe extern "C" fn dhcp_detect_leasetime_match(
let tx = cast_pointer!(tx, DHCPTransaction); let tx = cast_pointer!(tx, DHCPTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u64>); let ctx = cast_pointer!(ctx, DetectUintData<u64>);
if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_ADDRESS_TIME) { if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_ADDRESS_TIME) {
return rs_detect_u64_match(val, ctx); return SCDetectU64Match(val, ctx);
} }
return 0; return 0;
} }
@ -87,7 +87,7 @@ unsafe extern "C" fn dhcp_detect_leasetime_match(
unsafe extern "C" fn dhcp_detect_time_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn dhcp_detect_time_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u64>); let ctx = cast_pointer!(ctx, DetectUintData<u64>);
rs_detect_u64_free(ctx); SCDetectU64Free(ctx);
} }
unsafe extern "C" fn dhcp_detect_rebindingtime_setup( unsafe extern "C" fn dhcp_detect_rebindingtime_setup(
@ -96,7 +96,7 @@ unsafe extern "C" fn dhcp_detect_rebindingtime_setup(
if DetectSignatureSetAppProto(s, ALPROTO_DHCP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_DHCP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u64_parse(raw) as *mut c_void; let ctx = SCDetectU64Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -122,7 +122,7 @@ unsafe extern "C" fn dhcp_detect_rebindingtime_match(
let tx = cast_pointer!(tx, DHCPTransaction); let tx = cast_pointer!(tx, DHCPTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u64>); let ctx = cast_pointer!(ctx, DetectUintData<u64>);
if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_REBINDING_TIME) { if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_REBINDING_TIME) {
return rs_detect_u64_match(val, ctx); return SCDetectU64Match(val, ctx);
} }
return 0; return 0;
} }
@ -133,7 +133,7 @@ unsafe extern "C" fn dhcp_detect_renewaltime_setup(
if DetectSignatureSetAppProto(s, ALPROTO_DHCP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_DHCP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u64_parse(raw) as *mut c_void; let ctx = SCDetectU64Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -159,7 +159,7 @@ unsafe extern "C" fn dhcp_detect_renewaltime_match(
let tx = cast_pointer!(tx, DHCPTransaction); let tx = cast_pointer!(tx, DHCPTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u64>); let ctx = cast_pointer!(ctx, DetectUintData<u64>);
if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_RENEWAL_TIME) { if let Some(val) = dhcp_tx_get_time(tx, DHCP_OPT_RENEWAL_TIME) {
return rs_detect_u64_match(val, ctx); return SCDetectU64Match(val, ctx);
} }
return 0; return 0;
} }

@ -30,9 +30,9 @@ use super::parser::{
}; };
use crate::detect::uint::{ use crate::detect::uint::{
detect_match_uint, detect_parse_uint_enum, rs_detect_u16_free, rs_detect_u16_match, detect_match_uint, detect_parse_uint_enum, SCDetectU16Free, SCDetectU16Match,
rs_detect_u16_parse, rs_detect_u32_free, rs_detect_u32_match, rs_detect_u32_parse, SCDetectU16Parse, SCDetectU32Free, SCDetectU32Match, SCDetectU32Parse,
rs_detect_u8_free, rs_detect_u8_match, rs_detect_u8_parse, DetectUintData, SCDetectU8Free, SCDetectU8Match, SCDetectU8Parse, DetectUintData,
}; };
use crate::detect::{ use crate::detect::{
DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister, DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister,
@ -490,7 +490,7 @@ unsafe extern "C" fn capabilities_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -529,7 +529,7 @@ unsafe extern "C" fn capabilities_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(v) = tx_get_capabilities(tx) { if let Some(v) = tx_get_capabilities(tx) {
return rs_detect_u16_match(v, ctx); return SCDetectU16Match(v, ctx);
} }
return 0; return 0;
} }
@ -537,7 +537,7 @@ unsafe extern "C" fn capabilities_match(
unsafe extern "C" fn capabilities_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn capabilities_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn cip_attribute_setup( unsafe extern "C" fn cip_attribute_setup(
@ -546,7 +546,7 @@ unsafe extern "C" fn cip_attribute_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -577,7 +577,7 @@ unsafe extern "C" fn cip_attribute_match(
unsafe extern "C" fn cip_attribute_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn cip_attribute_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn cip_class_setup( unsafe extern "C" fn cip_class_setup(
@ -586,7 +586,7 @@ unsafe extern "C" fn cip_class_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -617,7 +617,7 @@ unsafe extern "C" fn cip_class_match(
unsafe extern "C" fn cip_class_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn cip_class_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn vendor_id_setup( unsafe extern "C" fn vendor_id_setup(
@ -626,7 +626,7 @@ unsafe extern "C" fn vendor_id_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -665,7 +665,7 @@ unsafe extern "C" fn vendor_id_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(val) = tx_get_vendor_id(tx) { if let Some(val) = tx_get_vendor_id(tx) {
return rs_detect_u16_match(val, ctx); return SCDetectU16Match(val, ctx);
} }
return 0; return 0;
} }
@ -673,7 +673,7 @@ unsafe extern "C" fn vendor_id_match(
unsafe extern "C" fn vendor_id_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn vendor_id_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn status_setup( unsafe extern "C" fn status_setup(
@ -700,7 +700,7 @@ unsafe extern "C" fn status_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
if let Some(x) = enip_get_status(tx, flags.into()) { if let Some(x) = enip_get_status(tx, flags.into()) {
return rs_detect_u32_match(x, ctx); return SCDetectU32Match(x, ctx);
} }
return 0; return 0;
} }
@ -708,7 +708,7 @@ unsafe extern "C" fn status_match(
unsafe extern "C" fn status_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn status_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn state_setup( unsafe extern "C" fn state_setup(
@ -717,7 +717,7 @@ unsafe extern "C" fn state_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u8_parse(raw) as *mut c_void; let ctx = SCDetectU8Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -748,7 +748,7 @@ unsafe extern "C" fn state_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
if let Some(val) = tx_get_state(tx) { if let Some(val) = tx_get_state(tx) {
return rs_detect_u8_match(val, ctx); return SCDetectU8Match(val, ctx);
} }
return 0; return 0;
} }
@ -756,7 +756,7 @@ unsafe extern "C" fn state_match(
unsafe extern "C" fn state_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn state_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
unsafe extern "C" fn serial_setup( unsafe extern "C" fn serial_setup(
@ -765,7 +765,7 @@ unsafe extern "C" fn serial_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -796,7 +796,7 @@ unsafe extern "C" fn serial_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
if let Some(val) = tx_get_serial(tx) { if let Some(val) = tx_get_serial(tx) {
return rs_detect_u32_match(val, ctx); return SCDetectU32Match(val, ctx);
} }
return 0; return 0;
} }
@ -804,7 +804,7 @@ unsafe extern "C" fn serial_match(
unsafe extern "C" fn serial_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn serial_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn revision_setup( unsafe extern "C" fn revision_setup(
@ -813,7 +813,7 @@ unsafe extern "C" fn revision_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -846,7 +846,7 @@ unsafe extern "C" fn revision_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(val) = tx_get_revision(tx) { if let Some(val) = tx_get_revision(tx) {
return rs_detect_u16_match(val, ctx); return SCDetectU16Match(val, ctx);
} }
return 0; return 0;
} }
@ -854,7 +854,7 @@ unsafe extern "C" fn revision_match(
unsafe extern "C" fn revision_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn revision_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn protocol_version_setup( unsafe extern "C" fn protocol_version_setup(
@ -863,7 +863,7 @@ unsafe extern "C" fn protocol_version_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -889,7 +889,7 @@ unsafe extern "C" fn protocol_version_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(val) = tx_get_protocol_version(tx, flags.into()) { if let Some(val) = tx_get_protocol_version(tx, flags.into()) {
return rs_detect_u16_match(val, ctx); return SCDetectU16Match(val, ctx);
} }
return 0; return 0;
} }
@ -897,7 +897,7 @@ unsafe extern "C" fn protocol_version_match(
unsafe extern "C" fn protocol_version_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn protocol_version_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn product_code_setup( unsafe extern "C" fn product_code_setup(
@ -906,7 +906,7 @@ unsafe extern "C" fn product_code_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -945,7 +945,7 @@ unsafe extern "C" fn product_code_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(v) = tx_get_product_code(tx) { if let Some(v) = tx_get_product_code(tx) {
return rs_detect_u16_match(v, ctx); return SCDetectU16Match(v, ctx);
} }
return 0; return 0;
} }
@ -953,7 +953,7 @@ unsafe extern "C" fn product_code_match(
unsafe extern "C" fn product_code_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn product_code_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn identity_status_setup( unsafe extern "C" fn identity_status_setup(
@ -962,7 +962,7 @@ unsafe extern "C" fn identity_status_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -1001,7 +1001,7 @@ unsafe extern "C" fn identity_status_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(v) = tx_get_identity_status(tx) { if let Some(v) = tx_get_identity_status(tx) {
return rs_detect_u16_match(v, ctx); return SCDetectU16Match(v, ctx);
} }
return 0; return 0;
} }
@ -1009,7 +1009,7 @@ unsafe extern "C" fn identity_status_match(
unsafe extern "C" fn identity_status_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn identity_status_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn device_type_setup( unsafe extern "C" fn device_type_setup(
@ -1018,7 +1018,7 @@ unsafe extern "C" fn device_type_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -1057,7 +1057,7 @@ unsafe extern "C" fn device_type_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(v) = tx_get_device_type(tx) { if let Some(v) = tx_get_device_type(tx) {
return rs_detect_u16_match(v, ctx); return SCDetectU16Match(v, ctx);
} }
return 0; return 0;
} }
@ -1065,7 +1065,7 @@ unsafe extern "C" fn device_type_match(
unsafe extern "C" fn device_type_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn device_type_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn command_setup( unsafe extern "C" fn command_setup(
@ -1105,7 +1105,7 @@ unsafe extern "C" fn command_match(
let tx = cast_pointer!(tx, EnipTransaction); let tx = cast_pointer!(tx, EnipTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
if let Some(v) = tx_get_command(tx, flags) { if let Some(v) = tx_get_command(tx, flags) {
return rs_detect_u16_match(v, ctx); return SCDetectU16Match(v, ctx);
} }
return 0; return 0;
} }
@ -1113,7 +1113,7 @@ unsafe extern "C" fn command_match(
unsafe extern "C" fn command_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn command_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
unsafe extern "C" fn cip_status_setup( unsafe extern "C" fn cip_status_setup(
@ -1122,7 +1122,7 @@ unsafe extern "C" fn cip_status_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u8_parse(raw) as *mut c_void; let ctx = SCDetectU8Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -1153,7 +1153,7 @@ unsafe extern "C" fn cip_status_match(
unsafe extern "C" fn cip_status_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn cip_status_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
unsafe extern "C" fn cip_instance_setup( unsafe extern "C" fn cip_instance_setup(
@ -1162,7 +1162,7 @@ unsafe extern "C" fn cip_instance_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -1193,7 +1193,7 @@ unsafe extern "C" fn cip_instance_match(
unsafe extern "C" fn cip_instance_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn cip_instance_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn cip_extendedstatus_setup( unsafe extern "C" fn cip_extendedstatus_setup(
@ -1202,7 +1202,7 @@ unsafe extern "C" fn cip_extendedstatus_setup(
if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_ENIP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u16_parse(raw) as *mut c_void; let ctx = SCDetectU16Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -1233,7 +1233,7 @@ unsafe extern "C" fn cip_extendedstatus_match(
unsafe extern "C" fn cip_extendedstatus_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn cip_extendedstatus_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u16>); let ctx = cast_pointer!(ctx, DetectUintData<u16>);
rs_detect_u16_free(ctx); SCDetectU16Free(ctx);
} }
pub unsafe extern "C" fn product_name_setup( pub unsafe extern "C" fn product_name_setup(

@ -17,8 +17,8 @@
use super::ldap::{LdapTransaction, ALPROTO_LDAP}; use super::ldap::{LdapTransaction, ALPROTO_LDAP};
use crate::detect::uint::{ use crate::detect::uint::{
detect_match_uint, detect_parse_uint_enum, rs_detect_u32_free, rs_detect_u32_parse, detect_match_uint, detect_parse_uint_enum, SCDetectU32Free, SCDetectU32Parse,
rs_detect_u8_free, DetectUintData, SCDetectU8Free, DetectUintData,
}; };
use crate::detect::{ use crate::detect::{
DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister, DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister,
@ -125,7 +125,7 @@ unsafe extern "C" fn ldap_detect_request_operation_match(
unsafe extern "C" fn ldap_detect_request_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn ldap_detect_request_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
fn parse_ldap_index(parts: &[&str]) -> Option<LdapIndex> { fn parse_ldap_index(parts: &[&str]) -> Option<LdapIndex> {
@ -265,7 +265,7 @@ unsafe extern "C" fn ldap_detect_responses_count_setup(
if DetectSignatureSetAppProto(s, ALPROTO_LDAP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_LDAP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -297,7 +297,7 @@ unsafe extern "C" fn ldap_detect_responses_count_match(
unsafe extern "C" fn ldap_detect_responses_count_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn ldap_detect_responses_count_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn ldap_detect_request_dn_setup( unsafe extern "C" fn ldap_detect_request_dn_setup(

@ -18,8 +18,8 @@
// written by Sascha Steinbiss <sascha@steinbiss.name> // written by Sascha Steinbiss <sascha@steinbiss.name>
use crate::detect::uint::{ use crate::detect::uint::{
detect_match_uint, detect_parse_uint, detect_parse_uint_enum, rs_detect_u8_free, detect_match_uint, detect_parse_uint, detect_parse_uint_enum, SCDetectU8Free,
rs_detect_u8_parse, DetectUintData, DetectUintMode, SCDetectU8Parse, DetectUintData, DetectUintMode,
}; };
use crate::detect::{ use crate::detect::{
DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister, DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister,
@ -450,7 +450,7 @@ unsafe extern "C" fn mqtt_type_match(
unsafe extern "C" fn mqtt_type_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn mqtt_type_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
unsafe extern "C" fn mqtt_reason_code_setup( unsafe extern "C" fn mqtt_reason_code_setup(
@ -459,7 +459,7 @@ unsafe extern "C" fn mqtt_reason_code_setup(
if DetectSignatureSetAppProto(s, ALPROTO_MQTT) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_MQTT) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u8_parse(raw) as *mut c_void; let ctx = SCDetectU8Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -495,7 +495,7 @@ unsafe extern "C" fn mqtt_reason_code_match(
unsafe extern "C" fn mqtt_reason_code_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn mqtt_reason_code_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
unsafe extern "C" fn mqtt_parse_qos(ustr: *const std::os::raw::c_char) -> *mut u8 { unsafe extern "C" fn mqtt_parse_qos(ustr: *const std::os::raw::c_char) -> *mut u8 {
@ -672,7 +672,7 @@ unsafe extern "C" fn mqtt_protocol_version_setup(
if DetectSignatureSetAppProto(s, ALPROTO_MQTT) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_MQTT) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u8_parse(raw) as *mut c_void; let ctx = SCDetectU8Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -705,7 +705,7 @@ unsafe extern "C" fn mqtt_protocol_version_match(
unsafe extern "C" fn mqtt_protocol_version_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn mqtt_protocol_version_free(_de: *mut c_void, ctx: *mut c_void) {
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
// maybe to factor with websocket.flags // maybe to factor with websocket.flags
@ -817,7 +817,7 @@ unsafe extern "C" fn mqtt_flags_match(
unsafe extern "C" fn mqtt_flags_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn mqtt_flags_free(_de: *mut c_void, ctx: *mut c_void) {
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
fn parse_conn_flag_list_item(s: &str) -> IResult<&str, MqttParsedFlagItem> { fn parse_conn_flag_list_item(s: &str) -> IResult<&str, MqttParsedFlagItem> {
@ -933,7 +933,7 @@ unsafe extern "C" fn mqtt_conn_flags_match(
unsafe extern "C" fn mqtt_conn_flags_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn mqtt_conn_flags_free(_de: *mut c_void, ctx: *mut c_void) {
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
unsafe extern "C" fn mqtt_conn_willtopic_setup( unsafe extern "C" fn mqtt_conn_willtopic_setup(

@ -20,7 +20,7 @@
use super::parser::RFBSecurityResultStatus; use super::parser::RFBSecurityResultStatus;
use super::rfb::{RFBTransaction, ALPROTO_RFB}; use super::rfb::{RFBTransaction, ALPROTO_RFB};
use crate::detect::uint::{ use crate::detect::uint::{
detect_match_uint, detect_parse_uint_enum, rs_detect_u32_free, rs_detect_u32_parse, detect_match_uint, detect_parse_uint_enum, SCDetectU32Free, SCDetectU32Parse,
DetectUintData, DetectUintData,
}; };
use crate::detect::{ use crate::detect::{
@ -89,7 +89,7 @@ unsafe extern "C" fn rfb_sec_type_setup(
if DetectSignatureSetAppProto(s, ALPROTO_RFB) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_RFB) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -121,7 +121,7 @@ unsafe extern "C" fn rfb_sec_type_match(
unsafe extern "C" fn rfb_sec_type_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn rfb_sec_type_free(_de: *mut c_void, ctx: *mut c_void) {
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn rfb_parse_sec_result( unsafe extern "C" fn rfb_parse_sec_result(
@ -183,7 +183,7 @@ unsafe extern "C" fn rfb_sec_result_match(
unsafe extern "C" fn rfb_sec_result_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn rfb_sec_result_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
#[no_mangle] #[no_mangle]

@ -19,7 +19,7 @@
use super::snmp::{SNMPTransaction, ALPROTO_SNMP}; use super::snmp::{SNMPTransaction, ALPROTO_SNMP};
use crate::detect::uint::{ use crate::detect::uint::{
rs_detect_u32_free, rs_detect_u32_match, rs_detect_u32_parse, DetectUintData, SCDetectU32Free, SCDetectU32Match, SCDetectU32Parse, DetectUintData,
}; };
use crate::detect::{ use crate::detect::{
DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister, DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister,
@ -41,7 +41,7 @@ unsafe extern "C" fn snmp_detect_version_setup(
if DetectSignatureSetAppProto(s, ALPROTO_SNMP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_SNMP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -59,13 +59,13 @@ unsafe extern "C" fn snmp_detect_version_match(
) -> c_int { ) -> c_int {
let tx = cast_pointer!(tx, SNMPTransaction); let tx = cast_pointer!(tx, SNMPTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
return rs_detect_u32_match(tx.version, ctx); return SCDetectU32Match(tx.version, ctx);
} }
unsafe extern "C" fn snmp_detect_version_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn snmp_detect_version_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn snmp_detect_pdutype_setup( unsafe extern "C" fn snmp_detect_pdutype_setup(
@ -74,7 +74,7 @@ unsafe extern "C" fn snmp_detect_pdutype_setup(
if DetectSignatureSetAppProto(s, ALPROTO_SNMP) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_SNMP) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -94,7 +94,7 @@ unsafe extern "C" fn snmp_detect_pdutype_match(
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
if let Some(ref info) = tx.info { if let Some(ref info) = tx.info {
let pdu_type = info.pdu_type.0; let pdu_type = info.pdu_type.0;
return rs_detect_u32_match(pdu_type, ctx); return SCDetectU32Match(pdu_type, ctx);
} }
return 0; return 0;
} }
@ -102,7 +102,7 @@ unsafe extern "C" fn snmp_detect_pdutype_match(
unsafe extern "C" fn snmp_detect_pdutype_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn snmp_detect_pdutype_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
pub unsafe extern "C" fn snmp_detect_usm_setup( pub unsafe extern "C" fn snmp_detect_usm_setup(

@ -17,8 +17,8 @@
use super::websocket::{WebSocketTransaction, ALPROTO_WEBSOCKET}; use super::websocket::{WebSocketTransaction, ALPROTO_WEBSOCKET};
use crate::detect::uint::{ use crate::detect::uint::{
detect_parse_uint, detect_parse_uint_enum, rs_detect_u32_free, rs_detect_u32_match, detect_parse_uint, detect_parse_uint_enum, SCDetectU32Free, SCDetectU32Match,
rs_detect_u32_parse, rs_detect_u8_free, rs_detect_u8_match, DetectUintData, DetectUintMode, SCDetectU32Parse, SCDetectU8Free, SCDetectU8Match, DetectUintData, DetectUintMode,
}; };
use crate::detect::{ use crate::detect::{
DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister, DetectBufferSetActiveList, DetectHelperBufferMpmRegister, DetectHelperBufferRegister,
@ -148,13 +148,13 @@ unsafe extern "C" fn websocket_detect_opcode_match(
) -> c_int { ) -> c_int {
let tx = cast_pointer!(tx, WebSocketTransaction); let tx = cast_pointer!(tx, WebSocketTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
return rs_detect_u8_match(tx.pdu.opcode, ctx); return SCDetectU8Match(tx.pdu.opcode, ctx);
} }
unsafe extern "C" fn websocket_detect_opcode_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn websocket_detect_opcode_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
unsafe extern "C" fn websocket_detect_mask_setup( unsafe extern "C" fn websocket_detect_mask_setup(
@ -163,7 +163,7 @@ unsafe extern "C" fn websocket_detect_mask_setup(
if DetectSignatureSetAppProto(s, ALPROTO_WEBSOCKET) != 0 { if DetectSignatureSetAppProto(s, ALPROTO_WEBSOCKET) != 0 {
return -1; return -1;
} }
let ctx = rs_detect_u32_parse(raw) as *mut c_void; let ctx = SCDetectU32Parse(raw) as *mut c_void;
if ctx.is_null() { if ctx.is_null() {
return -1; return -1;
} }
@ -189,7 +189,7 @@ unsafe extern "C" fn websocket_detect_mask_match(
let tx = cast_pointer!(tx, WebSocketTransaction); let tx = cast_pointer!(tx, WebSocketTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
if let Some(xorkey) = tx.pdu.mask { if let Some(xorkey) = tx.pdu.mask {
return rs_detect_u32_match(xorkey, ctx); return SCDetectU32Match(xorkey, ctx);
} }
return 0; return 0;
} }
@ -197,7 +197,7 @@ unsafe extern "C" fn websocket_detect_mask_match(
unsafe extern "C" fn websocket_detect_mask_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn websocket_detect_mask_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u32>); let ctx = cast_pointer!(ctx, DetectUintData<u32>);
rs_detect_u32_free(ctx); SCDetectU32Free(ctx);
} }
unsafe extern "C" fn websocket_detect_flags_setup( unsafe extern "C" fn websocket_detect_flags_setup(
@ -231,13 +231,13 @@ unsafe extern "C" fn websocket_detect_flags_match(
) -> c_int { ) -> c_int {
let tx = cast_pointer!(tx, WebSocketTransaction); let tx = cast_pointer!(tx, WebSocketTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
return rs_detect_u8_match(tx.pdu.flags, ctx); return SCDetectU8Match(tx.pdu.flags, ctx);
} }
unsafe extern "C" fn websocket_detect_flags_free(_de: *mut c_void, ctx: *mut c_void) { unsafe extern "C" fn websocket_detect_flags_free(_de: *mut c_void, ctx: *mut c_void) {
// Just unbox... // Just unbox...
let ctx = cast_pointer!(ctx, DetectUintData<u8>); let ctx = cast_pointer!(ctx, DetectUintData<u8>);
rs_detect_u8_free(ctx); SCDetectU8Free(ctx);
} }
pub unsafe extern "C" fn websocket_detect_payload_setup( pub unsafe extern "C" fn websocket_detect_payload_setup(

@ -219,7 +219,7 @@ void DetectBsizeFree(DetectEngineCtx *de_ctx, void *ptr)
return; return;
DetectU64Data *bsz = (DetectU64Data *)ptr; DetectU64Data *bsz = (DetectU64Data *)ptr;
rs_detect_u64_free(bsz); SCDetectU64Free(bsz);
} }
#ifdef UNITTESTS #ifdef UNITTESTS

@ -58,7 +58,7 @@ static void DetectDnsOpcodeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
SCEnter(); SCEnter();
if (ptr != NULL) { if (ptr != NULL) {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }
SCReturn; SCReturn;
} }

@ -54,7 +54,7 @@ static void DetectDnsRcodeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
SCEnter(); SCEnter();
if (ptr != NULL) { if (ptr != NULL) {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }
SCReturn; SCReturn;
} }

@ -54,7 +54,7 @@ static void DetectDnsRrtypeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
SCEnter(); SCEnter();
if (ptr != NULL) { if (ptr != NULL) {
rs_detect_u16_free(ptr); SCDetectU16Free(ptr);
} }
SCReturn; SCReturn;
} }

@ -137,7 +137,7 @@ static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *
SigMatch *sm = SigMatchAppendSMToList( SigMatch *sm = SigMatchAppendSMToList(
de_ctx, s, DETECT_DSIZE, (SigMatchCtx *)dd, DETECT_SM_LIST_MATCH); de_ctx, s, DETECT_DSIZE, (SigMatchCtx *)dd, DETECT_SM_LIST_MATCH);
if (sm == NULL) { if (sm == NULL) {
rs_detect_u16_free(dd); SCDetectU16Free(dd);
return -1; return -1;
} }
@ -162,7 +162,7 @@ static int DetectDsizeSetup (DetectEngineCtx *de_ctx, Signature *s, const char *
*/ */
void DetectDsizeFree(DetectEngineCtx *de_ctx, void *de_ptr) void DetectDsizeFree(DetectEngineCtx *de_ctx, void *de_ptr)
{ {
rs_detect_u16_free(de_ptr); SCDetectU16Free(de_ptr);
} }
/* prefilter code */ /* prefilter code */

@ -30,7 +30,7 @@
int DetectU32Match(const uint32_t parg, const DetectUintData_u32 *du32) int DetectU32Match(const uint32_t parg, const DetectUintData_u32 *du32)
{ {
return rs_detect_u32_match(parg, du32); return SCDetectU32Match(parg, du32);
} }
/** /**
@ -44,7 +44,7 @@ int DetectU32Match(const uint32_t parg, const DetectUintData_u32 *du32)
DetectUintData_u32 *DetectU32Parse(const char *u32str) DetectUintData_u32 *DetectU32Parse(const char *u32str)
{ {
return rs_detect_u32_parse(u32str); return SCDetectU32Parse(u32str);
} }
void void
@ -70,7 +70,7 @@ PrefilterPacketU32Compare(PrefilterPacketHeaderValue v, void *smctx)
//same as u32 but with u8 //same as u32 but with u8
int DetectU8Match(const uint8_t parg, const DetectUintData_u8 *du8) int DetectU8Match(const uint8_t parg, const DetectUintData_u8 *du8)
{ {
return rs_detect_u8_match(parg, du8); return SCDetectU8Match(parg, du8);
} }
/** /**
@ -84,7 +84,7 @@ int DetectU8Match(const uint8_t parg, const DetectUintData_u8 *du8)
DetectUintData_u8 *DetectU8Parse(const char *u8str) DetectUintData_u8 *DetectU8Parse(const char *u8str)
{ {
return rs_detect_u8_parse(u8str); return SCDetectU8Parse(u8str);
} }
void PrefilterPacketU8Set(PrefilterPacketHeaderValue *v, void *smctx) void PrefilterPacketU8Set(PrefilterPacketHeaderValue *v, void *smctx)
@ -106,7 +106,7 @@ bool PrefilterPacketU8Compare(PrefilterPacketHeaderValue v, void *smctx)
// same as u32 but with u16 // same as u32 but with u16
int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16) int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
{ {
return rs_detect_u16_match(parg, du16); return SCDetectU16Match(parg, du16);
} }
/** /**
@ -120,7 +120,7 @@ int DetectU16Match(const uint16_t parg, const DetectUintData_u16 *du16)
DetectUintData_u16 *DetectU16Parse(const char *u16str) DetectUintData_u16 *DetectU16Parse(const char *u16str)
{ {
return rs_detect_u16_parse(u16str); return SCDetectU16Parse(u16str);
} }
void PrefilterPacketU16Set(PrefilterPacketHeaderValue *v, void *smctx) void PrefilterPacketU16Set(PrefilterPacketHeaderValue *v, void *smctx)
@ -141,10 +141,10 @@ bool PrefilterPacketU16Compare(PrefilterPacketHeaderValue v, void *smctx)
int DetectU64Match(const uint64_t parg, const DetectUintData_u64 *du64) int DetectU64Match(const uint64_t parg, const DetectUintData_u64 *du64)
{ {
return rs_detect_u64_match(parg, du64); return SCDetectU64Match(parg, du64);
} }
DetectUintData_u64 *DetectU64Parse(const char *u64str) DetectUintData_u64 *DetectU64Parse(const char *u64str)
{ {
return rs_detect_u64_parse(u64str); return SCDetectU64Parse(u64str);
} }

@ -143,7 +143,7 @@ static int DetectFilesizeSetup (DetectEngineCtx *de_ctx, Signature *s, const cha
*/ */
static void DetectFilesizeFree(DetectEngineCtx *de_ctx, void *ptr) static void DetectFilesizeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u64_free(ptr); SCDetectU64Free(ptr);
} }
#ifdef UNITTESTS #ifdef UNITTESTS

@ -37,7 +37,7 @@ static int DetectFlowAgeMatch(
static void DetectFlowAgeFree(DetectEngineCtx *de_ctx, void *ptr) static void DetectFlowAgeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }
static int DetectFlowAgeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) static int DetectFlowAgeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)

@ -402,7 +402,7 @@ static int DetectHTTP2prioritySetup (DetectEngineCtx *de_ctx, Signature *s, cons
if (SigMatchAppendSMToList(de_ctx, s, DETECT_HTTP2_PRIORITY, (SigMatchCtx *)prio, if (SigMatchAppendSMToList(de_ctx, s, DETECT_HTTP2_PRIORITY, (SigMatchCtx *)prio,
g_http2_match_buffer_id) == NULL) { g_http2_match_buffer_id) == NULL) {
rs_detect_u8_free(prio); SCDetectU8Free(prio);
return -1; return -1;
} }
@ -416,7 +416,7 @@ static int DetectHTTP2prioritySetup (DetectEngineCtx *de_ctx, Signature *s, cons
*/ */
void DetectHTTP2priorityFree(DetectEngineCtx *de_ctx, void *ptr) void DetectHTTP2priorityFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }
/** /**
@ -464,7 +464,7 @@ static int DetectHTTP2windowSetup (DetectEngineCtx *de_ctx, Signature *s, const
if (SigMatchAppendSMToList(de_ctx, s, DETECT_HTTP2_WINDOW, (SigMatchCtx *)wu, if (SigMatchAppendSMToList(de_ctx, s, DETECT_HTTP2_WINDOW, (SigMatchCtx *)wu,
g_http2_match_buffer_id) == NULL) { g_http2_match_buffer_id) == NULL) {
rs_detect_u32_free(wu); SCDetectU32Free(wu);
return -1; return -1;
} }
@ -478,7 +478,7 @@ static int DetectHTTP2windowSetup (DetectEngineCtx *de_ctx, Signature *s, const
*/ */
void DetectHTTP2windowFree(DetectEngineCtx *de_ctx, void *ptr) void DetectHTTP2windowFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }
/** /**
@ -510,7 +510,7 @@ static int DetectHTTP2sizeUpdateSetup (DetectEngineCtx *de_ctx, Signature *s, co
if (DetectSignatureSetAppProto(s, ALPROTO_HTTP2) != 0) if (DetectSignatureSetAppProto(s, ALPROTO_HTTP2) != 0)
return -1; return -1;
void *su = rs_detect_u64_parse(str); void *su = SCDetectU64Parse(str);
if (su == NULL) if (su == NULL)
return -1; return -1;
@ -530,7 +530,7 @@ static int DetectHTTP2sizeUpdateSetup (DetectEngineCtx *de_ctx, Signature *s, co
*/ */
void DetectHTTP2sizeUpdateFree(DetectEngineCtx *de_ctx, void *ptr) void DetectHTTP2sizeUpdateFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u64_free(ptr); SCDetectU64Free(ptr);
} }
/** /**

@ -134,7 +134,7 @@ static int DetectICMPv6mtuSetup (DetectEngineCtx *de_ctx, Signature *s, const ch
*/ */
void DetectICMPv6mtuFree(DetectEngineCtx *de_ctx, void *ptr) void DetectICMPv6mtuFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }
/* prefilter code */ /* prefilter code */

@ -125,7 +125,7 @@ static int DetectICodeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *i
if (SigMatchAppendSMToList(de_ctx, s, DETECT_ICODE, (SigMatchCtx *)icd, DETECT_SM_LIST_MATCH) == if (SigMatchAppendSMToList(de_ctx, s, DETECT_ICODE, (SigMatchCtx *)icd, DETECT_SM_LIST_MATCH) ==
NULL) { NULL) {
rs_detect_u8_free(icd); SCDetectU8Free(icd);
return -1; return -1;
} }
s->flags |= SIG_FLAG_REQUIRE_PACKET; s->flags |= SIG_FLAG_REQUIRE_PACKET;
@ -140,7 +140,7 @@ static int DetectICodeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *i
*/ */
void DetectICodeFree(DetectEngineCtx *de_ctx, void *ptr) void DetectICodeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }
/* prefilter code */ /* prefilter code */

@ -135,5 +135,5 @@ error:
*/ */
static void DetectIkeExchTypeFree(DetectEngineCtx *de_ctx, void *ptr) static void DetectIkeExchTypeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }

@ -141,5 +141,5 @@ error:
*/ */
static void DetectIkeKeyExchangePayloadLengthFree(DetectEngineCtx *de_ctx, void *ptr) static void DetectIkeKeyExchangePayloadLengthFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }

@ -136,5 +136,5 @@ error:
*/ */
static void DetectIkeNoncePayloadLengthFree(DetectEngineCtx *de_ctx, void *ptr) static void DetectIkeNoncePayloadLengthFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }

@ -138,7 +138,7 @@ static int DetectITypeSetup(DetectEngineCtx *de_ctx, Signature *s, const char *i
void DetectITypeFree(DetectEngineCtx *de_ctx, void *ptr) void DetectITypeFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
DetectU8Data *itd = (DetectU8Data *)ptr; DetectU8Data *itd = (DetectU8Data *)ptr;
rs_detect_u8_free(itd); SCDetectU8Free(itd);
} }
/* prefilter code /* prefilter code

@ -133,7 +133,7 @@ static int DetectNfsProcedureMatch (DetectEngineThreadCtx *det_ctx,
*/ */
static DetectU32Data *DetectNfsProcedureParse(const char *rawstr) static DetectU32Data *DetectNfsProcedureParse(const char *rawstr)
{ {
return rs_detect_u32_parse_inclusive(rawstr); return SCDetectU32ParseInclusive(rawstr);
} }
@ -185,7 +185,7 @@ static int DetectNfsProcedureSetup (DetectEngineCtx *de_ctx, Signature *s,
*/ */
void DetectNfsProcedureFree(DetectEngineCtx *de_ctx, void *ptr) void DetectNfsProcedureFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }
#ifdef UNITTESTS #ifdef UNITTESTS

@ -118,7 +118,7 @@ static int DetectNfsVersionMatch (DetectEngineThreadCtx *det_ctx,
*/ */
static DetectU32Data *DetectNfsVersionParse(const char *rawstr) static DetectU32Data *DetectNfsVersionParse(const char *rawstr)
{ {
return rs_detect_u32_parse_inclusive(rawstr); return SCDetectU32ParseInclusive(rawstr);
} }
@ -171,5 +171,5 @@ error:
*/ */
void DetectNfsVersionFree(DetectEngineCtx *de_ctx, void *ptr) void DetectNfsVersionFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }

@ -121,7 +121,7 @@ static int DetectTcpmssSetup (DetectEngineCtx *de_ctx, Signature *s, const char
*/ */
void DetectTcpmssFree(DetectEngineCtx *de_ctx, void *ptr) void DetectTcpmssFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u16_free(ptr); SCDetectU16Free(ptr);
} }
/* prefilter code */ /* prefilter code */

@ -127,7 +127,7 @@ static int DetectTemplate2Setup (DetectEngineCtx *de_ctx, Signature *s, const ch
*/ */
void DetectTemplate2Free(DetectEngineCtx *de_ctx, void *ptr) void DetectTemplate2Free(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }
/* prefilter code */ /* prefilter code */

@ -210,7 +210,7 @@ static int DetectTLSCertChainLenMatch(DetectEngineThreadCtx *det_ctx, Flow *f, u
*/ */
static void DetectTLSCertChainLenFree(DetectEngineCtx *de_ctx, void *ptr) static void DetectTLSCertChainLenFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u32_free(ptr); SCDetectU32Free(ptr);
} }
/** /**
@ -237,7 +237,7 @@ static int DetectTLSCertChainLenSetup(DetectEngineCtx *de_ctx, Signature *s, con
if (SigMatchAppendSMToList(de_ctx, s, KEYWORD_ID, (SigMatchCtx *)dd, g_tls_cert_buffer_id) == if (SigMatchAppendSMToList(de_ctx, s, KEYWORD_ID, (SigMatchCtx *)dd, g_tls_cert_buffer_id) ==
NULL) { NULL) {
rs_detect_u32_free(dd); SCDetectU32Free(dd);
return -1; return -1;
} }
return 0; return 0;

@ -131,7 +131,7 @@ static int DetectTtlSetup (DetectEngineCtx *de_ctx, Signature *s, const char *tt
*/ */
void DetectTtlFree(DetectEngineCtx *de_ctx, void *ptr) void DetectTtlFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }
/* prefilter code */ /* prefilter code */

@ -152,7 +152,7 @@ static int DetectVlanLayersMatch(
static void DetectVlanLayersFree(DetectEngineCtx *de_ctx, void *ptr) static void DetectVlanLayersFree(DetectEngineCtx *de_ctx, void *ptr)
{ {
rs_detect_u8_free(ptr); SCDetectU8Free(ptr);
} }
static int DetectVlanLayersSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr) static int DetectVlanLayersSetup(DetectEngineCtx *de_ctx, Signature *s, const char *rawstr)

Loading…
Cancel
Save