/* Start DHCP Server: */
error = DHCPSRV_init("DHCP server", 7, 2000);
if (error != RTCS_OK) {
printf("\nFailed to initialize DHCP Server, error %x", error);
return;
}
printf("\nDHCP Server running");
/* Fill in the required parameters: */
/* 192.168.0.1: */
dhcpsrv_data.SERVERID = 0xC0A80001;
/* Infinite leases: */
dhcpsrv_data.LEASE = 0xFFFFFFFF;
/* 255.255.255.0: */
dhcpsrv_data.MASK = 0xFFFFFF00;
/* TFTP server address: */
dhcpsrv_data.SADDR = 0xC0A80001;
memset(dhcpsrv_data.SNAME, 0, sizeof(dhcpsrv_data.SNAME));
memset(dhcpsrv_data.FILE, 0, sizeof(dhcpsrv_data.FILE));
/* Fill in the options: */
optptr = dhcpsrv_options;
optlen = sizeof(dhcpsrv_options);
/* Default IP TTL: */
DHCPSRV_option_int8(&optptr, &optlen, 23, 64);
/* MTU: */
DHCPSRV_option_int16(&optptr, &optlen, 26, 1500);
/* Renewal time: */
DHCPSRV_option_int32(&optptr, &optlen, 58, 3600);
/* Rebinding time: */
DHCPSRV_option_int32(&optptr, &optlen, 59, 5400);
/* Domain name: */
DHCPSRV_option_string(&optptr, &optlen, 15, "arc.com");
/* Broadcast address: */
DHCPSRV_option_addr(&optptr, &optlen, 28, 0xC0A800FF);
/* Router list: */
routers[0] = 0xC0A80001;
// routers[1] = 0xC0A80005;
// routers[2] = 0xC0A80006;
DHCPSRV_option_addrlist( &optptr, &optlen, 3, routers, 1);
/* Serve addresses 192.168.0.129 to 192.168.0.135 inclusive: */
DHCPSRV_ippool_add(0xC0A80081, 7, &dhcpsrv_data, dhcpsrv_options,optptr - dhcpsrv_options);
modified the following function in dhcpsrv.c
Hi, I'm a new in this forum. I'm a french student and I would like know if you had a program or an example for connect the M52259DEMO in DHCP.
I would like connect the module any where.
Thanks.
Best Regard.
Orzor
/* Start DHCP Server: */
error = DHCPSRV_init("DHCP server", 7, 2000);
if (error != RTCS_OK) {
printf("\nFailed to initialize DHCP Server, error %x", error);
return;
}
printf("\nDHCP Server running");
/* Fill in the required parameters: */
/* 192.168.0.1: */
dhcpsrv_data.SERVERID = 0xC0A80001;
/* Infinite leases: */
dhcpsrv_data.LEASE = 0xFFFFFFFF;
/* 255.255.255.0: */
dhcpsrv_data.MASK = 0xFFFFFF00;
/* TFTP server address: */
dhcpsrv_data.SADDR = 0xC0A80001;
memset(dhcpsrv_data.SNAME, 0, sizeof(dhcpsrv_data.SNAME));
memset(dhcpsrv_data.FILE, 0, sizeof(dhcpsrv_data.FILE));
/* Fill in the options: */
optptr = dhcpsrv_options;
optlen = sizeof(dhcpsrv_options);
/* Default IP TTL: */
DHCPSRV_option_int8(&optptr, &optlen, 23, 64);
/* MTU: */
DHCPSRV_option_int16(&optptr, &optlen, 26, 1500);
/* Renewal time: */
DHCPSRV_option_int32(&optptr, &optlen, 58, 3600);
/* Rebinding time: */
DHCPSRV_option_int32(&optptr, &optlen, 59, 5400);
/* Domain name: */
DHCPSRV_option_string(&optptr, &optlen, 15, "arc.com");
/* Broadcast address: */
DHCPSRV_option_addr(&optptr, &optlen, 28, 0xC0A800FF);
/* Router list: */
routers[0] = 0xC0A80001;
// routers[1] = 0xC0A80005;
// routers[2] = 0xC0A80006;
DHCPSRV_option_addrlist( &optptr, &optlen, 3, routers, 1);
/* Serve addresses 192.168.0.129 to 192.168.0.135 inclusive: */
DHCPSRV_ippool_add(0xC0A80081, 7, &dhcpsrv_data, dhcpsrv_options,optptr - dhcpsrv_options);
modified the following function in dhcpsrv.c
Hi RBORB,
can you please explain me step-by-step how to implemet DHCP server on demo MCF52259 board.
I am new to MQXRTOS.
Thanks Vijay
Hi,
For hardware that implements two Ethernet ports (configured to be on different subnets), is there any way to configure the dhcp server to respond to discover requests on only one port?
I got the dhcp server working, however it would respond to dhcp discover requests received from either Ethernet port (which is something I do not want).
Thanks,
mitsaltair
Hello,
DHCP server example is planned to be included (among others) in further releases of MQX.
PetrM
Hi
This is not coming to this line
printf("\nDHCP Server running...\n");
it stays this line only
DHCPSRV_init();
help me its urgent
There's a missing initialization of ethernet device and RTCS itself. DHCP server depends on those two. Please look at some ethernet example (e.g. telnet_to_serial demo) for correct initialization procedure.
PetrM
Hi
This is my code.but this is not working. what i am doing wrong.
void dhcpserver_task(uint_32);
TASK_TEMPLATE_STRUCT MQX_template_list[] =
{
{HELLO_TASK, dhcpserver_task, 1500, 9, "hello", MQX_AUTO_START_TASK, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0}
};
void dhcpserver_task(uint_32 initial_data)
{
DHCPSRV_DATA_STRUCT dhcpserver_data;
uchar dhcpserver_options[200];
_ip_address routers[3];
uchar_ptr optptr;
uint_32 error;
uint_32 optlen;
error = DHCPSRV_init("mydhcp",7,2000);
if(error != RTCS_OK)
{
printf("\nDHCP server initialize returned : %08x\n",error);
printf("\nFailed to initialize the DHCP server\n");
_mqx_exit(0);
}
printf("\nDHCP Server running...\n");
dhcpserver_data.SERVERID = 0xC0A80101;
dhcpserver_data.LEASE = 0xFFFFFFFF;
dhcpserver_data.MASK = 0xFFFFFF00;
dhcpserver_data.SADDR = 0xC0A80102;
_mem_zero(dhcpserver_data.SNAME,sizeof(dhcpserver_data.SNAME));
_mem_zero(dhcpserver_data.FILE,sizeof(dhcpserver_data.FILE));
optptr = dhcpserver_options;
optlen = sizeof(dhcpserver_options);
DHCPSRV_option_int8(&optptr,&optlen,23,64);
DHCPSRV_option_int16(&optptr,&optlen,26,1500);
DHCPSRV_option_int32(&optptr,&optlen,58,3600);
DHCPSRV_option_int32(&optptr,&optlen,59,5400);
DHCPSRV_option_string(&optptr,&optlen,15,"arc.com");
DHCPSRV_option_addr(&optptr,&optlen,28,0xC0A801FF);
routers[0] = 0xC0A80104;
routers[1] = 0xC0A80105;
routers[2] = 0xC0A80106;
DHCPSRV_option_addrlist(&optptr,&optlen,3,routers,3);
DHCPSRV_ippool_add(0xC0A80181,7,&dhcpserver_data,dhcpserver_options,optptr - dhcpserver_options);
_task_block();
}
Thanks
Vijay