1 /*
2    CTDB event daemon
3 
4    Copyright (C) Amitay Isaacs  2018
5 
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10 
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15 
16    You should have received a copy of the GNU General Public License
17    along with this program; if not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #ifndef __CTDB_EVENT_PRIVATE_H__
21 #define __CTDB_EVENT_PRIVATE_H__
22 
23 #include <talloc.h>
24 #include <tevent.h>
25 
26 #include "common/run_event.h"
27 #include "common/sock_daemon.h"
28 
29 #include "event/event_protocol.h"
30 
31 struct event_config;
32 struct event_context;
33 
34 /* From event/event_cmd.c */
35 
36 struct tevent_req *event_cmd_dispatch_send(
37 					TALLOC_CTX *mem_ctx,
38 					struct tevent_context *ev,
39 					struct event_context *eventd,
40 					struct ctdb_event_request *request);
41 bool event_cmd_dispatch_recv(struct tevent_req *req,
42 			     int *perr,
43 			     TALLOC_CTX *mem_ctx,
44 			     struct ctdb_event_reply **reply);
45 
46 /* From event/event_config.c */
47 
48 int event_config_init(TALLOC_CTX *mem_ctx, struct event_config **result);
49 
50 const char *event_config_log_location(struct event_config *config);
51 const char *event_config_log_level(struct event_config *config);
52 const char *event_config_debug_script(struct event_config *config);
53 
54 int event_config_reload(struct event_config *config);
55 
56 /* From event/event_context.c */
57 
58 int eventd_client_add(struct event_context *eventd,
59 		      struct sock_client_context *client);
60 void eventd_client_del(struct event_context *eventd,
61 		       struct sock_client_context *client);
62 bool eventd_client_exists(struct event_context *eventd,
63 			  struct sock_client_context *client);
64 
65 int event_context_init(TALLOC_CTX *mem_ctx,
66 		       struct tevent_context *ev,
67 		       struct event_config *config,
68 		       struct event_context **result);
69 
70 struct event_config *eventd_config(struct event_context *eventd);
71 int eventd_run_ctx(struct event_context *eventd,
72 		   const char *comp_name,
73 		   struct run_event_context **result);
74 
75 int eventd_set_event_result(struct event_context *eventd,
76 			    const char *comp_name,
77 			    const char *event_name,
78 			    struct run_event_script_list *script_list);
79 int eventd_get_event_result(struct event_context *eventd,
80 			    const char *comp_name,
81 			    const char *event_name,
82 			    struct run_event_script_list **result);
83 
84 struct ctdb_event_script_list *eventd_script_list(
85 				TALLOC_CTX *mem_ctx,
86 				struct run_event_script_list *script_list);
87 
88 
89 /* From event/event_request.c */
90 
91 struct tevent_req *event_pkt_send(TALLOC_CTX *mem_ctx,
92 				     struct tevent_context *ev,
93 				     struct event_context *eventd,
94 				     uint8_t *buf,
95 				     size_t buflen);
96 
97 bool event_pkt_recv(struct tevent_req *req,
98 		    int *perr,
99 		    TALLOC_CTX *mem_ctx,
100 		    uint8_t **buf,
101 		    size_t *buflen);
102 
103 #endif /* __CTDB_EVENT_PRIVATE_H__ */
104