syslog-ng source
loggen_plugin.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018 Balabit
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * As an additional exemption you are allowed to compile & link against the
19  * OpenSSL libraries as published by the OpenSSL project. See the file
20  * COPYING for details.
21  *
22  */
23 
24 #ifndef LOGGEN_PLUGIN_H_INCLUDED
25 #define LOGGEN_PLUGIN_H_INCLUDED
26 
27 #include "compat/glib.h"
28 #include <gmodule.h>
29 #include <sys/time.h>
30 
31 #define LOGGEN_PLUGIN_INFO "loggen_plugin_info"
32 #define LOGGEN_PLUGIN_LIB_PREFIX "libloggen_"
33 #define LOGGEN_PLUGIN_NAME_MAXSIZE 100
34 
35 typedef struct _plugin_option
36 {
38  int interval;
40  int permanent;
43  int use_ipv6;
44  const char *target; /* command line argument */
45  const char *port;
46  int rate;
47  int reconnect;
48  gboolean proxied;
50  char *proxy_src_ip;
51  char *proxy_dst_ip;
54 } PluginOption;
55 
56 typedef struct _thread_data
57 {
59  int index;
60  int sent_messages;
61  struct timeval start_time;
62  struct timeval last_throttle_check;
63  long buckets;
65 
66  /* timestamp cache for logline generator */
67  struct timeval ts_formatted;
68  char stamp[32];
69 } ThreadData;
70 
71 typedef GOptionEntry *(*get_option_func)(void);
72 typedef gboolean (*start_plugin_func)(PluginOption *option);
73 typedef void (*stop_plugin_func)(PluginOption *option);
74 typedef int (*generate_message_func)(char *buffer, int buffer_size, ThreadData *thread_context, unsigned long seq);
75 typedef void (*set_generate_message_func)(generate_message_func gen_message);
76 typedef int (*get_thread_count_func)(void);
77 typedef gboolean (*is_plugin_activated_func)(void);
78 
79 typedef struct _plugin_info
80 {
81  gchar *name;
87  gboolean require_framing; /* plugin can indicates that framing is mandatory in message lines */
89 } PluginInfo;
90 
91 gboolean thread_check_exit_criteria(ThreadData *thread_context);
92 gboolean thread_check_time_bucket(ThreadData *thread_context);
93 
94 #endif
gboolean thread_check_time_bucket(ThreadData *thread_context)
Definition: loggen_plugin.c:72
void(* stop_plugin_func)(PluginOption *option)
Definition: loggen_plugin.h:73
gboolean thread_check_exit_criteria(ThreadData *thread_context)
Definition: loggen_plugin.c:35
void(* set_generate_message_func)(generate_message_func gen_message)
Definition: loggen_plugin.h:75
int(* generate_message_func)(char *buffer, int buffer_size, ThreadData *thread_context, unsigned long seq)
Definition: loggen_plugin.h:74
gboolean(* is_plugin_activated_func)(void)
Definition: loggen_plugin.h:77
int(* get_thread_count_func)(void)
Definition: loggen_plugin.h:76
GOptionEntry *(* get_option_func)(void)
Definition: loggen_plugin.h:71
gboolean(* start_plugin_func)(PluginOption *option)
Definition: loggen_plugin.h:72
Definition: loggen_plugin.h:80
set_generate_message_func set_generate_message
Definition: loggen_plugin.h:86
start_plugin_func start_plugin
Definition: loggen_plugin.h:85
is_plugin_activated_func is_plugin_activated
Definition: loggen_plugin.h:88
get_option_func get_options_list
Definition: loggen_plugin.h:82
gchar * name
Definition: loggen_plugin.h:81
gboolean require_framing
Definition: loggen_plugin.h:87
get_thread_count_func get_thread_count
Definition: loggen_plugin.h:83
stop_plugin_func stop_plugin
Definition: loggen_plugin.h:84
Definition: loggen_plugin.h:36
int message_length
Definition: loggen_plugin.h:37
int reconnect
Definition: loggen_plugin.h:47
int use_ipv6
Definition: loggen_plugin.h:43
int rate
Definition: loggen_plugin.h:46
char * proxy_src_port
Definition: loggen_plugin.h:52
int permanent
Definition: loggen_plugin.h:40
gint proxy_version
Definition: loggen_plugin.h:49
const char * target
Definition: loggen_plugin.h:44
const char * port
Definition: loggen_plugin.h:45
char * proxy_dst_ip
Definition: loggen_plugin.h:51
char * proxy_dst_port
Definition: loggen_plugin.h:53
int active_connections
Definition: loggen_plugin.h:41
int number_of_messages
Definition: loggen_plugin.h:39
int interval
Definition: loggen_plugin.h:38
int idle_connections
Definition: loggen_plugin.h:42
gboolean proxied
Definition: loggen_plugin.h:48
char * proxy_src_ip
Definition: loggen_plugin.h:50
Definition: loggen_plugin.h:57
PluginOption * option
Definition: loggen_plugin.h:58
int index
Definition: loggen_plugin.h:59
gboolean proxy_header_sent
Definition: loggen_plugin.h:64
long buckets
Definition: loggen_plugin.h:63
GString * buffer
Definition: test_smart_multi_line.c:69