log-host-addrs-as-dotted-quad-not-hex-in-viced-20010601
authorNathan Neulinger <nneul@umr.edu>
Fri, 1 Jun 2001 20:14:58 +0000 (20:14 +0000)
committerDerrick Brashear <shadow@dementia.org>
Fri, 1 Jun 2001 20:14:58 +0000 (20:14 +0000)
so you get a dotted quad and byte-correct port instead of a hex ip and a potentially
byteswapped port number from viced log messages

src/tviced/Makefile
src/util/afsutil.h
src/util/hostparse.c
src/viced/host.c
src/viced/viced.c

index 5049e95..83bab93 100644 (file)
@@ -45,7 +45,8 @@ objects= ${VICEDOBJS} ${VLSERVEROBJS} ${LWPOBJS} ${LIBACLOBJS} \
         ${UTILOBJS} ${DIROBJS} ${VOLOBJS} ${FSINTOBJS}
 
 LIBS=  ${SRCDIR}lib/libafsauthent.a    \
-       ${SRCDIR}lib/libafsrpc.a
+       ${SRCDIR}lib/libafsrpc.a \
+       ${SRCDIR}lib/afs/util.a
 
 include ../config/Makefile.version
 
index d2ff8c4..35fb5c4 100644 (file)
@@ -58,7 +58,7 @@ extern char *vctime(const time_t *atime);
 
 /* Convert a 4 byte integer to a text string. */
 extern char*   afs_inet_ntoa(afs_uint32 addr);
-
+extern char*    afs_inet_ntoa_r(afs_uint32 addr);
 
 /* copy strings, converting case along the way. */
 extern char *lcstring(char *d, char *s, int n);
index f0ba157..a49f9b1 100644 (file)
@@ -231,6 +231,24 @@ char* afs_inet_ntoa(afs_uint32 addr)
     return (char *) inet_ntoa(temp);
 }
 
+/* same as above, but to a non-static buffer, must be freed by called */
+char* afs_inet_ntoa_r(afs_uint32 addr)
+{
+    char *buf;
+    int temp;
+
+    temp = ntohl(addr);
+    buf = (char *) malloc(16); /* length of xxx.xxx.xxx.xxx\0 */
+    buf[15] = 0;
+
+    sprintf(buf, "%d.%d.%d.%d", 
+           (temp >> 24 ) & 0xff,
+           (temp >> 16 ) & 0xff, 
+           (temp >> 8  ) & 0xff,
+           (temp       ) & 0xff);
+    return buf;
+}
+
 /*
  * gettmpdir() -- Returns pointer to global temporary directory string.
  *     Always succeeds.  Never attempt to deallocate directory string.
index 19e3bd3..bba7bbc 100644 (file)
@@ -986,9 +986,11 @@ retry:
                    goto retry;
                }
        } else {
-               ViceLog(0,("CB: WhoAreYou failed for %x.%d, error %d\n", 
-                       host->host, host->port, code));
+               char *hoststr = afs_inet_ntoa_r(host->host);
+               ViceLog(0,("CB: WhoAreYou failed for %s:%d, error %d\n", 
+                       hoststr, ntohs(host->port), code));
                host->hostFlags |= VENUSDOWN;
+               free(hoststr);
        }
        host->hostFlags |= ALTADDR;
        h_Unlock_r(host);
@@ -1085,9 +1087,11 @@ retry:
                }
           }
           if (code) {
-               ViceLog(0,("CB: RCallBackConnectBack failed for %x.%d\n", 
-                       host->host, host->port));
+               char *hoststr = afs_inet_ntoa_r(host->host);
+               ViceLog(0,("CB: RCallBackConnectBack failed for %s:%d\n", 
+                       hoststr, ntohs(host->port)));
                host->hostFlags |= VENUSDOWN;
+               free(hoststr);
            }
            else
                host->hostFlags |= RESETDONE;
@@ -1905,10 +1909,12 @@ int CheckHost(host, held)
                    host->hostFlags |= ALTADDR; /* alternate addresses valid */
                    if ( code )
                    {
+                       char *hoststr = afs_inet_ntoa_r(host->host);
                        ViceLog(0,
-                           ("CB: RCallBackConnectBack (host.c) failed for host %x.%d\n",
-                           host->host, host->port));
+                           ("CB: RCallBackConnectBack (host.c) failed for host %s:%d\n",
+                           hoststr, ntohs(host->port)));
                        host->hostFlags |= VENUSDOWN;
+                       free(hoststr);
                     }
                    /* Note:  it's safe to delete hosts even if they have call
                     * back state, because break delayed callbacks (called when a
@@ -1927,10 +1933,12 @@ int CheckHost(host, held)
                        H_LOCK
                        if(code) {
                            if ( MultiProbeAlternateAddress_r(host) ) {
+                               char *hoststr = afs_inet_ntoa_r(host->host);
                                ViceLog(0,
-                                       ("ProbeUuid failed for host %x.%d\n",
-                                        host->host, host->port));
+                                       ("ProbeUuid failed for host %s:%d\n",
+                                        hoststr, ntohs(host->port)));
                                host->hostFlags |= VENUSDOWN;
+                               free(hoststr);
                            }
                        }
                    } else {
@@ -1938,9 +1946,11 @@ int CheckHost(host, held)
                        code = RXAFSCB_Probe(host->callback_rxcon);
                        H_LOCK
                        if (code) {
-                           ViceLog(0, ("ProbeUuid failed for host %x.%d\n",
-                                   host->host, host->port));
+                           char *hoststr = afs_inet_ntoa_r(host->host);
+                           ViceLog(0, ("ProbeUuid failed for host %s:%d\n",
+                                   hoststr, ntohs(host->port)));
                            host->hostFlags |= VENUSDOWN;
+                           free(hoststr);
                        }
                    }
                }
index d6da4ba..221f516 100644 (file)
@@ -599,10 +599,13 @@ main(argc, argv)
        ViceLog(0, ("Can't find address for FileServer '%s'\n", FS_HostName));
     }
     else {
+      char *hoststr;
       bcopy(he->h_addr, &FS_HostAddr_NBO, 4);
+      hoststr = afs_inet_ntoa_r(FS_HostAddr_NBO);
       FS_HostAddr_HBO = ntohl(FS_HostAddr_NBO);
-      ViceLog(0,("FileServer %s has address 0x%x (0x%x in host byte order)\n",
-                FS_HostName, FS_HostAddr_NBO, FS_HostAddr_HBO));
+      ViceLog(0,("FileServer %s has address %s (0x%x or 0x%x in host byte order)\n",
+                FS_HostName, hoststr, FS_HostAddr_NBO, FS_HostAddr_HBO));
+      free(hoststr);
     }
 
     /* Install handler to catch the shutdown signal */