1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
|
--- dhcp-3.0.2/common/parse.c.extended_option_environment 2005-04-05 17:49:36.513062562 -0400
+++ dhcp-3.0.2/common/parse.c 2005-04-05 17:49:36.580052656 -0400
@@ -1270,6 +1270,10 @@
option_hash_add (option -> universe -> hash,
(const char *)option -> name,
0, option, MDL);
+#ifdef EXTENDED_NEW_OPTION_INFO
+ if ( new_option_info_tree != 0L )
+ add_new_option_info( option );
+#endif
return 1;
}
--- dhcp-3.0.2/common/tables.c.extended_option_environment 2004-09-01 13:06:35.000000000 -0400
+++ dhcp-3.0.2/common/tables.c 2005-04-05 18:04:23.915838623 -0400
@@ -1238,3 +1238,40 @@
fqdn_universe.name, 0,
&fqdn_universe, MDL);
}
+
+#ifdef EXTENDED_NEW_OPTION_INFO
+#include <search.h>
+
+void *new_option_info_tree = 0L;
+
+static int new_option_info_comparator( const void* p1, const void *p2 )
+{
+ uint32_t ocode1 = (((const struct option*)p1)->universe->index << 8)
+ |(((const struct option*)p1)->code),
+ ocode2 = (((const struct option*)p2)->universe->index << 8)
+ |(((const struct option*)p2)->code);
+ return( (ocode1 == ocode2)
+ ? 0
+ :( ( ocode1 > ocode2 )
+ ? 1
+ : -1
+ )
+ );
+}
+
+void *add_new_option_info( struct option *option )
+{
+ if ( option->universe->index >= fqdn_universe.index )
+ return 0L;
+ if ( new_option_info_tree == GENERATE_NEW_OPTION_INFO )
+ new_option_info_tree = (void*)0L;
+ return tsearch( option, &(new_option_info_tree), new_option_info_comparator );
+}
+
+void *lookup_new_option_info( struct option *option )
+{
+ if ( new_option_info_tree == GENERATE_NEW_OPTION_INFO )
+ return 0L;
+ return tfind( option, &(new_option_info_tree), new_option_info_comparator );
+}
+#endif
--- dhcp-3.0.2/includes/dhcpd.h.extended_option_environment 2004-11-24 12:39:16.000000000 -0500
+++ dhcp-3.0.2/includes/dhcpd.h 2005-04-05 17:49:36.613047777 -0400
@@ -1800,6 +1800,13 @@
void initialize_common_option_spaces PROTO ((void));
struct universe *config_universe;
+#ifdef EXTENDED_NEW_OPTION_INFO
+#define GENERATE_NEW_OPTION_INFO ((void*)1)
+extern void *new_option_info_tree;
+extern void *add_new_option_info( struct option*);
+extern void *lookup_new_option_info( struct option *);
+#endif
+
/* stables.c */
#if defined (FAILOVER_PROTOCOL)
extern failover_option_t null_failover_option;
--- dhcp-3.0.2/client/dhclient.c.extended_option_environment 2005-04-05 17:49:36.566054726 -0400
+++ dhcp-3.0.2/client/dhclient.c 2005-04-05 17:49:36.617047185 -0400
@@ -74,7 +74,9 @@
int onetry=0;
int quiet=0;
int nowait=0;
-
+#ifdef EXTENDED_NEW_OPTION_INFO
+int extended_option_environment = 0;
+#endif
static void usage PROTO ((void));
void do_release(struct client_state *);
@@ -204,6 +206,11 @@
} else if (!strcmp (argv [i], "--version")) {
log_info ("isc-dhclient-%s", DHCP_VERSION);
exit (0);
+#ifdef EXTENDED_NEW_OPTION_INFO
+ } else if (!strcmp (argv [i], "-x")) {
+ extended_option_environment = 1;
+ new_option_info_tree = GENERATE_NEW_OPTION_INFO;
+#endif
} else if (argv [i][0] == '-') {
usage ();
} else {
@@ -572,7 +579,11 @@
log_info (arr);
log_info (url);
+#ifdef EXTENDED_NEW_OPTION_INFO
+ log_error ("Usage: dhclient [-1dqr] [-nwx] [-p <port>] %s",
+#else
log_error ("Usage: dhclient [-1dqr] [-nw] [-p <port>] %s",
+#endif
"[-s server]");
log_error (" [-cf config-file] [-lf lease-file]%s",
"[-pf pid-file] [-e VAR=val]");
@@ -2529,8 +2540,28 @@
struct envadd_state {
struct client_state *client;
const char *prefix;
+ struct universe *universe;
};
+#ifdef EXTENDED_NEW_OPTION_INFO
+static
+void build_universe_info_envvar
+( struct option_cache *oc,
+ struct packet *p, struct lease *l,
+ struct client_state *client,
+ struct option_state *in_o,
+ struct option_state *cf_o,
+ struct binding_scope **scope,
+ struct universe *u, void *es
+)
+{
+ char info_name[512], info_data[512];
+ snprintf(info_name, 512, "%s._universe_.", oc->option->universe->name);
+ snprintf(info_data, 512, "%u:%s", oc->option->code,oc->option->format);
+ client_envadd( client, info_name, oc->option->name, info_data );
+}
+#endif
+
void client_option_envadd (struct option_cache *oc,
struct packet *packet, struct lease *lease,
struct client_state *client_state,
@@ -2547,6 +2578,31 @@
in_options, cfg_options, scope, oc, MDL)) {
if (data.len) {
char name [256];
+#ifdef EXTENDED_NEW_OPTION_INFO
+ if ( extended_option_environment )
+ {
+ if( ( oc->option->universe != &dhcp_universe )
+ &&( oc->option->universe->index > fqdn_universe.index )
+ &&( es->universe != oc->option->universe )
+ )
+ {
+ es->universe = oc->option->universe;
+ (*(es->universe->foreach))
+ ( (struct packet *)0, (struct lease *)0,
+ client_state,
+ in_options, cfg_options,
+ scope, es->universe, es,
+ build_universe_info_envvar
+ );
+ }else
+ if ( lookup_new_option_info(oc->option) != 0L )
+ build_universe_info_envvar
+ ( oc, packet, lease, client_state,
+ in_options, cfg_options, scope,
+ oc->option->universe, es
+ );
+ }
+#endif
if (dhcp_option_ev_name (name, sizeof name,
oc -> option)) {
client_envadd (es -> client, es -> prefix,
@@ -2575,6 +2631,7 @@
es.client = client;
es.prefix = prefix;
+ es.universe = 0L;
client_envadd (client,
prefix, "ip_address", "%s", piaddr (lease -> address));
@@ -2788,7 +2845,14 @@
s = option -> name;
if (j + 1 == buflen)
return 0;
+#ifdef EXTENDED_NEW_OPTION_INFO
+ if ( ! extended_option_environment )
+ buf [j++] = '_';
+ else
+ buf [j++] = '.';
+#else
buf [j++] = '_';
+#endif
}
++i;
} while (i != 2);
--- dhcp-3.0.2/client/dhclient.8.extended_option_environment 2004-09-29 19:01:46.000000000 -0400
+++ dhcp-3.0.2/client/dhclient.8 2005-04-05 17:49:36.619046889 -0400
@@ -78,6 +78,9 @@
.B -w
]
[
+.B -x
+]
+[
.I if0
[
.I ...ifN
@@ -252,6 +255,10 @@
supplying the
.B -nw
flag.
+.PP
+The -x argument enables eXtended option information to be created in the
+-s dhclient-script environment, which would allow applications running
+in that environment to handle options they do not know about in advance.
.SH CONFIGURATION
The syntax of the dhclient.conf(5) file is discussed separately.
.SH OMAPI
|