[Pdns-users] Questions redux

Norbert Sendetzky norbert at linuxnetworks.de
Sun Sep 7 13:23:14 UTC 2003


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 07 September 2003 14:45, Chris Andrews wrote:
> Here's an example, long since fixed in pdns (from dnspacket.cc):
>
>  rr.content+=" ";rr.content+=itoa(ntohl(*(unsigned int
> *)(datapos+offset)));
>
> This code was replaced with:
>
>  rr.content+=" ";rr.content+=itoa(getLong( datapos+offset ));
>
> where getLong is:
>
>  u_int32_t getLong(const unsigned char* p)
>  {
>    return (p[0]<<24) + (p[1]<<16) + (p[2]<<8) + p[3];
>  }

Ok, I got the point. One further question:
What about big endian vs. little endian in this example? getLong() 
returns network byte order (at least I think so), but the replaced 
code misses the ntohl() function. Isn't the output in your example 
different?


Norbert

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj9bMUIACgkQxMLs5v5/7eAN1ACcCTkbknqex9ASPp95OlzZC+78
QhoAn0xQ95nVn/0EuIB5AkHCWUHqK024
=NbhL
-----END PGP SIGNATURE-----



More information about the Pdns-users mailing list