[Pdns-dev] Re: [patch] dnspacket endian issue
norbert at linuxnetworks.de
Mon Sep 8 16:41:52 CEST 2003
-----BEGIN PGP SIGNED MESSAGE-----
On Monday 08 September 2003 13:56, bert hubert wrote:
> > Here's a small patch to fix an endian problem in the getAnswers()
> > function.
> Can you explain to me how you think that this will not break pdns
> on little endian platforms?
ntohl() is a standard macro provided on all systems which is defined
differently on big endian and little endian architectures. On big
endian architectures it does nothing while it resorts the bytes on
little endian architectures.
If I remember the Intel byte order correctly, ntohl() changes
a.b.c.d (network byte order = big endian) to b.a.d.c (host byte order
on little endian architectures - correct me if I am wrong)
itoa() is implemented as outputing an int as string, but on i386 it
expects an int in host byte order. Contrary to this, the parameter is
still in network byte order (big endian output of getLong()), so the
output will be different on big endian and little endian
In short: ntohl() changes nothing in SPARC, but corrects the output on
I hope I've clarified what I've done.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
-----END PGP SIGNATURE-----
More information about the Pdns-dev