|
|
|
@ -205,6 +205,12 @@ impl DNSTransaction {
|
|
|
|
if self.events != std::ptr::null_mut() {
|
|
|
|
if self.events != std::ptr::null_mut() {
|
|
|
|
core::sc_app_layer_decoder_events_free_events(&mut self.events);
|
|
|
|
core::sc_app_layer_decoder_events_free_events(&mut self.events);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
match self.de_state {
|
|
|
|
|
|
|
|
Some(state) => {
|
|
|
|
|
|
|
|
core::sc_detect_engine_state_free(state);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
None => { },
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Get the DNS transactions ID (not the internal tracking ID).
|
|
|
|
/// Get the DNS transactions ID (not the internal tracking ID).
|
|
|
|
@ -278,15 +284,6 @@ impl DNSState {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn free(&mut self) {
|
|
|
|
|
|
|
|
SCLogDebug!("Freeing {} transactions left in state.",
|
|
|
|
|
|
|
|
self.transactions.len());
|
|
|
|
|
|
|
|
while self.transactions.len() > 0 {
|
|
|
|
|
|
|
|
self.free_tx_at_index(0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
assert!(self.transactions.len() == 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pub fn new_tx(&mut self) -> DNSTransaction {
|
|
|
|
pub fn new_tx(&mut self) -> DNSTransaction {
|
|
|
|
let mut tx = DNSTransaction::new();
|
|
|
|
let mut tx = DNSTransaction::new();
|
|
|
|
self.tx_id += 1;
|
|
|
|
self.tx_id += 1;
|
|
|
|
@ -308,17 +305,7 @@ impl DNSState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if found {
|
|
|
|
if found {
|
|
|
|
self.free_tx_at_index(index);
|
|
|
|
self.transactions.remove(index);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn free_tx_at_index(&mut self, index: usize) {
|
|
|
|
|
|
|
|
let tx = self.transactions.remove(index);
|
|
|
|
|
|
|
|
match tx.de_state {
|
|
|
|
|
|
|
|
Some(state) => {
|
|
|
|
|
|
|
|
core::sc_detect_engine_state_free(state);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
_ => {}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -335,7 +322,7 @@ impl DNSState {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SCLogDebug!("Purging DNS TX with ID {}", self.transactions[0].id);
|
|
|
|
SCLogDebug!("Purging DNS TX with ID {}", self.transactions[0].id);
|
|
|
|
self.free_tx_at_index(0);
|
|
|
|
self.transactions.remove(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -533,14 +520,6 @@ impl DNSState {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// Implement Drop for DNSState as transactions need to do some
|
|
|
|
|
|
|
|
/// explicit cleanup.
|
|
|
|
|
|
|
|
impl Drop for DNSState {
|
|
|
|
|
|
|
|
fn drop(&mut self) {
|
|
|
|
|
|
|
|
self.free();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// Probe input to see if it looks like DNS.
|
|
|
|
/// Probe input to see if it looks like DNS.
|
|
|
|
fn probe(input: &[u8]) -> bool {
|
|
|
|
fn probe(input: &[u8]) -> bool {
|
|
|
|
match parser::dns_parse_request(input) {
|
|
|
|
match parser::dns_parse_request(input) {
|
|
|
|
|