syslog-ng source
afsocket-dest.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_DEST_H_INCLUDED
25 #define AFSOCKET_DEST_H_INCLUDED
26 
27 #include "afsocket.h"
28 #include "socket-options.h"
29 #include "transport-mapper.h"
30 #include "driver.h"
31 #include "logwriter.h"
32 
33 #include <iv.h>
34 
35 typedef struct _AFSocketDestDriver AFSocketDestDriver;
36 typedef struct _AFSocketDestKeptAliveConnection AFSocketDestKeptAliveConnection;
37 
39 {
40  LogDestDriver super;
41 
42  guint
44  gint fd;
45  LogWriter *writer;
47  LogProtoClientFactory *proto_factory;
48 
52  struct iv_fd connect_fd;
53  struct iv_timer reconnect_timer;
54  SocketOptions *socket_options;
55  TransportMapper *transport_mapper;
56 
57  struct
58  {
61  const gchar *original_dest_name;
62 
63  LogWriter *(*construct_writer)(AFSocketDestDriver *self);
64  gboolean (*setup_addresses)(AFSocketDestDriver *s);
65  const gchar *(*get_dest_name)(const AFSocketDestDriver *s);
66 
67  void (*save_connection)(AFSocketDestDriver *s);
68  gboolean (*should_restore_connection)(AFSocketDestDriver *s, AFSocketDestKeptAliveConnection *c);
69  void (*restore_connection)(AFSocketDestDriver *s, AFSocketDestKeptAliveConnection *c);
70 };
71 
73 {
74  gchar *transport;
75  gchar *proto;
76 
78  LogWriter *writer;
79 
80  void (*free_fn)(AFSocketDestKeptAliveConnection *s);
81 };
82 
83 
84 static inline LogWriter *
85 afsocket_dd_construct_writer(AFSocketDestDriver *self)
86 {
87  return self->construct_writer(self);
88 }
89 
90 static inline gboolean
91 afsocket_dd_setup_addresses(AFSocketDestDriver *s)
92 {
93  return s->setup_addresses(s);
94 }
95 
96 static inline const gchar *
97 afsocket_dd_get_dest_name(const AFSocketDestDriver *s)
98 {
99  return s->get_dest_name(s);
100 }
101 
102 LogWriter *afsocket_dd_construct_writer_method(AFSocketDestDriver *self);
103 gboolean afsocket_dd_setup_addresses_method(AFSocketDestDriver *self);
104 void afsocket_dd_set_keep_alive(LogDriver *self, gint enable);
105 void afsocket_dd_init_instance(AFSocketDestDriver *self, SocketOptions *socket_options,
106  TransportMapper *transport_mapper, GlobalConfig *cfg);
107 void afsocket_dd_reconnect(AFSocketDestDriver *self);
108 void afsocket_dd_stop_watches(AFSocketDestDriver *self);
109 
110 gboolean afsocket_dd_init(LogPipe *s);
111 gboolean afsocket_dd_deinit(LogPipe *s);
112 void afsocket_dd_free(LogPipe *s);
113 void afsocket_dd_connected_with_fd(gpointer self, gint fd, GSockAddr *saddr);
114 
115 
116 void afsocket_dd_save_connection(AFSocketDestDriver *self, AFSocketDestKeptAliveConnection *c);
117 gboolean afsocket_dd_should_restore_connection_method(AFSocketDestDriver *self, AFSocketDestKeptAliveConnection *c);
118 void afsocket_dd_restore_connection_method(AFSocketDestDriver *self, AFSocketDestKeptAliveConnection *item);
119 
120 void afsocket_kept_alive_connection_init_instance(AFSocketDestKeptAliveConnection *s,
121  const gchar *transport, const gchar *proto,
122  GSockAddr *dest_addr, LogWriter *writer);
123 
124 void afsocket_kept_alive_connection_free_method(AFSocketDestKeptAliveConnection *s);
125 
126 static inline void
127 afsocket_kept_alive_connection_free(AFSocketDestKeptAliveConnection *self)
128 {
129  self->free_fn(self);
130  g_free(self);
131 }
132 
133 #endif
void afsocket_kept_alive_connection_free_method(AFSocketDestKeptAliveConnection *s)
Definition: afsocket-dest.c:62
void afsocket_dd_free(LogPipe *s)
Definition: afsocket-dest.c:782
gboolean afsocket_dd_setup_addresses_method(AFSocketDestDriver *self)
Definition: afsocket-dest.c:457
void afsocket_kept_alive_connection_init_instance(AFSocketDestKeptAliveConnection *s, const gchar *transport, const gchar *proto, GSockAddr *dest_addr, LogWriter *writer)
Definition: afsocket-dest.c:42
gboolean afsocket_dd_deinit(LogPipe *s)
Definition: afsocket-dest.c:741
void afsocket_dd_restore_connection_method(AFSocketDestDriver *self, AFSocketDestKeptAliveConnection *item)
Definition: afsocket-dest.c:489
void afsocket_dd_init_instance(AFSocketDestDriver *self, SocketOptions *socket_options, TransportMapper *transport_mapper, GlobalConfig *cfg)
Definition: afsocket-dest.c:797
void afsocket_dd_connected_with_fd(gpointer self, gint fd, GSockAddr *saddr)
Definition: afsocket-dest.c:289
void afsocket_dd_set_keep_alive(LogDriver *self, gint enable)
void afsocket_dd_stop_watches(AFSocketDestDriver *self)
Definition: afsocket-dest.c:210
gboolean afsocket_dd_init(LogPipe *s)
Definition: afsocket-dest.c:688
void afsocket_dd_save_connection(AFSocketDestDriver *self, AFSocketDestKeptAliveConnection *c)
Definition: afsocket-dest.c:721
gboolean afsocket_dd_should_restore_connection_method(AFSocketDestDriver *self, AFSocketDestKeptAliveConnection *c)
Definition: afsocket-dest.c:85
LogWriter * afsocket_dd_construct_writer_method(AFSocketDestDriver *self)
Definition: afsocket-dest.c:496
void afsocket_dd_reconnect(AFSocketDestDriver *self)
Definition: afsocket-dest.c:403
Definition: gsockaddr.h:46
Definition: logwriter.h:51
Definition: stats-counter.h:67
Definition: afsocket-dest.h:39
LogWriterOptions writer_options
Definition: afsocket-dest.h:46
guint connections_kept_alive_across_reloads
Definition: afsocket-dest.h:43
const gchar * original_dest_name
Definition: afsocket-dest.h:61
gboolean connection_initialized
Definition: afsocket-dest.h:51
void(* restore_connection)(AFSocketDestDriver *s, AFSocketDestKeptAliveConnection *c)
Definition: afsocket-dest.h:69
StatsCounterItem * output_unreachable
Definition: afsocket-dest.h:59
void(* save_connection)(AFSocketDestDriver *s)
Definition: afsocket-dest.h:67
gboolean(* setup_addresses)(AFSocketDestDriver *s)
Definition: afsocket-dest.h:64
struct iv_fd connect_fd
Definition: afsocket-dest.h:52
LogWriter * writer
Definition: afsocket-dest.h:45
LogProtoClientFactory * proto_factory
Definition: afsocket-dest.h:47
LogDestDriver super
Definition: afsocket-dest.h:40
struct iv_timer reconnect_timer
Definition: afsocket-dest.h:53
TransportMapper * transport_mapper
Definition: afsocket-dest.h:55
struct _AFSocketDestDriver::@111 metrics
SocketOptions * socket_options
Definition: afsocket-dest.h:54
gint fd
Definition: afsocket-dest.h:44
GSockAddr * bind_addr
Definition: afsocket-dest.h:49
GSockAddr * dest_addr
Definition: afsocket-dest.h:50
gboolean(* should_restore_connection)(AFSocketDestDriver *s, AFSocketDestKeptAliveConnection *c)
Definition: afsocket-dest.h:68
Definition: afsocket-dest.h:73
gchar * proto
Definition: afsocket-dest.h:75
void(* free_fn)(AFSocketDestKeptAliveConnection *s)
Definition: afsocket-dest.h:80
GSockAddr * dest_addr
Definition: afsocket-dest.h:77
gchar * transport
Definition: afsocket-dest.h:74
LogWriter * writer
Definition: afsocket-dest.h:78
GlobalConfig * cfg
Definition: test_batched_ack_tracker.c:34
TransportMapper * transport_mapper
Definition: transport-mapper-lib.c:25