[En-Nut-Discussion] NutDnsGetHostByName doesn't work

Mikael Ejberg Pedersen mikael at ejberg.dk
Sun Nov 24 23:31:58 CET 2002


On Sun, 24 Nov 2002 22:37:45 +0100, you wrote:

>If someone knows something about DNS, and can see anything unusual in
>the following debug dump, then please help me.

Well, I tried debugging a bit further, and found the problem myself.
The DNS returns more than one answer, so with a small extension of the
NutDnsGetHostByName function to allow it to decode multiple answers,
it now works :-)

I haven't checked if this has been corrected in the newer releases (I
use Ethernut version 2.5.2), but anyway, here is what I did...


I took this part of NutDnsGetHostByName:

            if(doh->doh_answers >= 1) {
                dor = CreateDnsResource(dor);
                len += DecodeDnsResource(dor, pkt + len);
#ifdef NUTDEBUG
                DumpDnsResource(dor);
#endif
                if(dor->dor_len == 4) {


And extended it into this:

            if(doh->doh_answers >= 1) {
                for(n = 1; n <= doh->doh_answers; n++) {
                    dor = CreateDnsResource(dor);
                    len += DecodeDnsResource(dor, pkt + len);
#ifdef NUTDEBUG
                    DumpDnsResource(dor);
#endif
                    if(dor->dor_type == 1)
                        break;
                }
                if(dor->dor_len == 4) {


Best regards,
Mikael

-- 
Mikael Ejberg Pedersen
http://www.ejberg.dk (Elektroniske dimser til modelflyvning)



More information about the En-Nut-Discussion mailing list