]> git.ipfire.org Git - people/ms/suricata.git/commitdiff
applayer: add flags to parser registration struct
authorJason Ish <jason.ish@oisf.net>
Mon, 13 Jul 2020 16:24:24 +0000 (10:24 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 14 Jul 2020 15:10:18 +0000 (09:10 -0600)
This will allow Rust parsers to register for gap handing from
Rust (some Rust parsers do handle gaps, but they set the flag
from C).

14 files changed:
rust/src/applayer.rs
rust/src/applayertemplate/template.rs
rust/src/dhcp/dhcp.rs
rust/src/dns/dns.rs
rust/src/ikev2/ikev2.rs
rust/src/krb/krb5.rs
rust/src/ntp/ntp.rs
rust/src/rdp/rdp.rs
rust/src/rfb/rfb.rs
rust/src/sip/sip.rs
rust/src/snmp/snmp.rs
rust/src/ssh/ssh.rs
src/app-layer-register.c
src/app-layer-register.h

index 8c9bc521aebe1b74462886b7e9381b7ac51afaf2..40d9064abac24f57f84163e72354a5ef6c1b41a0 100644 (file)
@@ -228,6 +228,8 @@ pub struct RustParser {
     // the requests and responses are not sharing tx. It is then up to
     // the implementation to make sure the config is applied correctly.
     pub apply_tx_config: Option<ApplyTxConfigFn>,
+
+    pub flags: u32,
 }
 
 /// Create a slice, given a buffer and a length
index e356d3364a5b5be4768a06e46b495ea061071bb9..1530046ef4f94d607f41e76c50f8883fdf355e6c 100644 (file)
@@ -518,6 +518,7 @@ pub unsafe extern "C" fn rs_template_register_parser() {
         get_tx_iterator: Some(rs_template_state_get_tx_iterator),
         get_tx_data: rs_template_get_tx_data,
         apply_tx_config: None,
+        flags: 0,
     };
 
     let ip_proto_str = CString::new("tcp").unwrap();
index 697cae680d320eac8629849a56420f04396e2ab6..32e72e8de754bf00998b1b3dbf49bcb9af8c04d9 100644 (file)
@@ -437,6 +437,7 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() {
         get_tx_iterator    : Some(rs_dhcp_state_get_tx_iterator),
         get_tx_data        : rs_dhcp_get_tx_data,
         apply_tx_config    : None,
+        flags              : 0,
     };
 
     let ip_proto_str = CString::new("udp").unwrap();
index e78810679739345a474b290f788a003d45681a5e..3d3ce4c953e8dc5f25e9707a15fc0b78e7efe4bd 100644 (file)
@@ -1038,6 +1038,7 @@ pub unsafe extern "C" fn rs_dns_udp_register_parser() {
         set_de_state: rs_dns_state_set_tx_detect_state,
         get_tx_data: rs_dns_state_get_tx_data,
         apply_tx_config: Some(rs_dns_apply_tx_config),
+        flags: 0,
     };
 
     let ip_proto_str = CString::new("udp").unwrap();
@@ -1083,6 +1084,7 @@ pub unsafe extern "C" fn rs_dns_tcp_register_parser() {
         set_de_state: rs_dns_state_set_tx_detect_state,
         get_tx_data: rs_dns_state_get_tx_data,
         apply_tx_config: Some(rs_dns_apply_tx_config),
+        flags: 0,
     };
 
     let ip_proto_str = CString::new("tcp").unwrap();
index 25af1dc6e99f110b67fde478aa9b0c869dc30383..e1fbac57eb300c465fd465da250f4b2a5e5fe602 100644 (file)
@@ -712,6 +712,7 @@ pub unsafe extern "C" fn rs_register_ikev2_parser() {
         get_tx_iterator    : None,
         get_tx_data        : rs_ikev2_get_tx_data,
         apply_tx_config    : None,
+        flags              : 0,
     };
 
     let ip_proto_str = CString::new("udp").unwrap();
index dd85db5daa72e4c2eb9fd8adc8d755dc3eaafc58..5e4550577513ee4ffa639bcb3697f558b007ab3b 100644 (file)
@@ -658,6 +658,7 @@ pub unsafe extern "C" fn rs_register_krb5_parser() {
         get_tx_iterator    : None,
         get_tx_data        : rs_krb5_get_tx_data,
         apply_tx_config    : None,
+        flags              : 0,
     };
     // register UDP parser
     let ip_proto_str = CString::new("udp").unwrap();
index e045807548c8c6be631ca3bc41a5eaeb9fc3544d..27bf3a6296b55a81f57a4c0f5850c6244c7c7360 100644 (file)
@@ -408,6 +408,7 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
         get_tx_iterator    : None,
         get_tx_data        : rs_ntp_get_tx_data,
         apply_tx_config    : None,
+        flags              : 0,
     };
 
     let ip_proto_str = CString::new("udp").unwrap();
index 3b0c66e9eb043265137c24adbeec3ffe6b996694..b96da51226093d12a4c48423a233e2791a79a323 100644 (file)
@@ -534,6 +534,7 @@ pub unsafe extern "C" fn rs_rdp_register_parser() {
         get_tx_iterator: None,
         get_tx_data: rs_rdp_get_tx_data,
         apply_tx_config: None,
+        flags: 0,
     };
 
     let ip_proto_str = std::ffi::CString::new("tcp").unwrap();
index 77c2388d76c37eff3c9e4ee2248b8c7f8c852c0a..8cb251c72402857c6b484dd2de7b333ca29e8374 100644 (file)
@@ -700,6 +700,7 @@ pub unsafe extern "C" fn rs_rfb_register_parser() {
         get_tx_iterator: Some(rs_rfb_state_get_tx_iterator),
         get_tx_data: rs_rfb_get_tx_data,
         apply_tx_config: None,
+        flags: 0,
     };
 
     let ip_proto_str = CString::new("tcp").unwrap();
index 3d4be29112a5afde5686e92b0ad25e69048a61a8..eb642d700eeafcd8c3438994faf93c8ef837db75 100755 (executable)
@@ -393,6 +393,7 @@ pub unsafe extern "C" fn rs_sip_register_parser() {
         get_tx_iterator: None,
         get_tx_data: rs_sip_get_tx_data,
         apply_tx_config: None,
+        flags: 0,
     };
 
     let ip_proto_str = CString::new("udp").unwrap();
index bb07c5a27ae481da7ab1c9725b29a8eee039d7f7..f71da30ab165332ea5d082f818a5824da4c930dc 100644 (file)
@@ -586,6 +586,7 @@ pub unsafe extern "C" fn rs_register_snmp_parser() {
         get_tx_iterator    : None,
         get_tx_data        : rs_snmp_get_tx_data,
         apply_tx_config    : None,
+        flags              : 0,
     };
     let ip_proto_str = CString::new("udp").unwrap();
     if AppLayerProtoDetectConfProtoDetectionEnabled(ip_proto_str.as_ptr(), parser.name) != 0 {
index a801cd61e8d666fa34cfe89b1eb1cc00d1547ad6..71e01f60d5541d52aa1494d080ffca305b0a6dfd 100644 (file)
@@ -560,6 +560,7 @@ pub unsafe extern "C" fn rs_ssh_register_parser() {
         get_tx_iterator: None,
         get_tx_data: rs_ssh_get_tx_data,
         apply_tx_config: None,
+        flags: 0,
     };
 
     let ip_proto_str = CString::new("tcp").unwrap();
index 961f0dfcb4ce30ee6b3c2c4fb43506963cd87efb..e999c67ef3c4ef46586126e353d3f867583ad5ea 100644 (file)
@@ -176,6 +176,12 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
                 p->ApplyTxConfig);
     }
 
+    if (p->flags) {
+        AppLayerParserRegisterOptionFlags(p->ip_proto, alproto,
+                p->flags);
+
+    }
+
     return 0;
 }
 
index 41f1d460c2efd721e81b744f08ec34de2cb274cb..29aba9d417794ff7fe883c4b5d47dfdedee3cd97 100644 (file)
@@ -68,6 +68,8 @@ typedef struct AppLayerParser {
 
     AppLayerTxData *(*GetTxData)(void *tx);
     bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig);
+
+    uint32_t flags;
 } AppLayerParser;
 
 /**