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.

NDK getting network information

using NDK 2.23.2.03 being configured by the XCONF. how do i find out my subnet mask, my gateway ip, my DNS server?

before we configured it using the xconf we would call CfgGetImmediate but now that the Cfg handle is hidden from us i don't know how to find this information. i tried using the HANDLE Cfg given to us by the service routine but it just gives me garbage for network info.  

so what do i have to do to find this information out?

  • There is a gap in our code generated by xgconf. We should be setting the default cfg for the stack so that users can subsequently use 0 (or NULL) for calls to the Cfg API functions. I modified the Global.xdt file to add this, re-built my project, and then tried the following sample. Note CfgGetImmediate() call uses 0 for the cfg handle:

       CI_IPNET ipCfg;
    
       if (CfgGetImmediate(0, CFGTAG_IPNET, 1, 1, sizeof(ipCfg), &ipCfg) == sizeof(ipCfg)) {
    
           char buf[16];
    
           inet_ntop(AF_INET, &ipCfg.IPAddr, buf, sizeof(buf));
    
           System_printf("Address: %s\n", buf);
    
           inet_ntop(AF_INET, &ipCfg.IPMask, buf, sizeof(buf));
    
           System_printf("Mask: %s\n", buf);
    
       }

    I'll file a bug to fix this in an upcoming release of the NDK. Meantime, you can patch your current release if you want to try this. Edit the packages/ti/ndk/config/Global.xdt file and add the two lines marked by "+" below which should be around line 587:

    +    /* Set the config default so apps can work with it w/o explicit handle */
    
    +   CfgSetDefault(hCfg);
    
    %
    
    % /* generate network start code + code to close the stack. */
    
    %
    
       /*
    
        *  Boot the system using this configuration

    Regards,

    Moses

  • does this patch require me to rebuild the NDK?
  • Hi,
    You only need to rebuild your project and not NDK. That xdt file is used during the configuro phase of the build.

    Regards,
    Moses
  • do i need to change the +'s to %? i don't see any other +'s in this document
  • The +'s are used to show lines that should be added to the file. If you're copying and pasting then get rid of the + signs at the beginning of the line.

    Moses