This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

RTOS: How to change external DNS address at run time

Tool/software: TI-RTOS

I am able to change the Static IP address at run time by these functions 

bzero(&NA, sizeof(NA));
NA.IPAddr = inet_addr("172.19.23.142");
NA.IPMask = inet_addr("255.255.254.0");
NA.NetType = 0;

/* get the current static IP entry */
CfgGetEntry(0, CFGTAG_IPNET, 1, 1, &hCfgIpAddr);

/* remove the current static IP entry */
CfgRemoveEntry(0, hCfgIpAddr);

/* add a new static IP entry */
CfgAddEntry(0, CFGTAG_IPNET, 1, 0,
sizeof(CI_IPNET), (UINT8 *)&NA, 0);

I need to change two more parameters, which I am unable to do so. Those are Ip.gatewayIpAddr and externDnsServIp. 

I am setting these parameters in the .cnf file as 

Ip.gatewayIpAddr = "172.19.23.129";
var Dns = xdc.useModule('ti.ndk.config.Dns');

Need this fix as soon as possible. 

Also how to change from Static to DHCP setting at run time?

Thanks


Dns.externDnsServIp = "172.19.23.129";

  • Hi Fehan,

    Which platform are you on, and which versions of TI-RTOS and NDK are you using?

    Thanks,
    Vincent
  • Hi

    I am using TIVA launchpad 129xl and latest TIRTOS

    I am more interested in changing settings from DHCP to Static IP and vice versa

    Kindly let me know if it is possible to do so in nDK

  • Hi Fehan,

    You can add the default gateway using the code shown in the NetworkTest() function in section 3.2.4.1.1 of the NDK User's Guide in the directory tirtos_tivac_2_16_01_14\products\ndk_2_25_00_09\docs

    To set a DNS server IP address, you can refer to section 3.2.4.1.3 of the same document. It discusses what to do both without DHCP or with DHCP enabled.

    Section 3.2.4.1.2 covers how to switch to DHCP mode at run time. It has a code example that does it.

    Hope this helps,
    Vincent
  • Thanks for the reply. Yes I am able to set the DNS server, gateway. Going to test the DHCP change over now.

    I found that when I am running defualt DHCP settings, and DHCP server is not active on the ethernet cable, RTOS does not get the IP address and HTTP Client task is not created using the netIPAddrHook.

    To check if DHCP has successfuly got the IP address, I am setting a flag in the netIPAddrHook () and testing in in another Task. Can there any other good method which I can use to know if the IP address has been acquired from the DHCP Line?

    Also Where the Run time IP address, IP Mask, Gateway IP are stored so that I can query those variable to display current network configuration?
  • Hi Fehan,

    There is also another callback that is called whenever the DHCP client changes status: dhcpc.cisargs.pCbSrv. The NDK documentation has more details on it. But I think your approach sounds ok.

    Here are a couple of threads that talk about how to obtain the IP address, etc.:
    e2e.ti.com/.../366420
    e2e.ti.com/.../522740

    Best regards,
    Vincent