]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: remove logged API calls
authorVictor Julien <victor@inliniac.net>
Sun, 7 Jun 2020 18:57:19 +0000 (20:57 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 11 Jul 2020 06:37:40 +0000 (08:37 +0200)
17 files changed:
rust/src/applayer.rs
rust/src/applayertemplate/template.rs
rust/src/dhcp/dhcp.rs
rust/src/dns/dns.rs
rust/src/ikev2/ikev2.rs
rust/src/krb/krb5.rs
rust/src/ntp/ntp.rs
rust/src/rdp/rdp.rs
rust/src/rfb/rfb.rs
rust/src/sip/sip.rs
rust/src/snmp/snmp.rs
rust/src/ssh/ssh.rs
src/app-layer-parser.c
src/app-layer-parser.h
src/app-layer-register.c
src/app-layer-register.h
src/output-tx.c

index 0feab3ebe0050f9d3e5085335b5dfd6e588ea55e..da7c78971daff159ca2e87e255dc5e12a72e91f3 100644 (file)
@@ -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<GetTxLoggedFn>,
-    /// Logged transaction setter function
-    pub set_tx_logged:      Option<SetTxLoggedFn>,
-
     /// 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;
index 89317277f2abddf5ebac186818bc7776f2c75c45..97826a0994aae6a188eb8252dfce078265460ca9 100644 (file)
@@ -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),
index 77c747f892c9ab808c9c1fc8c3d4bdef960d1304..a87b292485c58070197d0994af91f27054c05505 100644 (file)
@@ -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),
index 624782d93bbb96a4d7ada5680149965f76d2eb85..e54b8cb3cb15155022cf0a33d10105dbcdee19e2 100644 (file)
@@ -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),
index a5a323cc1872320bd094bf773192ae2a8709acad..2f6a911ebc524ce58569ef09d400fb07c1ac99ff 100644 (file)
@@ -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),
index f1710c155723544d2e3ade56c3540171d7169039..424017603936ff9fb6550181d537371bbb8d2687 100644 (file)
@@ -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),
index 837ccb4bc2416c4dc091155edc69edabaa4905cf..64a9035f54cbb2c0d872cfc7cd5c67f234dd96f9 100644 (file)
@@ -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),
index 25a678e2061504924b3fe8f8168d972d920ca474..432b1a4805b6a9b786a0f6d22f0cd65d143cd2c6 100644 (file)
@@ -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,
index 7984b252e6eea81f00c046a1766492c69a37c38c..fad695be443495a2240ec1d0e61e1de67cf06d6f 100644 (file)
@@ -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),
index 944c5aab84f3c4a73dca4ba88f0557cbcd0d2a0f..c1f1b8fa16fcb7e248dd49a9b5643e28a469e612 100755 (executable)
@@ -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),
index 7ef47578d2df4f28120b05b159604fa3fa7fdff9..3c976d5defc51ff5c879a59ce96960e5ce9d2219 100644 (file)
@@ -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),
index 5231e563a9abc90fd5a32050b5f57bebad7f18f7..1b5d5cea69e452c4feee020656ffda7e81f51d81 100644 (file)
@@ -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),
index fd6b24c6ab481e20ee770b7243386f9f930e784d..c312d9b30cc6a262a2f666998b74da0d3ba9e08c 100644 (file)
@@ -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;
     }
index 733a819324d803b72a0803a8d32299339bb9f22f..933d570e58d075e645e159327470d32dbefd62a6 100644 (file)
@@ -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);
index 5ac182e964aa13e24cdf1b93cfe23b5257eb76fd..41bf9f37532a7e13beed7d8719dbe65222366405 100644 (file)
@@ -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);
index a6d5f7530015d9d7e6338db8665742e1afcce963..9317e57b4b0c1f4177f60048307311d69fd81dc8 100644 (file)
@@ -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 *);
 
index 6e35dcfbac4a7ae1d9299966d791951627c746d1..9446c39a782f98c177dd1c5d783696f46daf7c76 100644 (file)
@@ -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);
             }
         }