[Pdns-users] PDNS && Solaris && Recursor setting not working

Remco Post remco at pipsworld.nl
Wed Feb 25 19:02:47 UTC 2004


On Feb 25, 2004, at 09:45, Norbert Sendetzky wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Tuesday 24 February 2004 21:32, Remco Post wrote:
>> + #ifdef WORDS_BIGENDIAN
>> +       // d.id is network-endian at this point and must be made
>> into a 'native'-endian u_int16_t
>> +       // on little-endian systems, network-endian is native so we
>> don't need to do anything
>
> That's not correct. Big-endian architectures use network byte order -
> little-endian systems do not.
>
>> +       d.id = ( 256 * (u_int16_t)buffer[1] ) +(u_int16_t)buffer[0];
>> + #endif
>
> It seems that the id sent by the recursor is in little endian format,
> so line setting the id must be changed in pdns_recursor too.
>

it's not the recursor that is bugging that is causing the problem here, 
it is the DNSPacket::spoofID function that is wrong:

inline void DNSPacket::spoofID(u_int16_t id)
{
   stringbuffer[1]=(id>>8)&0xff;
   stringbuffer[0]=id&0xff;
   d.id=id;
}

So we could probably do two things:

1- fix every peace of code that reads the d.id to do a htons() or
2- fix my comment and leave it at that

Either way is fine by me, probably, the first thing is more correct, 
but may also cause more problems that it solves....

> Simply use the ntohs() and htons() macros. They do conversion
> automatically dependent on your machine:
>
> pdns_recursor: ((u_int16_t*) buffer)[0] = htons( d.id );
> pdns_server: d.id = ntohs( ((u_int16_t*) buffer)[0] );
>
>
> Norbert
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.0.6 (GNU/Linux)
> Comment: For info see http://www.gnupg.org
>
> iEYEARECAAYFAkA8YMQACgkQxMLs5v5/7eAv/QCfdBXrGdYCdcAB4bVYBP7jl/PA
> ZjwAoITb1jXyrV+SSagPp2mMriwB9hII
> =yFON
> -----END PGP SIGNATURE-----
>
-- 
Met vriendelijke groeten,

Remco Post

SARA - Reken- en Netwerkdiensten                      http://www.sara.nl
High Performance Computing  Tel. +31 20 592 8008    Fax. +31 20 668 3167

"I really didn't foresee the Internet. But then, neither did the
computer industry. Not that that tells us very much of course - the
computer industry didn't even foresee that the century was going
to end."                                       -- Douglas Adams



More information about the Pdns-users mailing list