suricata
util-log-redis.h
Go to the documentation of this file.
1/* Copyright (C) 2016-2024 Open Information Security Foundation
2 *
3 * You can copy, redistribute or modify this Program under the terms of
4 * the GNU General Public License version 2 as published by the Free
5 * Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 *
12 * You should have received a copy of the GNU General Public License
13 * version 2 along with this program; if not, write to the Free Software
14 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15 * 02110-1301, USA.
16 */
17
18/**
19 * \file
20 *
21 * \author Paulo Pacheco <fooinha@gmail.com>
22 */
23
24#ifndef SURICATA_UTIL_LOG_REDIS_H
25#define SURICATA_UTIL_LOG_REDIS_H
26
27#ifdef HAVE_LIBHIREDIS
28#include <hiredis/hiredis.h>
29
30
31#ifdef HAVE_LIBEVENT
32#include <hiredis/async.h>
33#endif /* HAVE_LIBEVENT */
34
35#include "conf.h" /* ConfNode */
36
37enum RedisMode { REDIS_LIST, REDIS_CHANNEL };
38
39typedef struct RedisSetup_ {
40 enum RedisMode mode;
41 const char *format;
42 const char *command;
43 const char *key;
44 const char *server;
45 uint16_t port;
46 int is_async;
47 int batch_size;
48 char *stream_format;
49} RedisSetup;
50
51typedef struct SCLogRedisContext_ {
52 redisContext *sync;
53#if HAVE_LIBEVENT
54 redisAsyncContext *async;
55 struct event_base *ev_base;
56 int connected;
57#endif /* HAVE_LIBEVENT */
58 time_t tried;
59 int batch_count;
60 time_t last_push;
61} SCLogRedisContext;
62
63void SCLogRedisInit(void);
64int SCConfLogOpenRedis(SCConfNode *, void *);
65int LogFileWriteRedis(void *, const char *, size_t);
66
67#endif /* HAVE_LIBHIREDIS */
68#endif /* SURICATA_UTIL_LOG_REDIS_H */