|
From: <sv...@va...> - 2005-11-17 12:03:05
|
Author: tom
Date: 2005-11-17 12:02:58 +0000 (Thu, 17 Nov 2005)
New Revision: 5163
Log:
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.
Modified:
trunk/coregrind/m_syswrap/syswrap-generic.c
Modified: trunk/coregrind/m_syswrap/syswrap-generic.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/coregrind/m_syswrap/syswrap-generic.c 2005-11-17 12:01:56 UTC (=
rev 5162)
+++ trunk/coregrind/m_syswrap/syswrap-generic.c 2005-11-17 12:02:58 UTC (=
rev 5163)
@@ -536,20 +536,14 @@
if (sa =3D=3D NULL || len =3D=3D 0) {
VG_(sprintf)(name, "<unknown>");
} else {
- UInt addr =3D 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 =3D (((addr >> 24) & 0xFF) << 0) | (((addr >> 16) & 0xFF) << =
8)
- | (((addr >> 8) & 0xFF) << 16) | (((addr >> 0) & 0xFF) << 2=
4);
-# endif
+ UInt addr =3D VG_(ntohl)(sa->sin_addr.s_addr);
if (addr =3D=3D 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));
}
}
=20
|