[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: openntpd and ntpq



* Brett Lymn <blymn@baesystems.com.au> [2004-09-03 12:22]:
> On Thu, Sep 02, 2004 at 10:35:54AM +0200, Siegbert Marschall wrote:
> > read and learn.
> I had read the code it was simply that the ntoh was not where I 
> expected it.  Yes, I should have grepped, that was my error.  The
> idea of storing things in structures used internally in network
> order is slightly unusual, it works if you are really really careful
> about doing the conversion every time.  If it were me, I would do the
> conversion to/from wire format when handling the packet - which is
> the only place it is required and keep the integers in host format so
> if someone naively used the integer elsewhere they would get the correct
> value.

if you had checked further you'd notice that we copy quite some stuff 
from the query into the answer we form, without ever doing anything 
with it. There is no point in transforming something to host byte order 
that is never used on the host.

maybe the ntohl is not where YOU would expect it, but it's actually in 
a very logical place, in the function that converts from the ntp 
timestamp format to a double used internally.