]>
Commit | Line | Data |
---|---|---|
9fc60c65 ER |
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 | |
3 | @@ -74,6 +74,9 @@ | |
f4d18345 | 4 | int onetry=0; |
5 | int quiet=0; | |
6 | int nowait=0; | |
f4d18345 | 7 | +#ifdef EXTENDED_NEW_OPTION_INFO |
8 | +int extended_option_environment = 0; | |
9 | +#endif | |
9fc60c65 | 10 | |
f4d18345 | 11 | static void usage PROTO ((void)); |
12 | ||
9fc60c65 | 13 | @@ -203,6 +206,11 @@ |
f4d18345 | 14 | } else if (!strcmp (argv [i], "--version")) { |
15 | log_info ("isc-dhclient-%s", DHCP_VERSION); | |
16 | exit (0); | |
17 | +#ifdef EXTENDED_NEW_OPTION_INFO | |
9fc60c65 ER |
18 | + } else if (!strcmp (argv [i], "-x")) { |
19 | + extended_option_environment = 1; | |
20 | + new_option_info_tree = GENERATE_NEW_OPTION_INFO; | |
f4d18345 | 21 | +#endif |
22 | } else if (argv [i][0] == '-') { | |
23 | usage (); | |
24 | } else { | |
9fc60c65 | 25 | @@ -475,7 +483,11 @@ |
f4d18345 | 26 | log_info (arr); |
27 | log_info (url); | |
28 | ||
29 | +#ifdef EXTENDED_NEW_OPTION_INFO | |
9fc60c65 | 30 | + log_error ("Usage: dhclient [-1dqr] [-nwx] [-p <port>] %s", |
f4d18345 | 31 | +#else |
9fc60c65 | 32 | log_error ("Usage: dhclient [-1dqr] [-nw] [-p <port>] %s", |
f4d18345 | 33 | +#endif |
34 | "[-s server]"); | |
35 | log_error (" [-cf config-file] [-lf lease-file]%s", | |
36 | "[-pf pid-file] [-e VAR=val]"); | |
9fc60c65 | 37 | @@ -2426,8 +2438,30 @@ |
f4d18345 | 38 | struct envadd_state { |
39 | struct client_state *client; | |
40 | const char *prefix; | |
9fc60c65 ER |
41 | +#ifdef EXTENDED_NEW_OPTION_INFO |
42 | + struct universe *universe; | |
43 | +#endif | |
f4d18345 | 44 | }; |
45 | ||
9fc60c65 ER |
46 | +#ifdef EXTENDED_NEW_OPTION_INFO |
47 | +static | |
f4d18345 | 48 | +void build_universe_info_envvar |
9fc60c65 ER |
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 | |
f4d18345 | 56 | +) |
57 | +{ | |
9fc60c65 ER |
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 ); | |
f4d18345 | 62 | +} |
63 | +#endif | |
64 | + | |
65 | void client_option_envadd (struct option_cache *oc, | |
66 | struct packet *packet, struct lease *lease, | |
67 | struct client_state *client_state, | |
9fc60c65 | 68 | @@ -2444,6 +2478,28 @@ |
f4d18345 | 69 | in_options, cfg_options, scope, oc, MDL)) { |
70 | if (data.len) { | |
71 | char name [256]; | |
9fc60c65 ER |
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)) { | |
f4d18345 | 77 | + es->universe = oc->option->universe; |
9fc60c65 ER |
78 | + (*(es->universe->foreach)) ((struct packet *)0, |
79 | + (struct lease *)0, | |
80 | + client_state, | |
81 | + in_options, cfg_options, | |
82 | + scope, es->universe, es, | |
83 | + build_universe_info_envvar); | |
84 | + } else { | |
85 | + if (lookup_new_option_info(oc->option) != NULL) { | |
86 | + build_universe_info_envvar(oc, packet, lease, | |
87 | + client_state, in_options, | |
88 | + cfg_options, scope, | |
89 | + oc->option->universe, es); | |
90 | + } | |
91 | + } | |
f4d18345 | 92 | + } |
93 | +#endif | |
94 | if (dhcp_option_ev_name (name, sizeof name, | |
95 | oc -> option)) { | |
96 | client_envadd (es -> client, es -> prefix, | |
9fc60c65 | 97 | @@ -2470,6 +2526,7 @@ |
f4d18345 | 98 | |
99 | es.client = client; | |
100 | es.prefix = prefix; | |
9fc60c65 | 101 | + es.universe = NULL; |
f4d18345 | 102 | |
103 | client_envadd (client, | |
104 | prefix, "ip_address", "%s", piaddr (lease -> address)); | |
9fc60c65 | 105 | @@ -2679,7 +2736,14 @@ |
f4d18345 | 106 | s = option -> name; |
107 | if (j + 1 == buflen) | |
108 | return 0; | |
109 | +#ifdef EXTENDED_NEW_OPTION_INFO | |
9fc60c65 ER |
110 | + if (!extended_option_environment) |
111 | + buf[j++] = '_'; | |
f4d18345 | 112 | + else |
9fc60c65 | 113 | + buf[j++] = '.'; |
f4d18345 | 114 | +#else |
115 | buf [j++] = '_'; | |
116 | +#endif | |
117 | } | |
118 | ++i; | |
119 | } while (i != 2); | |
9fc60c65 ER |
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 | |
122 | @@ -82,6 +82,9 @@ | |
f4d18345 | 123 | .B -w |
124 | ] | |
125 | [ | |
9fc60c65 | 126 | +.B -x |
f4d18345 | 127 | +] |
128 | +[ | |
129 | .I if0 | |
130 | [ | |
131 | .I ...ifN | |
9fc60c65 | 132 | @@ -265,6 +268,11 @@ |
f4d18345 | 133 | supplying the |
134 | .B -nw | |
135 | flag. | |
136 | +.PP | |
9fc60c65 ER |
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. | |
f4d18345 | 141 | .SH CONFIGURATION |
142 | The syntax of the dhclient.conf(5) file is discussed separately. | |
143 | .SH OMAPI | |
9fc60c65 ER |
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, | |
149 | 0, option, MDL); | |
150 | +#ifdef EXTENDED_NEW_OPTION_INFO | |
151 | + if (new_option_info_tree != NULL) | |
152 | + add_new_option_info(option); | |
153 | +#endif | |
154 | return 1; | |
155 | } | |
156 | ||
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); | |
162 | } | |
163 | + | |
164 | +#ifdef EXTENDED_NEW_OPTION_INFO | |
165 | +#include <search.h> | |
166 | + | |
167 | +void *new_option_info_tree = NULL; | |
168 | + | |
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); | |
174 | + | |
175 | + return((ocode1 == ocode2) ? 0 : ((ocode1 > ocode2) ? 1 : -1)); | |
176 | +} | |
177 | + | |
178 | +void *add_new_option_info(struct option * option) { | |
179 | + if (option->universe->index >= fqdn_universe.index) | |
180 | + return NULL; | |
181 | + | |
182 | + if (new_option_info_tree == GENERATE_NEW_OPTION_INFO) | |
183 | + new_option_info_tree = NULL; | |
184 | + | |
185 | + return tsearch(option, &(new_option_info_tree), new_option_info_comparator); | |
186 | +} | |
187 | + | |
188 | +void *lookup_new_option_info(struct option * option) { | |
189 | + if (new_option_info_tree == GENERATE_NEW_OPTION_INFO) | |
190 | + return NULL; | |
191 | + | |
192 | + return tfind(option, &(new_option_info_tree), new_option_info_comparator); | |
193 | +} | |
194 | +#endif | |
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; | |
200 | ||
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 *); | |
206 | +#endif | |
207 | + | |
208 | /* stables.c */ | |
209 | #if defined (FAILOVER_PROTOCOL) | |
210 | extern failover_option_t null_failover_option; |