}
/// 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();
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 {
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 {
}
/// 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 {
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 {
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
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);
}
#[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;
}
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 {
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 {
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,
) {
}
#[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),
}
#[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),
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;
}
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;
}
}
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;
}
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);
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;
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)
if (tx == NULL) {
return LuaCallbackError(luastate, "internal error: no tx");
}
- rs_dns_lua_get_tx_id(luastate, tx);
+ SCDnsLuaGetTxId(luastate, tx);
return 1;
}
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)
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;
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)
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)
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 */