/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) 2015 Guenther Deschner
- Copyright (C) 2015 Jose A. Rivera
-
- 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/>.
-*/
+ * Unix SMB/CIFS implementation.
+ *
+ * Copyright (C) 2015 Guenther Deschner
+ * Copyright (C) 2015 Jose A. Rivera
+ *
+ * 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/>.
+ */
#include "includes.h"
#include "librpc/gen_ndr/ndr_witness.h"
-#include "rpc_server/witness/srv_witness.h"
-#include "rpc_server/witness/srv_witness_ctdb.h"
+#include "witness.h"
#include <tdb.h>
#include <ctdb_client.h>
#include "rpc_server/witness/srv_witness_ctdb.h"
--- /dev/null
+/*
+ Unix SMB/CIFS implementation.
+
+ Copyright (C) 2012 Stefan Metzmacher
+ Copyright (C) 2015 Guenther Deschner
+ Copyright (C) 2015 Jose A. Rivera
+
+ 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/>.
+*/
+
+#include "includes.h"
+#include "librpc/gen_ndr/ndr_witness.h"
+#include "witness.h"
+#include <tevent.h>
+#include "source3/include/proto.h"
+
+bool srv_witness_startup_witness_interfaces_from_ctdb(struct WitnessServerState *s)
+{
+ int ret;
+ struct witness_interfaceList *ifs;
+#if 0
+ ret = witness_get_ctdb_all_public_ips(s, server_event_context(), &ifs);
+#endif
+ ret = witness_get_ctdb_all_public_ips(s, s->ev, s, &ifs);
+ if (ret != 0) {
+ return false;
+ }
+
+ s->InterfaceList = *ifs;
+
+ return true;
+}
+
+#if 0
+static bool srv_witness_startup_witness_interfaces_from_config(struct WitnessServerState *s)
+{
+ uint32_t i;
+ const char **interfaces = NULL;
+ uint32_t num_interfaces;
+
+ if (s == NULL) {
+ return false;
+ }
+
+ interfaces = lp_parm_string_list(-1, "witness", "ipv4 interfaces", NULL);
+ if (interfaces == NULL) {
+ return false;
+ }
+
+ for (i=0; interfaces[i] != NULL; i++) {
+ ;;
+ }
+ num_interfaces = i;
+
+ s->InterfaceList.interfaces = talloc_zero_array(s, struct witness_interfaceInfo, num_interfaces);
+ if (s->InterfaceList.interfaces == NULL) {
+ return false;
+ }
+
+ s->InterfaceList.num_interfaces = num_interfaces;
+
+ for (i=0; i < num_interfaces; i++) {
+ struct witness_interfaceInfo *info = &s->InterfaceList.interfaces[i];
+
+ info->group_name = talloc_strdup(s, s->ServerGlobalName);
+ if (info->group_name == NULL) {
+ return false;
+ }
+ info->version = WITNESS_UNSPECIFIED_VERSION; /* WitnessServiceVersion; */
+ info->state = WITNESS_STATE_AVAILABLE;
+ info->ipv4 = interfaces[i];
+ info->flags |= WITNESS_INFO_IPv4_VALID;
+ info->ipv6 = "::";
+ if (!is_myname_or_ipaddr(interfaces[i])) {
+ info->flags |= WITNESS_INFO_WITNESS_IF;
+ }
+ /* only for testing set all interfaces as valid witness
+ * interfaces */
+ info->flags |= WITNESS_INFO_WITNESS_IF;
+ }
+
+ return true;
+}
+#endif
+
+bool srv_witness_startup(struct WitnessServerState *s)
+{
+ uint32_t version = lp_parm_int(-1, "witness", "max version", 0);
+
+ switch (version) {
+ case 1:
+ s->WitnessServiceVersion = WITNESS_V1;
+ break;
+ case 2:
+ s->WitnessServiceVersion = WITNESS_V2;
+ break;
+ default:
+ DEBUG(0,("Invalid Witness Version specified: %d\n", version));
+ return false;
+ }
+
+ //s->ServerGlobalName = talloc_strdup(s, lp_parm_const_string(-1, "witness", "server global name", lp_netbios_name()));
+ s->ServerGlobalName = talloc_strdup(s, lp_netbios_name());
+ if (s->ServerGlobalName == NULL) {
+ return false;
+ }
+
+ if (!srv_witness_startup_witness_interfaces_from_ctdb(s)) {
+ return false;
+ }
+#if 0
+ if (!srv_witness_startup_witness_interfaces_from_config(s)) {
+ return false;
+ }
+#endif
+ NDR_PRINT_DEBUG(WitnessServerState, s);
+
+ return true;
+}
+#if 0
+static bool init_witness_state(TALLOC_CTX *mem_ctx,
+ struct WitnessServerState **state_out)
+{
+ struct WitnessServerState *s;
+ bool ok;
+
+ s = talloc_zero(mem_ctx, struct WitnessServerState);
+ if (s == NULL) {
+ return false;
+ }
+
+ ok = srv_witness_startup(s);
+ if (!ok) {
+ talloc_free(s);
+ return false;
+ }
+
+ *state_out = s;
+
+ return true;
+}
+#endif
+bool witness_validate_net_name(struct WitnessServerState *s,
+ const char *net_name)
+{
+ bool ok;
+
+ if (net_name == NULL || !*net_name) {
+ return false;
+ }
+
+ ok = strequal(s->ServerGlobalName, net_name);
+ if (!ok) {
+ DEBUG(10,("witness_validate_net_name: net name validation failed, expected: %s\n",
+ s->ServerGlobalName));
+ }
+
+ return ok;
+}
+
+bool witness_validate_ip_address(struct WitnessServerState *s,
+ const char *ip_address)
+{
+ int i;
+
+ for (i=0; i < s->InterfaceList.num_interfaces; i++) {
+ struct witness_interfaceInfo *interface;
+
+ interface = &s->InterfaceList.interfaces[i];
+
+ if (interface->ipv4 && strequal(interface->ipv4, ip_address)) {
+ return true;
+ }
+ if (interface->ipv6 && strequal(interface->ipv6, ip_address)) {
+ return true;
+ }
+ }
+
+ DEBUG(10,("witness_validate_ip_address: failed ip address validation\n"));
+
+ return false;
+}
+
+/**
+* @brief create a notify response
+*
+* @param mem_ctx The talloc context
+* @param type The notify type
+* @param ipv4_address The ipv4 address
+* @param _r The returned notify response struct
+*
+* @return WERROR code
+*/
+WERROR witness_create_notify_response(TALLOC_CTX *mem_ctx,
+ uint32_t type,
+ const char *ipv4_address,
+ struct witness_notifyResponse **_r)
+{
+ struct witness_notifyResponse *r;
+ struct witness_IPaddrInfoList client_move;
+
+ r = talloc_zero(mem_ctx, struct witness_notifyResponse);
+ if (r == NULL) {
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
+
+ r->type = type;
+ r->num = 1;
+ r->messages = talloc_zero_array(r, union witness_notifyResponse_message, r->num);
+ if (r->messages == NULL) {
+ talloc_free(r);
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
+
+ client_move.num = 1;
+ client_move.addr = talloc_zero_array(r, struct witness_IPaddrInfo, client_move.num);
+ if (client_move.addr == NULL) {
+ talloc_free(r);
+ return WERR_NOT_ENOUGH_MEMORY;
+ }
+
+ client_move.addr[0].flags = WITNESS_IPADDR_V4 | WITNESS_IPADDR_ONLINE;
+ client_move.addr[0].ipv4 = ipv4_address;
+ client_move.addr[0].ipv6 = "::";
+
+ r->messages[0].client_move = client_move;
+
+ *_r = r;
+
+ return WERR_OK;
+}
+
+bool witness_create_one_interface(TALLOC_CTX *mem_ctx,
+ const char *group_name,
+ uint32_t witness_version,
+ uint32_t interface_state,
+ const char *ipv4,
+ const char *ipv6,
+ struct witness_interfaceInfo *i)
+{
+ ZERO_STRUCTP(i);
+
+ i->group_name = talloc_strdup(mem_ctx, group_name);
+ if (i->group_name == NULL) {
+ return false;
+ }
+
+ i->version = witness_version;
+ i->state = interface_state;
+
+ if (ipv4 && is_ipaddress_v4(ipv4)) {
+ i->ipv4 = ipv4;
+ i->flags |= WITNESS_INFO_IPv4_VALID;
+ if (!is_myname_or_ipaddr(ipv4)) {
+ i->flags |= WITNESS_INFO_WITNESS_IF;
+ }
+ } else {
+ i->ipv4 = "0.0.0.0";
+ }
+ if (ipv6 && is_ipaddress_v6(ipv6)) {
+ i->ipv6 = ipv6;
+ i->flags |= WITNESS_INFO_IPv6_VALID;
+ if (!is_myname_or_ipaddr(ipv6)) {
+ i->flags |= WITNESS_INFO_WITNESS_IF;
+ }
+ } else {
+ i->ipv6 = "::";
+ }
+
+ return true;
+}
+
+static bool witness_interface_equal(struct witness_interfaceInfo *i1,
+ struct witness_interfaceInfo *i2)
+{
+ if (i1 == NULL || i2 == NULL) {
+ return false;
+ }
+ if (!strequal(i1->group_name, i2->group_name)) {
+ return false;
+ }
+ if (i1->version != i2->version) {
+ return false;
+ }
+ if (i1->state != i2->state) {
+ return false;
+ }
+ if (!strequal(i1->ipv4, i2->ipv4)) {
+ return false;
+ }
+ if (!strequal(i1->ipv6, i2->ipv6)) {
+ return false;
+ }
+ if (i1->flags != i2->flags) {
+ return false;
+ }
+
+ return true;
+}
+
+bool witness_add_interface_to_array_unique(TALLOC_CTX *mem_ctx,
+ struct witness_interfaceInfo interface,
+ struct witness_interfaceInfo **array,
+ uint32_t *count)
+{
+ uint32_t i;
+
+ for (i=0; i<*count; i++) {
+ if (witness_interface_equal(&interface, &(*array)[i])) {
+ return true;
+ }
+ }
+
+ *array = talloc_realloc(mem_ctx, *array, struct witness_interfaceInfo,
+ *count+1);
+ if (*array == NULL) {
+ *count = 0;
+ return false;
+ }
+ (*array)[*count] = interface;
+ *count += 1;
+
+ return true;
+}
--- /dev/null
+/*
+ * Unix SMB/CIFS implementation.
+ *
+ * Copyright (C) 2012 Stefan Metzmacher
+ * Copyright (C) 2015 Guenther Deschner
+ * Copyright (C) 2015 Jose A. Rivera
+ *
+ * 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 _WITNESS_H_
+#define _WITNESS_H_
+
+/**
+ * @brief General server functionality.
+ */
+bool witness_create_one_interface(TALLOC_CTX *mem_ctx,
+ const char *group_name,
+ uint32_t witness_version,
+ uint32_t state,
+ const char *ipv4,
+ const char *ipv6,
+ struct witness_interfaceInfo *i);
+bool witness_add_interface_to_array_unique(TALLOC_CTX *mem_ctx,
+ struct witness_interfaceInfo interface,
+ struct witness_interfaceInfo **array,
+ uint32_t *count);
+bool witness_validate_net_name(struct WitnessServerState *s,
+ const char *net_name);
+bool witness_validate_ip_address(struct WitnessServerState *s,
+ const char *ip_address);
+WERROR witness_create_notify_response(TALLOC_CTX *mem_ctx,
+ uint32_t type,
+ const char *ipv4_address,
+ struct witness_notifyResponse **_r);
+bool srv_witness_startup_witness_interfaces_from_ctdb(struct WitnessServerState *s);
+bool srv_witness_startup(struct WitnessServerState *s);
+
+/**
+ * @brief CTDB integration functions.
+ */
+int witness_get_ctdb_all_public_ips(TALLOC_CTX *tmp_ctx,
+ struct tevent_context *ev,
+ struct WitnessServerState *state,
+ struct witness_interfaceList **list);
+int witnessd_ctdb_reconfigured(struct tevent_context *ev,
+ uint32_t src_vnn,
+ uint32_t dst_vnn,
+ uint64_t dst_srvid,
+ const uint8_t *msg,
+ size_t msglen,
+ void *private_data);
+
+#endif /*_WITNESS_H_ */
--- /dev/null
+#!/usr/bin/env python
+
+bld.SAMBA3_SUBSYSTEM('LIB_WITNESS',
+ source='server.c ctdb.c',
+ deps='''samba-util NDR_WITNESS
+ ctdb-client ctdb-common''')
+
+
#include "librpc/gen_ndr/ndr_srvsvc_c.h"
#include "messages.h"
#include "rpc_server/witness/srv_witness.h"
-#include "rpc_server/witness/srv_witness_ctdb.h"
+#include "lib/witness/witness.h"
#include <tevent.h>
struct WitnessServerState *state = NULL;
{
}
-static bool srv_witness_startup_witness_interfaces_from_ctdb(struct WitnessServerState *s)
-{
- int ret;
- struct witness_interfaceList *ifs;
-
- ret = witness_get_ctdb_all_public_ips(s, s->ev, s, &ifs);
- if (ret != 0) {
- return false;
- }
-
- s->InterfaceList = *ifs;
-
- return true;
-}
-#if 0
-static bool srv_witness_startup_witness_interfaces_from_config(struct WitnessServerState *s)
-{
- uint32_t i;
- const char **interfaces = NULL;
- uint32_t num_interfaces;
-
- if (s == NULL) {
- return false;
- }
-
- interfaces = lp_parm_string_list(-1, "witness", "ipv4 interfaces", NULL);
- if (interfaces == NULL) {
- return false;
- }
-
- for (i=0; interfaces[i] != NULL; i++) {
- ;;
- }
- num_interfaces = i;
-
- s->InterfaceList.interfaces = talloc_zero_array(s, struct witness_interfaceInfo, num_interfaces);
- if (s->InterfaceList.interfaces == NULL) {
- return false;
- }
-
- s->InterfaceList.num_interfaces = num_interfaces;
-
- for (i=0; i < num_interfaces; i++) {
- struct witness_interfaceInfo *info = &s->InterfaceList.interfaces[i];
-
- info->group_name = talloc_strdup(s, s->ServerGlobalName);
- if (info->group_name == NULL) {
- return false;
- }
- info->version = WITNESS_UNSPECIFIED_VERSION; /* WitnessServiceVersion; */
- info->state = WITNESS_STATE_AVAILABLE;
- info->ipv4 = interfaces[i];
- info->flags |= WITNESS_INFO_IPv4_VALID;
- info->ipv6 = "::";
- if (!is_myname_or_ipaddr(interfaces[i])) {
- info->flags |= WITNESS_INFO_WITNESS_IF;
- }
- /* only for testing set all interfaces as valid witness
- * interfaces */
- info->flags |= WITNESS_INFO_WITNESS_IF;
- }
-
- return true;
-}
-#endif
-
-bool srv_witness_startup(struct WitnessServerState *s)
-{
- uint32_t version = lp_parm_int(-1, "witness", "max version", 0);
-
- switch (version) {
- case 1:
- s->WitnessServiceVersion = WITNESS_V1;
- break;
- case 2:
- s->WitnessServiceVersion = WITNESS_V2;
- break;
- default:
- DEBUG(0,("Invalid Witness Version specified: %d\n", version));
- return false;
- }
-
- //s->ServerGlobalName = talloc_strdup(s, lp_parm_const_string(-1, "witness", "server global name", lp_netbios_name()));
- s->ServerGlobalName = talloc_strdup(s, lp_netbios_name());
- if (s->ServerGlobalName == NULL) {
- return false;
- }
-
- if (!srv_witness_startup_witness_interfaces_from_ctdb(s)) {
- return false;
- }
-#if 0
- if (!srv_witness_startup_witness_interfaces_from_config(s)) {
- return false;
- }
-#endif
- NDR_PRINT_DEBUG(WitnessServerState, s);
-
- return true;
-}
-#if 0
-static bool init_witness_state(TALLOC_CTX *mem_ctx,
- struct WitnessServerState **statep)
-{
- struct WitnessServerState *s;
- bool ok;
-
- s = talloc_zero(mem_ctx, struct WitnessServerState);
- if (s == NULL) {
- return false;
- }
-
- ok = srv_witness_startup(s);
- if (!ok) {
- talloc_free(s);
- return false;
- }
-
- *statep = s;
-
- return true;
-}
-#endif
-/*
- typedef struct {
- [charset(UTF16),to_null] uint16 group_name[260];
- uint32 version;
- uint16 state;
- ipv4address ipv4;
- ipv6address ipv6;
- uint32 flags;
- } witness_interfaceInfo;
-
- typedef struct {
- uint32 num_interfaces;
- [size_is(num_interfaces)] witness_interfaceInfo *interfaces;
- } witness_interfaceList;
-*/
-#if 0
-static const char * const ifaces[] = {
- "172.31.91.173",
- "172.31.91.174",
- "172.31.91.175",
-};
-static uint32_t ifaces_idx;
-
-static struct WitnessRegistration *WitnessRegistrationList;
-#endif
-
-uint32_t KeepAliveTime = 120; /* seconds */
-
-static bool witness_validate_net_name(struct WitnessServerState *s,
- const char *net_name)
-{
- bool ok;
-
- if (net_name == NULL || !*net_name) {
- return false;
- }
-
- ok = strequal(s->ServerGlobalName, net_name);
- if (!ok) {
- DEBUG(10,("witness_validate_net_name: net name validation failed, expected: %s\n",
- s->ServerGlobalName));
- }
-
- return ok;
-}
-
static bool witness_validate_share_name(const char *share_name,
TALLOC_CTX *mem_ctx,
struct messaging_context *msg_ctx)
return true;
}
-static bool witness_validate_ip_address(struct WitnessServerState *s,
- const char *ip_address)
-{
- int i;
-
- for (i=0; i < s->InterfaceList.num_interfaces; i++) {
- struct witness_interfaceInfo *interface;
-
- interface = &s->InterfaceList.interfaces[i];
-
- if (interface->ipv4 && strequal(interface->ipv4, ip_address)) {
- return true;
- }
- if (interface->ipv6 && strequal(interface->ipv6, ip_address)) {
- return true;
- }
- }
-
- DEBUG(10,("witness_validate_ip_address: failed ip address validation\n"));
-
- return false;
-}
/****************************************************************
_witness_GetInterfaceList
return WERR_OK;
}
-/**
-* @brief create a notify response
-*
-* @param mem_ctx The talloc context
-* @param type The notify type
-* @param ipv4_address The ipv4 address
-* @param _r The returned notify response struct
-*
-* @return WERROR code
-*/
-static WERROR create_notify_response(TALLOC_CTX *mem_ctx,
- uint32_t type,
- const char *ipv4_address,
- struct witness_notifyResponse **_r)
-{
- struct witness_notifyResponse *r;
- struct witness_IPaddrInfoList client_move;
-
- r = talloc_zero(mem_ctx, struct witness_notifyResponse);
- if (r == NULL) {
- return WERR_NOT_ENOUGH_MEMORY;
- }
-
- r->type = type;
- r->num = 1;
- r->messages = talloc_zero_array(r, union witness_notifyResponse_message, r->num);
- if (r->messages == NULL) {
- talloc_free(r);
- return WERR_NOT_ENOUGH_MEMORY;
- }
-
- client_move.num = 1;
- client_move.addr = talloc_zero_array(r, struct witness_IPaddrInfo, client_move.num);
- if (client_move.addr == NULL) {
- talloc_free(r);
- return WERR_NOT_ENOUGH_MEMORY;
- }
-
- client_move.addr[0].flags = WITNESS_IPADDR_V4 | WITNESS_IPADDR_ONLINE;
- client_move.addr[0].ipv4 = ipv4_address;
- client_move.addr[0].ipv6 = "::";
-
- r->messages[0].client_move = client_move;
-
- *_r = r;
-
- return WERR_OK;
-}
-
/****************************************************************
_witness_AsyncNotify
****************************************************************/
NDR_PRINT_DEBUG(WitnessRegistration, reg);
if (reg->PendingChangeNotifications != NULL) {
- result = create_notify_response(p->mem_ctx,
- WITNESS_NOTIFY_RESOURCE_CHANGE,
- interfaces[i],
- r->out.response);
+ result = witness_create_notify_response(p->mem_ctx,
+ WITNESS_NOTIFY_RESOURCE_CHANGE,
+ interfaces[i],
+ r->out.response);
if (!W_ERROR_IS_OK(result)) {
return result;
}
DEBUG(0,("using %s for reconnect\n", interfaces[i]));
/* we found an ip address which is not
* ours! send a notify */
- result = create_notify_response(p->mem_ctx,
- WITNESS_NOTIFY_CLIENT_MOVE,
- interfaces[i],
- r->out.response);
+ result = witness_create_notify_response(p->mem_ctx,
+ WITNESS_NOTIFY_CLIENT_MOVE,
+ interfaces[i],
+ r->out.response);
if (!W_ERROR_IS_OK(result)) {
return result;
return WERR_OK;
}
-
-bool witness_create_one_interface(TALLOC_CTX *mem_ctx,
- const char *group_name,
- uint32_t witness_version,
- uint32_t interface_state,
- const char *ipv4,
- const char *ipv6,
- struct witness_interfaceInfo *i)
-{
- ZERO_STRUCTP(i);
-
- i->group_name = talloc_strdup(mem_ctx, group_name);
- if (i->group_name == NULL) {
- return false;
- }
-
- i->version = witness_version;
- i->state = interface_state;
-
- if (ipv4 && is_ipaddress_v4(ipv4)) {
- i->ipv4 = ipv4;
- i->flags |= WITNESS_INFO_IPv4_VALID;
- if (!is_myname_or_ipaddr(ipv4)) {
- i->flags |= WITNESS_INFO_WITNESS_IF;
- }
- } else {
- i->ipv4 = "0.0.0.0";
- }
- if (ipv6 && is_ipaddress_v6(ipv6)) {
- i->ipv6 = ipv6;
- i->flags |= WITNESS_INFO_IPv6_VALID;
- if (!is_myname_or_ipaddr(ipv6)) {
- i->flags |= WITNESS_INFO_WITNESS_IF;
- }
- } else {
- i->ipv6 = "::";
- }
-
- return true;
-}
-
-static bool witness_interface_equal(struct witness_interfaceInfo *i1,
- struct witness_interfaceInfo *i2)
-{
- if (i1 == NULL || i2 == NULL) {
- return false;
- }
- if (!strequal(i1->group_name, i2->group_name)) {
- return false;
- }
- if (i1->version != i2->version) {
- return false;
- }
- if (i1->state != i2->state) {
- return false;
- }
- if (!strequal(i1->ipv4, i2->ipv4)) {
- return false;
- }
- if (!strequal(i1->ipv6, i2->ipv6)) {
- return false;
- }
- if (i1->flags != i2->flags) {
- return false;
- }
-
- return true;
-}
-
-bool witness_add_interface_to_array_unique(TALLOC_CTX *mem_ctx,
- struct witness_interfaceInfo interface,
- struct witness_interfaceInfo **array,
- uint32_t *count)
-{
- uint32_t i;
-
- for (i=0; i<*count; i++) {
- if (witness_interface_equal(&interface, &(*array)[i])) {
- return true;
- }
- }
-
- *array = talloc_realloc(mem_ctx, *array, struct witness_interfaceInfo,
- *count+1);
- if (*array == NULL) {
- *count = 0;
- return false;
- }
- (*array)[*count] = interface;
- *count += 1;
-
- return true;
-}
* @brief Cleanup memory and other stuff.
*/
void srv_witness_cleanup(void);
-bool srv_witness_startup(struct WitnessServerState *state);
bool witness_init_cb(void *ptr);
bool witness_shutdown_cb(void *ptr);
uint32_t msg_type,
struct server_id server_id,
DATA_BLOB *data);
-bool witness_create_one_interface(TALLOC_CTX *mem_ctx,
- const char *group_name,
- uint32_t witness_version,
- uint32_t state,
- const char *ipv4,
- const char *ipv6,
- struct witness_interfaceInfo *i);
-bool witness_add_interface_to_array_unique(TALLOC_CTX *mem_ctx,
- struct witness_interfaceInfo interface,
- struct witness_interfaceInfo **array,
- uint32_t *count);
#endif /*_SRV_WITNESS_H_ */
+++ /dev/null
-/*
- Unix SMB/CIFS implementation.
-
- Copyright (C) 2015 Guenther Deschner
- Copyright (C) 2015 Jose A. Rivera
-
- 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/>.
-*/
-
-int witness_get_ctdb_all_public_ips(TALLOC_CTX *tmp_ctx,
- struct tevent_context *ev,
- struct WitnessServerState *state,
- struct witness_interfaceList **list);
-int witnessd_ctdb_reconfigured(struct tevent_context *ev,
- uint32_t src_vnn,
- uint32_t dst_vnn,
- uint64_t dst_srvid,
- const uint8_t *msg,
- size_t msglen,
- void *private_data);
-
*
* Copyright (c) 2011 Andreas Schneider <asn@samba.org>
* Copyright (c) 2012 Stefan Metzmacher <metze@samba.org>
+ * Copyright (C) 2015 Guenther Deschner <gd@samba.org>
+ * Copyright (C) 2015 Jose A. Rivera <jarrpa@samba.org>
*
* 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
#include "rpc_server/rpc_server.h"
#include "rpc_server/rpc_sock_helper.h"
#include "rpc_server/rpc_ep_register.h"
+#include "../lib/witness/witness.h"
#include "rpc_server/witness/srv_witness.h"
-#include "rpc_server/witness/srv_witness_ctdb.h"
#include "../lib/util/pidfile.h"
#include "auth.h"
#include "lib/smbd_shim.h"
bld.SAMBA3_SUBSYSTEM('RPC_WITNESS',
source='''witness/srv_witness.c
- witness/srv_witness_ctdb.c
../../librpc/gen_ndr/srv_witness.c''',
- deps='''samba-util RPC_NDR_WITNESS
+ deps='''samba-util RPC_NDR_WITNESS LIB_WITNESS
ctdb-client ctdb-common''')
bld.SAMBA3_SUBSYSTEM('RPC_MGMT',
bld.RECURSE('file_server')
bld.RECURSE('lib/krb5_wrap')
bld.RECURSE('packaging')
+bld.RECURSE('lib/witness')
bld.RECURSE('testsuite/headers')