ukernel: get an ip address even when dns and hosts suck

gethostname plus gethostbyname being useless make things fun

make things less fun

Change-Id: I5595698b0b7f2448b8c86448bedd8b16ab088510
Reviewed-on: http://gerrit.openafs.org/5600
Tested-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This commit is contained in:
Derrick Brashear 2011-10-11 15:37:57 -04:00
parent 7829e71523
commit 6f59c71988

View File

@ -64,6 +64,9 @@
# include "afs/sysincludes.h" # include "afs/sysincludes.h"
# include "afsincludes.h" # include "afsincludes.h"
#endif #endif
#ifdef UKERNEL
# include "rx/rx_prototypes.h"
#endif
typedef struct { typedef struct {
char eaddr[6]; /* 6 bytes of ethernet hardware address */ char eaddr[6]; /* 6 bytes of ethernet hardware address */
@ -405,38 +408,37 @@ static int
uuid_get_address(uuid_address_p_t addr) uuid_get_address(uuid_address_p_t addr)
{ {
afs_int32 code; afs_int32 code;
afs_uint32 addr1; afs_uint32 addr1 = 0;
struct hostent *he; struct hostent *he = NULL;
code = gethostname(hostName1, 64); code = gethostname(hostName1, 64);
if (code) { if (!code)
printf("gethostname() failed\n"); he = gethostbyname(hostName1);
#ifdef AFS_NT40_ENV
return ENOENT; if (he)
#else
return errno;
#endif
}
he = gethostbyname(hostName1);
if (!he) {
printf("Can't find address for '%s'\n", hostName1);
#ifdef AFS_NT40_ENV
return ENOENT;
#else
return errno;
#endif
} else {
memcpy(&addr1, he->h_addr_list[0], 4); memcpy(&addr1, he->h_addr_list[0], 4);
addr1 = ntohl(addr1); #ifdef UKERNEL
memcpy(addr->eaddr, &addr1, 4); else
addr->eaddr[4] = 0xaa; addr1=rxi_getaddr();
addr->eaddr[5] = 0x77; #endif
#ifdef UUID_DEBUG
printf("uuid_get_address: %02x-%02x-%02x-%02x-%02x-%02x\n", if (!addr1) {
addr->eaddr[0], addr->eaddr[1], addr->eaddr[2], addr->eaddr[3], #ifdef AFS_NT40_ENV
addr->eaddr[4], addr->eaddr[5]); return ENOENT;
#else
return errno;
#endif #endif
} }
addr1 = ntohl(addr1);
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]);
#endif
return 0; return 0;
} }