Skip to content

Commit

Permalink
dns: replace usage of rs_dns_tx_get_query_name with SCDnsTxGetQueryName
Browse files Browse the repository at this point in the history
SCDnsTxGetQueryName was introduced to allow for getting the query name
in responses as well as requests, so covers the functionality of
rs_dns_tx_get_query_name.
  • Loading branch information
jasonish committed Nov 28, 2023
1 parent 6ac3e84 commit 8b74ea8
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 18 deletions.
17 changes: 0 additions & 17 deletions rust/src/dns/dns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -853,23 +853,6 @@ pub unsafe extern "C" fn rs_dns_state_get_tx_data(

export_state_data_get!(rs_dns_get_state_data, DNSState);

#[no_mangle]
pub unsafe extern "C" fn rs_dns_tx_get_query_name(
tx: &mut DNSTransaction, i: u32, buf: *mut *const u8, len: *mut u32,
) -> u8 {
if let Some(request) = &tx.request {
if (i as usize) < request.queries.len() {
let query = &request.queries[i as usize];
if !query.name.is_empty() {
*len = query.name.len() as u32;
*buf = query.name.as_ptr();
return 1;
}
}
}
return 0;
}

/// Get the DNS query name at index i.
#[no_mangle]
pub unsafe extern "C" fn SCDnsTxGetQueryName(
Expand Down
2 changes: 1 addition & 1 deletion src/detect-dns-query.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ static InspectionBuffer *DnsQueryGetData(DetectEngineThreadCtx *det_ctx,

const uint8_t *data;
uint32_t data_len;
if (rs_dns_tx_get_query_name(cbdata->txv, cbdata->local_id, &data, &data_len) == 0) {
if (SCDnsTxGetQueryName(cbdata->txv, false, cbdata->local_id, &data, &data_len) == 0) {
InspectionBufferSetupMultiEmpty(buffer);
return NULL;
}
Expand Down

0 comments on commit 8b74ea8

Please sign in to comment.