4 Replies Latest reply on Apr 20, 2016 5:43 PM by axel.lin_1746341

    DNS lookup fails on SDK 3.3.1 for some URL's

    ron.jaegers_1765426

      In the method "wiced_hostname_lookup" from wiced_tcpip_common.c, there is a check to see if a DNS lookup is necessary. For this check the method "str_to_ip" from wiced_lib.c is used. The str_to_ip method, however, considers URL's with three dots in them as IP addresses. Hence no DNS lookup is done.

       

      I have attached a very minimal example that reproduces this issue in dns_lookup-fails.c.

       

      Locally I have fixed the issue by patching str_to_ip to include a check if the IP address is nonzero.

       

      I.e. change "if ( num == 4 )" to "if ( num == 4 && (address->ip.v4 != 0) )"

        • 1. Re: DNS lookup fails on SDK 3.3.1 for some URL's
          chucklink

          I have fixed it in str_to_ip as:

           

          int str_to_ip( const char* arg, wiced_ip_address_t* address )

          {

              uint32_t* addr = &address->ip.v4;

              uint8_t num = 0;

              int error = 0;

           

              arg--;

           

              *addr = 0;

           

              do

              {

                  uint32_t tmp_val = 0;

                  *addr = *addr << 8;

           

          //      string_to_unsigned( ++arg, 3, &tmp_val, 0 );           // CML Problem is here

                  if (string_to_unsigned( ++arg, 3, &tmp_val, 0 ) == 0)  // CML change

                       error = -1;                                       // CML if bad conversion, set error return state

           

                  *addr += (uint32_t) tmp_val;

                  while ( ( *arg != '\x00' ) && ( *arg != '.' ) )

                  {

                      arg++;

                  }

                  num++;

              } while ( ( num < 4 ) && ( *arg != '\x00' ) );

              if ( num == 4 )

              {

           

                  address->version = WICED_IPV4;

                  return error;                                         //CML was "return 0"

              }

              return error;                                             // CML was "return -1"

          }

           

          I am not sure how to get this in the production code but easy test is to use the "snip.email..." test application and set "account.smpt_server = "smtp.mail.yahoo.com".  Most of the constructs were in place, it is just that if the function try to convert random letters it fails, but the failure is not checked in the above routine.

          • 2. Re: DNS lookup fails on SDK 3.3.1 for some URL's
            eman2611

            chucklink

            This might be exactly what I ran into. When the originally problem happens, I saw IP returns 0.0.0.0 without any error code. Is this what you see?

            • 3. Re: DNS lookup fails on SDK 3.3.1 for some URL's
              chucklink

              I believe that is what I saw.  I hope this is fixed in the latest code. 3.5.2

              • 4. Re: DNS lookup fails on SDK 3.3.1 for some URL's
                axel.lin_1746341

                The sdk-3.5.2 includes the fix already (with slightly different code).

                I just tested on sdk-3.5.2 and the DNS lookup for both smtp.mail.yahoo.com

                and www.dailymail.co.uk looks good.