lwip-users
[Top][All Lists]
Advanced

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

[lwip-users] Problem With dns.c Using 32-Bit Compilers


From: John Keil
Subject: [lwip-users] Problem With dns.c Using 32-Bit Compilers
Date: Thu, 17 Jan 2008 17:49:39 -0500

Hello,

We are using lwIP with TI C6711 and C6455 DSPs, running TI's DSP/BIOS
operating system.  We've discovered a problem with the way dns_recv is
working with our compiler, and I believe the problem may apply to other
32-bit platforms...

When a DNS response is received, the dns.c code attempts to look through all
the "answers" provided by the server to find a valid response.  If the
response is found in the first "answer" all is fine.  But the problem occurs
when the code has to go on to examine the 2nd (or 3rd or 4th...) answer.  It
moves ahead one "answer" using the following code:

            pHostname = pHostname + sizeof(struct dns_answer) +
htons(ans->len);

The struct dns_answer contains 3 16-bit values and 1 32-bit value, and is
therefore 10-bytes long.  Unfortunately, since it contains at least one
32-bit field, the compiler forces alignment on a 32-bit boundary, so sizeof
returns 12-bytes.  My quick and dirty fix was to change that line of code
to...

            pHostname = pHostname + sizeof(ans->type) + sizeof(ans->class) +
                                    sizeof(ans->ttl) + sizeof(ans->len) +
htons(ans->len);

which is not the prettiest solution, but I believe will work on any
architecture.

We're using v1.16 of dns.c from 2/Dec/07, but it looks like it's still a
problem in the version just tagged for release 1.3.

John Keil
Critical Link, LLC





reply via email to

[Prev in Thread] Current Thread [Next in Thread]