ctdb-ipalloc: Split IP allocation into its own build subsystem
[obnox/samba/samba-obnox.git] / ctdb / server / ipalloc.h
1 /*
2    CTDB IP takeover code
3
4    Copyright (C) Ronnie Sahlberg  2007
5    Copyright (C) Andrew Tridgell  2007
6    Copyright (C) Martin Schwenke  2015
7
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.
12
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.
17
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/>.
20 */
21
22 #ifndef __CTDB_IPALLOC_H__
23 #define __CTDB_IPALLOC_H__
24
25 #include "replace.h"
26 #include "system/network.h"
27
28 #include "include/ctdb_protocol.h"
29
30 struct public_ip_list {
31         struct public_ip_list *next;
32         uint32_t pnn;
33         ctdb_sock_addr addr;
34 };
35
36 #define IP_KEYLEN       4
37 uint32_t *ip_key(ctdb_sock_addr *ip);
38
39 /* Flags used in IP allocation algorithms. */
40 enum ipalloc_algorithm {
41         IPALLOC_DETERMINISTIC,
42         IPALLOC_NONDETERMINISTIC,
43         IPALLOC_LCP2,
44 };
45
46 struct ipalloc_state {
47         uint32_t num;
48
49         /* Arrays with data for each node */
50         struct ctdb_public_ip_list_old **known_public_ips;
51         struct ctdb_public_ip_list_old **available_public_ips;
52         bool *noiptakeover;
53         bool *noiphost;
54
55         struct public_ip_list *all_ips;
56         enum ipalloc_algorithm algorithm;
57         uint32_t no_ip_failback;
58         uint32_t *force_rebalance_nodes;
59 };
60
61 bool ipalloc(struct ipalloc_state *ipalloc_state);
62
63 #endif /* __CTDB_IPALLOC_H__ */