4 Copyright (C) Ronnie Sahlberg 2007
5 Copyright (C) Andrew Tridgell 2007
6 Copyright (C) Martin Schwenke 2011
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/>.
23 #include "system/network.h"
25 #include "lib/util/debug.h"
27 #include "common/logging.h"
29 #include "server/ipalloc_private.h"
31 /* The calculation part of the IP allocation algorithm. */
32 bool ipalloc(struct ipalloc_state *ipalloc_state)
36 switch (ipalloc_state->algorithm) {
38 ret = ipalloc_lcp2(ipalloc_state);
40 case IPALLOC_DETERMINISTIC:
41 ret = ipalloc_deterministic(ipalloc_state);
43 case IPALLOC_NONDETERMINISTIC:
44 ret = ipalloc_nondeterministic(ipalloc_state);
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