pub get_tx_detect_flags: Option<GetTxDetectFlagsFn>,
pub get_tx_data: Option<GetTxDataFn>,
+
+ // Function to apply config to a TX. Optional. Normal (bidirectional)
+ // transactions don't need to set this. It is meant for cases where
+ // 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>,
}
/// Create a slice, given a buffer and a length
pub type GetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8) -> u64;
pub type SetTxDetectFlagsFn = unsafe extern "C" fn(*mut c_void, u8, u64);
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);
// Defined in app-layer-register.h
extern {
get_tx_detect_flags: None,
set_tx_detect_flags: None,
get_tx_data: None,
+ apply_tx_config: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
set_tx_detect_flags: None,
get_tx_detect_flags: None,
get_tx_data : None,
+ apply_tx_config : None,
};
let ip_proto_str = CString::new("udp").unwrap();
get_de_state: rs_dns_state_get_tx_detect_state,
set_de_state: rs_dns_state_set_tx_detect_state,
get_tx_data: Some(rs_dns_state_get_tx_data),
+ apply_tx_config: None,
};
let ip_proto_str = CString::new("udp").unwrap();
get_de_state: rs_dns_state_get_tx_detect_state,
set_de_state: rs_dns_state_set_tx_detect_state,
get_tx_data: Some(rs_dns_state_get_tx_data),
+ apply_tx_config: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
get_tx_detect_flags: None,
set_tx_detect_flags: None,
get_tx_data : None,
+ apply_tx_config : None,
};
let ip_proto_str = CString::new("udp").unwrap();
get_tx_detect_flags: Some(rs_krb5_tx_detect_flags_get),
set_tx_detect_flags: Some(rs_krb5_tx_detect_flags_set),
get_tx_data : None,
+ apply_tx_config : None,
};
// register UDP parser
let ip_proto_str = CString::new("udp").unwrap();
get_tx_detect_flags: None,
set_tx_detect_flags: None,
get_tx_data : None,
+ apply_tx_config : None,
};
let ip_proto_str = CString::new("udp").unwrap();
get_tx_detect_flags: None,
set_tx_detect_flags: None,
get_tx_data: None,
+ apply_tx_config: None,
};
let ip_proto_str = std::ffi::CString::new("tcp").unwrap();
get_tx_detect_flags: Some(rs_rfb_get_tx_detect_flags),
set_tx_detect_flags: Some(rs_rfb_set_tx_detect_flags),
get_tx_data: None,
+ apply_tx_config: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
get_tx_detect_flags: None,
set_tx_detect_flags: None,
get_tx_data: None,
+ apply_tx_config: None,
};
let ip_proto_str = CString::new("udp").unwrap();
get_tx_detect_flags: Some(rs_snmp_get_tx_detect_flags),
set_tx_detect_flags: Some(rs_snmp_set_tx_detect_flags),
get_tx_data : None,
+ apply_tx_config : None,
};
let ip_proto_str = CString::new("udp").unwrap();
if AppLayerProtoDetectConfProtoDetectionEnabled(ip_proto_str.as_ptr(), parser.name) != 0 {
get_tx_detect_flags: Some(rs_ssh_get_tx_detect_flags),
set_tx_detect_flags: Some(rs_ssh_set_tx_detect_flags),
get_tx_data: None,
+ apply_tx_config: None,
};
let ip_proto_str = CString::new("tcp").unwrap();
uint64_t (*GetTxDetectFlags)(void *tx, uint8_t dir);
void (*SetTxDetectFlags)(void *tx, uint8_t dir, uint64_t);
AppLayerTxData *(*GetTxData)(void *tx);
+ bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig);
void (*SetStreamDepthFlag)(void *tx, uint8_t flags);
SCReturn;
}
+void AppLayerParserRegisterApplyTxConfigFunc(uint8_t ipproto, AppProto alproto,
+ bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig))
+{
+ SCEnter();
+
+ alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].ApplyTxConfig = ApplyTxConfig;
+
+ SCReturn;
+}
+
void AppLayerParserRegisterSetStreamDepthFlag(uint8_t ipproto, AppProto alproto,
void (*SetStreamDepthFlag)(void *tx, uint8_t flags))
{
SCReturnPtr(NULL, "AppLayerTxData");
}
+void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto,
+ void *state, void *tx, enum ConfigAction mode, AppLayerTxConfig config)
+{
+ SCEnter();
+ if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].ApplyTxConfig) {
+ alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].ApplyTxConfig(state, tx, mode, config);
+ }
+ SCReturn;
+}
+
/***** General *****/
/** \retval int -1 in case of unrecoverable error. App-layer tracking stops for this flow.
#include "util-file.h"
#include "stream-tcp-private.h"
#include "rust.h"
+#include "util-config.h"
/* Flags for AppLayerParserState. */
#define APP_LAYER_PARSER_EOF BIT_U8(0)
void AppLayerParserRegisterTxDataFunc(uint8_t ipproto, AppProto alproto,
AppLayerTxData *(*GetTxData)(void *tx));
+void AppLayerParserRegisterApplyTxConfigFunc(uint8_t ipproto, AppProto alproto,
+ bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig));
/***** Get and transaction functions *****/
bool AppLayerParserSupportsTxDetectFlags(AppProto alproto);
AppLayerTxData *AppLayerParserGetTxData(uint8_t ipproto, AppProto alproto, void *tx);
+void AppLayerParserApplyTxConfig(uint8_t ipproto, AppProto alproto,
+ void *state, void *tx, enum ConfigAction mode, AppLayerTxConfig);
/***** General *****/
p->GetTxData);
}
+ if (p->ApplyTxConfig) {
+ AppLayerParserRegisterApplyTxConfigFunc(p->ip_proto, alproto,
+ p->ApplyTxConfig);
+ }
+
return 0;
}
uint64_t (*GetTxDetectFlags)(void *, uint8_t);
AppLayerTxData *(*GetTxData)(void *tx);
+ bool (*ApplyTxConfig)(void *state, void *tx, int mode, AppLayerTxConfig);
} AppLayerParser;
/**