ctdb-tests: Replace parse_ip() -> ctdb_sock_addr_from_string()
authorMartin Schwenke <martin@meltin.net>
Tue, 19 Sep 2017 13:38:31 +0000 (23:38 +1000)
committerMartin Schwenke <martins@samba.org>
Thu, 5 Oct 2017 03:19:21 +0000 (05:19 +0200)
... and ctdb_sock_addr_set_port() where required.

Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
ctdb/tests/src/fake_ctdbd.c
ctdb/tests/src/ipalloc_read_known_ips.c

index 98aacbe37dfeb0f99f713c7d4e0cb3f6827e87a0..06b5b2265c926352437854d64b5891fd69b64f72 100644 (file)
@@ -37,7 +37,6 @@
 #include "protocol/protocol_util.h"
 
 #include "common/comm.h"
-#include "common/system.h"
 #include "common/logging.h"
 #include "common/tunable.h"
 #include "common/srvid.h"
@@ -170,6 +169,7 @@ static bool nodemap_parse(struct node_map *node_map)
                char *ip;
                ctdb_sock_addr saddr;
                struct node *node;
+               int ret;
 
                if (line[0] == '\n') {
                        break;
@@ -194,10 +194,12 @@ static bool nodemap_parse(struct node_map *node_map)
                        fprintf(stderr, "bad line (%s) - missing IP\n", line);
                        continue;
                }
-               if (!parse_ip(tok, NULL, CTDB_PORT, &saddr)) {
+               ret = ctdb_sock_addr_from_string(tok, &saddr, false);
+               if (ret != 0) {
                        fprintf(stderr, "bad line (%s) - invalid IP\n", line);
                        continue;
                }
+               ctdb_sock_addr_set_port(&saddr, CTDB_PORT);
                ip = talloc_strdup(node_map, tok);
                if (ip == NULL) {
                        goto fail;
@@ -249,7 +251,8 @@ static bool nodemap_parse(struct node_map *node_map)
                }
                node = &node_map->node[node_map->num_nodes];
 
-               parse_ip(ip, NULL, CTDB_PORT, &node->addr);
+               ctdb_sock_addr_from_string(ip, &node->addr, false);
+               ctdb_sock_addr_set_port(&node->addr, CTDB_PORT);
                node->pnn = pnn;
                node->flags = flags;
                node->capabilities = capabilities;
@@ -275,11 +278,14 @@ static bool node_map_add(struct ctdb_node_map *nodemap,
        ctdb_sock_addr addr;
        uint32_t num;
        struct ctdb_node_and_flags *n;
+       int ret;
 
-       if (! parse_ip(nstr, NULL, CTDB_PORT, &addr)) {
+       ret = ctdb_sock_addr_from_string(nstr, &addr, false);
+       if (ret != 0) {
                fprintf(stderr, "Invalid IP address %s\n", nstr);
                return false;
        }
+       ctdb_sock_addr_set_port(&addr, CTDB_PORT);
 
        num = nodemap->num;
        nodemap->node = talloc_realloc(nodemap, nodemap->node,
@@ -1959,7 +1965,8 @@ static void control_reload_nodes_file(TALLOC_CTX *mem_ctx,
                        node = &node_map->node[i];
 
                        node->flags |= NODE_FLAGS_DELETED;
-                       parse_ip("0.0.0.0", NULL, 0, &node->addr);
+                       ctdb_sock_addr_from_string("0.0.0.0", &node->addr,
+                                                  false);
 
                        continue;
                }
index 5725d6dc5233795006b0ce7164905e77d6acca99..354f7ec4fcda1a78abbab634fda72bc56e82553c 100644 (file)
@@ -25,8 +25,8 @@
 #include "lib/util/debug.h"
 
 #include "protocol/protocol.h"
+#include "protocol/protocol_util.h"
 #include "common/logging.h"
-#include "common/system.h"
 
 #include "ipalloc_read_known_ips.h"
 
@@ -69,6 +69,7 @@ static bool read_ctdb_public_ip_info_node(bool multi,
        }
 
        while (fgets(line, sizeof(line), stdin) != NULL) {
+               int ret;
 
                /* Get rid of pesky newline */
                if ((t = strchr(line, '\n')) != NULL) {
@@ -87,7 +88,8 @@ static bool read_ctdb_public_ip_info_node(bool multi,
                        continue;
                }
 
-               if (!parse_ip(tok, NULL, 0, &addr)) {
+               ret = ctdb_sock_addr_from_string(tok, &addr, false);
+               if (ret != 0) {
                        D_ERR("ERROR, bad address :%s\n", tok);
                        continue;
                }