]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
ukernel: get an ip address even when dns and hosts suck
authorDerrick Brashear <shadow@dementix.org>
Tue, 11 Oct 2011 19:37:57 +0000 (15:37 -0400)
committerDerrick Brashear <shadow@dementix.org>
Wed, 26 Oct 2011 22:58:15 +0000 (15:58 -0700)
gethostname plus gethostbyname being useless make things fun

make things less fun

(cherry picked from commit 6f59c71988d75f76750c46adb11cda7e9189d5f3)

Change-Id: Id7d9181b2d87f7a87a08991b96da664f4297604b
Reviewed-on: http://gerrit.openafs.org/5726
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
src/util/uuid.c

index f56834234c5d06fd02543103f1b8d0b4f86be90d..6f59923a6014d998d14043a1089e52941807e2e0 100644 (file)
@@ -89,6 +89,9 @@
 #define uuid_memcpy(A,B,C)     memcpy(A,B,C)
 #endif /* KERNEL */
 
+#ifdef UKERNEL
+# include "rx/rx_prototypes.h"
+#endif
 
 typedef struct {
     char eaddr[6];             /* 6 bytes of ethernet hardware address */
@@ -431,38 +434,38 @@ static int
 uuid_get_address(uuid_address_p_t addr)
 {
     afs_int32 code;
-    afs_uint32 addr1;
-    struct hostent *he;
+    afs_uint32 addr1 = 0;
+    struct hostent *he = NULL;
 
     code = gethostname(hostName1, 64);
-    if (code) {
-       printf("gethostname() failed\n");
-#ifdef AFS_NT40_ENV
-       return ENOENT;
-#else
-       return errno;
+    if (!code)
+       he = gethostbyname(hostName1);
+
+    if (he)
+       uuid_memcpy(&addr1, he->h_addr_list[0], 4);
+#ifdef UKERNEL
+    else
+       addr1=rxi_getaddr();
 #endif
-    }
-    he = gethostbyname(hostName1);
-    if (!he) {
-       printf("Can't find address for '%s'\n", hostName1);
+
+    if (!addr1) {
 #ifdef AFS_NT40_ENV
        return ENOENT;
 #else
        return errno;
 #endif
     } else {
-       uuid_memcpy(&addr1, he->h_addr_list[0], 4);
        addr1 = ntohl(addr1);
        uuid_memcpy(addr->eaddr, &addr1, 4);
        addr->eaddr[4] = 0xaa;
        addr->eaddr[5] = 0x77;
+    }
+
 #ifdef  UUID_DEBUG
-       printf("uuid_get_address: %02x-%02x-%02x-%02x-%02x-%02x\n",
-              addr->eaddr[0], addr->eaddr[1], addr->eaddr[2], addr->eaddr[3],
-              addr->eaddr[4], addr->eaddr[5]);
+    printf("uuid_get_address: %02x-%02x-%02x-%02x-%02x-%02x\n",
+          addr->eaddr[0], addr->eaddr[1], addr->eaddr[2], addr->eaddr[3],
+          addr->eaddr[4], addr->eaddr[5]);
 #endif
-    }
     return 0;
 }