Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next/696/20250121/v1 #12445

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
6 changes: 2 additions & 4 deletions rust/src/applayer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ pub unsafe extern "C" fn SCTxDataUpdateFileFlags(txd: &mut AppLayerTxData, state
#[macro_export]
macro_rules!export_tx_data_get {
($name:ident, $type:ty) => {
#[no_mangle]
pub unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void)
unsafe extern "C" fn $name(tx: *mut std::os::raw::c_void)
-> *mut $crate::applayer::AppLayerTxData
{
let tx = &mut *(tx as *mut $type);
Expand All @@ -272,8 +271,7 @@ impl AppLayerStateData {
#[macro_export]
macro_rules!export_state_data_get {
($name:ident, $type:ty) => {
#[no_mangle]
pub unsafe extern "C" fn $name(state: *mut std::os::raw::c_void)
unsafe extern "C" fn $name(state: *mut std::os::raw::c_void)
-> *mut $crate::applayer::AppLayerStateData
{
let state = &mut *(state as *mut $type);
Expand Down
8 changes: 4 additions & 4 deletions rust/src/applayertemplate/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,8 @@ unsafe extern "C" fn rs_template_tx_get_alstate_progress(tx: *mut c_void, _direc
return 0;
}

export_tx_data_get!(rs_template_get_tx_data, TemplateTransaction);
export_state_data_get!(rs_template_get_state_data, TemplateState);
export_tx_data_get!(template_get_tx_data, TemplateTransaction);
export_state_data_get!(template_get_state_data, TemplateState);

// Parser name as a C style string.
const PARSER_NAME: &[u8] = b"template\0";
Expand Down Expand Up @@ -390,8 +390,8 @@ pub unsafe extern "C" fn rs_template_register_parser() {
get_tx_iterator: Some(
applayer::state_get_tx_iterator::<TemplateState, TemplateTransaction>,
),
get_tx_data: rs_template_get_tx_data,
get_state_data: rs_template_get_state_data,
get_tx_data: template_get_tx_data,
get_state_data: template_get_state_data,
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
get_frame_id_by_name: None,
Expand Down
8 changes: 4 additions & 4 deletions rust/src/bittorrent_dht/bittorrent_dht.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,8 @@ impl BitTorrentDHTState {

// C exports.

export_tx_data_get!(rs_bittorrent_dht_get_tx_data, BitTorrentDHTTransaction);
export_state_data_get!(rs_bittorrent_dht_get_state_data, BitTorrentDHTState);
export_tx_data_get!(bittorrent_dht_get_tx_data, BitTorrentDHTTransaction);
export_state_data_get!(bittorrent_dht_get_state_data, BitTorrentDHTState);

#[no_mangle]
pub extern "C" fn rs_bittorrent_dht_state_new(
Expand Down Expand Up @@ -280,8 +280,8 @@ pub unsafe extern "C" fn rs_bittorrent_dht_udp_register_parser() {
localstorage_free: None,
get_tx_files: None,
get_tx_iterator: Some(rs_bittorrent_dht_state_get_tx_iterator),
get_tx_data: rs_bittorrent_dht_get_tx_data,
get_state_data: rs_bittorrent_dht_get_state_data,
get_tx_data: bittorrent_dht_get_tx_data,
get_state_data: bittorrent_dht_get_state_data,
apply_tx_config: None,
flags: 0,
get_frame_id_by_name: None,
Expand Down
6 changes: 0 additions & 6 deletions rust/src/detect/transforms/casechange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::ptr;
static mut G_TRANSFORM_TOLOWER_ID: c_int = 0;
static mut G_TRANSFORM_TOUPPER_ID: c_int = 0;

#[no_mangle]
unsafe extern "C" fn tolower_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -40,7 +39,6 @@ fn tolower_transform_do(input: &[u8], output: &mut [u8]) {
}
}

#[no_mangle]
unsafe extern "C" fn tolower_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand All @@ -61,7 +59,6 @@ unsafe extern "C" fn tolower_transform(buffer: *mut c_void, _ctx: *mut c_void) {
InspectionBufferTruncate(buffer, input_len);
}

#[no_mangle]
unsafe extern "C" fn tolower_validate(content: *const u8, len: u16, _ctx: *mut c_void) -> bool {
let input = build_slice!(content, len as usize);
for &c in input {
Expand Down Expand Up @@ -90,7 +87,6 @@ pub unsafe extern "C" fn DetectTransformToLowerRegister() {
}
}

#[no_mangle]
unsafe extern "C" fn toupper_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -103,7 +99,6 @@ fn toupper_transform_do(input: &[u8], output: &mut [u8]) {
}
}

#[no_mangle]
unsafe extern "C" fn toupper_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand All @@ -124,7 +119,6 @@ unsafe extern "C" fn toupper_transform(buffer: *mut c_void, _ctx: *mut c_void) {
InspectionBufferTruncate(buffer, input_len);
}

#[no_mangle]
unsafe extern "C" fn toupper_validate(content: *const u8, len: u16, _ctx: *mut c_void) -> bool {
let input = build_slice!(content, len as usize);
for &c in input {
Expand Down
3 changes: 0 additions & 3 deletions rust/src/detect/transforms/compress_whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::ptr;

static mut G_TRANSFORM_COMPRESS_WHITESPACE_ID: c_int = 0;

#[no_mangle]
unsafe extern "C" fn compress_whitespace_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -50,7 +49,6 @@ fn compress_whitespace_transform_do(input: &[u8], output: &mut [u8]) -> u32 {
return nb as u32;
}

#[no_mangle]
unsafe extern "C" fn compress_whitespace_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down Expand Up @@ -86,7 +84,6 @@ fn compress_whitespace_validate_do(input: &[u8]) -> bool {
return true;
}

#[no_mangle]
unsafe extern "C" fn compress_whitespace_validate(
content: *const u8, len: u16, _ctx: *mut c_void,
) -> bool {
Expand Down
2 changes: 0 additions & 2 deletions rust/src/detect/transforms/dotprefix.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::ptr;

static mut G_TRANSFORM_DOT_PREFIX_ID: c_int = 0;

#[no_mangle]
unsafe extern "C" fn dot_prefix_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -42,7 +41,6 @@ fn dot_prefix_transform_do(input: &[u8], output: &mut [u8]) {
output[0] = b'.';
}

#[no_mangle]
unsafe extern "C" fn dot_prefix_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input_len = InspectionBufferLength(buffer);
if input_len == 0 {
Expand Down
6 changes: 0 additions & 6 deletions rust/src/detect/transforms/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ static mut G_TRANSFORM_SHA256_ID: c_int = 0;

const SC_MD5_LEN: usize = 16;

#[no_mangle]
unsafe extern "C" fn md5_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -50,7 +49,6 @@ fn md5_transform_do(input: &[u8], output: &mut [u8]) {
Md5::new().chain(input).finalize_into(output.into());
}

#[no_mangle]
unsafe extern "C" fn md5_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down Expand Up @@ -89,7 +87,6 @@ pub unsafe extern "C" fn DetectTransformMd5Register() {
}
}

#[no_mangle]
unsafe extern "C" fn sha1_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -104,7 +101,6 @@ fn sha1_transform_do(input: &[u8], output: &mut [u8]) {
Sha1::new().chain(input).finalize_into(output.into());
}

#[no_mangle]
unsafe extern "C" fn sha1_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down Expand Up @@ -143,7 +139,6 @@ pub unsafe extern "C" fn DetectTransformSha1Register() {
}
}

#[no_mangle]
unsafe extern "C" fn sha256_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -158,7 +153,6 @@ fn sha256_transform_do(input: &[u8], output: &mut [u8]) {
Sha256::new().chain(input).finalize_into(output.into());
}

#[no_mangle]
unsafe extern "C" fn sha256_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down
4 changes: 0 additions & 4 deletions rust/src/detect/transforms/http_headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use std::ptr;
static mut G_TRANSFORM_HEADER_LOWER_ID: c_int = 0;
static mut G_TRANSFORM_STRIP_PSEUDO_ID: c_int = 0;

#[no_mangle]
unsafe extern "C" fn header_lowersetup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -53,7 +52,6 @@ fn header_lowertransform_do(input: &[u8], output: &mut [u8]) {
}
}

#[no_mangle]
unsafe extern "C" fn header_lowertransform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down Expand Up @@ -92,7 +90,6 @@ pub unsafe extern "C" fn DetectTransformHeaderLowercaseRegister() {
}
}

#[no_mangle]
unsafe extern "C" fn strip_pseudo_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -117,7 +114,6 @@ fn strip_pseudo_transform_do(input: &[u8], output: &mut [u8]) -> u32 {
return nb as u32;
}

#[no_mangle]
unsafe extern "C" fn strip_pseudo_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down
3 changes: 0 additions & 3 deletions rust/src/detect/transforms/strip_whitespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::ptr;

static mut G_TRANSFORM_STRIP_WHITESPACE_ID: c_int = 0;

#[no_mangle]
unsafe extern "C" fn strip_whitespace_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -47,7 +46,6 @@ fn strip_whitespace_transform_do(input: &[u8], output: &mut [u8]) -> u32 {
return nb as u32;
}

#[no_mangle]
unsafe extern "C" fn strip_whitespace_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand All @@ -68,7 +66,6 @@ unsafe extern "C" fn strip_whitespace_transform(buffer: *mut c_void, _ctx: *mut
InspectionBufferTruncate(buffer, output_len);
}

#[no_mangle]
unsafe extern "C" fn strip_whitespace_validate(
content: *const u8, len: u16, _ctx: *mut c_void,
) -> bool {
Expand Down
2 changes: 0 additions & 2 deletions rust/src/detect/transforms/urldecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ use std::ptr;

static mut G_TRANSFORM_URL_DECODE_ID: c_int = 0;

#[no_mangle]
unsafe extern "C" fn url_decode_setup(
_de: *mut c_void, s: *mut c_void, _opt: *const std::os::raw::c_char,
) -> c_int {
Expand Down Expand Up @@ -87,7 +86,6 @@ fn url_decode_transform_do(input: &[u8], output: &mut [u8]) -> u32 {
return nb as u32;
}

#[no_mangle]
unsafe extern "C" fn url_decode_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down
2 changes: 0 additions & 2 deletions rust/src/detect/transforms/xor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ unsafe fn xor_parse(raw: *const std::os::raw::c_char) -> *mut c_void {
return std::ptr::null_mut();
}

#[no_mangle]
unsafe extern "C" fn xor_setup(
de: *mut c_void, s: *mut c_void, opt_str: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -81,7 +80,6 @@ fn xor_transform_do(input: &[u8], output: &mut [u8], ctx: &DetectTransformXorDat
}
}

#[no_mangle]
unsafe extern "C" fn xor_transform(buffer: *mut c_void, ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down
10 changes: 5 additions & 5 deletions rust/src/dhcp/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::detect::{
};
use std::os::raw::{c_int, c_void};

fn rs_dhcp_tx_get_time(tx: &DHCPTransaction, code: u8) -> Option<u64> {
fn dhcp_tx_get_time(tx: &DHCPTransaction, code: u8) -> Option<u64> {
for option in &tx.message.options {
if option.code == code {
if let DHCPOptionWrapper::TimeValue(ref time_value) = option.option {
Expand Down Expand Up @@ -78,7 +78,7 @@ unsafe extern "C" fn dhcp_detect_leasetime_match(
) -> c_int {
let tx = cast_pointer!(tx, DHCPTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u64>);
if let Some(val) = rs_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 0;
Expand Down Expand Up @@ -121,7 +121,7 @@ unsafe extern "C" fn dhcp_detect_rebindingtime_match(
) -> c_int {
let tx = cast_pointer!(tx, DHCPTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u64>);
if let Some(val) = rs_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 0;
Expand Down Expand Up @@ -158,14 +158,14 @@ unsafe extern "C" fn dhcp_detect_renewaltime_match(
) -> c_int {
let tx = cast_pointer!(tx, DHCPTransaction);
let ctx = cast_pointer!(ctx, DetectUintData<u64>);
if let Some(val) = rs_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 0;
}

#[no_mangle]
pub unsafe extern "C" fn ScDetectDHCPRegister() {
pub unsafe extern "C" fn SCDetectDHCPRegister() {
let kw = SCSigTableElmt {
name: b"dhcp.leasetime\0".as_ptr() as *const libc::c_char,
desc: b"match DHCP leasetime\0".as_ptr() as *const libc::c_char,
Expand Down
Loading
Loading