1 /*
2  * Copyright (c) 2017 Balabit
3  * Copyright (c) 2002-2011 BalaBit IT Ltd, Budapest, Hungary
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 AFSNMPDEST_H_INCLUDED
25 #define AFSNMPDEST_H_INCLUDED
26 
27 #include <net-snmp/net-snmp-config.h>
28 #include <net-snmp/net-snmp-includes.h>
29 
30 #include "driver.h"
31 #include "mainloop-worker.h"
32 #include "logthrdest/logthrdestdrv.h"
33 
34 #define ENGINE_ID_MAX_LENGTH 32
35 #define ENGINE_ID_MIN_LENGTH 5
36 
37 extern const gchar *s_v2c,
38        *s_v3;
39 
40 typedef struct
41 {
42   LogThreadedDestDriver super;
43 
44   gchar *version;
45   gchar *host;
46   GString *host_port;
47   gint port;
48   GList *snmp_objs; /* the values are stored as string triplets (oid, type, value) - the list size is always dividable by 3 */
49   GList *snmp_templates;
50   GList *snmp_codes;
51   gchar *trap_oid,
52         *trap_type,
53         *trap_value;
54   gchar *community;
55   gchar *engine_id;
56   gchar *auth_username;
57   gchar *auth_algorithm;
58   gchar *auth_password;
59   gchar *enc_algorithm;
60   gchar *enc_password;
61   gchar *transport;
62 
63   netsnmp_session session,
64                   *ss;
65   gboolean session_initialized;
66   LogQueue *queue;
67   LogTemplate *message;
68   LogTemplateOptions template_options;
69   WorkerOptions worker_options;
70 
71 } SNMPDestDriver;
72 
73 LogDriver *snmpdest_dd_new(GlobalConfig *cfg);
74 
75 void snmpdest_dd_set_version(LogDriver *d, const gchar *version);
76 void snmpdest_dd_set_host(LogDriver *d, const gchar *host);
77 void snmpdest_dd_set_port(LogDriver *d, gint port);
78 gboolean snmpdest_dd_set_snmp_obj(LogDriver *d, GlobalConfig *cfg, const gchar *objectid, const gchar *type,
79                                   const gchar *value);
80 void snmpdest_dd_set_trap_obj(LogDriver *d, GlobalConfig *cfg, const gchar *objectid, const gchar *type,
81                               const gchar *value);
82 void snmpdest_dd_set_community(LogDriver *d, const gchar *community);
83 gboolean snmpdest_dd_set_engine_id(LogDriver *d, const gchar *eid);
84 void snmpdest_dd_set_auth_username(LogDriver *d, const gchar *auth_username);
85 void snmpdest_dd_set_auth_algorithm(LogDriver *d, const gchar *auth_algo);
86 void snmpdest_dd_set_auth_password(LogDriver *d, const gchar *auth_pwd);
87 void snmpdest_dd_set_enc_algorithm(LogDriver *d, const gchar *enc_algo);
88 void snmpdest_dd_set_enc_password(LogDriver *d, const gchar *epwd);
89 void snmpdest_dd_set_transport(LogDriver *d, const gchar *transport);
90 void snmpdest_dd_set_time_zone(LogDriver *d, const gchar *Time_zone);
91 
92 gboolean snmpdest_check_required_params(LogDriver *, gchar *err_msg);
93 gchar *snmpdest_dd_get_version(LogDriver *);
94 gboolean snmpdest_dd_check_auth_algorithm(gchar *algo);
95 gboolean snmpdest_dd_check_enc_algorithm(gchar *algo);
96 
97 #endif
98