[331] in bug-owl
Re: port number displayed is byteswapped on little-endian architectures
daemon@ATHENA.MIT.EDU (Arun A Tharuvai)
Sat Apr 10 11:35:29 2004
Date: Sat, 10 Apr 2004 11:34:59 -0400 (EDT)
From: Arun A Tharuvai <aatharuv@MIT.EDU>
To: "James M. Kretchmar" <kretch@MIT.EDU>
cc: bug-owl@MIT.EDU, aatharuv@MIT.EDU
In-Reply-To: <200404101456.KAA18644@mission-control.mit.edu>
Message-ID: <Pine.GSO.4.55L.0404101111350.7763@multics.mit.edu>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Hmmm, you're right. I probably didn't catch that since ntohs() and htons()
are are identical on both le and be architectures.
Arun
On Sat, 10 Apr 2004, James M. Kretchmar wrote:
> > On x86, and presumably other little-endian architectures, owl displays an
> > ascii representation of the port, before the port is converted to a
> > little-endian number. This is because Znotice_t.z_port is always in
> > network byte order. Here's a patch, that causes the port to be displayed
> > correctly on both big-endian and little-endian architectures.
>
> - sprintf(buff, " Port : %i\n", n->z_port);
> + sprintf(buff, " Port : %i\n", htons(n->z_port));
>
> Thanks for catching this. Though, if Znotice_t.z_port is always in
> network byte order, don't we want ntohs() ?
>
> kretch
>