From mboxrd@z Thu Jan 1 00:00:00 1970 From: fabbione@sourceware.org Date: 3 May 2007 09:06:40 -0000 Subject: [Cluster-devel] cluster/ccs/ccs_tool ccs_tool.c update.c Message-ID: <20070503090640.25151.qmail@sourceware.org> List-Id: To: cluster-devel.redhat.com MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit CVSROOT: /cvs/cluster Module name: cluster Changes by: fabbione at sourceware.org 2007-05-03 09:06:40 Modified files: ccs/ccs_tool : ccs_tool.c update.c Log message: Readd ipv6 support to ccs_tool update and add verbose option Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/ccs/ccs_tool/ccs_tool.c.diff?cvsroot=cluster&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/ccs/ccs_tool/update.c.diff?cvsroot=cluster&r1=1.10&r2=1.11 --- cluster/ccs/ccs_tool/ccs_tool.c 2006/09/19 13:17:04 1.5 +++ cluster/ccs/ccs_tool/ccs_tool.c 2007/05/03 09:06:39 1.6 @@ -10,6 +10,8 @@ static void print_usage(FILE *stream); +int globalverbose=0; + int main(int argc, char *argv[]) { optind = 1; @@ -26,6 +28,10 @@ } if(optind < argc){ + if(!strcmp(argv[optind], "-verbose")){ + optind++; + globalverbose=1; + } if(!strcmp(argv[optind], "help")){ print_usage(stdout); exit(EXIT_SUCCESS); @@ -106,6 +112,7 @@ " ccs_tool [options] \n" "\n" "Options:\n" + " -verbose Make some operations print more details.\n" " -h Print this usage and exit.\n" " -V Print version information and exit.\n" "\n" --- cluster/ccs/ccs_tool/update.c 2007/01/26 22:13:20 1.10 +++ cluster/ccs/ccs_tool/update.c 2007/05/03 09:06:39 1.11 @@ -19,6 +19,9 @@ #include #include #include +#include +#include +#include #include "comm_headers.h" #include "ccs.h" @@ -49,6 +52,8 @@ static int ipv6_connect(struct in6_addr *addr, uint16_t port, int timeout); static int connect_nb(int fd, struct sockaddr *addr, socklen_t len, int timeout); +extern int globalverbose; + int cluster_base_port = 50008; static int get_doc_version(xmlDocPtr ldoc) @@ -659,12 +664,43 @@ static int ccs_open(cman_node_t node, uint16_t port, int timeout) { struct in_addr *addr; - int fd; + struct in6_addr *addr6; + int fd, family; + char buf[INET6_ADDRSTRLEN]; - addr = &(((struct sockaddr_in *)&(node.cn_address.cna_address))->sin_addr); + if (globalverbose) { + memset(buf, 0, sizeof(buf)); + printf("Processing node: %s\n", node.cn_name); + } + + family = ((struct sockaddr *)&(node.cn_address.cna_address))->sa_family; + + if (family == AF_INET6) { + + addr6 = &(((struct sockaddr_in6 *)&(node.cn_address.cna_address))->sin6_addr); + + if (globalverbose) { + inet_ntop(family, addr6, buf, sizeof(buf)); + printf(" family: ipv6\n address: %s\n", buf); + } + + if ((fd = ipv6_connect(addr6, port, timeout)) < 0) { + return -1; + } + + } else { + + addr = &(((struct sockaddr_in *)&(node.cn_address.cna_address))->sin_addr); + + if (globalverbose) { + inet_ntop(family, addr, buf, sizeof(buf)); + printf(" family: ipv4\n address: %s\n", buf); + } + + if ((fd = ipv4_connect(addr, port, timeout)) < 0) { + return -1; + } - if ((fd = ipv4_connect(addr, port, timeout)) < 0) { - return -1; } return fd;