ACCOUNT: correctly account for network-order addresses on BE arches

This commit is contained in:
Jan Engelhardt
2009-10-23 17:37:54 +02:00
parent 578af6f726
commit 8bd6ef78f9
3 changed files with 14 additions and 11 deletions

View File

@@ -39,8 +39,9 @@ char *addr_to_dotted(unsigned int addr)
static char buf[17];
const unsigned char *bytep;
addr = ntohl(addr);
bytep = (const unsigned char *)&addr;
snprintf(buf, 16, "%u.%u.%u.%u", bytep[0], bytep[1], bytep[2], bytep[3]);
snprintf(buf, 16, "%u.%u.%u.%u", bytep[3], bytep[2], bytep[1], bytep[0]);
buf[16] = 0;
return buf;
}