AnsweredAssumed Answered

DNS under MQX 4.1

Question asked by Oscar Garcia Abad on Jul 1, 2014
Latest reply on Jul 8, 2014 by Oscar Garcia Abad

Hello all,

 

I'm running MQX 4.1 on a TWR-K60F120M. I want to translate www.google.com to an IP address. To do that I'm enabling DNS. I want to make the DNS request to my router (wich is located at 172.16.0.1 --> 0xA1160001).

 

I define DNS parameters under source/if/dnshost.c the following way:

 

char DNS_Local_network_name[] = ".";

uint32_t DNS_CACHE_NAME_LIMIT = 0;

char DNS_Local_server_name[] = "";

 

DNS_SLIST_STRUCT DNS_Local_server_list[] =

   {{DNS_Local_server_name, 0, 0xAC160001, 0, 0, 0, 0,

     0, DNS_A, DNS_IN }};

 

DNS_SLIST_STRUCT      *DNS_First_Local_server = &DNS_Local_server_list[0];

 

Then I call DNS_init() in my code.

 

After that I call gethostbyname() as you can see next:

 

HOSTENT_STRUCT_PTR CPTServer;

 

printf("Initializing DNS service...");

if(DNS_init() != RTCS_OK) {

  printf("KO\n");

  _task_block();

}

printf("OK\n");

printf("Resolving google.com");

CPTServer = gethostbyname("www.google.com.");

if(CPTServer == NULL) {

       printf("KO\n");

       _task_block();

}

printf("OK\n");

 

The code is running with no problems. But, how can I extract the IP from CPTServer?

 

Thanks in advance.

 

Óscar.

Outcomes