From 9664f73f75a072c0ef7b4417f17c287ec1d11281 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sun, 7 Jun 2020 20:57:19 +0200 Subject: [PATCH] app-layer: remove logged API calls --- rust/src/applayer.rs | 7 ---- rust/src/applayertemplate/template.rs | 2 - rust/src/dhcp/dhcp.rs | 2 - rust/src/dns/dns.rs | 4 -- rust/src/ikev2/ikev2.rs | 2 - rust/src/krb/krb5.rs | 2 - rust/src/ntp/ntp.rs | 2 - rust/src/rdp/rdp.rs | 2 - rust/src/rfb/rfb.rs | 2 - rust/src/sip/sip.rs | 2 - rust/src/snmp/snmp.rs | 2 - rust/src/ssh/ssh.rs | 2 - src/app-layer-parser.c | 53 +-------------------------- src/app-layer-parser.h | 4 -- src/app-layer-register.c | 7 +--- src/app-layer-register.h | 3 -- src/output-tx.c | 5 +-- 17 files changed, 3 insertions(+), 100 deletions(-) diff --git a/rust/src/applayer.rs b/rust/src/applayer.rs index 0feab3ebe0..da7c78971d 100644 --- a/rust/src/applayer.rs +++ b/rust/src/applayer.rs @@ -199,11 +199,6 @@ pub struct RustParser { /// Function returning the current transaction progress pub tx_get_progress: StateGetProgressFn, - /// Logged transaction getter function - pub get_tx_logged: Option, - /// Logged transaction setter function - pub set_tx_logged: Option, - /// Function called to get a detection state pub get_de_state: GetDetectStateFn, /// Function called to set a detection state @@ -278,8 +273,6 @@ pub type SetDetectStateFn = extern "C" fn (*mut c_void, &mut DetectEngineState pub type GetEventInfoFn = extern "C" fn (*const c_char, *mut c_int, *mut AppLayerEventType) -> c_int; pub type GetEventInfoByIdFn = extern "C" fn (c_int, *mut *const c_char, *mut AppLayerEventType) -> i8; pub type GetEventsFn = extern "C" fn (*mut c_void) -> *mut AppLayerDecoderEvents; -pub type GetTxLoggedFn = extern "C" fn (*mut c_void, *mut c_void) -> u32; -pub type SetTxLoggedFn = extern "C" fn (*mut c_void, *mut c_void, u32); pub type LocalStorageNewFn = extern "C" fn () -> *mut c_void; pub type LocalStorageFreeFn = extern "C" fn (*mut c_void); pub type GetFilesFn = extern "C" fn (*mut c_void, u8) -> *mut FileContainer; diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index 89317277f2..97826a0994 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -507,8 +507,6 @@ pub unsafe extern "C" fn rs_template_register_parser() { get_tx: rs_template_state_get_tx, tx_get_comp_st: rs_template_state_progress_completion_status, tx_get_progress: rs_template_tx_get_alstate_progress, - get_tx_logged: None, - set_tx_logged: None, get_de_state: rs_template_tx_get_detect_state, set_de_state: rs_template_tx_set_detect_state, get_events: Some(rs_template_state_get_events), diff --git a/rust/src/dhcp/dhcp.rs b/rust/src/dhcp/dhcp.rs index 77c747f892..a87b292485 100644 --- a/rust/src/dhcp/dhcp.rs +++ b/rust/src/dhcp/dhcp.rs @@ -426,8 +426,6 @@ pub unsafe extern "C" fn rs_dhcp_register_parser() { get_tx : rs_dhcp_state_get_tx, tx_get_comp_st : rs_dhcp_state_progress_completion_status, tx_get_progress : rs_dhcp_tx_get_alstate_progress, - get_tx_logged : None, - set_tx_logged : None, get_de_state : rs_dhcp_tx_get_detect_state, set_de_state : rs_dhcp_tx_set_detect_state, get_events : Some(rs_dhcp_state_get_events), diff --git a/rust/src/dns/dns.rs b/rust/src/dns/dns.rs index 624782d93b..e54b8cb3cb 100644 --- a/rust/src/dns/dns.rs +++ b/rust/src/dns/dns.rs @@ -969,8 +969,6 @@ pub unsafe extern "C" fn rs_dns_udp_register_parser() { get_tx: rs_dns_state_get_tx, tx_get_comp_st: rs_dns_state_progress_completion_status, tx_get_progress: rs_dns_tx_get_alstate_progress, - get_tx_logged: None, - set_tx_logged: None, get_events: Some(rs_dns_state_get_events), get_eventinfo: Some(rs_dns_state_get_event_info), get_eventinfo_byid: Some(rs_dns_state_get_event_info_by_id), @@ -1016,8 +1014,6 @@ pub unsafe extern "C" fn rs_dns_tcp_register_parser() { get_tx: rs_dns_state_get_tx, tx_get_comp_st: rs_dns_state_progress_completion_status, tx_get_progress: rs_dns_tx_get_alstate_progress, - get_tx_logged: None, - set_tx_logged: None, get_events: Some(rs_dns_state_get_events), get_eventinfo: Some(rs_dns_state_get_event_info), get_eventinfo_byid: Some(rs_dns_state_get_event_info_by_id), diff --git a/rust/src/ikev2/ikev2.rs b/rust/src/ikev2/ikev2.rs index a5a323cc18..2f6a911ebc 100644 --- a/rust/src/ikev2/ikev2.rs +++ b/rust/src/ikev2/ikev2.rs @@ -701,8 +701,6 @@ pub unsafe extern "C" fn rs_register_ikev2_parser() { get_tx : rs_ikev2_state_get_tx, tx_get_comp_st : rs_ikev2_state_progress_completion_status, tx_get_progress : rs_ikev2_tx_get_alstate_progress, - get_tx_logged : None, - set_tx_logged : None, get_de_state : rs_ikev2_state_get_tx_detect_state, set_de_state : rs_ikev2_state_set_tx_detect_state, get_events : Some(rs_ikev2_state_get_events), diff --git a/rust/src/krb/krb5.rs b/rust/src/krb/krb5.rs index f1710c1557..4240176039 100644 --- a/rust/src/krb/krb5.rs +++ b/rust/src/krb/krb5.rs @@ -647,8 +647,6 @@ pub unsafe extern "C" fn rs_register_krb5_parser() { get_tx : rs_krb5_state_get_tx, tx_get_comp_st : rs_krb5_state_progress_completion_status, tx_get_progress : rs_krb5_tx_get_alstate_progress, - get_tx_logged : None, - set_tx_logged : None, get_de_state : rs_krb5_state_get_tx_detect_state, set_de_state : rs_krb5_state_set_tx_detect_state, get_events : Some(rs_krb5_state_get_events), diff --git a/rust/src/ntp/ntp.rs b/rust/src/ntp/ntp.rs index 837ccb4bc2..64a9035f54 100644 --- a/rust/src/ntp/ntp.rs +++ b/rust/src/ntp/ntp.rs @@ -397,8 +397,6 @@ pub unsafe extern "C" fn rs_register_ntp_parser() { get_tx : rs_ntp_state_get_tx, tx_get_comp_st : rs_ntp_state_progress_completion_status, tx_get_progress : rs_ntp_tx_get_alstate_progress, - get_tx_logged : None, - set_tx_logged : None, get_de_state : rs_ntp_state_get_tx_detect_state, set_de_state : rs_ntp_state_set_tx_detect_state, get_events : Some(rs_ntp_state_get_events), diff --git a/rust/src/rdp/rdp.rs b/rust/src/rdp/rdp.rs index 25a678e206..432b1a4805 100644 --- a/rust/src/rdp/rdp.rs +++ b/rust/src/rdp/rdp.rs @@ -519,8 +519,6 @@ pub unsafe extern "C" fn rs_rdp_register_parser() { get_tx: rs_rdp_state_get_tx, tx_get_comp_st: rs_rdp_tx_get_progress_complete, tx_get_progress: rs_rdp_tx_get_progress, - get_tx_logged: None, - set_tx_logged: None, get_de_state: rs_rdp_tx_get_detect_state, set_de_state: rs_rdp_tx_set_detect_state, get_events: None, diff --git a/rust/src/rfb/rfb.rs b/rust/src/rfb/rfb.rs index 7984b252e6..fad695be44 100644 --- a/rust/src/rfb/rfb.rs +++ b/rust/src/rfb/rfb.rs @@ -689,8 +689,6 @@ pub unsafe extern "C" fn rs_rfb_register_parser() { get_tx: rs_rfb_state_get_tx, tx_get_comp_st: rs_rfb_state_progress_completion_status, tx_get_progress: rs_rfb_tx_get_alstate_progress, - get_tx_logged: None, - set_tx_logged: None, get_de_state: rs_rfb_tx_get_detect_state, set_de_state: rs_rfb_tx_set_detect_state, get_events: Some(rs_rfb_state_get_events), diff --git a/rust/src/sip/sip.rs b/rust/src/sip/sip.rs index 944c5aab84..c1f1b8fa16 100755 --- a/rust/src/sip/sip.rs +++ b/rust/src/sip/sip.rs @@ -382,8 +382,6 @@ pub unsafe extern "C" fn rs_sip_register_parser() { get_tx: rs_sip_state_get_tx, tx_get_comp_st: rs_sip_state_progress_completion_status, tx_get_progress: rs_sip_tx_get_alstate_progress, - get_tx_logged: None, - set_tx_logged: None, get_de_state: rs_sip_state_get_tx_detect_state, set_de_state: rs_sip_state_set_tx_detect_state, get_events: Some(rs_sip_state_get_events), diff --git a/rust/src/snmp/snmp.rs b/rust/src/snmp/snmp.rs index 7ef47578d2..3c976d5def 100644 --- a/rust/src/snmp/snmp.rs +++ b/rust/src/snmp/snmp.rs @@ -575,8 +575,6 @@ pub unsafe extern "C" fn rs_register_snmp_parser() { get_tx : rs_snmp_state_get_tx, tx_get_comp_st : rs_snmp_state_progress_completion_status, tx_get_progress : rs_snmp_tx_get_alstate_progress, - get_tx_logged : None, - set_tx_logged : None, get_de_state : rs_snmp_state_get_tx_detect_state, set_de_state : rs_snmp_state_set_tx_detect_state, get_events : Some(rs_snmp_state_get_events), diff --git a/rust/src/ssh/ssh.rs b/rust/src/ssh/ssh.rs index 5231e563a9..1b5d5cea69 100644 --- a/rust/src/ssh/ssh.rs +++ b/rust/src/ssh/ssh.rs @@ -549,8 +549,6 @@ pub unsafe extern "C" fn rs_ssh_register_parser() { get_tx: rs_ssh_state_get_tx, tx_get_comp_st: rs_ssh_state_progress_completion_status, tx_get_progress: rs_ssh_tx_get_alstate_progress, - get_tx_logged: None, - set_tx_logged: None, get_de_state: rs_ssh_tx_get_detect_state, set_de_state: rs_ssh_tx_set_detect_state, get_events: Some(rs_ssh_state_get_events), diff --git a/src/app-layer-parser.c b/src/app-layer-parser.c index fd6b24c6ab..c312d9b30c 100644 --- a/src/app-layer-parser.c +++ b/src/app-layer-parser.c @@ -117,9 +117,6 @@ typedef struct AppLayerParserProtoCtx_ int (*StateGetEventInfo)(const char *event_name, int *event_id, AppLayerEventType *event_type); - LoggerId (*StateGetTxLogged)(void *alstate, void *tx); - void (*StateSetTxLogged)(void *alstate, void *tx, LoggerId logger); - DetectEngineState *(*GetTxDetectState)(void *tx); int (*SetTxDetectState)(void *tx, DetectEngineState *); @@ -442,21 +439,6 @@ void AppLayerParserRegisterGetEventsFunc(uint8_t ipproto, AppProto alproto, SCReturn; } -void AppLayerParserRegisterLoggerFuncs(uint8_t ipproto, AppProto alproto, - LoggerId (*StateGetTxLogged)(void *, void *), - void (*StateSetTxLogged)(void *, void *, LoggerId)) -{ - SCEnter(); - - alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateGetTxLogged = - StateGetTxLogged; - - alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].StateSetTxLogged = - StateSetTxLogged; - - SCReturn; -} - void AppLayerParserRegisterLoggerBits(uint8_t ipproto, AppProto alproto, LoggerId bits) { SCEnter(); @@ -701,34 +683,6 @@ AppLayerGetTxIteratorFunc AppLayerGetTxIterator(const uint8_t ipproto, return Func ? Func : AppLayerDefaultGetTxIterator; } -void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto, - void *alstate, void *tx, LoggerId logger) -{ - SCEnter(); - - if (alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto]. - StateSetTxLogged != NULL) { - alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto]. - StateSetTxLogged(alstate, tx, logger); - } - - SCReturn; -} - -LoggerId AppLayerParserGetTxLogged(const Flow *f, - void *alstate, void *tx) -{ - SCEnter(); - - LoggerId r = 0; - if (alp_ctx.ctxs[f->protomap][f->alproto].StateGetTxLogged != NULL) { - r = alp_ctx.ctxs[f->protomap][f->alproto]. - StateGetTxLogged(alstate, tx); - } - - SCReturnUInt(r); -} - uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate) { SCEnter(); @@ -787,9 +741,8 @@ static inline uint32_t GetTxLogged(const Flow *f, void *alstate, void *tx) AppLayerTxData *txd = AppLayerParserGetTxData(f->proto, f->alproto, tx); if (txd) { return txd->logged.flags; - } else { - return AppLayerParserGetTxLogged(f, alstate, tx); } + return 0; } void AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate, @@ -1549,7 +1502,6 @@ static void ValidateParserProtoDump(AppProto alproto, uint8_t ipproto) printf("- GetTxDetectState %p SetTxDetectState %p\n", ctx->GetTxDetectState, ctx->SetTxDetectState); printf("Optional:\n"); printf("- LocalStorageAlloc %p LocalStorageFree %p\n", ctx->LocalStorageAlloc, ctx->LocalStorageFree); - printf("- StateGetTxLogged %p StateSetTxLogged %p\n", ctx->StateGetTxLogged, ctx->StateSetTxLogged); printf("- StateGetEvents %p StateGetEventInfo %p StateGetEventInfoById %p\n", ctx->StateGetEvents, ctx->StateGetEventInfo, ctx->StateGetEventInfoById); } @@ -1585,9 +1537,6 @@ static void ValidateParserProto(AppProto alproto, uint8_t ipproto) if (!(BOTH_SET_OR_BOTH_UNSET(ctx->LocalStorageAlloc, ctx->LocalStorageFree))) { goto bad; } - if (!(BOTH_SET_OR_BOTH_UNSET(ctx->StateGetTxLogged, ctx->StateSetTxLogged))) { - goto bad; - } if (!(BOTH_SET(ctx->GetTxDetectState, ctx->SetTxDetectState))) { goto bad; } diff --git a/src/app-layer-parser.h b/src/app-layer-parser.h index 733a819324..933d570e58 100644 --- a/src/app-layer-parser.h +++ b/src/app-layer-parser.h @@ -206,10 +206,6 @@ void AppLayerParserDestroyProtocolParserLocalStorage(uint8_t ipproto, AppProto a uint64_t AppLayerParserGetTransactionLogId(AppLayerParserState *pstate); void AppLayerParserSetTransactionLogId(AppLayerParserState *pstate, uint64_t tx_id); -void AppLayerParserSetTxLogged(uint8_t ipproto, AppProto alproto, void *alstate, - void *tx, LoggerId logged); -LoggerId AppLayerParserGetTxLogged(const Flow *f, void *alstate, void *tx); - uint64_t AppLayerParserGetTransactionInspectId(AppLayerParserState *pstate, uint8_t direction); void AppLayerParserSetTransactionInspectId(const Flow *f, AppLayerParserState *pstate, void *alstate, const uint8_t flags, bool tag_txs_as_inspected); diff --git a/src/app-layer-register.c b/src/app-layer-register.c index 5ac182e964..41bf9f3753 100644 --- a/src/app-layer-register.c +++ b/src/app-layer-register.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Open Information Security Foundation +/* Copyright (C) 2017-2020 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -136,11 +136,6 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto) AppLayerParserRegisterGetTx(p->ip_proto, alproto, p->StateGetTx); - if (p->StateGetTxLogged && p->StateSetTxLogged) { - AppLayerParserRegisterLoggerFuncs(p->ip_proto, alproto, - p->StateGetTxLogged, p->StateSetTxLogged); - } - /* What is this being registered for? */ AppLayerParserRegisterDetectStateFuncs(p->ip_proto, alproto, p->GetTxDetectState, p->SetTxDetectState); diff --git a/src/app-layer-register.h b/src/app-layer-register.h index a6d5f75300..9317e57b4b 100644 --- a/src/app-layer-register.h +++ b/src/app-layer-register.h @@ -48,9 +48,6 @@ typedef struct AppLayerParser { int (*StateGetProgressCompletionStatus)(uint8_t direction); int (*StateGetProgress)(void *alstate, uint8_t direction); - uint32_t (*StateGetTxLogged)(void *alstate, void *tx); - void (*StateSetTxLogged)(void *alstate, void *tx, uint32_t logger); - DetectEngineState *(*GetTxDetectState)(void *tx); int (*SetTxDetectState)(void *tx, DetectEngineState *); diff --git a/src/output-tx.c b/src/output-tx.c index 6e35dcfbac..9446c39a78 100644 --- a/src/output-tx.c +++ b/src/output-tx.c @@ -223,7 +223,7 @@ static TmEcode OutputTxLog(ThreadVars *tv, Packet *p, void *thread_data) goto next_tx; } - LoggerId tx_logged = txd ? txd->logged.flags : AppLayerParserGetTxLogged(f, alstate, tx); + LoggerId tx_logged = txd ? txd->logged.flags : 0; const LoggerId tx_logged_old = tx_logged; SCLogDebug("logger: expect %08x, have %08x", logger_expectation, tx_logged); if (tx_logged == logger_expectation) { @@ -297,9 +297,6 @@ next_logger: tx_logged, tx_logged_old); if (txd != NULL) { txd->logged.flags |= tx_logged; - } else { - AppLayerParserSetTxLogged(p->proto, alproto, alstate, tx, - tx_logged); } }