[prev in list] [next in list] [prev in thread] [next in thread] 

List:       dhcp-client
Subject:    Patch for using new options
From:       "Sharad Mittal" <sharad_mittal12 () hotmail ! com>
Date:       2003-01-07 11:59:26
[Download RAW message or body]

   *** From dhcp-client -- To unsubscribe, see the end of this message. ***


Hi all,
         Here is a patch to be applied to the file common/parse.c that 
enables defining new options and using them in /etc/dhclient.conf.

*** parse.c	Wed Jun 27 00:03:32 2001
--- ../../../dhcp-3.0pl1/common/parse.c	Tue Jan  7 16:36:13 2003
***************
*** 1023,1026 ****
--- 1023,1027 ----
  	enum dhcp_token token;
  	unsigned arrayp = 0;
+ 	int known = 0;
  	int recordp = 0;
  	int no_more_in_record = 0;
***************
*** 1033,1036 ****
--- 1034,1043 ----
  	int has_encapsulation = 0;

+ 	if (option->code) {
+ 	     /* Sharad : This option is either a RFC pre-defined option */
+ 	     /*          or has been defined before by the client */
+ 	     known = 1;
+ 	}
+
  	/* Parse the option code. */
  	token = next_token (&val, (unsigned *)0, cfile);
***************
*** 1042,1045 ****
--- 1049,1059 ----
  	option -> code = atoi (val);

+ 	/* Sharad : Just verifying this code already exists */
+ 	if (dhcp_options [option->code].name[0] != '#') {
+ 	     /* printf ("Code %d already is being used for %s",
+ 		option->code, dhcp_options [option->code].name ); */
+ 	     known = 1;
+ 	}
+
  	token = next_token (&val, (unsigned *)0, cfile);
  	if (token != EQUAL) {
***************
*** 1273,1280 ****
  		   XXX may start out static. */
  	}
! 	option -> universe -> options [option -> code] = option;
! 	option_hash_add (option -> universe -> hash,
! 			 (const char *)option -> name,
! 			 0, option, MDL);
  	return 1;
  }
--- 1287,1298 ----
  		   XXX may start out static. */
  	}
! 	if (!known) {
! 	     option -> universe -> options [option -> code] = option;
! 	     /* Sharad: Changing dhcp_options[i] */
! 	     memcpy (&dhcp_options[option->code], option, sizeof (option));
! 	     option_hash_add (option -> universe -> hash,
! 			      (const char *)option -> name,
! 			      0, option, MDL);
! 	}
  	return 1;
  }


Hope it helps,
Sharad





_________________________________________________________________
The new MSN 8 is here: Try it free* for 2 months 
http://join.msn.com/?page=dept/dialup


-- Binary/unsupported file stripped by Ecartis --
-- Type: application/octet-stream
-- File: parse.c.patch


-----------------------------------------------------------------------
To unsubscribe from this list, visit http://www.isc.org/dhcp-lists.html
or send mail to dhcp-client-request@isc.org with the subject line of
'unsubscribe'.
-----------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic