]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
eve/filetypes: use more const
authorJason Ish <jason.ish@oisf.net>
Mon, 11 Mar 2024 23:13:25 +0000 (17:13 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 16 Mar 2024 08:29:34 +0000 (09:29 +0100)
examples/plugins/c-json-filetype/filetype.c
src/output-eve-null.c
src/output-eve-syslog.c
src/output-eve.h

index e20697bcb4c13b72e7dc2eb8ebeed668dcf71f13..a66b9779dfb3161e3c28e15f238d9a1bd1d2d1d7 100644 (file)
@@ -64,7 +64,7 @@ typedef struct Context_ {
  * configuration for the eve instance, not just a node named after the plugin.
  * This allows the plugin to get more context about what it is logging.
  */
-static int FiletypeInit(ConfNode *conf, bool threaded, void **data)
+static int FiletypeInit(const ConfNode *conf, const bool threaded, void **data)
 {
     SCLogNotice("Initializing template eve output plugin: threaded=%d", threaded);
     Context *context = SCCalloc(1, sizeof(Context));
@@ -125,7 +125,7 @@ static void FiletypeDeinit(void *data)
  * In the case of non-threaded EVE logging this function is called
  * once with a thread_id of 0.
  */
-static int FiletypeThreadInit(void *ctx, ThreadId thread_id, void **thread_data)
+static int FiletypeThreadInit(const void *ctx, const ThreadId thread_id, void **thread_data)
 {
     SCLogNotice("thread_id=%d", thread_id);
     ThreadData *tdata = SCCalloc(1, sizeof(ThreadData));
@@ -146,7 +146,7 @@ static int FiletypeThreadInit(void *ctx, ThreadId thread_id, void **thread_data)
  * This is where any cleanup per thread should be done including free'ing of the
  * thread_data if needed.
  */
-static void FiletypeThreadDeinit(void *ctx, void *thread_data)
+static void FiletypeThreadDeinit(const void *ctx, void *thread_data)
 {
     SCLogNotice("thread_data=%p", thread_data);
     if (thread_data == NULL) {
@@ -171,9 +171,10 @@ static void FiletypeThreadDeinit(void *ctx, void *thread_data)
  * to any resource that may block it might be best to enqueue the buffers for
  * further processing which will require copying of the provided buffer.
  */
-static int FiletypeWrite(const char *buffer, int buffer_len, void *data, void *thread_data)
+static int FiletypeWrite(
+        const char *buffer, const int buffer_len, const void *data, void *thread_data)
 {
-    Context *ctx = data;
+    const Context *ctx = data;
     ThreadData *thread = thread_data;
 
     SCLogNotice("thread_id=%d, data=%p, thread_data=%p", thread->thread_id, data, thread_data);
index 59e8c452fbec38c6abce7c0b56e1ec76dc806c38..368836e78301faf98b8b1c25ef35086b740a5ee6 100644 (file)
@@ -37,24 +37,25 @@ void NullLogInitialize(void)
 
 #define OUTPUT_NAME "nullsink"
 
-static int NullLogInit(ConfNode *conf, bool threaded, void **init_data)
+static int NullLogInit(const ConfNode *conf, const bool threaded, void **init_data)
 {
     *init_data = NULL;
     return 0;
 }
 
-static int NullLogWrite(const char *buffer, int buffer_len, void *init_data, void *thread_data)
+static int NullLogWrite(
+        const char *buffer, const int buffer_len, const void *init_data, void *thread_data)
 {
     return 0;
 }
 
-static int NullLogThreadInit(void *init_data, ThreadId thread_id, void **thread_data)
+static int NullLogThreadInit(const void *init_data, const ThreadId thread_id, void **thread_data)
 {
     *thread_data = NULL;
     return 0;
 }
 
-static void NullLogThreadDeInit(void *init_data, void *thread_data)
+static void NullLogThreadDeInit(const void *init_data, void *thread_data)
 {
 }
 
index 0787e4b75071ba2f4f8baff80d9dd5d7560da803..4560bc73e3a8043258403b9a8bac9cc57a57ea88 100644 (file)
@@ -41,7 +41,7 @@ typedef struct Context_ {
     int alert_syslog_level;
 } Context;
 
-static int SyslogInit(ConfNode *conf, bool threaded, void **init_data)
+static int SyslogInit(const ConfNode *conf, const bool threaded, void **init_data)
 {
     Context *context = SCCalloc(1, sizeof(Context));
     if (context == NULL) {
@@ -79,9 +79,10 @@ static int SyslogInit(ConfNode *conf, bool threaded, void **init_data)
     return 0;
 }
 
-static int SyslogWrite(const char *buffer, int buffer_len, void *init_data, void *thread_data)
+static int SyslogWrite(
+        const char *buffer, const int buffer_len, const void *init_data, void *thread_data)
 {
-    Context *context = init_data;
+    const Context *context = init_data;
     syslog(context->alert_syslog_level, "%s", (const char *)buffer);
 
     return 0;
index 6ee0228a07ea0462f47a8ee99cab6f4ff9f6f9ab..3b2637f64ccfe669a3775b4084e2e6cb8a90eb90 100644 (file)
@@ -100,7 +100,7 @@ typedef struct SCEveFileType_ {
      *
      * \retval 0 on success, -1 on failure
      */
-    int (*Init)(ConfNode *conf, bool threaded, void **init_data);
+    int (*Init)(const ConfNode *conf, const bool threaded, void **init_data);
 
     /**
      * \brief Called for each EVE log record.
@@ -119,7 +119,8 @@ typedef struct SCEveFileType_ {
      *
      * \retval 0 on success, -1 on failure
      */
-    int (*Write)(const char *buffer, int buffer_len, void *init_data, void *thread_data);
+    int (*Write)(
+            const char *buffer, const int buffer_len, const void *init_data, void *thread_data);
 
     /**
      * \brief Final call to deinitialize this filetype.
@@ -150,7 +151,7 @@ typedef struct SCEveFileType_ {
      *
      * \retval 0 on success, -1 on failure
      */
-    int (*ThreadInit)(void *init_data, ThreadId thread_id, void **thread_data);
+    int (*ThreadInit)(const void *init_data, const ThreadId thread_id, void **thread_data);
 
     /**
      * \brief Called to deinitialize each thread.
@@ -162,7 +163,7 @@ typedef struct SCEveFileType_ {
      *
      * \param thread_data The data setup in ThreadInit
      */
-    void (*ThreadDeinit)(void *init_data, void *thread_data);
+    void (*ThreadDeinit)(const void *init_data, void *thread_data);
 
     /* Internal list management. */
     TAILQ_ENTRY(SCEveFileType_) entries;