]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/dns: ffi naming and visibility cleanups
authorJason Ish <jason.ish@oisf.net>
Fri, 26 Apr 2024 18:23:44 +0000 (12:23 -0600)
committerVictor Julien <victor@inliniac.net>
Sun, 28 Apr 2024 09:43:08 +0000 (11:43 +0200)
- Remove no_mangle and pub from FFI functions that are only accessed
  with a function pointer.
- Rename all no_mangle FFI functions to our C naming scheme.

rust/src/dns/detect.rs
rust/src/dns/dns.rs
rust/src/dns/log.rs
rust/src/dns/lua.rs
src/app-layer-parser.c
src/detect-dns-opcode.c
src/detect-dns-rcode.c
src/detect-dns-rrtype.c
src/output-json-dns.c
src/util-lua-dns.c

index d425853a8b6d9b3f4a5adee686420b22d82b2d65..67e30c9546c53ce237cddfa12cd4202211c6ecb0 100644 (file)
@@ -23,7 +23,7 @@ use crate::detect::uint::{detect_match_uint, DetectUintData};
 ///
 /// 1 will be returned on match, otherwise 0 will be returned.
 #[no_mangle]
-pub extern "C" fn rs_dns_opcode_match(
+pub extern "C" fn SCDnsDetectOpcodeMatch(
     tx: &mut DNSTransaction, detect: &mut DetectUintData<u8>, flags: u8,
 ) -> u8 {
     let header_flags = if flags & Direction::ToServer as u8 != 0 {
@@ -54,7 +54,7 @@ pub extern "C" fn rs_dns_opcode_match(
 ///
 /// 1 will be returned on match, otherwise 0 will be returned.
 #[no_mangle]
-pub extern "C" fn rs_dns_rcode_match(
+pub extern "C" fn SCDnsDetectRcodeMatch(
     tx: &mut DNSTransaction, detect: &mut DetectUintData<u8>, flags: u8,
 ) -> u8 {
     let header_flags = if flags & Direction::ToServer as u8 != 0 {
@@ -80,7 +80,7 @@ pub extern "C" fn rs_dns_rcode_match(
 /// Perform the DNS rrtype match.
 /// 1 will be returned on match, otherwise 0 will be returned.
 #[no_mangle]
-pub extern "C" fn rs_dns_rrtype_match(
+pub extern "C" fn SCDnsDetectRrtypeMatch(
     tx: &mut DNSTransaction, detect: &mut DetectUintData<u16>, flags: u8,
 ) -> u16 {
     if flags & Direction::ToServer as u8 != 0 {
index d4f71d2682735ff9ba0fc7c69053844de7651434..9e70136026a310ddc34f45ba872e7bb356873eb2 100644 (file)
@@ -713,8 +713,7 @@ pub fn probe_tcp(input: &[u8]) -> (bool, bool, bool) {
 }
 
 /// Returns *mut DNSState
-#[no_mangle]
-pub extern "C" fn rs_dns_state_new(
+extern "C" fn state_new(
     _orig_state: *mut std::os::raw::c_void, _orig_proto: AppProto,
 ) -> *mut std::os::raw::c_void {
     let state = DNSState::new();
@@ -722,31 +721,20 @@ pub extern "C" fn rs_dns_state_new(
     return Box::into_raw(boxed) as *mut _;
 }
 
-/// Returns *mut DNSState
-#[no_mangle]
-pub extern "C" fn rs_dns_state_tcp_new() -> *mut std::os::raw::c_void {
-    let state = DNSState::new();
-    let boxed = Box::new(state);
-    return Box::into_raw(boxed) as *mut _;
-}
-
 /// Params:
 /// - state: *mut DNSState as void pointer
-#[no_mangle]
-pub extern "C" fn rs_dns_state_free(state: *mut std::os::raw::c_void) {
+extern "C" fn state_free(state: *mut std::os::raw::c_void) {
     // Just unbox...
     std::mem::drop(unsafe { Box::from_raw(state as *mut DNSState) });
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) {
+unsafe extern "C" fn state_tx_free(state: *mut std::os::raw::c_void, tx_id: u64) {
     let state = cast_pointer!(state, DNSState);
     state.free_tx(tx_id);
 }
 
 /// C binding parse a DNS request. Returns 1 on success, -1 on failure.
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_parse_request(
+unsafe extern "C" fn parse_request(
     flow: *const core::Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void,
     stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
 ) -> AppLayerResult {
@@ -755,8 +743,7 @@ pub unsafe extern "C" fn rs_dns_parse_request(
     AppLayerResult::ok()
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_parse_response(
+unsafe extern "C" fn parse_response(
     flow: *const core::Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void,
     stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
 ) -> AppLayerResult {
@@ -766,8 +753,7 @@ pub unsafe extern "C" fn rs_dns_parse_response(
 }
 
 /// C binding parse a DNS request. Returns 1 on success, -1 on failure.
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_parse_request_tcp(
+unsafe extern "C" fn parse_request_tcp(
     flow: *const core::Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void,
     stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
 ) -> AppLayerResult {
@@ -780,8 +766,7 @@ pub unsafe extern "C" fn rs_dns_parse_request_tcp(
     AppLayerResult::ok()
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_parse_response_tcp(
+unsafe extern "C" fn parse_response_tcp(
     flow: *const core::Flow, state: *mut std::os::raw::c_void, _pstate: *mut std::os::raw::c_void,
     stream_slice: StreamSlice, _data: *const std::os::raw::c_void,
 ) -> AppLayerResult {
@@ -794,8 +779,7 @@ pub unsafe extern "C" fn rs_dns_parse_response_tcp(
     AppLayerResult::ok()
 }
 
-#[no_mangle]
-pub extern "C" fn rs_dns_tx_get_alstate_progress(
+extern "C" fn tx_get_alstate_progress(
     _tx: *mut std::os::raw::c_void, _direction: u8,
 ) -> std::os::raw::c_int {
     // This is a stateless parser, just the existence of a transaction
@@ -804,15 +788,13 @@ pub extern "C" fn rs_dns_tx_get_alstate_progress(
     return 1;
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 {
+unsafe extern "C" fn state_get_tx_count(state: *mut std::os::raw::c_void) -> u64 {
     let state = cast_pointer!(state, DNSState);
     SCLogDebug!("rs_dns_state_get_tx_count: returning {}", state.tx_id);
     return state.tx_id;
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_state_get_tx(
+unsafe extern "C" fn state_get_tx(
     state: *mut std::os::raw::c_void, tx_id: u64,
 ) -> *mut std::os::raw::c_void {
     let state = cast_pointer!(state, DNSState);
@@ -827,18 +809,16 @@ pub unsafe extern "C" fn rs_dns_state_get_tx(
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_tx_is_request(tx: &mut DNSTransaction) -> bool {
+pub extern "C" fn SCDnsTxIsRequest(tx: &mut DNSTransaction) -> bool {
     tx.request.is_some()
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_tx_is_response(tx: &mut DNSTransaction) -> bool {
+pub extern "C" fn SCDnsTxIsResponse(tx: &mut DNSTransaction) -> bool {
     tx.response.is_some()
 }
 
-pub unsafe extern "C" fn rs_dns_state_get_tx_data(
-    tx: *mut std::os::raw::c_void,
-) -> *mut AppLayerTxData {
+unsafe extern "C" fn state_get_tx_data(tx: *mut std::os::raw::c_void) -> *mut AppLayerTxData {
     let tx = cast_pointer!(tx, DNSTransaction);
     return &mut tx.tx_data;
 }
@@ -895,40 +875,15 @@ pub unsafe extern "C" fn SCDnsTxGetAnswerName(
     false
 }
 
-/// Get the DNS transaction ID of a transaction.
-//
-/// extern uint16_t rs_dns_tx_get_tx_id(RSDNSTransaction *);
-#[no_mangle]
-pub extern "C" fn rs_dns_tx_get_tx_id(tx: &mut DNSTransaction) -> u16 {
-    return tx.tx_id();
-}
-
 /// Get the DNS response flags for a transaction.
 ///
-/// extern uint16_t rs_dns_tx_get_response_flags(RSDNSTransaction *);
+/// extern uint16_t SCDnsTxGetResponseFlags(RSDNSTransaction *);
 #[no_mangle]
-pub extern "C" fn rs_dns_tx_get_response_flags(tx: &mut DNSTransaction) -> u16 {
+pub extern "C" fn SCDnsTxGetResponseFlags(tx: &mut DNSTransaction) -> u16 {
     return tx.rcode();
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_tx_get_query_rrtype(
-    tx: &mut DNSTransaction, i: u16, rrtype: *mut u16,
-) -> 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() {
-                *rrtype = query.rrtype;
-                return 1;
-            }
-        }
-    }
-    return 0;
-}
-
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_probe(
+unsafe extern "C" fn probe_udp(
     _flow: *const core::Flow, _dir: u8, input: *const u8, len: u32, rdir: *mut u8,
 ) -> AppProto {
     if len == 0 || len < std::mem::size_of::<DNSHeader>() as u32 {
@@ -948,8 +903,7 @@ pub unsafe extern "C" fn rs_dns_probe(
     return 0;
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_probe_tcp(
+unsafe extern "C" fn c_probe_tcp(
     _flow: *const core::Flow, direction: u8, input: *const u8, len: u32, rdir: *mut u8,
 ) -> AppProto {
     if len == 0 || len < std::mem::size_of::<DNSHeader>() as u32 + 2 {
@@ -972,8 +926,7 @@ pub unsafe extern "C" fn rs_dns_probe_tcp(
     return 0;
 }
 
-#[no_mangle]
-pub unsafe extern "C" fn rs_dns_apply_tx_config(
+unsafe extern "C" fn apply_tx_config(
     _state: *mut std::os::raw::c_void, _tx: *mut std::os::raw::c_void, _mode: std::os::raw::c_int,
     config: AppLayerTxConfig,
 ) {
@@ -990,35 +943,35 @@ pub unsafe extern "C" fn rs_dns_apply_tx_config(
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn rs_dns_udp_register_parser() {
+pub unsafe extern "C" fn SCRegisterDnsUdpParser() {
     let default_port = std::ffi::CString::new("[53]").unwrap();
     let parser = RustParser {
         name: b"dns\0".as_ptr() as *const std::os::raw::c_char,
         default_port: default_port.as_ptr(),
         ipproto: IPPROTO_UDP,
-        probe_ts: Some(rs_dns_probe),
-        probe_tc: Some(rs_dns_probe),
+        probe_ts: Some(probe_udp),
+        probe_tc: Some(probe_udp),
         min_depth: 0,
         max_depth: std::mem::size_of::<DNSHeader>() as u16,
-        state_new: rs_dns_state_new,
-        state_free: rs_dns_state_free,
-        tx_free: rs_dns_state_tx_free,
-        parse_ts: rs_dns_parse_request,
-        parse_tc: rs_dns_parse_response,
-        get_tx_count: rs_dns_state_get_tx_count,
-        get_tx: rs_dns_state_get_tx,
+        state_new,
+        state_free,
+        tx_free: state_tx_free,
+        parse_ts: parse_request,
+        parse_tc: parse_response,
+        get_tx_count: state_get_tx_count,
+        get_tx: state_get_tx,
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
-        tx_get_progress: rs_dns_tx_get_alstate_progress,
+        tx_get_progress: tx_get_alstate_progress,
         get_eventinfo: Some(DNSEvent::get_event_info),
         get_eventinfo_byid: Some(DNSEvent::get_event_info_by_id),
         localstorage_new: None,
         localstorage_free: None,
         get_tx_files: None,
         get_tx_iterator: Some(crate::applayer::state_get_tx_iterator::<DNSState, DNSTransaction>),
-        get_tx_data: rs_dns_state_get_tx_data,
+        get_tx_data: state_get_tx_data,
         get_state_data: rs_dns_get_state_data,
-        apply_tx_config: Some(rs_dns_apply_tx_config),
+        apply_tx_config: Some(apply_tx_config),
         flags: 0,
         truncate: None,
         get_frame_id_by_name: Some(DnsFrameType::ffi_id_from_name),
@@ -1036,35 +989,35 @@ pub unsafe extern "C" fn rs_dns_udp_register_parser() {
 }
 
 #[no_mangle]
-pub unsafe extern "C" fn rs_dns_tcp_register_parser() {
+pub unsafe extern "C" fn SCRegisterDnsTcpParser() {
     let default_port = std::ffi::CString::new("53").unwrap();
     let parser = RustParser {
         name: b"dns\0".as_ptr() as *const std::os::raw::c_char,
         default_port: default_port.as_ptr(),
         ipproto: IPPROTO_TCP,
-        probe_ts: Some(rs_dns_probe_tcp),
-        probe_tc: Some(rs_dns_probe_tcp),
+        probe_ts: Some(c_probe_tcp),
+        probe_tc: Some(c_probe_tcp),
         min_depth: 0,
         max_depth: std::mem::size_of::<DNSHeader>() as u16 + 2,
-        state_new: rs_dns_state_new,
-        state_free: rs_dns_state_free,
-        tx_free: rs_dns_state_tx_free,
-        parse_ts: rs_dns_parse_request_tcp,
-        parse_tc: rs_dns_parse_response_tcp,
-        get_tx_count: rs_dns_state_get_tx_count,
-        get_tx: rs_dns_state_get_tx,
+        state_new,
+        state_free,
+        tx_free: state_tx_free,
+        parse_ts: parse_request_tcp,
+        parse_tc: parse_response_tcp,
+        get_tx_count: state_get_tx_count,
+        get_tx: state_get_tx,
         tx_comp_st_ts: 1,
         tx_comp_st_tc: 1,
-        tx_get_progress: rs_dns_tx_get_alstate_progress,
+        tx_get_progress: tx_get_alstate_progress,
         get_eventinfo: Some(DNSEvent::get_event_info),
         get_eventinfo_byid: Some(DNSEvent::get_event_info_by_id),
         localstorage_new: None,
         localstorage_free: None,
         get_tx_files: None,
         get_tx_iterator: Some(crate::applayer::state_get_tx_iterator::<DNSState, DNSTransaction>),
-        get_tx_data: rs_dns_state_get_tx_data,
+        get_tx_data: state_get_tx_data,
         get_state_data: rs_dns_get_state_data,
-        apply_tx_config: Some(rs_dns_apply_tx_config),
+        apply_tx_config: Some(apply_tx_config),
         flags: APP_LAYER_PARSER_OPT_ACCEPT_GAPS,
         truncate: None,
         get_frame_id_by_name: Some(DnsFrameType::ffi_id_from_name),
index b2bf72ba1e467107b288626d6dd5bb4b704c45bb..7e2fbaf24a5856c7dc667fba4e33f2a1f1cc50f5 100644 (file)
@@ -636,7 +636,7 @@ fn dns_log_query(
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_log_json_query(
+pub extern "C" fn SCDnsLogJsonQuery(
     tx: &mut DNSTransaction, i: u16, flags: u64, jb: &mut JsonBuilder,
 ) -> bool {
     match dns_log_query(tx, i, flags, jb) {
@@ -650,7 +650,7 @@ pub extern "C" fn rs_dns_log_json_query(
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_log_json_answer(
+pub extern "C" fn SCDnsLogJsonAnswer(
     tx: &mut DNSTransaction, flags: u64, js: &mut JsonBuilder,
 ) -> bool {
     if let Some(response) = &tx.response {
@@ -664,7 +664,7 @@ pub extern "C" fn rs_dns_log_json_answer(
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_do_log_answer(tx: &mut DNSTransaction, flags: u64) -> bool {
+pub extern "C" fn SCDnsLogAnswerEnabled(tx: &mut DNSTransaction, flags: u64) -> bool {
     if let Some(response) = &tx.response {
         for query in &response.queries {
             if dns_log_rrtype_enabled(query.rrtype, flags) {
index b9935f87da84ce50c5f017103dfbb8302cdce683..a7847ecaf3217da61629a0e30d1aa270ffd45b0c 100644 (file)
@@ -22,14 +22,14 @@ use crate::dns::log::*;
 use crate::lua::*;
 
 #[no_mangle]
-pub extern "C" fn rs_dns_lua_get_tx_id(clua: &mut CLuaState, tx: &mut DNSTransaction) {
+pub extern "C" fn SCDnsLuaGetTxId(clua: &mut CLuaState, tx: &mut DNSTransaction) {
     let lua = LuaState { lua: clua };
 
     lua.pushinteger(tx.tx_id() as i64);
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_lua_get_rrname(clua: &mut CLuaState, tx: &mut DNSTransaction) -> c_int {
+pub extern "C" fn SCDnsLuaGetRrname(clua: &mut CLuaState, tx: &mut DNSTransaction) -> c_int {
     let lua = LuaState { lua: clua };
 
     if let Some(request) = &tx.request {
@@ -48,7 +48,7 @@ pub extern "C" fn rs_dns_lua_get_rrname(clua: &mut CLuaState, tx: &mut DNSTransa
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_lua_get_rcode(clua: &mut CLuaState, tx: &mut DNSTransaction) -> c_int {
+pub extern "C" fn SCDnsLuaGetRcode(clua: &mut CLuaState, tx: &mut DNSTransaction) -> c_int {
     let lua = LuaState { lua: clua };
 
     let rcode = tx.rcode();
@@ -61,9 +61,7 @@ pub extern "C" fn rs_dns_lua_get_rcode(clua: &mut CLuaState, tx: &mut DNSTransac
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_lua_get_query_table(
-    clua: &mut CLuaState, tx: &mut DNSTransaction,
-) -> c_int {
+pub extern "C" fn SCDnsLuaGetQueryTable(clua: &mut CLuaState, tx: &mut DNSTransaction) -> c_int {
     let lua = LuaState { lua: clua };
 
     let mut i: i64 = 0;
@@ -116,9 +114,7 @@ pub extern "C" fn rs_dns_lua_get_query_table(
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_lua_get_answer_table(
-    clua: &mut CLuaState, tx: &mut DNSTransaction,
-) -> c_int {
+pub extern "C" fn SCDnsLuaGetAnswerTable(clua: &mut CLuaState, tx: &mut DNSTransaction) -> c_int {
     let lua = LuaState { lua: clua };
 
     let mut i: i64 = 0;
@@ -195,7 +191,7 @@ pub extern "C" fn rs_dns_lua_get_answer_table(
 }
 
 #[no_mangle]
-pub extern "C" fn rs_dns_lua_get_authority_table(
+pub extern "C" fn SCDnsLuaGetAuthorityTable(
     clua: &mut CLuaState, tx: &mut DNSTransaction,
 ) -> c_int {
     let lua = LuaState { lua: clua };
index 83bd5bb03d122c6d79b5458b4fa4cb2277066286..895d4355f9202e2ccc2bbe72cbed2a6f901c68dd 100644 (file)
@@ -1731,8 +1731,8 @@ void AppLayerParserRegisterProtocolParsers(void)
     RegisterFTPParsers();
     RegisterSSHParsers();
     RegisterSMTPParsers();
-    rs_dns_udp_register_parser();
-    rs_dns_tcp_register_parser();
+    SCRegisterDnsUdpParser();
+    SCRegisterDnsTcpParser();
     rs_bittorrent_dht_udp_register_parser();
     RegisterModbusParsers();
     RegisterENIPUDPParsers();
index f5dcab700f27593d4883ac28bd3bf49f546bb3af..e069c5563266df0ca8e45b8d29efe099ea3d2d75 100644 (file)
@@ -67,7 +67,7 @@ static int DetectDnsOpcodeMatch(DetectEngineThreadCtx *det_ctx,
     Flow *f, uint8_t flags, void *state, void *txv, const Signature *s,
     const SigMatchCtx *ctx)
 {
-    return rs_dns_opcode_match(txv, (void *)ctx, flags);
+    return SCDnsDetectOpcodeMatch(txv, (void *)ctx, flags);
 }
 
 void DetectDnsOpcodeRegister(void)
index 876e68c097fe2550547d5943202c46e786b7daa8..fa5d52e67e54bda8b4fdb472b3656c32d2fc6836 100644 (file)
@@ -62,7 +62,7 @@ static void DetectDnsRcodeFree(DetectEngineCtx *de_ctx, void *ptr)
 static int DetectDnsRcodeMatch(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, void *state,
         void *txv, const Signature *s, const SigMatchCtx *ctx)
 {
-    return rs_dns_rcode_match(txv, (void *)ctx, flags);
+    return SCDnsDetectRcodeMatch(txv, (void *)ctx, flags);
 }
 
 void DetectDnsRcodeRegister(void)
index 6145817635d8c1e10e35a70446a3160e66a4c35d..1178d3e68af16d89f0f0df912dcff5baf6f87642 100644 (file)
@@ -62,7 +62,7 @@ static void DetectDnsRrtypeFree(DetectEngineCtx *de_ctx, void *ptr)
 static int DetectDnsRrtypeMatch(DetectEngineThreadCtx *det_ctx, Flow *f, uint8_t flags, void *state,
         void *txv, const Signature *s, const SigMatchCtx *ctx)
 {
-    return rs_dns_rrtype_match(txv, (void *)ctx, flags);
+    return SCDnsDetectRrtypeMatch(txv, (void *)ctx, flags);
 }
 
 void DetectDnsRrtypeRegister(void)
index 9cab2bde55c2280bb6cc34acd1392768fa7b6177..973c777fdd3bedd90fe0680ed631cb218098ceff 100644 (file)
@@ -260,7 +260,7 @@ static JsonBuilder *JsonDNSLogQuery(void *txptr)
 
     for (uint16_t i = 0; i < UINT16_MAX; i++) {
         JsonBuilder *js = jb_new_object();
-        if (!rs_dns_log_json_query((void *)txptr, i, LOG_ALL_RRTYPES, js)) {
+        if (!SCDnsLogJsonQuery((void *)txptr, i, LOG_ALL_RRTYPES, js)) {
             jb_free(js);
             break;
         }
@@ -281,11 +281,11 @@ static JsonBuilder *JsonDNSLogQuery(void *txptr)
 
 static JsonBuilder *JsonDNSLogAnswer(void *txptr)
 {
-    if (!rs_dns_do_log_answer(txptr, LOG_ALL_RRTYPES)) {
+    if (!SCDnsLogAnswerEnabled(txptr, LOG_ALL_RRTYPES)) {
         return NULL;
     } else {
         JsonBuilder *js = jb_new_object();
-        rs_dns_log_json_answer(txptr, LOG_ALL_RRTYPES, js);
+        SCDnsLogJsonAnswer(txptr, LOG_ALL_RRTYPES, js);
         jb_close(js);
         return js;
     }
@@ -330,7 +330,7 @@ static int JsonDnsLoggerToServer(ThreadVars *tv, void *thread_data,
         }
 
         jb_open_object(jb, "dns");
-        if (!rs_dns_log_json_query(txptr, i, td->dnslog_ctx->flags, jb)) {
+        if (!SCDnsLogJsonQuery(txptr, i, td->dnslog_ctx->flags, jb)) {
             jb_free(jb);
             break;
         }
@@ -355,14 +355,14 @@ static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data,
         return TM_ECODE_OK;
     }
 
-    if (rs_dns_do_log_answer(txptr, td->dnslog_ctx->flags)) {
+    if (SCDnsLogAnswerEnabled(txptr, td->dnslog_ctx->flags)) {
         JsonBuilder *jb = CreateEveHeader(p, LOG_DIR_FLOW, "dns", NULL, dnslog_ctx->eve_ctx);
         if (unlikely(jb == NULL)) {
             return TM_ECODE_OK;
         }
 
         jb_open_object(jb, "dns");
-        rs_dns_log_json_answer(txptr, td->dnslog_ctx->flags, jb);
+        SCDnsLogJsonAnswer(txptr, td->dnslog_ctx->flags, jb);
         jb_close(jb);
         OutputJsonBuilderBuffer(jb, td->ctx);
         jb_free(jb);
@@ -374,9 +374,9 @@ static int JsonDnsLoggerToClient(ThreadVars *tv, void *thread_data,
 static int JsonDnsLogger(ThreadVars *tv, void *thread_data, const Packet *p, Flow *f, void *alstate,
         void *txptr, uint64_t tx_id)
 {
-    if (rs_dns_tx_is_request(txptr)) {
+    if (SCDnsTxIsRequest(txptr)) {
         return JsonDnsLoggerToServer(tv, thread_data, p, f, alstate, txptr, tx_id);
-    } else if (rs_dns_tx_is_response(txptr)) {
+    } else if (SCDnsTxIsResponse(txptr)) {
         return JsonDnsLoggerToClient(tv, thread_data, p, f, alstate, txptr, tx_id);
     }
     return TM_ECODE_OK;
index 3fbd84a75ae27e787ead313c3554c42669f0de26..3d19d9308e2ef8b1e448a6e61bfaf8faf5f77ddd 100644 (file)
@@ -65,7 +65,7 @@ static int DnsGetDnsRrname(lua_State *luastate)
     if (tx == NULL) {
         return LuaCallbackError(luastate, "internal error: no tx");
     }
-    return rs_dns_lua_get_rrname(luastate, tx);
+    return SCDnsLuaGetRrname(luastate, tx);
 }
 
 static int DnsGetTxid(lua_State *luastate)
@@ -76,7 +76,7 @@ static int DnsGetTxid(lua_State *luastate)
     if (tx == NULL) {
         return LuaCallbackError(luastate, "internal error: no tx");
     }
-    rs_dns_lua_get_tx_id(luastate, tx);
+    SCDnsLuaGetTxId(luastate, tx);
     return 1;
 }
 
@@ -88,7 +88,7 @@ static int DnsGetRcode(lua_State *luastate)
     if (tx == NULL) {
         return LuaCallbackError(luastate, "internal error: no tx");
     }
-    return rs_dns_lua_get_rcode(luastate, tx);
+    return SCDnsLuaGetRcode(luastate, tx);
 }
 
 static int DnsGetRecursionDesired(lua_State *luastate)
@@ -99,7 +99,7 @@ static int DnsGetRecursionDesired(lua_State *luastate)
     if (tx == NULL) {
         return LuaCallbackError(luastate, "internal error: no tx");
     }
-    uint16_t flags = rs_dns_tx_get_response_flags(tx);
+    uint16_t flags = SCDnsTxGetResponseFlags(tx);
     int recursion_desired = flags & 0x0080 ? 1 : 0;
     lua_pushboolean(luastate, recursion_desired);
     return 1;
@@ -113,7 +113,7 @@ static int DnsGetQueryTable(lua_State *luastate)
     if (tx == NULL) {
         return LuaCallbackError(luastate, "internal error: no tx");
     }
-    return rs_dns_lua_get_query_table(luastate, tx);
+    return SCDnsLuaGetQueryTable(luastate, tx);
 }
 
 static int DnsGetAnswerTable(lua_State *luastate)
@@ -121,7 +121,7 @@ static int DnsGetAnswerTable(lua_State *luastate)
     if (!(LuaStateNeedProto(luastate, ALPROTO_DNS)))
         return LuaCallbackError(luastate, "error: protocol not dns");
     RSDNSTransaction *tx = LuaStateGetTX(luastate);
-    return rs_dns_lua_get_answer_table(luastate, tx);
+    return SCDnsLuaGetAnswerTable(luastate, tx);
 }
 
 static int DnsGetAuthorityTable(lua_State *luastate)
@@ -129,7 +129,7 @@ static int DnsGetAuthorityTable(lua_State *luastate)
     if (!(LuaStateNeedProto(luastate, ALPROTO_DNS)))
         return LuaCallbackError(luastate, "error: protocol not dns");
     RSDNSTransaction *tx = LuaStateGetTX(luastate);
-    return rs_dns_lua_get_authority_table(luastate, tx);
+    return SCDnsLuaGetAuthorityTable(luastate, tx);
 }
 
 /** \brief register http lua extensions in a luastate */