Tool/software: TI-RTOS
I am having difficulties retrieving the the default gateway when using DHCP with the TI-RTOS NDK (TI-RTOS version 2.16.01.14, NDK version 2.25.00.09).
In my hook function that gets called when new IP address info is received via DHCP, I have the following code, which is intended to retrieve the default gateway address:
int Result;
int NumberOfInstances = CfgGetEntryCnt(0, CFGTAG_IPNET, 1); // success
if (NumberOfInstances >= 1) {
CI_IPNET IpConfig;
bzero(&IpConfig, sizeof(CI_IPNET));
Result = CfgGetImmediate(
0, CFGTAG_IPNET, 1, NumberOfInstances,
sizeof(CI_IPNET), (UINT8*)&IpConfig); // success
...
}
NumberOfInstances = CfgGetEntryCnt(0, CFGTAG_ROUTE, 1); // fails
if (NumberOfInstances >= 1) {
CI_ROUTE RouteConfig;
bzero(&RouteConfig, sizeof(CI_ROUTE));
Result = CfgGetImmediate(
0, CFGTAG_ROUTE, 1, NumberOfInstances,
sizeof(CI_ROUTE), (UINT8*)&RouteConfig);
if (Result) {
...
}
}
NumberOfInstances is always zero after calling CfgGetEntryCnt for tag CFGTAG_ROUTE, implying there is no route information in the configuration.
In looking through other forum posts, I see this post below, which suggests using functions Rt* in routeif.h, with function DumpRouteTable in NDK file conroute.c providing an example of how to use those functions. This function and code seems complicated though.
What is the proper way to get the default gateway IP address when using DHCP. Is my code above right, or do I have to do something like what is found in function DumpRouteTable in NDK file conroute.c?
Thanks in advance