Tool/software: Code Composer Studio
How to get the IP address of the DHCP server?
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.
Tool/software: Code Composer Studio
How to get the IP address of the DHCP server?
Hi,
Can you clarify what TI software package you used? C6457 is a very old device, the software package may similar to what we have for the C665x, C667x. In that we have a "hello world" example, it is RTOS using NDK and NIMU driver. The hello world can use either a static IP address or DHCP.
When using the DHCP, the C66x or C64x is the DHCP client and sends out the discovery packets. The DHCP server is on the same network and you configured with an IP address, do you mean in your C64x application how you read out/record the DHCP server IP address?
Regards, Eric
Hi,
I searched NDK source code, ndk_2/3_xx_xx_xx\packages\ti\ndk\nettools\dhcp, there is a:
/* structure of a DHCP lease information */
typedef struct _dhcpLEASE
{
UINT16 StateInitial; /* Starting State */
UINT16 State; /* Current State */
UINT16 StateNext; /* Next State */
IPN IPAddress; /* IP Address from DHCP Server */
IPN IPAddressOld; /* IP Address being used */
IPN IPSubnetMask; /* IP SubnetMask */
IPN IPGate; /* IP Gateway Address */
UINT32 LeaseExpires; /* Time to moved to Init State *
...
}
Code:
static void StateSelecting(DHCPLEASE *pLease)
{
IPN IPOffer,IPServer;
UINT16 MaxTries;
UINT32 TimeStart;
MaxTries = 3;
Retry:
#if DEBUGON
DbgPrintf(DBG_INFO, "DHCP: StateSelecting:\r\n");
#endif
/* Build the DHCP request packet and Send it */
pLease->SendSize = dhcpBuildDiscover(pLease);
dhcpPacketSend( pLease, INADDR_BROADCAST );
/* Get the time */
TimeStart = llTimerGetTime(0);
while( (TimeStart + 2) >= llTimerGetTime(0) )
{
/* Get reply (waits for 3 seconds) */
dhcpPacketReceive(pLease);
if( dhcpVerifyMessage( pLease, &IPOffer, &IPServer ) == DHCPOFFER)
{
pLease->IPAddress = IPOffer;
pLease->IPServer = IPServer;
pLease->StateNext = REQUESTING;
return;
}
}
You can find DHCP server address here.
Regards, Eric