How can i read the received IP, from the DHCP server?
I will open a communication via Ethernet with:
RTCS_create(), ENET_initialize(), RTCS_if_add(), RTCS_if_bind_DHCP() an open a socket.
So my system (MQX 4.1.1 with twrk70f120m) is reached a Ping korrect. My ftp-server is running.
After the initialise i will with:
IPCFG_IP_ADDRESS_DATA ip_data = {0,0,0};
error = ipcfg_get_ip (ENET_DEVICE_0, &ip_data);
read the received IP. But it always returns FALSE, but no IP. Which function is available for the IP-Read?
---------------------------------
#include "econ9_Device_config.h"
#include <rtcs.h>
#include <ipcfg.h>
#define ENET_DEVICE_0 0 // 1. Enet-Device
_enet_handle ehandle; // (Bind TCP&MSK to Adapter)
unsigned int eth_init(void)
{
uint32_t error;
_rtcs_if_handle ihandle; // (Bind MAC to Eth-Device)
uint32_t optlen = 580;
unsigned char option_array[optlen];
unsigned char * optptr;
DHCP_DATA_STRUCT params;
unsigned char parm_options[3] = { DHCPOPT_SERVERNAME, DHCPOPT_FILENAME, DHCPOPT_FINGER_SRV};
_enet_address macadrarray;
_mem_zero(¶ms, sizeof(params));
/* Setup RTCS */
_RTCSTASK_priority = RTCSTASK;
error = RTCS_create();
/* Init ETH Interface */
_IP_forward = TRUE;
error = ENET_initialize (ENET_DEVICE_0, econ9_Device_config.ethernet.ENET_MAC_0, 0, &ehandle);
if (error != RTCS_OK)
{
DEBUGPRINTF("eth_init - Error: RTCS initialization failed\n");
return 1;
}
error = RTCS_if_add (ehandle, RTCS_IF_ENET, &ihandle);
if (error != RTCS_OK)
{
DEBUGPRINTF("eth_init - Error: RTCS_if_add failed\n");
return 3;
}
/* IP Configuration */
/* DHCP */
optptr = option_array;
DHCP_option_int32(&optptr, &optlen, DHCPOPT_LEASE, 180);
DHCP_option_variable(&optptr, &optlen, DHCPOPT_PARAMLIST, parm_options, 3);
error = RTCS_if_bind_DHCP(ihandle, ¶ms, &option_array, optlen);
if (error)
{
DEBUGPRINTF("eth_init - DHCP boot failed, error = %x.\n", error);
return 5;
}
return 0;
}