mirror of
https://github.com/Zenithsiz/ftmemsim-valgrind.git
synced 2026-02-04 02:18:37 +00:00
Use VG_(ntohl) and VG_(ntohs) to decode IP addresses and ports. Note
that this also required reversing the order of the arguments to the print call as the previous ordering assumed that the address was still byte swapped. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5163
This commit is contained in:
parent
2605f9b94e
commit
91b44ff30e
@ -536,20 +536,14 @@ Char *inet2name(struct vki_sockaddr_in *sa, UInt len, Char *name)
|
||||
if (sa == NULL || len == 0) {
|
||||
VG_(sprintf)(name, "<unknown>");
|
||||
} else {
|
||||
UInt addr = sa->sin_addr.s_addr;
|
||||
# if defined(VG_BIGENDIAN)
|
||||
/* This is a hack. I don't know enough to navigate my way through the
|
||||
ntohl/ntonl maze. JRS 17 Nov 05. */
|
||||
addr = (((addr >> 24) & 0xFF) << 0) | (((addr >> 16) & 0xFF) << 8)
|
||||
| (((addr >> 8) & 0xFF) << 16) | (((addr >> 0) & 0xFF) << 24);
|
||||
# endif
|
||||
UInt addr = VG_(ntohl)(sa->sin_addr.s_addr);
|
||||
if (addr == 0) {
|
||||
VG_(sprintf)(name, "<unbound>");
|
||||
} else {
|
||||
VG_(sprintf)(name, "%u.%u.%u.%u:%u",
|
||||
addr & 0xFF, (addr>>8) & 0xFF,
|
||||
(addr>>16) & 0xFF, (addr>>24) & 0xFF,
|
||||
vki_ntohs(sa->sin_port));
|
||||
(addr>>24) & 0xFF, (addr>>16) & 0xFF,
|
||||
(addr>>8) & 0xFF, addr & 0xFF,
|
||||
VG_(ntohs)(sa->sin_port));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user