]> git.proxmox.com Git - mirror_corosync.git/commitdiff
testcpg -i shows node ids as IP addresses.
authorPatrick Caulfield <pcaulfie@redhat.com>
Fri, 7 Jul 2006 09:36:03 +0000 (09:36 +0000)
committerPatrick Caulfield <pcaulfie@redhat.com>
Fri, 7 Jul 2006 09:36:03 +0000 (09:36 +0000)
git-svn-id: http://svn.fedorahosted.org/svn/corosync/trunk@1109 fd59a12c-fef9-0310-b244-a6a79926bd2f

test/testcpg.c

index c5b52a021ddfab71cbc12bf51bfdbc4f470e1ac2..5d2746ad097b105bc59628d5aebe288d6fa57218 100644 (file)
@@ -49,6 +49,7 @@
 #include "cpg.h"
 
 static int quit = 0;
+static int show_ip = 0;
 
 void print_cpgname (struct cpg_name *name)
 {
@@ -67,7 +68,15 @@ void DeliverCallback (
        void *msg,
        int msg_len)
 {
-       printf("DeliverCallback: message (len=%d)from node/pid %d/%d: '%s'\n", msg_len, nodeid, pid, (char *)msg);
+       if (show_ip) {
+               struct in_addr saddr;
+               saddr.s_addr = nodeid;
+               printf("DeliverCallback: message (len=%d)from node/pid %s/%d: '%s'\n",
+                      msg_len, inet_ntoa(saddr), pid, (char *)msg);
+       }
+       else {
+               printf("DeliverCallback: message (len=%d)from node/pid %d/%d: '%s'\n", msg_len, nodeid, pid, (char *)msg);
+       }
 }
 
 void ConfchgCallback (
@@ -80,27 +89,46 @@ void ConfchgCallback (
        int i;
        struct in_addr saddr;
 
-
        printf("\nConfchgCallback: group '"); print_cpgname(groupName); printf("'\n");
        for (i=0; i<joined_list_entries; i++) {
-               saddr.s_addr = joined_list[i].nodeid;
-               printf("joined node/pid: %s/%d reason: %d\n",
-                       inet_ntoa (saddr), joined_list[i].pid,
-                       joined_list[i].reason);
+               if (show_ip) {
+                       saddr.s_addr = joined_list[i].nodeid;
+                       printf("joined node/pid: %s/%d reason: %d\n",
+                              inet_ntoa (saddr), joined_list[i].pid,
+                              joined_list[i].reason);
+               }
+               else {
+                       printf("joined node/pid: %d/%d reason: %d\n",
+                              joined_list[i].nodeid, joined_list[i].pid,
+                              joined_list[i].reason);
+               }
        }
 
        for (i=0; i<left_list_entries; i++) {
-               saddr.s_addr = left_list[i].nodeid;
-               printf("left node/pid: %s/%d reason: %d\n",
-                       inet_ntoa (saddr), left_list[i].pid,
-                       left_list[i].reason);
+               if (show_ip) {
+                       saddr.s_addr = left_list[i].nodeid;
+                       printf("left node/pid: %s/%d reason: %d\n",
+                              inet_ntoa (saddr), left_list[i].pid,
+                              left_list[i].reason);
+               }
+               else {
+                       printf("left node/pid: %d/%d reason: %d\n",
+                              left_list[i].nodeid, left_list[i].pid,
+                              left_list[i].reason);
+               }
        }
 
        printf("nodes in group now %d\n", member_list_entries);
        for (i=0; i<member_list_entries; i++) {
-               saddr.s_addr = member_list[i].nodeid;
-               printf("node/pid: %s/%d\n",
-                       inet_ntoa (saddr), member_list[i].pid);
+               if (show_ip) {
+                       saddr.s_addr = member_list[i].nodeid;
+                       printf("node/pid: %s/%d\n",
+                              inet_ntoa (saddr), member_list[i].pid);
+               }
+               else {
+                       printf("node/pid: %d/%d\n",
+                              member_list[i].nodeid, member_list[i].pid);
+               }
        }
 
        /* Is it us??
@@ -126,10 +154,20 @@ int main (int argc, char *argv[]) {
        fd_set read_fds;
        int select_fd;
        int result;
+       const char *options = "i";
+       int opt;
+
+       while ( (opt = getopt(argc, argv, options)) != -1 ) {
+               switch (opt) {
+               case 'i':
+                       show_ip = 1;
+                       break;
+               }
+       }
 
-       if (argc > 1) {
-               strcpy(group_name.value, argv[1]);
-               group_name.length = strlen(argv[1])+1;
+       if (argc > optind) {
+               strcpy(group_name.value, argv[optind]);
+               group_name.length = strlen(argv[optind])+1;
        }
        else {
                strcpy(group_name.value, "GROUP");