From 9489d5b9e36e4f0fbcffc157a330aad3e8a96563 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 3 Jun 2016 15:38:02 -0600 Subject: [PATCH] logging: remove dead code from output-json The "parent" json logger was setup like a real logger, but some of that code was never being called. --- src/output-json.c | 111 +--------------------------------------- src/output-json.h | 1 - src/tm-modules.c | 1 - src/tm-threads-common.h | 1 - 4 files changed, 1 insertion(+), 113 deletions(-) diff --git a/src/output-json.c b/src/output-json.c index 7fb06c535a..6a91cbd0fb 100644 --- a/src/output-json.c +++ b/src/output-json.c @@ -65,45 +65,11 @@ * */ -TmEcode OutputJson (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode OutputJsonThreadInit(ThreadVars *, void *, void **); -TmEcode OutputJsonThreadDeinit(ThreadVars *, void *); int OutputJsonOpenFileCtx(LogFileCtx *, char *); -void OutputJsonRegisterTests(void); void TmModuleOutputJsonRegister (void) { - tmm_modules[TMM_OUTPUTJSON].name = "OutputJSON"; - tmm_modules[TMM_OUTPUTJSON].ThreadInit = OutputJsonThreadInit; - tmm_modules[TMM_OUTPUTJSON].Func = OutputJson; - tmm_modules[TMM_OUTPUTJSON].ThreadDeinit = OutputJsonThreadDeinit; - tmm_modules[TMM_OUTPUTJSON].RegisterTests = OutputJsonRegisterTests; -} - -OutputCtx *OutputJsonInitCtx(ConfNode *conf) -{ - SCLogDebug("Can't init JSON output - JSON support was disabled during build."); - return NULL; -} - -TmEcode OutputJsonThreadInit(ThreadVars *t, void *initdata, void **data) -{ - SCLogDebug("Can't init JSON output thread - JSON support was disabled during build."); - return TM_ECODE_FAILED; -} - -TmEcode OutputJson (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq) -{ - return TM_ECODE_OK; -} - -TmEcode OutputJsonThreadDeinit(ThreadVars *t, void *data) -{ - return TM_ECODE_FAILED; -} - -void OutputJsonRegisterTests (void) -{ + SCLogDebug("Can't register JSON output - JSON support was disabled during build."); } #else /* implied we do have JSON support */ @@ -116,23 +82,10 @@ void OutputJsonRegisterTests (void) #define OUTPUT_BUFFER_SIZE 65536 -TmEcode OutputJson (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *); -TmEcode OutputJsonThreadInit(ThreadVars *, void *, void **); -TmEcode OutputJsonThreadDeinit(ThreadVars *, void *); -void OutputJsonExitPrintStats(ThreadVars *, void *); -void OutputJsonRegisterTests(void); static void OutputJsonDeInitCtx(OutputCtx *); void TmModuleOutputJsonRegister (void) { - tmm_modules[TMM_OUTPUTJSON].name = MODULE_NAME; - tmm_modules[TMM_OUTPUTJSON].ThreadInit = OutputJsonThreadInit; - tmm_modules[TMM_OUTPUTJSON].Func = OutputJson; - tmm_modules[TMM_OUTPUTJSON].ThreadExitPrintStats = OutputJsonExitPrintStats; - tmm_modules[TMM_OUTPUTJSON].ThreadDeinit = OutputJsonThreadDeinit; - tmm_modules[TMM_OUTPUTJSON].RegisterTests = OutputJsonRegisterTests; - tmm_modules[TMM_OUTPUTJSON].cap_flags = 0; - OutputRegisterModule(MODULE_NAME, "eve-log", OutputJsonInitCtx); } @@ -372,51 +325,6 @@ int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer) return 0; } -TmEcode OutputJson (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq) -{ - return TM_ECODE_OK; -} - -TmEcode OutputJsonThreadInit(ThreadVars *t, void *initdata, void **data) -{ - AlertJsonThread *aft = SCMalloc(sizeof(AlertJsonThread)); - if (unlikely(aft == NULL)) - return TM_ECODE_FAILED; - memset(aft, 0, sizeof(AlertJsonThread)); - - if(initdata == NULL) - { - SCLogDebug("Error getting context for EveLog. \"initdata\" argument NULL"); - SCFree(aft); - return TM_ECODE_FAILED; - } - - *data = (void *)aft; - return TM_ECODE_OK; -} - -TmEcode OutputJsonThreadDeinit(ThreadVars *t, void *data) -{ - AlertJsonThread *aft = (AlertJsonThread *)data; - if (aft == NULL) { - return TM_ECODE_OK; - } - - SCFree(aft); - return TM_ECODE_OK; -} - -void OutputJsonExitPrintStats(ThreadVars *tv, void *data) -{ - AlertJsonThread *aft = (AlertJsonThread *)data; - if (aft == NULL) { - return; - } - - SCLogInfo("JSON output wrote %" PRIu64 " alerts", aft->file_ctx->alerts); - -} - /** * \brief Create a new LogFileCtx for "fast" output style. * \param conf The configuration node for this output. @@ -621,21 +529,4 @@ static void OutputJsonDeInitCtx(OutputCtx *output_ctx) SCFree(output_ctx); } -/*------------------------------Unittests-------------------------------------*/ - -#ifdef UNITTESTS - -#endif /* UNITTESTS */ - -/** - * \brief This function registers unit tests for AlertFastLog API. - */ -void OutputJsonRegisterTests(void) -{ - -#ifdef UNITTESTS - -#endif /* UNITTESTS */ - -} #endif diff --git a/src/output-json.h b/src/output-json.h index 467062db33..7f43392664 100644 --- a/src/output-json.h +++ b/src/output-json.h @@ -43,7 +43,6 @@ void CreateJSONFlowId(json_t *js, const Flow *f); void JsonTcpFlags(uint8_t flags, json_t *js); json_t *CreateJSONHeader(const Packet *p, int direction_sensative, const char *event_type); json_t *CreateJSONHeaderWithTxId(const Packet *p, int direction_sensitive, const char *event_type, uint64_t tx_id); -TmEcode OutputJSON(json_t *js, void *data, uint64_t *count); int OutputJSONBuffer(json_t *js, LogFileCtx *file_ctx, MemBuffer **buffer); OutputCtx *OutputJsonInitCtx(ConfNode *); diff --git a/src/tm-modules.c b/src/tm-modules.c index d47637f296..97c4b5223f 100644 --- a/src/tm-modules.c +++ b/src/tm-modules.c @@ -233,7 +233,6 @@ const char * TmModuleTmmIdToString(TmmId id) CASE_CODE (TMM_FILELOGGER); CASE_CODE (TMM_FILEDATALOGGER); CASE_CODE (TMM_STREAMINGLOGGER); - CASE_CODE (TMM_OUTPUTJSON); CASE_CODE (TMM_FLOWMANAGER); CASE_CODE (TMM_FLOWRECYCLER); CASE_CODE (TMM_UNIXMANAGER); diff --git a/src/tm-threads-common.h b/src/tm-threads-common.h index c9a449bcde..30ca6740b3 100644 --- a/src/tm-threads-common.h +++ b/src/tm-threads-common.h @@ -42,7 +42,6 @@ typedef enum { TMM_RECEIVEPFRING, TMM_DECODEPFRING, TMM_RESPONDREJECT, - TMM_OUTPUTJSON, TMM_PCAPLOG, TMM_DECODEIPFW, TMM_VERDICTIPFW,