applayer/rust: expose truncate callback

pull/5442/head
Victor Julien 5 years ago
parent 2cfa35ccc9
commit 4da0d9bdea

@ -230,6 +230,10 @@ pub struct RustParser {
pub apply_tx_config: Option<ApplyTxConfigFn>,
pub flags: u32,
/// Function to handle the end of data coming on one of the sides
/// due to the stream reaching its 'depth' limit.
pub truncate: Option<TruncateFn>,
}
/// Create a slice, given a buffer and a length
@ -279,6 +283,8 @@ pub type GetTxIteratorFn = extern "C" fn (ipproto: u8, alproto: AppProto,
-> AppLayerGetTxIterTuple;
pub type GetTxDataFn = unsafe extern "C" fn(*mut c_void) -> *mut AppLayerTxData;
pub type ApplyTxConfigFn = unsafe extern "C" fn (*mut c_void, *mut c_void, c_int, AppLayerTxConfig);
pub type TruncateFn = unsafe extern "C" fn (*mut c_void, u8);
// Defined in app-layer-register.h
extern {

@ -549,6 +549,7 @@ pub unsafe extern "C" fn rs_template_register_parser() {
get_tx_data: rs_template_get_tx_data,
apply_tx_config: None,
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
truncate: None,
};
let ip_proto_str = CString::new("tcp").unwrap();

@ -437,6 +437,7 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() {
get_tx_data : rs_dhcp_get_tx_data,
apply_tx_config : None,
flags : 0,
truncate : None,
};
let ip_proto_str = CString::new("udp").unwrap();

@ -1086,6 +1086,7 @@ pub unsafe extern "C" fn rs_dns_udp_register_parser() {
get_tx_data: rs_dns_state_get_tx_data,
apply_tx_config: Some(rs_dns_apply_tx_config),
flags: APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
};
let ip_proto_str = CString::new("udp").unwrap();
@ -1130,6 +1131,7 @@ pub unsafe extern "C" fn rs_dns_tcp_register_parser() {
get_tx_data: rs_dns_state_get_tx_data,
apply_tx_config: Some(rs_dns_apply_tx_config),
flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS | APP_LAYER_PARSER_OPT_UNIDIR_TXS,
truncate: None,
};
let ip_proto_str = CString::new("tcp").unwrap();

@ -1108,6 +1108,7 @@ pub unsafe extern "C" fn rs_http2_register_parser() {
get_tx_data: rs_http2_get_tx_data,
apply_tx_config: None,
flags: 0,
truncate: None,
};
let ip_proto_str = CString::new("tcp").unwrap();

@ -711,6 +711,7 @@ pub unsafe extern "C" fn rs_register_ikev2_parser() {
get_tx_data : rs_ikev2_get_tx_data,
apply_tx_config : None,
flags : 0,
truncate : None,
};
let ip_proto_str = CString::new("udp").unwrap();

@ -657,6 +657,7 @@ pub unsafe extern "C" fn rs_register_krb5_parser() {
get_tx_data : rs_krb5_get_tx_data,
apply_tx_config : None,
flags : 0,
truncate : None,
};
// register UDP parser
let ip_proto_str = CString::new("udp").unwrap();

@ -829,6 +829,7 @@ pub unsafe extern "C" fn rs_mqtt_register_parser(cfg_max_msg_len: u32) {
get_tx_data: rs_mqtt_get_tx_data,
apply_tx_config: None,
flags: 0,
truncate: None,
};
let ip_proto_str = CString::new("tcp").unwrap();

@ -407,6 +407,7 @@ pub unsafe extern "C" fn rs_register_ntp_parser() {
get_tx_data : rs_ntp_get_tx_data,
apply_tx_config : None,
flags : 0,
truncate : None,
};
let ip_proto_str = CString::new("udp").unwrap();

@ -488,6 +488,7 @@ pub unsafe extern "C" fn rs_rdp_register_parser() {
get_tx_data: rs_rdp_get_tx_data,
apply_tx_config: None,
flags: 0,
truncate: None,
};
let ip_proto_str = std::ffi::CString::new("tcp").unwrap();

@ -700,6 +700,7 @@ pub unsafe extern "C" fn rs_rfb_register_parser() {
get_tx_data: rs_rfb_get_tx_data,
apply_tx_config: None,
flags: 0,
truncate: None,
};
let ip_proto_str = CString::new("tcp").unwrap();

@ -393,6 +393,7 @@ pub unsafe extern "C" fn rs_sip_register_parser() {
get_tx_data: rs_sip_get_tx_data,
apply_tx_config: None,
flags: 0,
truncate: None,
};
let ip_proto_str = CString::new("udp").unwrap();

@ -585,6 +585,7 @@ pub unsafe extern "C" fn rs_register_snmp_parser() {
get_tx_data : rs_snmp_get_tx_data,
apply_tx_config : None,
flags : 0,
truncate : None,
};
let ip_proto_str = CString::new("udp").unwrap();
if AppLayerProtoDetectConfProtoDetectionEnabled(ip_proto_str.as_ptr(), parser.name) != 0 {

@ -566,6 +566,7 @@ pub unsafe extern "C" fn rs_ssh_register_parser() {
get_tx_data: rs_ssh_get_tx_data,
apply_tx_config: None,
flags: 0,
truncate: None,
};
let ip_proto_str = CString::new("tcp").unwrap();

@ -182,6 +182,10 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
}
if (p->Truncate) {
AppLayerParserRegisterTruncateFunc(p->ip_proto, alproto, p->Truncate);
}
return 0;
}

@ -70,6 +70,9 @@ typedef struct AppLayerParser {
bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig);
uint32_t flags;
void (*Truncate)(void *state, uint8_t direction);
} AppLayerParser;
/**

Loading…
Cancel
Save