Strange behavior in RTCS ipcfg.c when using LWDNS

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Strange behavior in RTCS ipcfg.c when using LWDNS

999 Views
TravisHidlay
Contributor III

Hello,

 

I've been working on using DHCP to automatically configure a K60 using a TWR-K60 + TWR-SER development setup. 

 

The OS is MQX 3.7.  I tried using the code below:

 

error = ipcfg_bind_dhcp_wait(IPCFG_default_enet_device, 0, NULL);

 

This was followed by checking the error for the result, and printing out the resulting ip information

using the same code that's in the Security_Network.c file (lines 98-101).

 

The scenario was this:

 

I plugged in the TWR-SER board to an isolated switch connected only to a DHCP server.  The configuration worked, and I was able to see the correct IP Address, Netmask, Gateway, and DNS address.  The lease time on the DHCP server was set to 5 minutes.  After about 1 minute, I plugged the TWR-SER board into another network with a different DHCP server.  The lease was renewed after a few minutes, and I was able to see the correct IP, Gateway, and NetMask, but the DNS server address was the same as before.

 

After digging through some of the RTCS code, I found the relevant section called during a renew of the DHCP lease, starting at line 949 in ipcfg.c, and it looks like (with RTCSCFG_ENABLE_LWDNS set) the only update to the DNS address happens by:

 

ipcfg_data[device].dns = ntohl (optptr);

 

The global LWDNS_server_ipaddr is never updated when the lease is renewed.  Is there any reason for this?  I added the following line:

 

ipcfg_add_dns_ip (device, ipcfg_data[device].dns);

 

This seems to do the trick, the DNS address is now included in the new DHCP lease.

 

0 Kudos
3 Replies

554 Views
TravisHidlay
Contributor III

I probably should have posted this in the MQX RTCS forum...  Can a moderator move the post?

0 Kudos

554 Views
DavidS
NXP Employee
NXP Employee

Hi Travis,

Have you resolved this issue?

Regards,

David

0 Kudos

554 Views
Jarpba
Contributor II

This might be helpful for someone. Before binding dhcp, use the following to make sure the network link is ready:

 

//wait for the network to be ready

while (ipcfg_task_poll() == FALSE);

//next bind dhcp 

 

I had the same problem that after wireless had been disconnected I was unable to get correct DNS address. This thread was helpful but my problem finally was solved by code mentioned above. 

0 Kudos