1 /*****
2 *
3 * Copyright (C) 2004-2015 CS-SI. All Rights Reserved.
4 * Author: Yoann Vandoorselaere <yoann.v@prelude-ids.com>
5 *
6 * This file is part of the Prelude library.
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2, or (at your option)
11 * any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 *****/
23 
24 #ifndef _LIBPRELUDE_PRELUDE_CLIENT_H
25 #define _LIBPRELUDE_PRELUDE_CLIENT_H
26 
27 #ifdef __cplusplus
28  extern "C" {
29 #endif
30 
31 typedef enum {
32         PRELUDE_CLIENT_EXIT_STATUS_SUCCESS = 0,
33         PRELUDE_CLIENT_EXIT_STATUS_FAILURE = -1
34 } prelude_client_exit_status_t;
35 
36 
37 typedef enum {
38         PRELUDE_CLIENT_FLAGS_ASYNC_SEND  = 0x01,
39         PRELUDE_CLIENT_FLAGS_ASYNC_TIMER = 0x02,
40         PRELUDE_CLIENT_FLAGS_HEARTBEAT   = 0x04,
41         PRELUDE_CLIENT_FLAGS_CONNECT     = 0x08,
42         PRELUDE_CLIENT_FLAGS_AUTOCONFIG  = 0x10
43 } prelude_client_flags_t;
44 
45 
46 typedef struct prelude_client prelude_client_t;
47 
48 
49 #include "prelude-client-profile.h"
50 #include "prelude-ident.h"
51 #include "prelude-connection.h"
52 #include "prelude-connection-pool.h"
53 #include "idmef.h"
54 
55 
56 prelude_ident_t *prelude_client_get_unique_ident(prelude_client_t *client);
57 
58 void prelude_client_set_connection_pool(prelude_client_t *client, prelude_connection_pool_t *pool);
59 
60 prelude_connection_pool_t *prelude_client_get_connection_pool(prelude_client_t *client);
61 
62 int prelude_client_start(prelude_client_t *client);
63 
64 int prelude_client_init(prelude_client_t *client);
65 
66 int prelude_client_new(prelude_client_t **client, const char *profile);
67 
68 prelude_client_t *prelude_client_ref(prelude_client_t *client);
69 
70 idmef_analyzer_t *prelude_client_get_analyzer(prelude_client_t *client);
71 
72 prelude_client_flags_t prelude_client_get_flags(prelude_client_t *client);
73 
74 void prelude_client_set_required_permission(prelude_client_t *client, prelude_connection_permission_t permission);
75 
76 prelude_connection_permission_t prelude_client_get_required_permission(prelude_client_t *client);
77 
78 void prelude_client_send_msg(prelude_client_t *client, prelude_msg_t *msg);
79 
80 int prelude_client_recv_msg(prelude_client_t *client, int timeout, prelude_msg_t **msg);
81 
82 void prelude_client_set_heartbeat_cb(prelude_client_t *client, void (*cb)(prelude_client_t *client, idmef_message_t *hb));
83 
84 void prelude_client_send_idmef(prelude_client_t *client, idmef_message_t *msg);
85 
86 int prelude_client_recv_idmef(prelude_client_t *client, int timeout, idmef_message_t **idmef);
87 
88 void prelude_client_destroy(prelude_client_t *client, prelude_client_exit_status_t status);
89 
90 int prelude_client_set_flags(prelude_client_t *client, prelude_client_flags_t flags);
91 
92 int prelude_client_set_config_filename(prelude_client_t *client, const char *filename);
93 
94 const char *prelude_client_get_config_filename(prelude_client_t *client);
95 
96 prelude_client_profile_t *prelude_client_get_profile(prelude_client_t *client);
97 
98 int prelude_client_new_msgbuf(prelude_client_t *client, prelude_msgbuf_t **msgbuf);
99 
100 int prelude_client_handle_msg_default(prelude_client_t *client, prelude_msg_t *msg, prelude_msgbuf_t *msgbuf);
101 
102 int _prelude_client_register_options(void);
103 
104 #ifndef PRELUDE_DISABLE_DEPRECATED
105 const char *prelude_client_get_setup_error(prelude_client_t *client);
106 
107 prelude_bool_t prelude_client_is_setup_needed(int error);
108 #endif
109 
110 void prelude_client_print_setup_error(prelude_client_t *client);
111 
112 
113 #ifdef __cplusplus
114  }
115 #endif
116 
117 #endif
118