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/MSP432E401Y: NDK Get Current IP Configuration

Part Number: MSP432E401Y

Tool/software: TI-RTOS

Hi,

I need some help getting the running IP configuration out of NDK.

Here's my failed stab at it.

void ndk_cfg_test(void)
{
       int i, count;
       void *hCfg = NULL;
       CI_IPNET *ip_cfg;
       CI_ROUTE *ip_route;

 

       hCfg = CfgGetDefault();

       if(hCfg != NULL)
       {
              count = CfgGetEntryCnt(hCfg, CFGTAG_IPNET, 1);
              CfgGetEntry(hCfg, CFGTAG_IPNET, 1, 1, &ip_cfg);
       }

       asm(" nop");
}

  • I will ask my colleague for some more specific guidance. Here is the related Network Developer's Kit (NDK) Reference Guide section: dev.ti.com/.../NDK_API_Reference.html

    Regards,
    Chris
  • Thanks Chris. Here's an update to the code I'm working on. The router section looks like it's working but I just guessed at how to do it.

    void ndk_cfg_test(void)
    {
    	int count;
    	int size;
    	void *hCfg = NULL;
    	int *handle;
    	CI_IPNET ip_cfg;
    	CI_ROUTE ip_route;
    	uint32 tmp_u32;
    
    
    
    	hCfg = CfgGetDefault();
    
    	if(hCfg != NULL)
    	{
    		count = CfgGetEntryCnt(hCfg, CFGTAG_IPNET, 1);
    		count *= 1;
    
    //extern int  CfgGetEntry( void *hCfg, uint32_t Tag, uint32_t Item, uint32_t Index, void **phCfgEntry );
    
    		CfgGetEntry(hCfg, CFGTAG_IPNET, 1, 1, &handle);
    		CfgEntryGetData(handle, &size, (uint8_t*)&ip_cfg);
    
    		CfgGetEntry(hCfg, CFGTAG_ROUTE, 0, 1, &handle);
    		CfgEntryGetData(handle, &size, (uint8_t*)&ip_route);
    
    
    		tmp_u32 = htonl(ip_cfg.IPAddr);
    		printf("IPv4 Address. . . .%d. %d. %d. %d\r\n",
    			(uint8)(tmp_u32 >> 24),
    			(uint8)(tmp_u32 >> 16),
    			(uint8)(tmp_u32 >> 8),
    			(uint8)(tmp_u32 >> 0));
    
    		tmp_u32 = htonl(ip_cfg.IPMask);
    		printf("Subnet Mask . . . .%d. %d. %d. %d\r\n",
    			(uint8)(tmp_u32 >> 24),
    			(uint8)(tmp_u32 >> 16),
    			(uint8)(tmp_u32 >> 8),
    			(uint8)(tmp_u32 >> 0));
    
    		tmp_u32 = htonl(ip_route.IPGateAddr);
    		printf("Default Gateway . .%d. %d. %d. %d\r\n",
    			(uint8)(tmp_u32 >> 24),
    			(uint8)(tmp_u32 >> 16),
    			(uint8)(tmp_u32 >> 8),
    			(uint8)(tmp_u32 >> 0));
    	}
    
    	asm(" nop");
    }

  • Hello Mike_d,

    There are a couple of ways to go about doing this. The easiest is to use ROV to see the IP address. You don't have to do anything to get this to work, but it also looks like you want to get the IP address in your code. 

    If you are trying to get the IP in your code some methods are covered in this forum post. Let me know if you need any help implementing them. 

    Regards,

    Dalton

  • Hi Dalton, the e2e link didn't work for me. FYI, to see NDK in ROV this has to be added to CCS post-build: ${CCS_INSTALL_ROOT}/tools/node/node ${COM_TI_SIMPLELINK_MSP432E4_SDK_INSTALL_DIR}/source/ti/ndk/rov_ndk.js ${BuildArtifactFileBaseName}.rov.js
  • Hello Mike_d,

    Sorry about that. I fixed the link in my original response.

    Regards,
    Dalton
  • Thanks Dalton, that helped me think about it more.  The following code is working...

    void ndk_cfg_test(void)
    {
    	int size;
    	int count;
    	void *hCfg = NULL;
    	void *handle;
    	CI_IPNET ip_cfg;
    	CI_ROUTE ip_route;
    	uint32 tmp_u32;
    
    
    
    	hCfg = CfgGetDefault();
    
    	if(hCfg != NULL)
    	{
    		count = CfgGetEntryCnt(hCfg, CFGTAG_IPNET, 1);
    		count *= 1;
    
    		size = sizeof(CI_IPNET);
    		CfgGetEntry(hCfg, CFGTAG_IPNET, 1, 1, &handle);
    		CfgEntryGetData(handle, &size, (uint8_t*)&ip_cfg);
    
    		size = sizeof(CI_ROUTE);
    		CfgGetEntry(hCfg, CFGTAG_ROUTE, 0, 1, &handle);
    		CfgEntryGetData(handle, &size, (uint8_t*)&ip_route);
    
    
    		printf("\r\n\r\nIP Configuration\r\n");
    
    		tmp_u32 = htonl(ip_cfg.IPAddr);
    		printf("  IPv4 Address. . . .%d.%d.%d.%d\r\n",
    			(uint8)(tmp_u32 >> 24),
    			(uint8)(tmp_u32 >> 16),
    			(uint8)(tmp_u32 >> 8),
    			(uint8)(tmp_u32 >> 0));
    
    		tmp_u32 = htonl(ip_cfg.IPMask);
    		printf("  Subnet Mask . . . .%d.%d.%d.%d\r\n",
    			(uint8)(tmp_u32 >> 24),
    			(uint8)(tmp_u32 >> 16),
    			(uint8)(tmp_u32 >> 8),
    			(uint8)(tmp_u32 >> 0));
    
    		tmp_u32 = htonl(ip_route.IPGateAddr);
    		printf("  Default Gateway . .%d.%d.%d.%d\r\n",
    			(uint8)(tmp_u32 >> 24),
    			(uint8)(tmp_u32 >> 16),
    			(uint8)(tmp_u32 >> 8),
    			(uint8)(tmp_u32 >> 0));
    
    		printf("\r\n");
    	}
    
    	asm(" nop");
    }

**Attention** This is a public forum