2015-11-23 08:18:16 +03:00
/*
CTDB IP takeover code
Copyright ( C ) Ronnie Sahlberg 2007
Copyright ( C ) Andrew Tridgell 2007
Copyright ( C ) Martin Schwenke 2015
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program ; if not , see < http : //www.gnu.org/licenses/>.
*/
# ifndef __CTDB_IPALLOC_H__
# define __CTDB_IPALLOC_H__
2016-05-23 07:28:33 +03:00
# include <talloc.h>
2015-11-23 08:18:16 +03:00
# include "replace.h"
# include "system/network.h"
2016-12-02 06:21:59 +03:00
# include "lib/util/bitmap.h"
2015-11-23 08:18:16 +03:00
struct public_ip_list {
struct public_ip_list * next ;
uint32_t pnn ;
ctdb_sock_addr addr ;
2016-12-02 06:21:59 +03:00
struct bitmap * available_on ;
2015-11-23 08:18:16 +03:00
} ;
# define IP_KEYLEN 4
uint32_t * ip_key ( ctdb_sock_addr * ip ) ;
/* Flags used in IP allocation algorithms. */
enum ipalloc_algorithm {
IPALLOC_DETERMINISTIC ,
IPALLOC_NONDETERMINISTIC ,
IPALLOC_LCP2 ,
} ;
2016-06-22 07:23:38 +03:00
struct ipalloc_state ;
2015-11-23 08:18:16 +03:00
2016-05-23 07:28:33 +03:00
struct ipalloc_state * ipalloc_state_init ( TALLOC_CTX * mem_ctx ,
uint32_t num_nodes ,
enum ipalloc_algorithm algorithm ,
2016-12-10 11:39:11 +03:00
bool no_ip_takeover ,
2016-05-23 07:28:33 +03:00
bool no_ip_failback ,
2016-12-10 12:03:38 +03:00
bool no_ip_host_on_all_disabled ,
2016-05-23 07:28:33 +03:00
uint32_t * force_rebalance_nodes ) ;
2016-06-22 06:18:04 +03:00
void ipalloc_set_node_flags ( struct ipalloc_state * ipalloc_state ,
2016-12-10 12:03:38 +03:00
struct ctdb_node_map * nodemap ) ;
2016-06-22 06:18:04 +03:00
2016-09-12 09:04:18 +03:00
void ipalloc_set_public_ips ( struct ipalloc_state * ipalloc_state ,
2016-05-23 13:23:18 +03:00
struct ctdb_public_ip_list * known_ips ,
struct ctdb_public_ip_list * available_ips ) ;
2016-06-21 14:16:27 +03:00
bool ipalloc_can_host_ips ( struct ipalloc_state * ipalloc_state ) ;
2016-06-22 07:22:02 +03:00
struct public_ip_list * ipalloc ( struct ipalloc_state * ipalloc_state ) ;
2015-11-23 08:18:16 +03:00
# endif /* __CTDB_IPALLOC_H__ */