1 --- dhcp-3.0.2/common/parse.c.extended_option_environment 2005-04-05 17:49:36.513062562 -0400
2 +++ dhcp-3.0.2/common/parse.c 2005-04-05 17:49:36.580052656 -0400
5 option_name_hash_add(option->universe->name_hash, option->name, 0,
7 +#ifdef EXTENDED_NEW_OPTION_INFO
8 + if ( new_option_info_tree != 0L )
9 + add_new_option_info( option );
14 --- dhcp-3.0.2/common/tables.c.extended_option_environment 2004-09-01 13:06:35.000000000 -0400
15 +++ dhcp-3.0.2/common/tables.c 2005-04-05 18:04:23.915838623 -0400
16 @@ -1238,3 +1238,40 @@
17 fqdn_universe.name, 0,
21 +#ifdef EXTENDED_NEW_OPTION_INFO
24 +void *new_option_info_tree = 0L;
26 +static int new_option_info_comparator( const void* p1, const void *p2 )
28 + uint32_t ocode1 = (((const struct option*)p1)->universe->index << 8)
29 + |(((const struct option*)p1)->code),
30 + ocode2 = (((const struct option*)p2)->universe->index << 8)
31 + |(((const struct option*)p2)->code);
32 + return( (ocode1 == ocode2)
34 + :( ( ocode1 > ocode2 )
41 +void *add_new_option_info( struct option *option )
43 + if ( option->universe->index >= fqdn_universe.index )
45 + if ( new_option_info_tree == GENERATE_NEW_OPTION_INFO )
46 + new_option_info_tree = (void*)0L;
47 + return tsearch( option, &(new_option_info_tree), new_option_info_comparator );
50 +void *lookup_new_option_info( struct option *option )
52 + if ( new_option_info_tree == GENERATE_NEW_OPTION_INFO )
54 + return tfind( option, &(new_option_info_tree), new_option_info_comparator );
57 --- dhcp-3.0.2/includes/dhcpd.h.extended_option_environment 2004-11-24 12:39:16.000000000 -0500
58 +++ dhcp-3.0.2/includes/dhcpd.h 2005-04-05 17:49:36.613047777 -0400
59 @@ -1800,6 +1800,13 @@
60 void initialize_common_option_spaces PROTO ((void));
61 struct universe *config_universe;
63 +#ifdef EXTENDED_NEW_OPTION_INFO
64 +#define GENERATE_NEW_OPTION_INFO ((void*)1)
65 +extern void *new_option_info_tree;
66 +extern void *add_new_option_info( struct option*);
67 +extern void *lookup_new_option_info( struct option *);
71 #if defined (FAILOVER_PROTOCOL)
72 extern failover_option_t null_failover_option;
73 --- dhcp-3.0.2/client/dhclient.c.extended_option_environment 2005-04-05 17:49:36.566054726 -0400
74 +++ dhcp-3.0.2/client/dhclient.c 2005-04-05 17:49:36.617047185 -0400
80 +#ifdef EXTENDED_NEW_OPTION_INFO
81 +int extended_option_environment = 0;
83 static void usage PROTO ((void));
85 void do_release(struct client_state *);
87 } else if (!strcmp (argv [i], "--version")) {
88 log_info ("isc-dhclient-%s", DHCP_VERSION);
90 +#ifdef EXTENDED_NEW_OPTION_INFO
91 + } else if (!strcmp (argv [i], "-y")) {
92 + extended_option_environment = 1;
93 + new_option_info_tree = GENERATE_NEW_OPTION_INFO;
95 } else if (argv [i][0] == '-') {
102 +#ifdef EXTENDED_NEW_OPTION_INFO
103 + log_error ("Usage: dhclient [-1dqrx] [-nwy] [-p <port>] %s",
105 log_error ("Usage: dhclient [-1dqrx] [-nw] [-p <port>] %s",
108 log_error (" [-cf config-file] [-lf lease-file]%s",
109 "[-pf pid-file] [-e VAR=val]");
110 @@ -2529,8 +2540,28 @@
111 struct envadd_state {
112 struct client_state *client;
114 + struct universe *universe;
117 +#ifdef EXTENDED_NEW_OPTION_INFO
119 +void build_universe_info_envvar
120 +( struct option_cache *oc,
121 + struct packet *p, struct lease *l,
122 + struct client_state *client,
123 + struct option_state *in_o,
124 + struct option_state *cf_o,
125 + struct binding_scope **scope,
126 + struct universe *u, void *es
129 + char info_name[512], info_data[512];
130 + snprintf(info_name, 512, "%s._universe_.", oc->option->universe->name);
131 + snprintf(info_data, 512, "%u:%s", oc->option->code,oc->option->format);
132 + client_envadd( client, info_name, oc->option->name, info_data );
136 void client_option_envadd (struct option_cache *oc,
137 struct packet *packet, struct lease *lease,
138 struct client_state *client_state,
139 @@ -2547,6 +2578,31 @@
140 in_options, cfg_options, scope, oc, MDL)) {
143 +#ifdef EXTENDED_NEW_OPTION_INFO
144 + if ( extended_option_environment )
146 + if( ( oc->option->universe != &dhcp_universe )
147 + &&( oc->option->universe->index > fqdn_universe.index )
148 + &&( es->universe != oc->option->universe )
151 + es->universe = oc->option->universe;
152 + (*(es->universe->foreach))
153 + ( (struct packet *)0, (struct lease *)0,
155 + in_options, cfg_options,
156 + scope, es->universe, es,
157 + build_universe_info_envvar
160 + if ( lookup_new_option_info(oc->option) != 0L )
161 + build_universe_info_envvar
162 + ( oc, packet, lease, client_state,
163 + in_options, cfg_options, scope,
164 + oc->option->universe, es
168 if (dhcp_option_ev_name (name, sizeof name,
170 client_envadd (es -> client, es -> prefix,
171 @@ -2575,6 +2631,7 @@
177 client_envadd (client,
178 prefix, "ip_address", "%s", piaddr (lease -> address));
179 @@ -2788,7 +2845,14 @@
183 +#ifdef EXTENDED_NEW_OPTION_INFO
184 + if ( ! extended_option_environment )
194 --- dhcp-3.0.2/client/dhclient.8.extended_option_environment 2004-09-29 19:01:46.000000000 -0400
195 +++ dhcp-3.0.2/client/dhclient.8 2005-04-05 17:49:36.619046889 -0400
211 +The -y argument enables eXtended option information to be created in the
212 +-s dhclient-script environment, which would allow applications running
213 +in that environment to handle options they do not know about in advance.
215 The syntax of the dhclient.conf(5) file is discussed separately.