struct pnn_node {
struct pnn_node *next, *prev;
- const char *addr;
+ ctdb_sock_addr addr;
int pnn;
};
}
pnn_node = talloc(mem_ctx, struct pnn_node);
pnn_node->pnn = pnn++;
- pnn_node->addr = talloc_strdup(pnn_node, node);
+
+ if (!parse_ip(node, NULL, 0, &pnn_node->addr)) {
+ DEBUG(DEBUG_ERR,
+ ("Invalid IP address '%s' in file %s\n",
+ node, file));
+ /* Caller will free mem_ctx */
+ return NULL;
+ }
DLIST_ADD_END(pnn_nodes, pnn_node, NULL);
}
}
for(pnn_node=pnn_nodes;pnn_node;pnn_node=pnn_node->next) {
- ctdb_sock_addr addr;
-
- if (parse_ip(pnn_node->addr, NULL, 63999, &addr) == 0) {
- DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s' in nodes file\n", pnn_node->addr));
- talloc_free(mem_ctx);
- return -1;
- }
-
- if (ctdb_sys_have_ip(&addr)) {
+ if (ctdb_sys_have_ip(&pnn_node->addr)) {
printf("PNN:%d\n", pnn_node->pnn);
talloc_free(mem_ctx);
return 0;
for (i = 0; i < nodemap->num; i++) {
for(n = nodes; n != NULL ; n = n->next) {
- if (!strcmp(n->addr,
- ctdb_addr_to_str(&nodemap->nodes[i].addr))) {
+ if (ctdb_same_ip(&n->addr,
+ &nodemap->nodes[i].addr)) {
break;
}
}
}
for(pnn_node=pnn_nodes;pnn_node;pnn_node=pnn_node->next) {
- ctdb_sock_addr addr;
- if (parse_ip(pnn_node->addr, NULL, 63999, &addr) == 0) {
- DEBUG(DEBUG_ERR,("Wrongly formed ip address '%s' in nodes file\n", pnn_node->addr));
- talloc_free(mem_ctx);
- return -1;
- }
+ const char *addr = ctdb_addr_to_str(&pnn_node->addr);
if (options.machinereadable){
- printf(":%d:%s:\n", pnn_node->pnn, pnn_node->addr);
+ printf(":%d:%s:\n", pnn_node->pnn, addr);
} else {
- printf("%s\n", pnn_node->addr);
+ printf("%s\n", addr);
}
}
talloc_free(mem_ctx);