udhcpd get DNS address dynamic

Tito farmatito at tiscali.it
Fri Aug 17 18:51:58 UTC 2007


On Friday 17 August 2007 17:13:43 Tito wrote:
> On Friday 17 August 2007 02:08:24 kylix wrote:
> > Hi,all
> > 
> >     I want to build a DHCP server on my embedded linux system.  
> > My busybox version is v1.3. 
> >     when udhcpd running, it will get the configure infomation from 
> > "udhcpd.conf", and then send the offer to client 
> > with IP, Gateway, DNS, Mask. 
> >     But My machine has two ethernet interface, It be 
> > configure as gateway. the first one run udhcpc, and 
> > the second run udhcpd.
> >     udhcpd send the offer message include DNS address,
> > this address in static, I want to get the DNS  option
> > from "/etc/reslov.conf" , because this file is configued
> > dynamic by udhcpc.
> >     How will I do ?
> > 
> >     I had try to modify the "busybox/networking/udhcp/serverpacket.c",
> > but no success.  I add two function in it, and add a call in
> > the line 174: addDnsOption( packet.options );
> > 
> > **********************************************************************************
> > static int  getDnsAddr(  uint8_t *dbuf, uint32_t seq )
> > {
> > 	FILE  *fp;
> > 	uint8_t  *ptr1, *ptr2, rebuf[256];
> > 	memset( dbuf, 0, 32 );
> > 	fp = fopen( "/etc/resolv.conf", "r");
> > 	if( fp==NULL )
> > 		return -1;
> > 
> > 	fread( rebuf, 255 , 1, fp );
> > 	fclose( fp );
> > 
> > 	if( seq == 1 )
> > 		ptr1 = strstr( rebuf, "nameserver " );
> > 	else if( seq == 2 ) {
> > 		if( ptr1 = strstr( rebuf, "nameserver " ))
> 
> 		if ((ptr1 = strstr(rebuf, "nameserver"))  ops....

		if ((ptr1 = strstr(rebuf, "nameserver")) != NULL)  ;-)

This should fix the compiling error....

> 
> > 			ptr1 = strstr( ptr1+11,  "nameserver " );
> > 	}
> > 	else
> > 		return -1;
> > 	
>  snip
> 
Ciao,
Tito




More information about the busybox mailing list