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__
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
,
47 int ctdb_sock_addr_from_sockaddr(struct sockaddr
*addr
,
48 ctdb_sock_addr
*sock_addr
);
49 unsigned int ctdb_sock_addr_port(ctdb_sock_addr
*addr
);
50 void ctdb_sock_addr_set_port(ctdb_sock_addr
*addr
, unsigned int port
);
51 int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr
*addr1
,
52 const ctdb_sock_addr
*addr2
);
53 int ctdb_sock_addr_cmp(const ctdb_sock_addr
*addr1
,
54 const ctdb_sock_addr
*addr2
);
55 bool ctdb_sock_addr_same_ip(const ctdb_sock_addr
*addr1
,
56 const ctdb_sock_addr
*addr2
);
57 bool ctdb_sock_addr_same(const ctdb_sock_addr
*addr1
,
58 const ctdb_sock_addr
*addr2
);
60 bool ctdb_connection_same(const struct ctdb_connection
*conn1
,
61 const struct ctdb_connection
*conn2
);
63 int ctdb_connection_to_buf(char *buf
,
65 struct ctdb_connection
* conn
,
68 char *ctdb_connection_to_string(TALLOC_CTX
*mem_ctx
,
69 struct ctdb_connection
* conn
,
71 int ctdb_connection_from_string(const char *str
, bool client_first
,
72 struct ctdb_connection
*conn
);
74 int ctdb_connection_list_add(struct ctdb_connection_list
*conn_list
,
75 struct ctdb_connection
*conn
);
76 int ctdb_connection_list_sort(struct ctdb_connection_list
*conn_list
);
77 char *ctdb_connection_list_to_string(
79 struct ctdb_connection_list
*conn_list
, bool client_first
);
80 int ctdb_connection_list_read(TALLOC_CTX
*mem_ctx
,
83 struct ctdb_connection_list
**conn_list
);
85 #endif /* __CTDB_PROTOCOL_UTIL_H__ */