How to get the current IP-Address/Mask/Gateway in

If I configure my Digi Connect ME (JTAG or -C Device) with a static IP configuration then I have no problem to read the current IP settings [customizeAceGetConfig(…), customizeAceGetStaticConfig(…)].

But if I have my Digi device configured to obtain the IP parameters from the network (DHCP) then I have some problems… If I call customizeAceGetDhcpConfig(…) the parameter suggested_ip_address is zero.

In this forum I found the function NAIpAddress() which gives me the obtained IP-Address. But how can I get des SubnetMask and the Gateway-Address?


I found the solution for my problem…

I studied the function NAIpAddress() which contains the following code (nainet.c):

unsigned long NAIpAddress (void)

netdev 			*ndp;

unsigned long iplong = 0;
if ( (ndp = ll_dev_2_ndp("eth0")) != (netdev *)0 )
	iplong = ndp->nd_ipas[0].nd_ipaddr;
return (ntohl(iplong));


While looking for nd_ipaddr I found the struct nd_ipa in netdev.h:

typedef struct nd_ipa {
u32 nd_ipaddr;
u32 nd_ipmask;
u32 nd_ipbcast;
u16 nd_ipflags;
int nd_secidx;
void *ip_circ;
void *nd_parent;
struct nd_ipa *next;

}nd_ipaddr, *nd_ipaddr_pt;

My code for the IP-Address and the Subnetmask looks like this:

netdev *ndp;
unsigned long ipAddress, subnetMask

ndp = (netdev*)ll_dev_2_ndp(“eth0”);
ipAddress = ntohl( ndp->nd_ipas[0].nd_ipaddr );

ndp = (netdev*)ll_dev_2_ndp(“eth0”);
subnetMask = ntohl( ndp->nd_ipas[0].nd_ipmask );


you have to include netdev.h

Jul 25, 2006 11:20 AM
The procedure above does not work properly! The returned ipAddress is correct, but the SubnetMask is wrong.
Use the the function customizeAceGetInterfaceAddrInfo(…) instead.