ctdb-protocol: Add marshalling for ctdb_latency_counter
[kai/samba-autobuild/.git] / ctdb / protocol / protocol_private.h
1 /*
2    CTDB protocol marshalling
3
4    Copyright (C) Amitay Isaacs  2015
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 __PROTOCOL_PRIVATE_H__
21 #define __PROTOCOL_PRIVATE_H__
22
23 #include "protocol.h"
24
25 /*
26  * From protocol/protocol_basic.c
27  */
28
29 size_t ctdb_uint8_len(uint8_t *in);
30 void ctdb_uint8_push(uint8_t *in, uint8_t *buf, size_t *npush);
31 int ctdb_uint8_pull(uint8_t *buf, size_t buflen, uint8_t *out, size_t *npull);
32
33 size_t ctdb_uint16_len(uint16_t *in);
34 void ctdb_uint16_push(uint16_t *in, uint8_t *buf, size_t *npush);
35 int ctdb_uint16_pull(uint8_t *buf, size_t buflen, uint16_t *out,
36                      size_t *npull);
37
38 size_t ctdb_int32_len(int32_t *in);
39 void ctdb_int32_push(int32_t *in, uint8_t *buf, size_t *npush);
40 int ctdb_int32_pull(uint8_t *buf, size_t buflen, int32_t *out, size_t *npull);
41
42 size_t ctdb_uint32_len(uint32_t *in);
43 void ctdb_uint32_push(uint32_t *in, uint8_t *buf, size_t *npush);
44 int ctdb_uint32_pull(uint8_t *buf, size_t buflen, uint32_t *out,
45                      size_t *npull);
46
47 size_t ctdb_uint64_len(uint64_t *in);
48 void ctdb_uint64_push(uint64_t *in, uint8_t *buf, size_t *npush);
49 int ctdb_uint64_pull(uint8_t *buf, size_t buflen, uint64_t *out,
50                      size_t *npull);
51
52 size_t ctdb_double_len(double *in);
53 void ctdb_double_push(double *in, uint8_t *buf, size_t *npush);
54 int ctdb_double_pull(uint8_t *buf, size_t buflen, double *out, size_t *npull);
55
56 size_t ctdb_bool_len(bool *in);
57 void ctdb_bool_push(bool *in, uint8_t *buf, size_t *npush);
58 int ctdb_bool_pull(uint8_t *buf, size_t buflen, bool *out, size_t *npull);
59
60 size_t ctdb_chararray_len(char *in, size_t len);
61 void ctdb_chararray_push(char *in, size_t len, uint8_t *buf, size_t *npush);
62 int ctdb_chararray_pull(uint8_t *buf, size_t buflen, char *out, size_t len,
63                         size_t *npull);
64
65 size_t ctdb_string_len(const char **in);
66 void ctdb_string_push(const char **in, uint8_t *buf, size_t *npush);
67 int ctdb_string_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
68                      const char **out, size_t *npull);
69
70 size_t ctdb_stringn_len(const char **in);
71 void ctdb_stringn_push(const char **in, uint8_t *buf, size_t *npush);
72 int ctdb_stringn_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
73                       const char **out, size_t *npull);
74
75 size_t ctdb_pid_len(pid_t *in);
76 void ctdb_pid_push(pid_t *in, uint8_t *buf, size_t *npush);
77 int ctdb_pid_pull(uint8_t *buf, size_t buflen, pid_t *out, size_t *npull);
78
79 size_t ctdb_timeval_len(struct timeval *in);
80 void ctdb_timeval_push(struct timeval *in, uint8_t *buf, size_t *npush);
81 int ctdb_timeval_pull(uint8_t *buf, size_t buflen, struct timeval *out,
82                       size_t *npull);
83
84 size_t ctdb_padding_len(int count);
85 void ctdb_padding_push(int count, uint8_t *buf, size_t *npush);
86 int ctdb_padding_pull(uint8_t *buf, size_t buflen, int count, size_t *npull);
87
88 /*
89  * From protocol/protocol_types.c
90  */
91
92 size_t ctdb_tdb_data_len(TDB_DATA *in);
93 void ctdb_tdb_data_push(TDB_DATA *in, uint8_t *buf, size_t *npush);
94 int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
95                        TDB_DATA *out, size_t *npull);
96
97 size_t ctdb_tdb_datan_len(TDB_DATA *in);
98 void ctdb_tdb_datan_push(TDB_DATA *in, uint8_t *buf, size_t *npush);
99 int ctdb_tdb_datan_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
100                         TDB_DATA *out, size_t *npull);
101
102 size_t ctdb_latency_counter_len(struct ctdb_latency_counter *in);
103 void ctdb_latency_counter_push(struct ctdb_latency_counter *in, uint8_t *buf,
104                                size_t *npush);
105 int ctdb_latency_counter_pull(uint8_t *buf, size_t buflen,
106                               struct ctdb_latency_counter *out, size_t *npull);
107
108 size_t ctdb_statistics_len(struct ctdb_statistics *stats);
109 void ctdb_statistics_push(struct ctdb_statistics *stats, uint8_t *buf);
110 int ctdb_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
111                          struct ctdb_statistics **out);
112
113 size_t ctdb_statistics_list_len(struct ctdb_statistics_list *stats_list);
114 void ctdb_statistics_list_push(struct ctdb_statistics_list *stats_list,
115                                uint8_t *buf);
116 int ctdb_statistics_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
117                               struct ctdb_statistics_list **out);
118
119 size_t ctdb_vnn_map_len(struct ctdb_vnn_map *vnnmap);
120 void ctdb_vnn_map_push(struct ctdb_vnn_map *vnnmap, uint8_t *buf);
121 int ctdb_vnn_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
122                       struct ctdb_vnn_map **out);
123
124 size_t ctdb_dbid_map_len(struct ctdb_dbid_map *dbmap);
125 void ctdb_dbid_map_push(struct ctdb_dbid_map *dbmap, uint8_t *buf);
126 int ctdb_dbid_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
127                        struct ctdb_dbid_map **out);
128
129 size_t ctdb_pulldb_len(struct ctdb_pulldb *pulldb);
130 void ctdb_pulldb_push(struct ctdb_pulldb *pulldb, uint8_t *buf);
131 int ctdb_pulldb_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
132                      struct ctdb_pulldb **out);
133
134 size_t ctdb_pulldb_ext_len(struct ctdb_pulldb_ext *pulldb);
135 void ctdb_pulldb_ext_push(struct ctdb_pulldb_ext *pulldb, uint8_t *buf);
136 int ctdb_pulldb_ext_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
137                          struct ctdb_pulldb_ext **out);
138
139 size_t ctdb_traverse_start_len(struct ctdb_traverse_start *traverse);
140 void ctdb_traverse_start_push(struct ctdb_traverse_start *traverse,
141                               uint8_t *buf);
142 int ctdb_traverse_start_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
143                              struct ctdb_traverse_start **out);
144
145 size_t ctdb_traverse_all_len(struct ctdb_traverse_all *traverse);
146 void ctdb_traverse_all_push(struct ctdb_traverse_all *traverse, uint8_t *buf);
147 int ctdb_traverse_all_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
148                            struct ctdb_traverse_all **out);
149
150 size_t ctdb_traverse_start_ext_len(struct ctdb_traverse_start_ext *traverse);
151 void ctdb_traverse_start_ext_push(struct ctdb_traverse_start_ext *traverse,
152                                   uint8_t *buf);
153 int ctdb_traverse_start_ext_pull(uint8_t *buf, size_t buflen,
154                                  TALLOC_CTX *mem_ctx,
155                                  struct ctdb_traverse_start_ext **out);
156
157 size_t ctdb_traverse_all_ext_len(struct ctdb_traverse_all_ext *traverse);
158 void ctdb_traverse_all_ext_push(struct ctdb_traverse_all_ext *traverse,
159                                 uint8_t *buf);
160 int ctdb_traverse_all_ext_pull(uint8_t *buf, size_t buflen,
161                                TALLOC_CTX *mem_ctx,
162                                struct ctdb_traverse_all_ext **out);
163
164 size_t ctdb_sock_addr_len(ctdb_sock_addr *addr);
165 void ctdb_sock_addr_push(ctdb_sock_addr *addr, uint8_t *buf);
166 int ctdb_sock_addr_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
167                         ctdb_sock_addr **out);
168
169 size_t ctdb_connection_len(struct ctdb_connection *conn);
170 void ctdb_connection_push(struct ctdb_connection *conn, uint8_t *buf);
171 int ctdb_connection_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
172                          struct ctdb_connection **out);
173
174 size_t ctdb_tunable_len(struct ctdb_tunable *tunable);
175 void ctdb_tunable_push(struct ctdb_tunable *tunable, uint8_t *buf);
176 int ctdb_tunable_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
177                       struct ctdb_tunable **out);
178
179 size_t ctdb_node_flag_change_len(struct ctdb_node_flag_change *flag_change);
180 void ctdb_node_flag_change_push(struct ctdb_node_flag_change *flag_change,
181                                 uint8_t *buf);
182 int ctdb_node_flag_change_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
183                                struct ctdb_node_flag_change **out);
184
185 size_t ctdb_var_list_len(struct ctdb_var_list *var_list);
186 void ctdb_var_list_push(struct ctdb_var_list *var_list, uint8_t *buf);
187 int ctdb_var_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
188                        struct ctdb_var_list **out);
189
190 size_t ctdb_tunable_list_len(struct ctdb_tunable_list *tun_list);
191 void ctdb_tunable_list_push(struct ctdb_tunable_list *tun_list, uint8_t *buf);
192 int ctdb_tunable_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
193                            struct ctdb_tunable_list **out);
194
195 size_t ctdb_tickle_list_len(struct ctdb_tickle_list *tickles);
196 void ctdb_tickle_list_push(struct ctdb_tickle_list *tickles, uint8_t *buf);
197 int ctdb_tickle_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
198                           struct ctdb_tickle_list **out);
199
200 size_t ctdb_addr_info_len(struct ctdb_addr_info *addr_info);
201 void ctdb_addr_info_push(struct ctdb_addr_info *addr_info, uint8_t *buf);
202 int ctdb_addr_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
203                         struct ctdb_addr_info **out);
204
205 size_t ctdb_transdb_len(struct ctdb_transdb *transdb);
206 void ctdb_transdb_push(struct ctdb_transdb *transdb, uint8_t *buf);
207 int ctdb_transdb_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
208                      struct ctdb_transdb **out);
209
210 size_t ctdb_uptime_len(struct ctdb_uptime *uptime);
211 void ctdb_uptime_push(struct ctdb_uptime *uptime, uint8_t *buf);
212 int ctdb_uptime_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
213                      struct ctdb_uptime **out);
214
215 size_t ctdb_public_ip_len(struct ctdb_public_ip *public_ip);
216 void ctdb_public_ip_push(struct ctdb_public_ip *public_ip, uint8_t *buf);
217 int ctdb_public_ip_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
218                         struct ctdb_public_ip **out);
219
220 size_t ctdb_public_ip_list_len(struct ctdb_public_ip_list *pubip_list);
221 void ctdb_public_ip_list_push(struct ctdb_public_ip_list *pubip_list,
222                               uint8_t *buf);
223 int ctdb_public_ip_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
224                              struct ctdb_public_ip_list **out);
225
226 size_t ctdb_node_and_flags_len(struct ctdb_node_and_flags *node);
227 void ctdb_node_and_flags_push(struct ctdb_node_and_flags *node, uint8_t *buf);
228 int ctdb_node_and_flags_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
229                              struct ctdb_node_and_flags **out);
230
231 size_t ctdb_node_map_len(struct ctdb_node_map *nodemap);
232 void ctdb_node_map_push(struct ctdb_node_map *nodemap, uint8_t *buf);
233 int ctdb_node_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
234                        struct ctdb_node_map **out);
235
236 size_t ctdb_script_len(struct ctdb_script *script);
237 void ctdb_script_push(struct ctdb_script *script, uint8_t *buf);
238 int ctdb_script_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
239                      struct ctdb_script **out);
240
241 size_t ctdb_script_list_len(struct ctdb_script_list *script_list);
242 void ctdb_script_list_push(struct ctdb_script_list *script_list, uint8_t *buf);
243 int ctdb_script_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
244                           struct ctdb_script_list **out);
245
246 size_t ctdb_ban_state_len(struct ctdb_ban_state *ban_state);
247 void ctdb_ban_state_push(struct ctdb_ban_state *ban_state, uint8_t *buf);
248 int ctdb_ban_state_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
249                         struct ctdb_ban_state **out);
250
251 size_t ctdb_notify_data_len(struct ctdb_notify_data *notify);
252 void ctdb_notify_data_push(struct ctdb_notify_data *notify, uint8_t *buf);
253 int ctdb_notify_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
254                           struct ctdb_notify_data **out);
255
256 size_t ctdb_iface_len(struct ctdb_iface *iface);
257 void ctdb_iface_push(struct ctdb_iface *iface, uint8_t *buf);
258 int ctdb_iface_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
259                     struct ctdb_iface **out);
260
261 size_t ctdb_iface_list_len(struct ctdb_iface_list *iface_list);
262 void ctdb_iface_list_push(struct ctdb_iface_list *iface_list, uint8_t *buf);
263 int ctdb_iface_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
264                          struct ctdb_iface_list **out);
265
266 size_t ctdb_public_ip_info_len(struct ctdb_public_ip_info *ipinfo);
267 void ctdb_public_ip_info_push(struct ctdb_public_ip_info *ipinfo, uint8_t *buf);
268 int ctdb_public_ip_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
269                              struct ctdb_public_ip_info **out);
270
271 size_t ctdb_key_data_len(struct ctdb_key_data *key);
272 void ctdb_key_data_push(struct ctdb_key_data *key, uint8_t *buf);
273 int ctdb_key_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
274                        struct ctdb_key_data **out);
275
276 size_t ctdb_db_statistics_len(struct ctdb_db_statistics *dbstats);
277 void ctdb_db_statistics_push(struct ctdb_db_statistics *dbstats, void *buf);
278 int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
279                             struct ctdb_db_statistics **out);
280
281 size_t ctdb_election_message_len(struct ctdb_election_message *election);
282 void ctdb_election_message_push(struct ctdb_election_message *election,
283                                 uint8_t *buf);
284 int ctdb_election_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
285                                struct ctdb_election_message **out);
286
287 size_t ctdb_srvid_message_len(struct ctdb_srvid_message *msg);
288 void ctdb_srvid_message_push(struct ctdb_srvid_message *msg, uint8_t *buf);
289 int ctdb_srvid_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
290                             struct ctdb_srvid_message **out);
291
292 size_t ctdb_disable_message_len(struct ctdb_disable_message *disable);
293 void ctdb_disable_message_push(struct ctdb_disable_message *disable,
294                                uint8_t *buf);
295 int ctdb_disable_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
296                               struct ctdb_disable_message **out);
297
298 #endif /* __PROTOCOL_PRIVATE_H__ */