syslog-ng source
afsocket-source.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2002-2012 Balabit
3  * Copyright (c) 1998-2012 Balázs Scheidler
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License version 2 as published
7  * by the Free Software Foundation, or (at your option) any later version.
8  *
9  * This program 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
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; 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 AFSOCKET_SOURCE_H_INCLUDED
25 #define AFSOCKET_SOURCE_H_INCLUDED
26 
27 #include "afsocket.h"
28 #include "socket-options.h"
29 #include "transport-mapper.h"
30 #include "driver.h"
31 #include "logreader.h"
32 #include "dynamic-window-pool.h"
33 #include "atomic-gssize.h"
34 #include "stats/stats-counter.h"
35 
36 #include <iv.h>
37 
38 typedef struct _AFSocketSourceDriver AFSocketSourceDriver;
39 
41 {
42  LogSrcDriver super;
46  struct iv_fd listen_fd;
47  struct iv_timer dynamic_window_timer;
52  gint fd;
54  DynamicWindowPool *dynamic_window_pool;
55  LogProtoServerFactory *proto_factory;
56 
57  struct
58  {
59  struct iv_timer packet_stats_timer;
65 
70  GList *connections;
71  SocketOptions *socket_options;
72  TransportMapper *transport_mapper;
73 
74  /*
75  * Apply transport options, set up bind_addr based on the
76  * information processed during parse time. This used to be
77  * constructed during the parser, however that made the ordering of
78  * various options matter and behave incorrectly when the port() was
79  * specified _after_ transport(). Now, it collects the information,
80  * and then applies them with a separate call to apply_transport()
81  * during init().
82  */
83 
84  gboolean (*setup_addresses)(AFSocketSourceDriver *s);
85 
86  /* optionally acquire a socket from the runtime environment (e.g. systemd) */
87  gboolean (*acquire_socket)(AFSocketSourceDriver *s, gint *fd);
88 };
89 
90 void afsocket_sd_set_keep_alive(LogDriver *self, gint enable);
91 void afsocket_sd_set_max_connections(LogDriver *self, gint max_connections);
92 void afsocket_sd_set_listen_backlog(LogDriver *self, gint listen_backlog);
93 void afsocket_sd_set_dynamic_window_size(LogDriver *self, gint dynamic_window_size);
94 void afsocket_sd_set_dynamic_window_stats_freq(LogDriver *self, gdouble stats_freq);
95 void afsocket_sd_set_dynamic_window_realloc_ticks(LogDriver *self, gint realloc_ticks);
96 
97 static inline gboolean
98 afsocket_sd_acquire_socket(AFSocketSourceDriver *s, gint *fd)
99 {
100  if (s->acquire_socket)
101  return s->acquire_socket(s, fd);
102  *fd = -1;
103  return TRUE;
104 }
105 
106 static inline gboolean
107 afsocket_sd_setup_addresses(AFSocketSourceDriver *s)
108 {
109  return s->setup_addresses(s);
110 }
111 
112 gboolean afsocket_sd_setup_addresses_method(AFSocketSourceDriver *self);
113 
114 gboolean afsocket_sd_init_method(LogPipe *s);
115 gboolean afsocket_sd_deinit_method(LogPipe *s);
116 void afsocket_sd_free_method(LogPipe *self);
117 
118 void afsocket_sd_init_instance(AFSocketSourceDriver *self, SocketOptions *socket_options,
119  TransportMapper *transport_mapper, GlobalConfig *cfg);
120 
121 #endif
gboolean afsocket_sd_init_method(LogPipe *s)
Definition: afsocket-source.c:1320
void afsocket_sd_set_dynamic_window_realloc_ticks(LogDriver *self, gint realloc_ticks)
Definition: afsocket-source.c:365
void afsocket_sd_set_keep_alive(LogDriver *self, gint enable)
Definition: afsocket-source.c:325
void afsocket_sd_set_max_connections(LogDriver *self, gint max_connections)
Definition: afsocket-source.c:333
gboolean afsocket_sd_deinit_method(LogPipe *s)
Definition: afsocket-source.c:1346
void afsocket_sd_init_instance(AFSocketSourceDriver *self, SocketOptions *socket_options, TransportMapper *transport_mapper, GlobalConfig *cfg)
Definition: afsocket-source.c:1404
void afsocket_sd_free_method(LogPipe *self)
Definition: afsocket-source.c:1391
void afsocket_sd_set_dynamic_window_stats_freq(LogDriver *self, gdouble stats_freq)
Definition: afsocket-source.c:357
void afsocket_sd_set_listen_backlog(LogDriver *self, gint listen_backlog)
Definition: afsocket-source.c:341
gboolean afsocket_sd_setup_addresses_method(AFSocketSourceDriver *self)
Definition: afsocket-source.c:1211
void afsocket_sd_set_dynamic_window_size(LogDriver *self, gint dynamic_window_size)
Definition: afsocket-source.c:349
Definition: gsockaddr.h:46
Definition: logreader.h:47
Definition: stats-counter.h:67
Definition: afsocket-source.h:41
guint32 window_size_initialized
Definition: afsocket-source.h:44
StatsCounterItem * socket_dropped_packets
Definition: afsocket-source.h:60
GList * connections
Definition: afsocket-source.h:70
struct _AFSocketSourceDriver::@112 metrics
gboolean(* setup_addresses)(AFSocketSourceDriver *s)
Definition: afsocket-source.h:84
atomic_gssize max_connections
Definition: afsocket-source.h:67
gint dynamic_window_realloc_ticks
Definition: afsocket-source.h:51
GSockAddr * bind_addr
Definition: afsocket-source.h:66
StatsCounterItem * socket_receive_buffer_max
Definition: afsocket-source.h:61
DynamicWindowPool * dynamic_window_pool
Definition: afsocket-source.h:54
struct iv_timer dynamic_window_timer
Definition: afsocket-source.h:47
gsize dynamic_window_size
Definition: afsocket-source.h:48
StatsCounterItem * rejected_connections
Definition: afsocket-source.h:63
gint fd
Definition: afsocket-source.h:52
gboolean(* acquire_socket)(AFSocketSourceDriver *s, gint *fd)
Definition: afsocket-source.h:87
LogProtoServerFactory * proto_factory
Definition: afsocket-source.h:55
LogSrcDriver super
Definition: afsocket-source.h:42
guint32 connections_kept_alive_across_reloads
Definition: afsocket-source.h:43
SocketOptions * socket_options
Definition: afsocket-source.h:71
guint32 activate_listener
Definition: afsocket-source.h:45
atomic_gssize num_connections
Definition: afsocket-source.h:68
glong dynamic_window_stats_freq
Definition: afsocket-source.h:50
StatsCounterItem * socket_receive_buffer_used
Definition: afsocket-source.h:62
struct iv_timer packet_stats_timer
Definition: afsocket-source.h:59
gint listen_backlog
Definition: afsocket-source.h:69
gsize dynamic_window_timer_tick
Definition: afsocket-source.h:49
LogReaderOptions reader_options
Definition: afsocket-source.h:53
struct iv_fd listen_fd
Definition: afsocket-source.h:46
TransportMapper * transport_mapper
Definition: afsocket-source.h:72
Definition: atomic-gssize.h:33
GlobalConfig * cfg
Definition: test_batched_ack_tracker.c:34
TransportMapper * transport_mapper
Definition: transport-mapper-lib.c:25