1 --- dhcp-3.0.5/client/dhclient.c.enoi 2007-03-30 16:27:32.000000000 -0400
2 +++ dhcp-3.0.5/client/dhclient.c 2007-03-30 16:27:51.000000000 -0400
7 +#ifdef EXTENDED_NEW_OPTION_INFO
8 +int extended_option_environment = 0;
11 static void usage PROTO ((void));
14 } else if (!strcmp (argv [i], "--version")) {
15 log_info ("isc-dhclient-%s", DHCP_VERSION);
17 +#ifdef EXTENDED_NEW_OPTION_INFO
18 + } else if (!strcmp (argv [i], "-x")) {
19 + extended_option_environment = 1;
20 + new_option_info_tree = GENERATE_NEW_OPTION_INFO;
22 } else if (argv [i][0] == '-') {
29 +#ifdef EXTENDED_NEW_OPTION_INFO
30 + log_error ("Usage: dhclient [-1dqr] [-nwx] [-p <port>] %s",
32 log_error ("Usage: dhclient [-1dqr] [-nw] [-p <port>] %s",
35 log_error (" [-cf config-file] [-lf lease-file]%s",
36 "[-pf pid-file] [-e VAR=val]");
37 @@ -2426,8 +2438,30 @@
39 struct client_state *client;
41 +#ifdef EXTENDED_NEW_OPTION_INFO
42 + struct universe *universe;
46 +#ifdef EXTENDED_NEW_OPTION_INFO
48 +void build_universe_info_envvar
49 +( struct option_cache *oc,
50 + struct packet *p, struct lease *l,
51 + struct client_state *client,
52 + struct option_state *in_o,
53 + struct option_state *cf_o,
54 + struct binding_scope **scope,
55 + struct universe *u, void *es
58 + char info_name[512], info_data[512];
59 + snprintf(info_name, 512, "%s._universe_.", oc->option->universe->name);
60 + snprintf(info_data, 512, "%u:%s", oc->option->code,oc->option->format);
61 + client_envadd( client, info_name, oc->option->name, info_data );
65 void client_option_envadd (struct option_cache *oc,
66 struct packet *packet, struct lease *lease,
67 struct client_state *client_state,
68 @@ -2444,6 +2478,28 @@
69 in_options, cfg_options, scope, oc, MDL)) {
72 +#ifdef EXTENDED_NEW_OPTION_INFO
73 + if (extended_option_environment) {
74 + if ((oc->option->universe != &dhcp_universe)
75 + && (oc->option->universe->index > fqdn_universe.index)
76 + && (es->universe != oc->option->universe)) {
77 + es->universe = oc->option->universe;
78 + (*(es->universe->foreach)) ((struct packet *)0,
81 + in_options, cfg_options,
82 + scope, es->universe, es,
83 + build_universe_info_envvar);
85 + if (lookup_new_option_info(oc->option) != NULL) {
86 + build_universe_info_envvar(oc, packet, lease,
87 + client_state, in_options,
89 + oc->option->universe, es);
94 if (dhcp_option_ev_name (name, sizeof name,
96 client_envadd (es -> client, es -> prefix,
101 + es.universe = NULL;
103 client_envadd (client,
104 prefix, "ip_address", "%s", piaddr (lease -> address));
105 @@ -2679,7 +2736,14 @@
109 +#ifdef EXTENDED_NEW_OPTION_INFO
110 + if (!extended_option_environment)
120 --- dhcp-3.0.5/client/dhclient.8.enoi 2005-09-14 12:03:33.000000000 -0400
121 +++ dhcp-3.0.5/client/dhclient.8 2007-03-30 16:27:32.000000000 -0400
137 +The -x argument enables extended option information to be created in the
138 +-s dhclient-script environment, which would allow applications running
139 +in that environment to handle options they do not know about in advance -
140 +this is a Red Hat extension to support dhcdbd and NetworkManager.
142 The syntax of the dhclient.conf(5) file is discussed separately.
144 --- dhcp-3.0.5/common/parse.c.enoi 2007-03-30 16:27:32.000000000 -0400
145 +++ dhcp-3.0.5/common/parse.c 2007-03-30 16:27:32.000000000 -0400
146 @@ -1266,6 +1266,10 @@
147 option_hash_add (option -> universe -> hash,
148 (const char *)option -> name,
150 +#ifdef EXTENDED_NEW_OPTION_INFO
151 + if (new_option_info_tree != NULL)
152 + add_new_option_info(option);
157 --- dhcp-3.0.5/common/tables.c.enoi 2006-02-22 17:43:27.000000000 -0500
158 +++ dhcp-3.0.5/common/tables.c 2007-03-30 16:27:32.000000000 -0400
159 @@ -1250,3 +1250,35 @@
160 fqdn_universe.name, 0,
161 &fqdn_universe, MDL);
164 +#ifdef EXTENDED_NEW_OPTION_INFO
167 +void *new_option_info_tree = NULL;
169 +static int new_option_info_comparator(const void * p1, const void * p2) {
170 + uint32_t ocode1 = (((const struct option*)p1)->universe->index << 8)
171 + | (((const struct option*)p1)->code),
172 + ocode2 = (((const struct option*)p2)->universe->index << 8)
173 + | (((const struct option*)p2)->code);
175 + return((ocode1 == ocode2) ? 0 : ((ocode1 > ocode2) ? 1 : -1));
178 +void *add_new_option_info(struct option * option) {
179 + if (option->universe->index >= fqdn_universe.index)
182 + if (new_option_info_tree == GENERATE_NEW_OPTION_INFO)
183 + new_option_info_tree = NULL;
185 + return tsearch(option, &(new_option_info_tree), new_option_info_comparator);
188 +void *lookup_new_option_info(struct option * option) {
189 + if (new_option_info_tree == GENERATE_NEW_OPTION_INFO)
192 + return tfind(option, &(new_option_info_tree), new_option_info_comparator);
195 --- dhcp-3.0.5/includes/dhcpd.h.enoi 2006-05-17 16:16:59.000000000 -0400
196 +++ dhcp-3.0.5/includes/dhcpd.h 2007-03-30 16:27:32.000000000 -0400
197 @@ -1811,6 +1811,13 @@
198 void initialize_common_option_spaces PROTO ((void));
199 struct universe *config_universe;
201 +#ifdef EXTENDED_NEW_OPTION_INFO
202 +#define GENERATE_NEW_OPTION_INFO ((void*)1)
203 +extern void *new_option_info_tree;
204 +extern void *add_new_option_info(struct option *);
205 +extern void *lookup_new_option_info(struct option *);
209 #if defined (FAILOVER_PROTOCOL)
210 extern failover_option_t null_failover_option;