mirror of
https://git.openafs.org/openafs.git
synced 2025-01-19 07:20:11 +00:00
Kill afs_inet_ntoa
Replace all calls to afs_inet_ntoa with the threadsafe afs_inet_ntoa_r. afs_inet_ntoa was being used in a few places that may be threaded (ubik), and in general should be avoided in case the relevant code becomes threaded. Remove the definition of afs_inet_ntoa to prevent anyone from using it. Change-Id: I163d3f58fdd3d28077780963ced9995247682d78 Reviewed-on: http://gerrit.openafs.org/1680 Tested-by: Andrew Deason <adeason@sinenomine.net> Reviewed-by: Derrick Brashear <shadow@dementia.org> Tested-by: Derrick Brashear <shadow@dementia.org>
This commit is contained in:
parent
73dd2783d7
commit
5a7d6da525
@ -67,7 +67,8 @@ cmdproc(register struct cmd_syndesc *as, void * arock)
|
||||
ctime(&rdata.last_use));
|
||||
} else {
|
||||
char *hostIP;
|
||||
hostIP = afs_inet_ntoa(rdata.host);
|
||||
char hoststr[16];
|
||||
hostIP = afs_inet_ntoa_r(rdata.host, hoststr);
|
||||
printf("%s: last operation from host %s at %s",
|
||||
(char *)key.dptr, hostIP,
|
||||
ctime(&rdata.last_use));
|
||||
|
@ -795,6 +795,7 @@ SocketListener(void *unused)
|
||||
struct packet packet;
|
||||
socklen_t fromLen;
|
||||
afs_int32 code;
|
||||
char hoststr[16];
|
||||
|
||||
printf("Starting to listen for UDP packets\n");
|
||||
while (1) {
|
||||
@ -830,7 +831,7 @@ SocketListener(void *unused)
|
||||
packet.len = code;
|
||||
if (krb_udp_debug) {
|
||||
printf("Kerb:udp: Got %d bytes from addr %s which are '",
|
||||
code, afs_inet_ntoa(packet.from.sin_addr.s_addr));
|
||||
code, afs_inet_ntoa_r(packet.from.sin_addr.s_addr, hoststr));
|
||||
ka_PrintBytes(packet.data, packet.len);
|
||||
printf("'\n");
|
||||
}
|
||||
@ -852,7 +853,7 @@ SocketListener(void *unused)
|
||||
packet.len = code;
|
||||
if (krb_udp_debug) {
|
||||
printf("Kerb5:udp: Got %d bytes from addr %s which are '",
|
||||
code, afs_inet_ntoa(packet.from.sin_addr.s_addr));
|
||||
code, afs_inet_ntoa_r(packet.from.sin_addr.s_addr, hoststr));
|
||||
ka_PrintBytes(packet.data, packet.len);
|
||||
printf("'\n");
|
||||
}
|
||||
|
@ -1278,8 +1278,9 @@ dump_he_hdr(void)
|
||||
static void
|
||||
dump_he_entry(void)
|
||||
{
|
||||
char hoststr[16];
|
||||
DPFSO0("hostDiskEntry");
|
||||
DPFS1("host", afs_inet_ntoa(he_cursor.he.host));
|
||||
DPFS1("host", afs_inet_ntoa_r(he_cursor.he.host, hoststr));
|
||||
DPFV1("port", "u", he_cursor.he.port);
|
||||
DPFX1("hostFlags", he_cursor.he.hostFlags);
|
||||
DPFV1("Console", "u", he_cursor.he.Console);
|
||||
@ -1307,6 +1308,7 @@ dump_he_interfaces(void)
|
||||
char temp_str[40];
|
||||
struct Interface * ifp;
|
||||
int len, i;
|
||||
char hoststr[16];
|
||||
|
||||
if (!he_cursor.hdr.interfaces)
|
||||
return;
|
||||
@ -1325,7 +1327,7 @@ dump_he_interfaces(void)
|
||||
for (i = 0; i < he_cursor.hdr.interfaces; i++) {
|
||||
snprintf(temp_str, sizeof(temp_str), "interface[%d]", i);
|
||||
DPFSO1(temp_str);
|
||||
DPFS2("addr", afs_inet_ntoa(ifp->interface[i].addr));
|
||||
DPFS2("addr", afs_inet_ntoa_r(ifp->interface[i].addr, hoststr));
|
||||
DPFV2("port", "u", ifp->interface[i].port);
|
||||
DPFSC1;
|
||||
}
|
||||
|
@ -420,6 +420,7 @@ ubeacon_Interact(void *dummy)
|
||||
* Don't waste time using mult Rx calls if there are no connections out there
|
||||
*/
|
||||
if (i > 0) {
|
||||
char hoststr[16];
|
||||
multi_Rx(connections, i) {
|
||||
multi_VOTE_Beacon(syncsite, startTime, &ubik_dbase->version,
|
||||
&ttid);
|
||||
@ -442,19 +443,19 @@ ubeacon_Interact(void *dummy)
|
||||
ts->up = 1; /* server is up (not really necessary: recovery does this for real) */
|
||||
ts->beaconSinceDown = 1;
|
||||
ubik_dprint("yes vote from host %s\n",
|
||||
afs_inet_ntoa(ts->addr[0]));
|
||||
afs_inet_ntoa_r(ts->addr[0], hoststr));
|
||||
} else if (code == 0) {
|
||||
ts->lastVoteTime = temp;
|
||||
ts->lastVote = 0;
|
||||
ts->beaconSinceDown = 1;
|
||||
ubik_dprint("no vote from %s\n",
|
||||
afs_inet_ntoa(ts->addr[0]));
|
||||
afs_inet_ntoa_r(ts->addr[0], hoststr));
|
||||
} else if (code < 0) {
|
||||
ts->up = 0;
|
||||
ts->beaconSinceDown = 0;
|
||||
urecovery_LostServer();
|
||||
ubik_dprint("time out from %s\n",
|
||||
afs_inet_ntoa(ts->addr[0]));
|
||||
afs_inet_ntoa_r(ts->addr[0], hoststr));
|
||||
}
|
||||
}
|
||||
multi_End;
|
||||
@ -520,6 +521,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
|
||||
afs_uint32 aservers[]) {
|
||||
afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList, tmpAddr;
|
||||
afs_uint32 myAddr2[UBIK_MAX_INTERFACE_ADDR];
|
||||
char hoststr[16];
|
||||
int tcount, count, found, i, j, totalServers, start, end, usednetfiles =
|
||||
0;
|
||||
|
||||
@ -568,7 +570,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
|
||||
|
||||
if (!found) {
|
||||
ubik_print("ubik: primary address %s does not exist\n",
|
||||
afs_inet_ntoa(*ame));
|
||||
afs_inet_ntoa_r(*ame, hoststr));
|
||||
/* if we had the result of rx_getAllAddr already, avoid subverting
|
||||
* the "is gethostbyname(gethostname()) us" check. If we're
|
||||
* using NetInfo/NetRestrict, we assume they have enough clue
|
||||
@ -613,7 +615,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info,
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
ubik_print("Using %s as my primary address\n", afs_inet_ntoa(*ame));
|
||||
ubik_print("Using %s as my primary address\n", afs_inet_ntoa_r(*ame, hoststr));
|
||||
|
||||
if (!info) {
|
||||
/* get rid of servers which were purged because all
|
||||
@ -667,6 +669,7 @@ updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR])
|
||||
struct rx_connection *conns[MAXSERVERS];
|
||||
struct ubik_server *ts, *server[MAXSERVERS];
|
||||
char buffer[32];
|
||||
char hoststr[16];
|
||||
|
||||
for (count = 0, ts = ubik_servers; ts; count++, ts = ts->next) {
|
||||
conns[count] = ts->disk_rxcid;
|
||||
@ -690,9 +693,10 @@ updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR])
|
||||
if (!multi_error) {
|
||||
if (ts->addr[0] != htonl(outAddr.hostAddr[0])) {
|
||||
code = UBADHOST;
|
||||
strcpy(buffer, (char *)afs_inet_ntoa(ts->addr[0]));
|
||||
strcpy(buffer, afs_inet_ntoa_r(ts->addr[0], hoststr));
|
||||
ubik_print("ubik:Two primary addresses for same server \
|
||||
%s %s\n", buffer, afs_inet_ntoa(htonl(outAddr.hostAddr[0])));
|
||||
%s %s\n", buffer,
|
||||
afs_inet_ntoa_r(htonl(outAddr.hostAddr[0]), hoststr));
|
||||
} else {
|
||||
for (j = 1; j < UBIK_MAX_INTERFACE_ADDR; j++)
|
||||
ts->addr[j] = htonl(outAddr.hostAddr[j]);
|
||||
@ -700,12 +704,12 @@ updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR])
|
||||
} else if (multi_error == RXGEN_OPCODE) { /* pre 3.5 remote server */
|
||||
ubik_print
|
||||
("ubik server %s does not support UpdateInterfaceAddr RPC\n",
|
||||
afs_inet_ntoa(ts->addr[0]));
|
||||
afs_inet_ntoa_r(ts->addr[0], hoststr));
|
||||
} else if (multi_error == UBADHOST) {
|
||||
code = UBADHOST; /* remote CellServDB inconsistency */
|
||||
ubik_print("Inconsistent Cell Info on server: ");
|
||||
for (j = 0; j < UBIK_MAX_INTERFACE_ADDR && ts->addr[j]; j++)
|
||||
ubik_print("%s ", afs_inet_ntoa(ts->addr[j]));
|
||||
ubik_print("%s ", afs_inet_ntoa_r(ts->addr[j], hoststr));
|
||||
ubik_print("\n");
|
||||
} else {
|
||||
ts->up = 0; /* mark the remote server as down */
|
||||
|
@ -456,6 +456,7 @@ urecovery_Interact(void *dummy)
|
||||
char tbuffer[1024];
|
||||
struct ubik_stat ubikstat;
|
||||
struct in_addr inAddr;
|
||||
char hoststr[16];
|
||||
#ifndef OLD_URECOVERY
|
||||
char pbuffer[1028];
|
||||
int flen, fd = -1;
|
||||
@ -576,7 +577,7 @@ urecovery_Interact(void *dummy)
|
||||
rxcall = rx_NewCall(bestServer->disk_rxcid);
|
||||
|
||||
ubik_print("Ubik: Synchronize database with server %s\n",
|
||||
afs_inet_ntoa(bestServer->addr[0]));
|
||||
afs_inet_ntoa_r(bestServer->addr[0], hoststr));
|
||||
|
||||
code = StartDISK_GetFile(rxcall, file);
|
||||
if (code) {
|
||||
@ -788,12 +789,12 @@ urecovery_Interact(void *dummy)
|
||||
inAddr.s_addr = ts->addr[0];
|
||||
if (!ts->up) {
|
||||
ubik_dprint("recovery cannot send version to %s\n",
|
||||
afs_inet_ntoa(inAddr.s_addr));
|
||||
afs_inet_ntoa_r(inAddr.s_addr, hoststr));
|
||||
dbok = 0;
|
||||
continue;
|
||||
}
|
||||
ubik_dprint("recovery sending version to %s\n",
|
||||
afs_inet_ntoa(inAddr.s_addr));
|
||||
afs_inet_ntoa_r(inAddr.s_addr, hoststr));
|
||||
if (vcmp(ts->version, ubik_dbase->version) != 0) {
|
||||
ubik_dprint("recovery stating local database\n");
|
||||
|
||||
@ -868,6 +869,7 @@ DoProbe(struct ubik_server *server)
|
||||
int i, j;
|
||||
afs_uint32 addr;
|
||||
char buffer[32];
|
||||
char hoststr[16];
|
||||
extern afs_int32 ubikSecIndex;
|
||||
extern struct rx_securityClass *ubikSecClass;
|
||||
|
||||
@ -900,10 +902,10 @@ DoProbe(struct ubik_server *server)
|
||||
server->vote_rxcid = rx_NewConnection(addr, ubik_callPortal, VOTE_SERVICE_ID, ubikSecClass, ubikSecIndex); /* for vote reqs */
|
||||
|
||||
connSuccess = conns[multi_i];
|
||||
strcpy(buffer, (char *)afs_inet_ntoa(server->addr[0]));
|
||||
strcpy(buffer, afs_inet_ntoa_r(server->addr[0], hoststr));
|
||||
ubik_print
|
||||
("ubik:server %s is back up: will be contacted through %s\n",
|
||||
buffer, afs_inet_ntoa(addr));
|
||||
buffer, afs_inet_ntoa_r(addr, hoststr));
|
||||
|
||||
multi_Abort;
|
||||
}
|
||||
@ -916,7 +918,7 @@ DoProbe(struct ubik_server *server)
|
||||
|
||||
if (!connSuccess)
|
||||
ubik_dprint("ubik:server %s still down\n",
|
||||
afs_inet_ntoa(server->addr[0]));
|
||||
afs_inet_ntoa_r(server->addr[0], hoststr));
|
||||
|
||||
if (connSuccess)
|
||||
return 0; /* success */
|
||||
|
@ -478,6 +478,7 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
|
||||
struct rx_peer *tpeer;
|
||||
struct rx_connection *tconn;
|
||||
afs_uint32 otherHost = 0;
|
||||
char hoststr[16];
|
||||
#ifndef OLD_URECOVERY
|
||||
char pbuffer[1028];
|
||||
int flen, fd = -1;
|
||||
@ -518,7 +519,7 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
|
||||
urecovery_AbortAll(dbase);
|
||||
|
||||
ubik_print("Ubik: Synchronize database with server %s\n",
|
||||
afs_inet_ntoa(otherHost));
|
||||
afs_inet_ntoa_r(otherHost, hoststr));
|
||||
|
||||
offset = 0;
|
||||
#ifdef OLD_URECOVERY
|
||||
@ -627,7 +628,7 @@ SDISK_SendFile(register struct rx_call *rxcall, afs_int32 file,
|
||||
#endif
|
||||
ubik_print
|
||||
("Ubik: Synchronize database with server %s failed (error = %d)\n",
|
||||
afs_inet_ntoa(otherHost), code);
|
||||
afs_inet_ntoa_r(otherHost, hoststr), code);
|
||||
} else {
|
||||
ubik_print("Ubik: Synchronize database completed\n");
|
||||
}
|
||||
@ -655,6 +656,7 @@ SDISK_UpdateInterfaceAddr(register struct rx_call *rxcall,
|
||||
struct ubik_server *ts, *tmp;
|
||||
afs_uint32 remoteAddr; /* in net byte order */
|
||||
int i, j, found = 0, probableMatch = 0;
|
||||
char hoststr[16];
|
||||
|
||||
/* copy the output parameters */
|
||||
for (i = 0; i < UBIK_MAX_INTERFACE_ADDR; i++)
|
||||
@ -692,7 +694,7 @@ SDISK_UpdateInterfaceAddr(register struct rx_call *rxcall,
|
||||
if (!probableMatch || found) {
|
||||
ubik_print("Inconsistent Cell Info from server: ");
|
||||
for (i = 0; i < UBIK_MAX_INTERFACE_ADDR && inAddr->hostAddr[i]; i++)
|
||||
ubik_print("%s ", afs_inet_ntoa(htonl(inAddr->hostAddr[i])));
|
||||
ubik_print("%s ", afs_inet_ntoa_r(htonl(inAddr->hostAddr[i]), hoststr));
|
||||
ubik_print("\n");
|
||||
fflush(stdout);
|
||||
fflush(stderr);
|
||||
@ -706,7 +708,7 @@ SDISK_UpdateInterfaceAddr(register struct rx_call *rxcall,
|
||||
|
||||
ubik_print("ubik: A Remote Server has addresses: ");
|
||||
for (i = 0; i < UBIK_MAX_INTERFACE_ADDR && ts->addr[i]; i++)
|
||||
ubik_print("%s ", afs_inet_ntoa(ts->addr[i]));
|
||||
ubik_print("%s ", afs_inet_ntoa_r(ts->addr[i], hoststr));
|
||||
ubik_print("\n");
|
||||
|
||||
return 0;
|
||||
@ -717,12 +719,13 @@ printServerInfo(void)
|
||||
{
|
||||
struct ubik_server *ts;
|
||||
int i, j = 1;
|
||||
char hoststr[16];
|
||||
|
||||
ubik_print("Local CellServDB:");
|
||||
for (ts = ubik_servers; ts; ts = ts->next, j++) {
|
||||
ubik_print("Server %d: ", j);
|
||||
for (i = 0; (i < UBIK_MAX_INTERFACE_ADDR) && ts->addr[i]; i++)
|
||||
ubik_print("%s ", afs_inet_ntoa(ts->addr[i]));
|
||||
ubik_print("%s ", afs_inet_ntoa_r(ts->addr[i], hoststr));
|
||||
}
|
||||
ubik_print("\n");
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
|
||||
struct ubik_sdebug usdebug;
|
||||
int oldServer = 0; /* are we talking to a pre 3.5 server? */
|
||||
afs_int32 isClone = 0;
|
||||
char hoststr[16];
|
||||
|
||||
int32p = (as->parms[2].items ? 1 : 0);
|
||||
|
||||
@ -164,10 +165,10 @@ CommandProc(struct cmd_syndesc *as, void *arock)
|
||||
printf("Host's addresses are: ");
|
||||
for (j = 0; udebug.interfaceAddr[j] && (j < UBIK_MAX_INTERFACE_ADDR);
|
||||
j++)
|
||||
printf("%s ", afs_inet_ntoa(htonl(udebug.interfaceAddr[j])));
|
||||
printf("%s ", afs_inet_ntoa_r(htonl(udebug.interfaceAddr[j]), hoststr));
|
||||
printf("\n");
|
||||
}
|
||||
printf("Host's %s time is %s\n", afs_inet_ntoa(hostAddr), times);
|
||||
printf("Host's %s time is %s\n", afs_inet_ntoa_r(hostAddr, hoststr), times);
|
||||
|
||||
times = ctime(&now);
|
||||
times[24] = 0;
|
||||
@ -192,7 +193,7 @@ CommandProc(struct cmd_syndesc *as, void *arock)
|
||||
} else {
|
||||
diff = udebug.now - udebug.lastYesTime;
|
||||
printf("Last yes vote for %s was %d secs ago (%ssync site); \n",
|
||||
afs_inet_ntoa(htonl(udebug.lastYesHost)),
|
||||
afs_inet_ntoa_r(htonl(udebug.lastYesHost), hoststr),
|
||||
afs_cast_time_t(diff),
|
||||
((udebug.lastYesState) ? "" : "not "));
|
||||
|
||||
@ -233,12 +234,12 @@ CommandProc(struct cmd_syndesc *as, void *arock)
|
||||
printf("I am not sync site\n");
|
||||
diff = udebug.now - udebug.lowestTime;
|
||||
printf("Lowest host %s was set %d secs ago\n",
|
||||
afs_inet_ntoa(htonl(udebug.lowestHost)),
|
||||
afs_inet_ntoa_r(htonl(udebug.lowestHost), hoststr),
|
||||
afs_cast_time_t(diff));
|
||||
|
||||
diff = udebug.now - udebug.syncTime;
|
||||
printf("Sync host %s was set %d secs ago\n",
|
||||
afs_inet_ntoa(htonl(udebug.syncHost)),
|
||||
afs_inet_ntoa_r(htonl(udebug.syncHost), hoststr),
|
||||
afs_cast_time_t(diff));
|
||||
}
|
||||
|
||||
@ -289,11 +290,11 @@ CommandProc(struct cmd_syndesc *as, void *arock)
|
||||
break;
|
||||
}
|
||||
/* otherwise print the structure */
|
||||
printf("\nServer (%s", afs_inet_ntoa(htonl(usdebug.addr)));
|
||||
printf("\nServer (%s", afs_inet_ntoa_r(htonl(usdebug.addr), hoststr));
|
||||
for (j = 0;
|
||||
((usdebug.altAddr[j]) && (j < UBIK_MAX_INTERFACE_ADDR - 1));
|
||||
j++)
|
||||
printf(" %s", afs_inet_ntoa(htonl(usdebug.altAddr[j])));
|
||||
printf(" %s", afs_inet_ntoa_r(htonl(usdebug.altAddr[j]), hoststr));
|
||||
printf("): (db %d.%d)", usdebug.remoteVersion.epoch,
|
||||
usdebug.remoteVersion.counter);
|
||||
if (isClone)
|
||||
|
@ -198,6 +198,7 @@ SVOTE_Beacon(register struct rx_call * rxcall, afs_int32 astate,
|
||||
struct rx_peer *rxp;
|
||||
struct ubik_server *ts;
|
||||
int isClone = 0;
|
||||
char hoststr[16];
|
||||
|
||||
now = FT_ApproxTime(); /* close to current time */
|
||||
if (rxcall) { /* caller's host */
|
||||
@ -210,7 +211,7 @@ SVOTE_Beacon(register struct rx_call * rxcall, afs_int32 astate,
|
||||
otherHost = ubikGetPrimaryInterfaceAddr(otherHost);
|
||||
if (!otherHost) {
|
||||
ubik_dprint("Received beacon from unknown host %s\n",
|
||||
afs_inet_ntoa(rx_HostOf(rxp)));
|
||||
afs_inet_ntoa_r(rx_HostOf(rxp), hoststr));
|
||||
return 0; /* I don't know about you: vote no */
|
||||
}
|
||||
for (ts = ubik_servers; ts; ts = ts->next) {
|
||||
@ -227,7 +228,7 @@ SVOTE_Beacon(register struct rx_call * rxcall, afs_int32 astate,
|
||||
}
|
||||
|
||||
ubik_dprint("Received beacon type %d from host %s\n", astate,
|
||||
afs_inet_ntoa(otherHost));
|
||||
afs_inet_ntoa_r(otherHost, hoststr));
|
||||
|
||||
/* compute the lowest server we've heard from. We'll try to only vote for
|
||||
* this dude if we don't already have a synchronization site. Also, don't
|
||||
@ -277,7 +278,7 @@ SVOTE_Beacon(register struct rx_call * rxcall, afs_int32 astate,
|
||||
if (syncHost) {
|
||||
ubik_dprint
|
||||
("Ubik: Lost contact with sync-site %s (NOT in quorum)\n",
|
||||
afs_inet_ntoa(syncHost));
|
||||
afs_inet_ntoa_r(syncHost, hoststr));
|
||||
}
|
||||
syncHost = 0;
|
||||
}
|
||||
@ -327,7 +328,7 @@ SVOTE_Beacon(register struct rx_call * rxcall, afs_int32 astate,
|
||||
|| (lastYesState != astate)) {
|
||||
/* A new vote or a change in the vote or changed quorum */
|
||||
ubik_dprint("Ubik: vote 'yes' for %s %s\n",
|
||||
afs_inet_ntoa(otherHost),
|
||||
afs_inet_ntoa_r(otherHost, hoststr),
|
||||
(astate ? "(in quorum)" : "(NOT in quorum)"));
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,6 @@ extern int afs_is_foreign_ticket_name(char *tname, char *tinst, char * tcell, ch
|
||||
extern struct hostent *hostutil_GetHostByName(register char *ahost);
|
||||
extern char *hostutil_GetNameByINet(afs_uint32 addr);
|
||||
extern afs_uint32 extractAddr(char *line, int maxSize);
|
||||
extern char *afs_inet_ntoa(afs_uint32 addr);
|
||||
extern char *afs_inet_ntoa_r(afs_uint32 addr, char *buf);
|
||||
extern char *gettmpdir(void);
|
||||
|
||||
|
@ -233,20 +233,7 @@ extractAddr(char *line, int maxSize)
|
||||
return val;
|
||||
}
|
||||
|
||||
/*
|
||||
** converts a 4byte IP address into a static string (e.g. w.x.y.z)
|
||||
** On Solaris, if we pass a 4 byte integer directly into inet_ntoa(), it
|
||||
** causes a memory fault.
|
||||
*/
|
||||
char *
|
||||
afs_inet_ntoa(afs_uint32 addr)
|
||||
{
|
||||
struct in_addr temp;
|
||||
temp.s_addr = addr;
|
||||
return (char *)inet_ntoa(temp);
|
||||
}
|
||||
|
||||
/* same as above, but to a non-static buffer, must be freed by called */
|
||||
/* same as inet_ntoa, but to a non-static buffer, must be freed by called */
|
||||
char *
|
||||
afs_inet_ntoa_r(afs_uint32 addr, char *buf)
|
||||
{
|
||||
|
@ -97,6 +97,7 @@ PrintInterfaces(struct rx_connection *aconn)
|
||||
char uuidstr[128];
|
||||
#endif
|
||||
int i, code;
|
||||
char hoststr[16];
|
||||
|
||||
caps.Capabilities_val = NULL;
|
||||
caps.Capabilities_len = 0;
|
||||
@ -121,9 +122,9 @@ PrintInterfaces(struct rx_connection *aconn)
|
||||
|
||||
printf("Host interfaces:\n");
|
||||
for (i = 0; i < addr.numberOfInterfaces; i++) {
|
||||
printf("%s", afs_inet_ntoa(htonl(addr.addr_in[i])));
|
||||
printf("%s", afs_inet_ntoa_r(htonl(addr.addr_in[i]), hoststr));
|
||||
if (addr.subnetmask[i])
|
||||
printf(", netmask %s", afs_inet_ntoa(htonl(addr.subnetmask[i])));
|
||||
printf(", netmask %s", afs_inet_ntoa_r(htonl(addr.subnetmask[i]), hoststr));
|
||||
if (addr.mtu[i])
|
||||
printf(", MTU %d", addr.mtu[i]);
|
||||
printf("\n");
|
||||
@ -492,12 +493,13 @@ PrintCellServDBEntry(struct rx_connection *aconn, afs_int32 cellnum)
|
||||
printf(">%-23s#%s\n", cellname, cellname);
|
||||
|
||||
if (sl.serverList_val) {
|
||||
char hoststr[16];
|
||||
for ( n=0; n<sl.serverList_len; n++) {
|
||||
struct hostent *host;
|
||||
afs_uint32 addr = ntohl(sl.serverList_val[n]);
|
||||
|
||||
host = gethostbyaddr((const char *)&addr, sizeof(afs_uint32), AF_INET);
|
||||
printf("%-28s#%s\n", afs_inet_ntoa(addr),
|
||||
printf("%-28s#%s\n", afs_inet_ntoa_r(addr, hoststr),
|
||||
host ? host->h_name : "");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user