NAME

DHCP Server - dhcpd

SYNOPSIS

#include <netinet/dhcp.h>

int DHCP_SERVER(struct tcpinit *init,DHCP_SETUP *dhcp_setup);



DESCRIPTION

DHCP server allows a computer to be configured IP address automatically. The DHCP server manages a pool of IP addresses and information about client configuration parameters such as default gateway.

On receiving a valid request, the server assigns the computer an IP address,and other IP configuration parameters, such as the subnet mask and the default gateway.

Parameters and a range of IP addresses (which the server will provide) specified in the structure dhcp_setup. These structure can be found in the file <netinet/dhcp.h>

EXAMPLE

TDHCP_SETUP dhcp_setup;

THREAD Main(void * args)
{	pthread_t pid;
	pthread_attr_t attr;
	struct sched_param myNewPriority;
	int ret;

	pthread_attr_init(&attr);
	myNewPriority.sched_priority = 5;
	pthread_attr_setschedparam(&attr, &myNewPriority);
 	pthread_attr_setstacksize(&attr, 2048);

	if(pthread_create(&pid, &attr, &tcp_shell, 0)!=0)
	{
		xprintf("pthread_create = %d\n", errno);
		pthread_exit(0);
	}

	if(dir_register("/dev/tcpd", pid, TYPE_SERVER)==0)
	{
		xprintf("dir_register = %d\n", errno);
		pthread_exit(0);
	}



    dhcp_setup.ip_router      	= inet_addr("192.168.20.2");
    dhcp_setup.ip_subnet_mask 	= inet_addr("255.255.255.0");
    dhcp_setup.ip_start		= inet_addr("192.168.20.20");
    dhcp_setup.ip_end		= inet_addr("192.168.20.35");

     /* Start dhcp server */
    ret=DHCP_SERVER(&etherinit,&dhcp_setup)'
    return 0;
}
/*************************************************************************
 *  Subroutine  : tcp_shell
 *  Purpose     : Task shell for starting device specific tcpserver
 ************************************************************************/
THREAD tcp_shell(void * arg)
{
	tcpd((char *)&etherinit, 0);
}

NOTES



SEE ALSO

tcpd




< Copyright Rowebots Research Inc. and Multiprocessor Toolsmiths Inc. 1987-2009 >