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));
struct packet packet;
socklen_t fromLen;
afs_int32 code;
+ char hoststr[16];
printf("Starting to listen for UDP packets\n");
while (1) {
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");
}
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");
}
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);
char temp_str[40];
struct Interface * ifp;
int len, i;
+ char hoststr[16];
if (!he_cursor.hdr.interfaces)
return;
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;
}
* 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);
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;
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;
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
}
}
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
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;
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]);
} 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 */
char tbuffer[1024];
struct ubik_stat ubikstat;
struct in_addr inAddr;
+ char hoststr[16];
#ifndef OLD_URECOVERY
char pbuffer[1028];
int flen, fd = -1;
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) {
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");
int i, j;
afs_uint32 addr;
char buffer[32];
+ char hoststr[16];
extern afs_int32 ubikSecIndex;
extern struct rx_securityClass *ubikSecClass;
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;
}
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 */
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;
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
#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");
}
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++)
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);
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;
{
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");
}
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);
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;
} 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 "));
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));
}
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)
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 */
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) {
}
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
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;
}
|| (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)"));
}
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);
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)
{
char uuidstr[128];
#endif
int i, code;
+ char hoststr[16];
caps.Capabilities_val = NULL;
caps.Capabilities_len = 0;
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");
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 : "");
}
}