9b5579c7c698716b4c471588bba9419214e8a1cf
[obnox/samba/samba-obnox.git] / ctdb / server / ipalloc.c
1 /*
2    ctdb ip takeover code
3
4    Copyright (C) Ronnie Sahlberg  2007
5    Copyright (C) Andrew Tridgell  2007
6    Copyright (C) Martin Schwenke  2011
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 #include "replace.h"
23 #include "system/network.h"
24
25 #include "lib/util/debug.h"
26
27 #include "common/logging.h"
28
29 #include "server/ipalloc_private.h"
30
31 /* The calculation part of the IP allocation algorithm. */
32 bool ipalloc(struct ipalloc_state *ipalloc_state)
33 {
34         bool ret;
35
36         switch (ipalloc_state->algorithm) {
37         case IPALLOC_LCP2:
38                 ret = ipalloc_lcp2(ipalloc_state);
39                 break;
40         case IPALLOC_DETERMINISTIC:
41                 ret = ipalloc_deterministic(ipalloc_state);
42                 break;
43         case IPALLOC_NONDETERMINISTIC:
44                 ret = ipalloc_nondeterministic(ipalloc_state);
45                break;
46         }
47
48         /* at this point ->pnn is the node which will own each IP
49            or -1 if there is no node that can cover this ip
50         */
51
52         return ret;
53 }