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 #include "protocol_basic.h"
25 
26 /*
27  * From protocol/protocol_types.c
28  */
29 
30 size_t ctdb_tdb_data_len(TDB_DATA *in);
31 void ctdb_tdb_data_push(TDB_DATA *in, uint8_t *buf, size_t *npush);
32 int ctdb_tdb_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
33 		       TDB_DATA *out, size_t *npull);
34 
35 size_t ctdb_tdb_datan_len(TDB_DATA *in);
36 void ctdb_tdb_datan_push(TDB_DATA *in, uint8_t *buf, size_t *npush);
37 int ctdb_tdb_datan_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
38 			TDB_DATA *out, size_t *npull);
39 
40 size_t ctdb_latency_counter_len(struct ctdb_latency_counter *in);
41 void ctdb_latency_counter_push(struct ctdb_latency_counter *in, uint8_t *buf,
42 			       size_t *npush);
43 int ctdb_latency_counter_pull(uint8_t *buf, size_t buflen,
44 			      struct ctdb_latency_counter *out, size_t *npull);
45 
46 size_t ctdb_statistics_len(struct ctdb_statistics *in);
47 void ctdb_statistics_push(struct ctdb_statistics *in, uint8_t *buf,
48 			  size_t *npush);
49 int ctdb_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
50 			 struct ctdb_statistics **out, size_t *npull);
51 
52 size_t ctdb_statistics_list_len(struct ctdb_statistics_list *in);
53 void ctdb_statistics_list_push(struct ctdb_statistics_list *in,
54 			       uint8_t *buf, size_t *npull);
55 int ctdb_statistics_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
56 			      struct ctdb_statistics_list **out,
57 			      size_t *npull);
58 
59 size_t ctdb_vnn_map_len(struct ctdb_vnn_map *in);
60 void ctdb_vnn_map_push(struct ctdb_vnn_map *in, uint8_t *buf, size_t *npush);
61 int ctdb_vnn_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
62 		      struct ctdb_vnn_map **out, size_t  *npull);
63 
64 size_t ctdb_dbid_len(struct ctdb_dbid *in);
65 void ctdb_dbid_push(struct ctdb_dbid *in, uint8_t *buf, size_t *npush);
66 int ctdb_dbid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
67 		   struct ctdb_dbid **out, size_t *npull);
68 
69 size_t ctdb_dbid_map_len(struct ctdb_dbid_map *in);
70 void ctdb_dbid_map_push(struct ctdb_dbid_map *in, uint8_t *buf,
71 			size_t *npush);
72 int ctdb_dbid_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
73 		       struct ctdb_dbid_map **out, size_t *npull);
74 
75 size_t ctdb_pulldb_len(struct ctdb_pulldb *in);
76 void ctdb_pulldb_push(struct ctdb_pulldb *in, uint8_t *buf, size_t *npush);
77 int ctdb_pulldb_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
78 		     struct ctdb_pulldb **out, size_t *npull);
79 
80 size_t ctdb_pulldb_ext_len(struct ctdb_pulldb_ext *in);
81 void ctdb_pulldb_ext_push(struct ctdb_pulldb_ext *in, uint8_t *buf,
82 			  size_t *npush);
83 int ctdb_pulldb_ext_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
84 			 struct ctdb_pulldb_ext **out, size_t *npull);
85 
86 size_t ctdb_db_vacuum_len(struct ctdb_db_vacuum *in);
87 void ctdb_db_vacuum_push(struct ctdb_db_vacuum *in,
88 			 uint8_t *buf,
89 			 size_t *npush);
90 int ctdb_db_vacuum_pull(uint8_t *buf,
91 			size_t buflen,
92 			TALLOC_CTX *mem_ctx,
93 			struct ctdb_db_vacuum **out,
94 			size_t *npull);
95 
96 size_t ctdb_traverse_start_len(struct ctdb_traverse_start *in);
97 void ctdb_traverse_start_push(struct ctdb_traverse_start *in, uint8_t *buf,
98 			      size_t *npush);
99 int ctdb_traverse_start_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
100 			     struct ctdb_traverse_start **out, size_t *npull);
101 
102 size_t ctdb_traverse_all_len(struct ctdb_traverse_all *in);
103 void ctdb_traverse_all_push(struct ctdb_traverse_all *in, uint8_t *buf,
104 			    size_t *npush);
105 int ctdb_traverse_all_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
106 			   struct ctdb_traverse_all **out, size_t *npull);
107 
108 size_t ctdb_traverse_start_ext_len(struct ctdb_traverse_start_ext *in);
109 void ctdb_traverse_start_ext_push(struct ctdb_traverse_start_ext *in,
110 				  uint8_t *buf, size_t *npush);
111 int ctdb_traverse_start_ext_pull(uint8_t *buf, size_t buflen,
112 				 TALLOC_CTX *mem_ctx,
113 				 struct ctdb_traverse_start_ext **out,
114 				 size_t *npull);
115 
116 size_t ctdb_traverse_all_ext_len(struct ctdb_traverse_all_ext *in);
117 void ctdb_traverse_all_ext_push(struct ctdb_traverse_all_ext *in,
118 				uint8_t *buf, size_t *npush);
119 int ctdb_traverse_all_ext_pull(uint8_t *buf, size_t buflen,
120 			       TALLOC_CTX *mem_ctx,
121 			       struct ctdb_traverse_all_ext **out,
122 			       size_t *npull);
123 
124 size_t ctdb_sock_addr_len(ctdb_sock_addr *in);
125 void ctdb_sock_addr_push(ctdb_sock_addr *in, uint8_t *buf, size_t *npush);
126 int ctdb_sock_addr_pull_elems(uint8_t *buf, size_t buflen,
127 			      TALLOC_CTX *mem_ctx, ctdb_sock_addr *out,
128 			      size_t *npull);
129 int ctdb_sock_addr_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
130 			ctdb_sock_addr **out, size_t *npull);
131 
132 size_t ctdb_connection_len(struct ctdb_connection *in);
133 void ctdb_connection_push(struct ctdb_connection *in, uint8_t *buf,
134 			  size_t *npush);
135 int ctdb_connection_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
136 			 struct ctdb_connection **out, size_t *npull);
137 
138 size_t ctdb_connection_list_len(struct ctdb_connection_list *in);
139 void ctdb_connection_list_push(struct ctdb_connection_list *in, uint8_t *buf,
140 			       size_t *npush);
141 int ctdb_connection_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
142 			      struct ctdb_connection_list **out, size_t *npull);
143 
144 size_t ctdb_tunable_len(struct ctdb_tunable *in);
145 void ctdb_tunable_push(struct ctdb_tunable *in, uint8_t *buf, size_t *npush);
146 int ctdb_tunable_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
147 		      struct ctdb_tunable **out, size_t *npull);
148 
149 size_t ctdb_node_flag_change_len(struct ctdb_node_flag_change *in);
150 void ctdb_node_flag_change_push(struct ctdb_node_flag_change *in,
151 				uint8_t *buf, size_t *npush);
152 int ctdb_node_flag_change_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
153 			       struct ctdb_node_flag_change **out,
154 			       size_t *npull);
155 
156 size_t ctdb_var_list_len(struct ctdb_var_list *in);
157 void ctdb_var_list_push(struct ctdb_var_list *in, uint8_t *buf, size_t *npush);
158 int ctdb_var_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
159 		       struct ctdb_var_list **out, size_t *npull);
160 
161 size_t ctdb_tunable_list_len(struct ctdb_tunable_list *in);
162 void ctdb_tunable_list_push(struct ctdb_tunable_list *in, uint8_t *buf,
163 			    size_t *npush);
164 int ctdb_tunable_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
165 			   struct ctdb_tunable_list **out, size_t *npull);
166 
167 size_t ctdb_tickle_list_len(struct ctdb_tickle_list *in);
168 void ctdb_tickle_list_push(struct ctdb_tickle_list *in, uint8_t *buf,
169 			   size_t *npush);
170 int ctdb_tickle_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
171 			  struct ctdb_tickle_list **out, size_t *npull);
172 
173 size_t ctdb_addr_info_len(struct ctdb_addr_info *in);
174 void ctdb_addr_info_push(struct ctdb_addr_info *in, uint8_t *buf,
175 			 size_t *npush);
176 int ctdb_addr_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
177 			struct ctdb_addr_info **out, size_t *npull);
178 
179 size_t ctdb_transdb_len(struct ctdb_transdb *in);
180 void ctdb_transdb_push(struct ctdb_transdb *in, uint8_t *buf, size_t *npush);
181 int ctdb_transdb_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
182 		     struct ctdb_transdb **out, size_t *npull);
183 
184 size_t ctdb_uptime_len(struct ctdb_uptime *in);
185 void ctdb_uptime_push(struct ctdb_uptime *in, uint8_t *buf, size_t *npush);
186 int ctdb_uptime_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
187 		     struct ctdb_uptime **out, size_t *npull);
188 
189 size_t ctdb_public_ip_len(struct ctdb_public_ip *in);
190 void ctdb_public_ip_push(struct ctdb_public_ip *in, uint8_t *buf,
191 			 size_t *npush);
192 int ctdb_public_ip_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
193 			struct ctdb_public_ip **out, size_t *npull);
194 
195 size_t ctdb_public_ip_list_len(struct ctdb_public_ip_list *in);
196 void ctdb_public_ip_list_push(struct ctdb_public_ip_list *in, uint8_t *buf,
197 			      size_t *npush);
198 int ctdb_public_ip_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
199 			     struct ctdb_public_ip_list **out, size_t *npull);
200 
201 size_t ctdb_node_and_flags_len(struct ctdb_node_and_flags *in);
202 void ctdb_node_and_flags_push(struct ctdb_node_and_flags *in, uint8_t *buf,
203 			      size_t *npush);
204 int ctdb_node_and_flags_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
205 			     struct ctdb_node_and_flags **out, size_t *npull);
206 
207 size_t ctdb_node_map_len(struct ctdb_node_map *in);
208 void ctdb_node_map_push(struct ctdb_node_map *in, uint8_t *buf, size_t *npush);
209 int ctdb_node_map_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
210 		       struct ctdb_node_map **out, size_t *npull);
211 
212 size_t ctdb_script_len(struct ctdb_script *in);
213 void ctdb_script_push(struct ctdb_script *in, uint8_t *buf, size_t *npush);
214 int ctdb_script_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
215 		     struct ctdb_script **out, size_t *npull);
216 
217 size_t ctdb_script_list_len(struct ctdb_script_list *in);
218 void ctdb_script_list_push(struct ctdb_script_list *in, uint8_t *buf,
219 			   size_t *npush);
220 int ctdb_script_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
221 			  struct ctdb_script_list **out, size_t *npull);
222 
223 size_t ctdb_ban_state_len(struct ctdb_ban_state *in);
224 void ctdb_ban_state_push(struct ctdb_ban_state *in, uint8_t *buf,
225 			 size_t *npush);
226 int ctdb_ban_state_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
227 			struct ctdb_ban_state **out, size_t *npull);
228 
229 size_t ctdb_notify_data_len(struct ctdb_notify_data *in);
230 void ctdb_notify_data_push(struct ctdb_notify_data *in, uint8_t *buf,
231 			   size_t *npush);
232 int ctdb_notify_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
233 			  struct ctdb_notify_data **out, size_t *npull);
234 
235 size_t ctdb_iface_len(struct ctdb_iface *in);
236 void ctdb_iface_push(struct ctdb_iface *in, uint8_t *buf, size_t *npush);
237 int ctdb_iface_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
238 		    struct ctdb_iface **out, size_t *npull);
239 
240 size_t ctdb_iface_list_len(struct ctdb_iface_list *in);
241 void ctdb_iface_list_push(struct ctdb_iface_list *in, uint8_t *buf,
242 			  size_t *npush);
243 int ctdb_iface_list_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
244 			 struct ctdb_iface_list **out, size_t *npull);
245 
246 size_t ctdb_public_ip_info_len(struct ctdb_public_ip_info *in);
247 void ctdb_public_ip_info_push(struct ctdb_public_ip_info *in, uint8_t *buf,
248 			      size_t *npush);
249 int ctdb_public_ip_info_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
250 			     struct ctdb_public_ip_info **out, size_t *npull);
251 
252 size_t ctdb_key_data_len(struct ctdb_key_data *in);
253 void ctdb_key_data_push(struct ctdb_key_data *in, uint8_t *buf, size_t *npush);
254 int ctdb_key_data_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
255 		       struct ctdb_key_data **out, size_t *npull);
256 
257 size_t ctdb_db_statistics_len(struct ctdb_db_statistics *in);
258 void ctdb_db_statistics_push(struct ctdb_db_statistics *in, uint8_t *buf,
259 			     size_t *npush);
260 int ctdb_db_statistics_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
261 			    struct ctdb_db_statistics **out, size_t *npull);
262 
263 size_t ctdb_pid_srvid_len(struct ctdb_pid_srvid *in);
264 void ctdb_pid_srvid_push(struct ctdb_pid_srvid *in, uint8_t *buf,
265 			 size_t *npush);
266 int ctdb_pid_srvid_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
267 			struct ctdb_pid_srvid **out, size_t *npull);
268 
269 size_t ctdb_election_message_len(struct ctdb_election_message *in);
270 void ctdb_election_message_push(struct ctdb_election_message *in,
271 				uint8_t *buf, size_t *npush);
272 int ctdb_election_message_pull(uint8_t *buf, size_t buflen,
273 			       TALLOC_CTX *mem_ctx,
274 			       struct ctdb_election_message **out,
275 			       size_t *npull);
276 
277 size_t ctdb_srvid_message_len(struct ctdb_srvid_message *in);
278 void ctdb_srvid_message_push(struct ctdb_srvid_message *in, uint8_t *buf,
279 			     size_t *npush);
280 int ctdb_srvid_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
281 			    struct ctdb_srvid_message **out, size_t *npull);
282 
283 size_t ctdb_disable_message_len(struct ctdb_disable_message *in);
284 void ctdb_disable_message_push(struct ctdb_disable_message *in, uint8_t *buf,
285 			       size_t *npush);
286 int ctdb_disable_message_pull(uint8_t *buf, size_t buflen, TALLOC_CTX *mem_ctx,
287 			      struct ctdb_disable_message **out,
288 			      size_t *npull);
289 
290 #endif /* __PROTOCOL_PRIVATE_H__ */
291