diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h index d165ba25ade..67f32a0b8cc 100644 --- a/ctdb/protocol/protocol_api.h +++ b/ctdb/protocol/protocol_api.h @@ -678,22 +678,4 @@ void sock_packet_header_set_reqid(struct sock_packet_header *h, void sock_packet_header_set_length(struct sock_packet_header *h, uint32_t length); -/* From protocol/protocol_util.c */ - -const char *ctdb_runstate_to_string(enum ctdb_runstate runstate); -enum ctdb_runstate ctdb_runstate_from_string(const char *runstate_str); - -const char *ctdb_event_to_string(enum ctdb_event event); -enum ctdb_event ctdb_event_from_string(const char *event_str); - -const char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr); -int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, - const ctdb_sock_addr *addr2); -int ctdb_sock_addr_cmp(const ctdb_sock_addr *addr1, - const ctdb_sock_addr *addr2); -bool ctdb_sock_addr_same_ip(const ctdb_sock_addr *addr1, - const ctdb_sock_addr *addr2); -bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1, - const ctdb_sock_addr *addr2); - #endif /* __CTDB_PROTOCOL_API_H__ */ diff --git a/ctdb/protocol/protocol_util.c b/ctdb/protocol/protocol_util.c index 0e1bf286799..3b039446af3 100644 --- a/ctdb/protocol/protocol_util.c +++ b/ctdb/protocol/protocol_util.c @@ -21,11 +21,9 @@ #include "system/network.h" #include -#include #include "protocol.h" -#include "protocol_private.h" -#include "protocol_api.h" +#include "protocol_util.h" static struct { enum ctdb_runstate runstate; diff --git a/ctdb/protocol/protocol_util.h b/ctdb/protocol/protocol_util.h new file mode 100644 index 00000000000..94778817efd --- /dev/null +++ b/ctdb/protocol/protocol_util.h @@ -0,0 +1,43 @@ +/* + CTDB protocol marshalling + + Copyright (C) Amitay Isaacs 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 . +*/ + +#ifndef __CTDB_PROTOCOL_UTIL_H__ +#define __CTDB_PROTOCOL_UTIL_H__ + +#include + +#include "protocol/protocol.h" + +const char *ctdb_runstate_to_string(enum ctdb_runstate runstate); +enum ctdb_runstate ctdb_runstate_from_string(const char *runstate_str); + +const char *ctdb_event_to_string(enum ctdb_event event); +enum ctdb_event ctdb_event_from_string(const char *event_str); + +const char *ctdb_sock_addr_to_string(TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr); +int ctdb_sock_addr_cmp_ip(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2); +int ctdb_sock_addr_cmp(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2); +bool ctdb_sock_addr_same_ip(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2); +bool ctdb_sock_addr_same(const ctdb_sock_addr *addr1, + const ctdb_sock_addr *addr2); + +#endif /* __CTDB_PROTOCOL_UTIL_H__ */ diff --git a/ctdb/server/ctdb_eventd.c b/ctdb/server/ctdb_eventd.c index 68ba2761b42..1a6c69c00ea 100644 --- a/ctdb/server/ctdb_eventd.c +++ b/ctdb/server/ctdb_eventd.c @@ -35,6 +35,7 @@ #include "lib/async_req/async_sock.h" #include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "common/comm.h" #include "common/logging.h" diff --git a/ctdb/server/ctdb_takeover_helper.c b/ctdb/server/ctdb_takeover_helper.c index 5efd6198394..41d4d1c886b 100644 --- a/ctdb/server/ctdb_takeover_helper.c +++ b/ctdb/server/ctdb_takeover_helper.c @@ -42,6 +42,7 @@ #include "protocol/protocol.h" #include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "client/client.h" #include "common/logging.h" diff --git a/ctdb/server/ipalloc.c b/ctdb/server/ipalloc.c index 5dffb0d7216..caa50224156 100644 --- a/ctdb/server/ipalloc.c +++ b/ctdb/server/ipalloc.c @@ -29,7 +29,7 @@ #include "common/logging.h" #include "common/rb_tree.h" -#include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "server/ipalloc_private.h" diff --git a/ctdb/server/ipalloc_common.c b/ctdb/server/ipalloc_common.c index 50bb59a5937..9d5cd03e6be 100644 --- a/ctdb/server/ipalloc_common.c +++ b/ctdb/server/ipalloc_common.c @@ -32,7 +32,7 @@ #include "common/common.h" #include "common/rb_tree.h" -#include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "server/ipalloc_private.h" diff --git a/ctdb/server/ipalloc_lcp2.c b/ctdb/server/ipalloc_lcp2.c index 48e0d0218e8..715041f4b91 100644 --- a/ctdb/server/ipalloc_lcp2.c +++ b/ctdb/server/ipalloc_lcp2.c @@ -25,7 +25,7 @@ #include "lib/util/debug.h" #include "common/logging.h" -#include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "server/ipalloc_private.h" diff --git a/ctdb/server/ipalloc_nondeterministic.c b/ctdb/server/ipalloc_nondeterministic.c index bb5f8faf9c8..46001dcafd2 100644 --- a/ctdb/server/ipalloc_nondeterministic.c +++ b/ctdb/server/ipalloc_nondeterministic.c @@ -28,7 +28,7 @@ #include "common/logging.h" #include "common/common.h" -#include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "server/ipalloc_private.h" diff --git a/ctdb/tests/src/ctdb_takeover_tests.c b/ctdb/tests/src/ctdb_takeover_tests.c index 5093757adc3..0fae679bd38 100644 --- a/ctdb/tests/src/ctdb_takeover_tests.c +++ b/ctdb/tests/src/ctdb_takeover_tests.c @@ -26,7 +26,7 @@ #include "lib/util/debug.h" #include "protocol/protocol.h" -#include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "common/logging.h" #include "common/system.h" diff --git a/ctdb/tests/src/fake_ctdbd.c b/ctdb/tests/src/fake_ctdbd.c index 57783f7fd7b..48440f2c1d1 100644 --- a/ctdb/tests/src/fake_ctdbd.c +++ b/ctdb/tests/src/fake_ctdbd.c @@ -34,6 +34,7 @@ #include "protocol/protocol.h" #include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "common/comm.h" #include "common/system.h" diff --git a/ctdb/tools/ctdb.c b/ctdb/tools/ctdb.c index 60d7a172b2d..23960c3218f 100644 --- a/ctdb/tools/ctdb.c +++ b/ctdb/tools/ctdb.c @@ -39,6 +39,7 @@ #include "common/logging.h" #include "protocol/protocol.h" #include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "common/system.h" #include "client/client.h" #include "client/client_sync.h" diff --git a/ctdb/tools/ctdb_event.c b/ctdb/tools/ctdb_event.c index 07bc73bc9e7..ee2c25bc1e0 100644 --- a/ctdb/tools/ctdb_event.c +++ b/ctdb/tools/ctdb_event.c @@ -26,7 +26,7 @@ #include "lib/util/debug.h" -#include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "client/client_event.h" #include "common/logging.h" diff --git a/ctdb/tools/ctdb_killtcp.c b/ctdb/tools/ctdb_killtcp.c index 5db7ec7853b..39f1aaf8997 100644 --- a/ctdb/tools/ctdb_killtcp.c +++ b/ctdb/tools/ctdb_killtcp.c @@ -26,7 +26,7 @@ #include "lib/util/debug.h" #include "protocol/protocol.h" -#include "protocol/protocol_api.h" +#include "protocol/protocol_util.h" #include "common/rb_tree.h" #include "common/system.h" diff --git a/ctdb/wscript b/ctdb/wscript index 505f2e58bcb..2679c56db30 100644 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -400,12 +400,15 @@ def build(bld): protocol_keepalive.c protocol_client.c protocol_debug.c - protocol_util.c protocol_event.c protocol_sock.c'''), includes='include', deps='replace talloc tdb') + bld.SAMBA_SUBSYSTEM('ctdb-protocol-util', + source='protocol/protocol_util.c', + deps='replace talloc tdb') + bld.SAMBA_SUBSYSTEM('ctdb-client', source=bld.SUBDIR('client', 'ctdb_client.c'), includes='include', @@ -439,7 +442,7 @@ def build(bld): ipalloc.c '''), includes='include', - deps='ctdb-protocol replace talloc tevent') + deps='ctdb-protocol-util replace talloc tevent') bld.SAMBA_BINARY('ctdbd', source='server/ctdbd.c ' + @@ -469,21 +472,21 @@ def build(bld): bld.SAMBA_BINARY('ctdb', source='tools/ctdb.c', - deps='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system - samba-util sys_rw popt''', + deps='''ctdb-client2 ctdb-protocol ctdb-protocol-util + ctdb-util ctdb-system samba-util sys_rw popt''', install_path='${BINDIR}', manpages='ctdb.1') bld.SAMBA_BINARY('ctdb_killtcp', source='tools/ctdb_killtcp.c', - deps='''ctdb-protocol ctdb-util ctdb-system + deps='''ctdb-protocol-util ctdb-util ctdb-system samba-util replace''', install_path='${CTDB_HELPER_BINDIR}') bld.SAMBA_BINARY('ctdb_event', source='tools/ctdb_event.c', - deps='''ctdb-client2 ctdb-protocol ctdb-util ctdb-system - samba-util replace''', + deps='''ctdb-client2 ctdb-protocol ctdb-protocol-util + ctdb-util ctdb-system samba-util replace''', install_path='${CTDB_HELPER_BINDIR}') bld.SAMBA_BINARY('ltdbtool', @@ -495,8 +498,8 @@ def build(bld): bld.SAMBA_BINARY('ctdb_eventd', source='server/ctdb_eventd.c', - deps='''ctdb-server-util ctdb-protocol ctdb-util - samba-util LIBASYNC_REQ replace popt''', + deps='''ctdb-server-util ctdb-protocol ctdb-protocol-util + ctdb-util samba-util LIBASYNC_REQ replace popt''', install_path='${CTDB_HELPER_BINDIR}') bld.SAMBA_BINARY('ctdb_lock_helper', @@ -840,8 +843,9 @@ def build(bld): bld.SAMBA_BINARY('fake_ctdbd', source='''tests/src/fake_ctdbd.c tests/src/ipalloc_read_known_ips.c''', - deps='''ctdb-util ctdb-protocol ctdb-system - samba-util tevent-util LIBASYNC_REQ popt''', + deps='''ctdb-util ctdb-protocol ctdb-protocol-util + ctdb-system samba-util tevent-util + LIBASYNC_REQ popt''', install_path='${CTDB_TEST_LIBEXECDIR}') if bld.env.HAVE_INFINIBAND: