rust/dns: implement detect_flags API

pull/3182/head
Victor Julien 7 years ago
parent 00b0a41b55
commit 98eca55241

@ -179,6 +179,8 @@ pub struct DNSTransaction {
pub id: u64,
pub request: Option<DNSRequest>,
pub response: Option<DNSResponse>,
detect_flags_ts: u64,
detect_flags_tc: u64,
pub logged: LoggerFlags,
pub de_state: Option<*mut core::DetectEngineState>,
pub events: *mut core::AppLayerDecoderEvents,
@ -191,6 +193,8 @@ impl DNSTransaction {
id: 0,
request: None,
response: None,
detect_flags_ts: 0,
detect_flags_tc: 0,
logged: LoggerFlags::new(),
de_state: None,
events: std::ptr::null_mut(),
@ -684,6 +688,30 @@ pub extern "C" fn rs_dns_tx_get_alstate_progress(_tx: &mut DNSTransaction,
return 1;
}
#[no_mangle]
pub extern "C" fn rs_dns_tx_set_detect_flags(tx: &mut DNSTransaction,
dir: libc::uint8_t,
flags: libc::uint64_t)
{
if dir & core::STREAM_TOSERVER != 0 {
tx.detect_flags_ts = flags as u64;
} else {
tx.detect_flags_tc = flags as u64;
}
}
#[no_mangle]
pub extern "C" fn rs_dns_tx_get_detect_flags(tx: &mut DNSTransaction,
dir: libc::uint8_t)
-> libc::uint64_t
{
if dir & core::STREAM_TOSERVER != 0 {
return tx.detect_flags_ts as libc::uint64_t;
} else {
return tx.detect_flags_tc as libc::uint64_t;
}
}
#[no_mangle]
pub extern "C" fn rs_dns_tx_set_logged(_state: &mut DNSState,
tx: &mut DNSTransaction,

@ -112,6 +112,17 @@ static int RustDNSSetTxDetectState(void *state, void *tx,
return 0;
}
static void RustDNSSetDetectFlags(void *tx, uint8_t dir, uint64_t flags)
{
rs_dns_tx_set_detect_flags(tx, dir, flags);
}
static uint64_t RustDNSGetDetectFlags(void *tx, uint8_t dir)
{
return rs_dns_tx_get_detect_flags(tx, dir);
}
static int RustDNSHasEvents(void *state)
{
return rs_dns_state_has_events(state);
@ -172,6 +183,8 @@ void RegisterRustDNSUDPParsers(void)
AppLayerParserRegisterDetectStateFuncs(IPPROTO_UDP, ALPROTO_DNS,
RustDNSStateHasTxDetectState, RustDNSGetTxDetectState,
RustDNSSetTxDetectState);
AppLayerParserRegisterDetectFlagsFuncs(IPPROTO_UDP, ALPROTO_DNS,
RustDNSGetDetectFlags, RustDNSSetDetectFlags);
AppLayerParserRegisterGetTx(IPPROTO_UDP, ALPROTO_DNS, RustDNSGetTx);
AppLayerParserRegisterGetTxCnt(IPPROTO_UDP, ALPROTO_DNS,

Loading…
Cancel
Save