]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
prelude: fix configure and cleanup
authorVictor Julien <victor@inliniac.net>
Tue, 14 Jan 2014 16:02:33 +0000 (17:02 +0100)
committerVictor Julien <victor@inliniac.net>
Mon, 27 Jan 2014 14:20:59 +0000 (15:20 +0100)
Fixes configure enabling of prelude. CFLAGS is reset, so the previous
adding of -DPRELUDE was nixed. Using AC_DEFINE now.

Cleanups:
- make functions static
- simplify handling of no prelude support
- move registration to the bottom

configure.ac
src/alert-prelude.c
src/alert-prelude.h

index 7d28b6d446d2442947c303ed2b518034cd928626..f54464b61bf2c8fff524ad16d56a6560c989c42f 100644 (file)
     CFLAGS="${CFLAGS} -Wno-error=unused-result"
 
     AS_IF([test "x$enable_prelude" = "xyes"], [
-        CFLAGS="$CFLAGS -DPRELUDE"
         AM_PATH_LIBPRELUDE(0.9.9, , AC_MSG_ERROR(Cannot find libprelude: Is libprelude-config in the path?), no)
         if test "x${LIBPRELUDE_CFLAGS}" != "x"; then
             CPPFLAGS="${CPPFLAGS} ${LIBPRELUDE_CFLAGS}"
         if test "x${LIBPRELUDE_LIBS}" != "x"; then
             LDFLAGS="${LDFLAGS} ${LIBPRELUDE_LIBS}"
         fi
+        AC_DEFINE([PRELUDE], [1], [Libprelude support enabled])
     ])
     CFLAGS="${STORECFLAGS}"
 
index 6dbbf8728da0ead679bc3f312d230731dd10007a..6bd97de56e77646727d1ca63bd7e767773c48726 100644 (file)
 #include "stream.h"
 
 #ifndef PRELUDE
-/** Handle the case where no PRELUDE support is compiled in.
- *
- */
-
-TmEcode AlertPrelude (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
-TmEcode AlertPreludeThreadInit(ThreadVars *, void *, void **);
-TmEcode AlertPreludeThreadDeinit(ThreadVars *, void *);
-int AlertPreludeOpenFileCtx(LogFileCtx *, char *);
-void AlertPreludeRegisterTests(void);
-
-void TmModuleAlertPreludeRegister (void) {
-    tmm_modules[TMM_ALERTPRELUDE].name = "AlertPrelude";
-    tmm_modules[TMM_ALERTPRELUDE].ThreadInit = AlertPreludeThreadInit;
-    tmm_modules[TMM_ALERTPRELUDE].Func = AlertPrelude;
-    tmm_modules[TMM_ALERTPRELUDE].ThreadDeinit = AlertPreludeThreadDeinit;
-    tmm_modules[TMM_ALERTPRELUDE].RegisterTests = AlertPreludeRegisterTests;
-}
 
-LogFileCtx *AlertPreludeInitCtx(ConfNode *conf)
-{
-    SCLogDebug("Can't init Prelude output - Prelude support was disabled during build.");
-    return NULL;
-}
+/* Handle the case where no PRELUDE support is compiled in. */
 
-TmEcode AlertPreludeThreadInit(ThreadVars *t, void *initdata, void **data)
+static TmEcode AlertPreludeThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     SCLogDebug("Can't init Prelude output thread - Prelude support was disabled during build.");
     return TM_ECODE_FAILED;
 }
 
-TmEcode AlertPrelude (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq)
-{
-    return TM_ECODE_OK;
-}
-
-TmEcode AlertPreludeThreadDeinit(ThreadVars *t, void *data)
+static TmEcode AlertPreludeThreadDeinit(ThreadVars *t, void *data)
 {
     return TM_ECODE_FAILED;
 }
 
-void AlertPreludeRegisterTests (void) {
+void TmModuleAlertPreludeRegister (void) {
+    tmm_modules[TMM_ALERTPRELUDE].name = "AlertPrelude";
+    tmm_modules[TMM_ALERTPRELUDE].ThreadInit = AlertPreludeThreadInit;
+    tmm_modules[TMM_ALERTPRELUDE].ThreadDeinit = AlertPreludeThreadDeinit;
 }
 
 #else /* implied we do have PRELUDE support */
 
-
 #include <libprelude/prelude.h>
 
 #define ANALYZER_CLASS "NIDS"
@@ -121,26 +97,6 @@ static unsigned int info_priority = 4;
 static unsigned int low_priority  = 3;
 static unsigned int mid_priority  = 2;
 
-
-OutputCtx *AlertPreludeInitCtx(ConfNode *conf);
-TmEcode AlertPrelude (ThreadVars *, Packet *, void *, PacketQueue *, PacketQueue *);
-TmEcode AlertPreludeThreadInit(ThreadVars *, void *, void **);
-TmEcode AlertPreludeThreadDeinit(ThreadVars *, void *);
-int AlertPreludeOpenFileCtx(LogFileCtx *, char *);
-void AlertPreludeRegisterTests(void);
-static void AlertPreludeDeinitCtx(OutputCtx *output_ctx);
-
-void TmModuleAlertPreludeRegister (void) {
-    tmm_modules[TMM_ALERTPRELUDE].name = "AlertPrelude";
-    tmm_modules[TMM_ALERTPRELUDE].ThreadInit = AlertPreludeThreadInit;
-    tmm_modules[TMM_ALERTPRELUDE].Func = AlertPrelude;
-    tmm_modules[TMM_ALERTPRELUDE].ThreadDeinit = AlertPreludeThreadDeinit;
-    tmm_modules[TMM_ALERTPRELUDE].RegisterTests = AlertPreludeRegisterTests;
-    tmm_modules[TMM_ALERTPRELUDE].cap_flags = 0;
-
-    OutputRegisterModule("AlertPrelude", "alert-prelude", AlertPreludeInitCtx);
-}
-
 /**
  * This holds global structures and variables. Since libprelude is thread-safe,
  * there is no need to store a mutex.
@@ -626,7 +582,7 @@ static int EventToReference(PacketAlert *pa, Packet *p, idmef_classification_t *
     SCReturnInt(0);
 }
 
-static int PreludePrintStreamSegmentCallback(Packet *p, void *data, uint8_t *buf, uint32_t buflen)
+static int PreludePrintStreamSegmentCallback(const Packet *p, void *data, uint8_t *buf, uint32_t buflen)
 {
     int ret;
 
@@ -654,7 +610,7 @@ static int PreludePrintStreamSegmentCallback(Packet *p, void *data, uint8_t *buf
  *
  * \return TM_ECODE_OK if ok, else TM_ECODE_FAILED
  */
-TmEcode AlertPrelude (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq)
+static TmEcode AlertPrelude (ThreadVars *tv, Packet *p, void *data, PacketQueue *pq, PacketQueue *postpq)
 {
     AlertPreludeThread *apn = (AlertPreludeThread *)data;
     int ret;
@@ -763,7 +719,7 @@ err:
  *
  * \return TM_ECODE_OK if ok, else TM_ECODE_FAILED
  */
-TmEcode AlertPreludeThreadInit(ThreadVars *t, void *initdata, void **data)
+static TmEcode AlertPreludeThreadInit(ThreadVars *t, void *initdata, void **data)
 {
     AlertPreludeThread *aun;
 
@@ -792,7 +748,7 @@ TmEcode AlertPreludeThreadInit(ThreadVars *t, void *initdata, void **data)
  *
  * \return TM_ECODE_OK if ok, else TM_ECODE_FAILED
  */
-TmEcode AlertPreludeThreadDeinit(ThreadVars *t, void *data)
+static TmEcode AlertPreludeThreadDeinit(ThreadVars *t, void *data)
 {
     AlertPreludeThread *aun = (AlertPreludeThread *)data;
 
@@ -810,6 +766,13 @@ TmEcode AlertPreludeThreadDeinit(ThreadVars *t, void *data)
     SCReturnInt(TM_ECODE_OK);
 }
 
+static void AlertPreludeDeinitCtx(OutputCtx *output_ctx)
+{
+    AlertPreludeCtx *ctx = (AlertPreludeCtx *)output_ctx->data;
+
+    prelude_client_destroy(ctx->client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
+    SCFree(output_ctx);
+}
 
 /** \brief Initialize the Prelude logging module: initialize
  * library, create the client and try to establish the connection
@@ -820,7 +783,7 @@ TmEcode AlertPreludeThreadDeinit(ThreadVars *t, void *data)
  *
  * \return A newly allocated AlertPreludeCtx structure, or NULL
  */
-OutputCtx *AlertPreludeInitCtx(ConfNode *conf)
+static OutputCtx *AlertPreludeInitCtx(ConfNode *conf)
 {
     int ret;
     prelude_client_t *client;
@@ -897,18 +860,14 @@ OutputCtx *AlertPreludeInitCtx(ConfNode *conf)
     SCReturnPtr((void*)output_ctx, "OutputCtx");
 }
 
-static void AlertPreludeDeinitCtx(OutputCtx *output_ctx)
-{
-    AlertPreludeCtx *ctx = (AlertPreludeCtx *)output_ctx->data;
-
-    prelude_client_destroy(ctx->client, PRELUDE_CLIENT_EXIT_STATUS_SUCCESS);
-    SCFree(output_ctx);
-}
+void TmModuleAlertPreludeRegister (void) {
+    tmm_modules[TMM_ALERTPRELUDE].name = "AlertPrelude";
+    tmm_modules[TMM_ALERTPRELUDE].ThreadInit = AlertPreludeThreadInit;
+    tmm_modules[TMM_ALERTPRELUDE].Func = AlertPrelude;
+    tmm_modules[TMM_ALERTPRELUDE].ThreadDeinit = AlertPreludeThreadDeinit;
+    tmm_modules[TMM_ALERTPRELUDE].cap_flags = 0;
 
-void AlertPreludeRegisterTests (void) {
-#ifdef UNITTESTS
-#endif /* UNITTESTS */
+    OutputRegisterModule("AlertPrelude", "alert-prelude", AlertPreludeInitCtx);
 }
-
 #endif /* PRELUDE */
 
index dfa09215520b584a2d3128dd8fffa4afb5daf8df..ac3b3ffa8cbaddae65004a5bcd60f1e80aba0b3f 100644 (file)
@@ -27,6 +27,5 @@
 #define __ALERT_PRELUDE_H__
 
 void TmModuleAlertPreludeRegister (void);
-LogFileCtx *AlertPreludeInitCtx(ConfNode *conf);
 
 #endif /* __ALERT_PRELUDE_H__ */