lib:crypto: Fix Coverity build
[Samba.git] / ctdb / protocol / protocol_util.h
blob70f35d122a89d722500a4a6fb2799f7c7928338d
1 /*
2 CTDB protocol marshalling
4 Copyright (C) Amitay Isaacs 2015
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.
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.
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/>.
20 #ifndef __CTDB_PROTOCOL_UTIL_H__
21 #define __CTDB_PROTOCOL_UTIL_H__
23 #include <talloc.h>
25 #include "protocol/protocol.h"
27 const char *ctdb_runstate_to_string(enum ctdb_runstate runstate);
28 enum ctdb_runstate ctdb_runstate_from_string(const char *runstate_str);
30 const char *ctdb_event_to_string(enum ctdb_event event);
31 enum ctdb_event ctdb_event_from_string(const char *event_str);
34 * buflen must be long enough to hold the longest possible "address:port".
35 * For example, 1122:3344:5566:7788:99aa:bbcc:ddee:ff00:12345.
36 * 64 is sane value for buflen.
38 int ctdb_sock_addr_to_buf(char *buf, socklen_t buflen,
39 ctdb_sock_addr *addr, bool with_port);
40 char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx,
41 ctdb_sock_addr *addr, bool with_port);
42 int ctdb_sock_addr_from_string(const char *str,
43 ctdb_sock_addr *addr, bool with_port);
44 int ctdb_sock_addr_mask_from_string(const char *str,
45 ctdb_sock_addr *addr,
46 unsigned int *mask);
47 unsigned int ctdb_sock_addr_port(ctdb_sock_addr *addr);
48 void ctdb_sock_addr_set_port(ctdb_sock_addr *addr, unsigned int port);
49 int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1,
50 const ctdb_sock_addr *addr2);
51 int ctdb_sock_addr_cmp(const ctdb_sock_addr *addr1,
52 const ctdb_sock_addr *addr2);
53 bool ctdb_sock_addr_same_ip(const ctdb_sock_addr *addr1,
54 const ctdb_sock_addr *addr2);
55 bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1,
56 const ctdb_sock_addr *addr2);
58 bool ctdb_connection_same(const struct ctdb_connection *conn1,
59 const struct ctdb_connection *conn2);
61 int ctdb_connection_to_buf(char *buf,
62 size_t buflen,
63 struct ctdb_connection * conn,
64 bool client_first,
65 const char *sep);
66 char *ctdb_connection_to_string(TALLOC_CTX *mem_ctx,
67 struct ctdb_connection * conn,
68 bool client_first);
69 int ctdb_connection_from_string(const char *str, bool client_first,
70 struct ctdb_connection *conn);
72 int ctdb_connection_list_add(struct ctdb_connection_list *conn_list,
73 struct ctdb_connection *conn);
74 int ctdb_connection_list_sort(struct ctdb_connection_list *conn_list);
75 char *ctdb_connection_list_to_string(
76 TALLOC_CTX *mem_ctx,
77 struct ctdb_connection_list *conn_list, bool client_first);
78 int ctdb_connection_list_read(TALLOC_CTX *mem_ctx,
79 int fd,
80 bool client_first,
81 struct ctdb_connection_list **conn_list);
83 #endif /* __CTDB_PROTOCOL_UTIL_H__ */