ldb: Release ldb 1.3.0
[Samba.git] / ctdb / server / ipalloc.h
blob590dcb31e4a443f608e9108d8ee9d72f98f7ccd7
1 /*
2 CTDB IP takeover code
4 Copyright (C) Ronnie Sahlberg 2007
5 Copyright (C) Andrew Tridgell 2007
6 Copyright (C) Martin Schwenke 2015
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, see <http://www.gnu.org/licenses/>.
22 #ifndef __CTDB_IPALLOC_H__
23 #define __CTDB_IPALLOC_H__
25 #include <talloc.h>
27 #include "replace.h"
28 #include "system/network.h"
30 #include "lib/util/bitmap.h"
32 struct public_ip_list {
33 struct public_ip_list *next;
34 uint32_t pnn;
35 ctdb_sock_addr addr;
36 struct bitmap *known_on;
37 struct bitmap *available_on;
40 #define IP_KEYLEN 4
41 uint32_t *ip_key(ctdb_sock_addr *ip);
43 /* Flags used in IP allocation algorithms. */
44 enum ipalloc_algorithm {
45 IPALLOC_DETERMINISTIC,
46 IPALLOC_NONDETERMINISTIC,
47 IPALLOC_LCP2,
50 struct ipalloc_state;
52 struct ipalloc_state * ipalloc_state_init(TALLOC_CTX *mem_ctx,
53 uint32_t num_nodes,
54 enum ipalloc_algorithm algorithm,
55 bool no_ip_takeover,
56 bool no_ip_failback,
57 bool no_ip_host_on_all_disabled,
58 uint32_t *force_rebalance_nodes);
60 void ipalloc_set_node_flags(struct ipalloc_state *ipalloc_state,
61 struct ctdb_node_map *nodemap);
63 void ipalloc_set_public_ips(struct ipalloc_state *ipalloc_state,
64 struct ctdb_public_ip_list *known_ips,
65 struct ctdb_public_ip_list *available_ips);
67 bool ipalloc_can_host_ips(struct ipalloc_state *ipalloc_state);
69 struct public_ip_list *ipalloc(struct ipalloc_state *ipalloc_state);
71 #endif /* __CTDB_IPALLOC_H__ */