Home/Support/Support Forum/how to read the IP assigned by DHCP???
New and improved user forum site going live on 12/6 (All users will need to reset their password when the new forum is active)
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

how to read the IP assigned by DHCP???

0 votes
Hi all!!!

I'm working with the software DIGI ESP for NET+OS for my CONNECTME


How I get the value of IP assigned in my CONNECTME?? , when I configure by DHCP!!
asked Nov 5, 2009 in NET+OS by isaac New to the Community (8 points)
recategorized Dec 10, 2013 by tuxembb

Please log in or register to answer this question.

4 Answers

0 votes
Hello

Try API call customizeIamGetIfAddrInfo(). It is described in the API reference manual. The address contained in the structure is a 32-bit integer. If you want the dotted notation, you need to convert it.
answered Nov 5, 2009 by sparkys_dad Community Contributor (99 points)
0 votes
I'm working with the software DIGI ESP for NET+OS for my ConnectME with jtag
when I create my project, in parameters of Network , I select " obtain an IP adress automatically (DHCP)"

When start my project, then my ConnectMe is asigned an IP automatically

I need read the value of the IP asigned to my Connect ME.

If I configure my Digi Connect ME with a static IP configuration then I have no problem to read the current IP (CustomizeIamGetStaticConfig and CustomizeGetIP)

But if I have my Digi device configured to obtain the IP parameters from the network (DHCP) then I have problems...

If I call CustomizeIamGetDhcpConfig , as I get the value of IP?

I used the function customizeIamGetIfAddrInfo but
not work

friends of the forum I hope your help!!!
answered Nov 6, 2009 by isaac New to the Community (8 points)
0 votes
Hello

What do you mean by it does not work? Did you get an address of 0.0.0.0 or an error? What interface name did you pass in?

Are you sure the interface is completely up before you call customizeIamGetIfAddrInfo. I was using customizeIamGetIfAddrInfo today in some code that switches between static and DHCP-configured addresses. customizeIamGetIfAddrInfo was able to track the changes. But there was a lag time between the switch and when the interface could return its address.
answered Nov 6, 2009 by sparkys_dad Community Contributor (99 points)
0 votes
It also works fine for me...

static NaIamIfAddrInfo_t addrInfo;
struct sockaddr_storage myaddr;
char ipstring[20];

if(customizeIamGetIfAddrInfo("eth0", &addrInfo) != NA_IAM_STATUS_SUCCESS)
printf("Error getting IP info!\n");
else
{
NAInet_toa(addrInfo.v4Info.ipAddress.addr.ipv4.sin_addr.s_addr, ipstring);
printf("IP Address: %s\n", ipstring);
NAInet_toa(addrInfo.v4Info.subnetMask, ipstring);
printf("SubMask: %s\n", ipstring);
NAInet_toa(addrInfo.v4Info.defaultGateway.addr.ipv4.sin_addr.s_addr, ipstring);
printf("Gateway: %s\n", ipstring);

}
answered Nov 17, 2009 by charliek Veteran of the Digi Community (408 points)
...