Skip to content

Commit

Permalink
rust: add tx detect flags function to registration struct
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonish committed Nov 27, 2019
1 parent 20bc08a commit cde49ec
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 0 deletions.
2 changes: 2 additions & 0 deletions rust/src/applayertemplate/template.rs
Expand Up @@ -544,6 +544,8 @@ pub unsafe extern "C" fn rs_template_register_parser() {
set_tx_mpm_id: None,
get_files: None,
get_tx_iterator: Some(rs_template_state_get_tx_iterator),
get_tx_detect_flags: None,
set_tx_detect_flags: None,
};

let ip_proto_str = CString::new("tcp").unwrap();
Expand Down
2 changes: 2 additions & 0 deletions rust/src/dhcp/dhcp.rs
Expand Up @@ -452,6 +452,8 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() {
set_tx_mpm_id : None,
get_files : None,
get_tx_iterator : Some(rs_dhcp_state_get_tx_iterator),
set_tx_detect_flags: None,
get_tx_detect_flags: None,
};

let ip_proto_str = CString::new("udp").unwrap();
Expand Down
2 changes: 2 additions & 0 deletions rust/src/ikev2/ikev2.rs
Expand Up @@ -730,6 +730,8 @@ pub unsafe extern "C" fn rs_register_ikev2_parser() {
set_tx_mpm_id : None,
get_files : None,
get_tx_iterator : None,
get_tx_detect_flags: None,
set_tx_detect_flags: None,
};

let ip_proto_str = CString::new("udp").unwrap();
Expand Down
2 changes: 2 additions & 0 deletions rust/src/krb/krb5.rs
Expand Up @@ -669,6 +669,8 @@ pub unsafe extern "C" fn rs_register_krb5_parser() {
set_tx_mpm_id : None,
get_files : None,
get_tx_iterator : None,
get_tx_detect_flags: None,
set_tx_detect_flags: None,
};
// register UDP parser
let ip_proto_str = CString::new("udp").unwrap();
Expand Down
2 changes: 2 additions & 0 deletions rust/src/ntp/ntp.rs
Expand Up @@ -429,6 +429,8 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
set_tx_mpm_id : None,
get_files : None,
get_tx_iterator : None,
get_tx_detect_flags: None,
set_tx_detect_flags: None,
};

let ip_proto_str = CString::new("udp").unwrap();
Expand Down
14 changes: 14 additions & 0 deletions rust/src/parser.rs
Expand Up @@ -100,6 +100,12 @@ pub struct RustParser {

/// Function to get the TX iterator
pub get_tx_iterator: Option<GetTxIteratorFn>,

// Function to set TX detect flags.
pub set_tx_detect_flags: Option<SetTxDetectFlagsFn>,

// Function to get TX detect flags.
pub get_tx_detect_flags: Option<GetTxDetectFlagsFn>,
}


Expand Down Expand Up @@ -154,6 +160,8 @@ pub type GetTxIteratorFn = extern "C" fn (ipproto: u8, alproto: AppProto,
max_tx_id: u64,
istate: &mut u64)
-> AppLayerGetTxIterTuple;
pub type GetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8) -> u64;
pub type SetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8, u64);

// Defined in app-layer-register.h
extern {
Expand Down Expand Up @@ -185,4 +193,10 @@ extern {
pub fn AppLayerParserStateIssetFlag(state: *mut c_void, flag: u8) -> c_int;
pub fn AppLayerParserConfParserEnabled(ipproto: *const c_char, proto: *const c_char) -> c_int;
pub fn AppLayerParserRegisterGetTxIterator(ipproto: u8, alproto: AppProto, fun: AppLayerGetTxIteratorFn);
pub fn AppLayerParserRegisterDetectFlagsFuncs(
ipproto: u8,
alproto: AppProto,
GetTxDetectFlats: GetTxDetectFlagsFn,
SetTxDetectFlags: SetTxDetectFlagsFn,
);
}
2 changes: 2 additions & 0 deletions rust/src/rdp/rdp.rs
Expand Up @@ -531,6 +531,8 @@ pub unsafe extern "C" fn rs_rdp_register_parser() {
set_tx_mpm_id: None,
get_files: None,
get_tx_iterator: None,
get_tx_detect_flags: None,
set_tx_detect_flags: None,
};

/* For 5.0 we want this disabled by default, so check that it
Expand Down
2 changes: 2 additions & 0 deletions rust/src/sip/sip.rs
Expand Up @@ -422,6 +422,8 @@ pub unsafe extern "C" fn rs_sip_register_parser() {
set_tx_mpm_id: None,
get_files: None,
get_tx_iterator: None,
get_tx_detect_flags: None,
set_tx_detect_flags: None,
};

/* For 5.0 we want this disabled by default, so check that it
Expand Down
2 changes: 2 additions & 0 deletions rust/src/snmp/snmp.rs
Expand Up @@ -607,6 +607,8 @@ pub unsafe extern "C" fn rs_register_snmp_parser() {
set_tx_mpm_id : None,
get_files : None,
get_tx_iterator : None,
get_tx_detect_flags: None,
set_tx_detect_flags: None,
};
let ip_proto_str = CString::new("udp").unwrap();
if AppLayerProtoDetectConfProtoDetectionEnabled(ip_proto_str.as_ptr(), parser.name) != 0 {
Expand Down

0 comments on commit cde49ec

Please sign in to comment.