]> git.pld-linux.org Git - packages/dhcp.git/blob - dhcp-3.0.3-x-option.patch
- updated
[packages/dhcp.git] / dhcp-3.0.3-x-option.patch
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
3 @@ -1270,6 +1270,10 @@
4                              option, MDL);
5         option_name_hash_add(option->universe->name_hash, option->name, 0,
6                              option, MDL);
7 +#ifdef EXTENDED_NEW_OPTION_INFO
8 +       if ( new_option_info_tree != 0L )
9 +               add_new_option_info( option );
10 +#endif
11         return 1;
12  }
13  
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,
18                            &fqdn_universe, MDL);
19  }
20 +
21 +#ifdef EXTENDED_NEW_OPTION_INFO
22 +#include <search.h>
23 +
24 +void *new_option_info_tree = 0L;
25 +
26 +static int  new_option_info_comparator( const void* p1, const void *p2 )
27 +{
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) 
33 +               ? 0 
34 +               :( ( ocode1 > ocode2 )
35 +                  ?  1
36 +                  : -1
37 +                )
38 +             );
39 +}
40 +
41 +void *add_new_option_info( struct option *option )
42 +{
43 +       if ( option->universe->index >= fqdn_universe.index )
44 +               return 0L;
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 );
48 +}
49 +
50 +void *lookup_new_option_info( struct option *option )
51 +{
52 +       if ( new_option_info_tree == GENERATE_NEW_OPTION_INFO )
53 +               return 0L;
54 +       return tfind( option, &(new_option_info_tree), new_option_info_comparator );
55 +}
56 +#endif
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;
62  
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 *);
68 +#endif
69 +
70  /* stables.c */
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
75 @@ -74,7 +74,9 @@
76  int onetry=0;
77  int quiet=0;
78  int nowait=0;
79 -
80 +#ifdef EXTENDED_NEW_OPTION_INFO
81 +int extended_option_environment = 0;
82 +#endif
83  static void usage PROTO ((void));
84  
85  void do_release(struct client_state *);
86 @@ -204,6 +206,11 @@
87                 } else if (!strcmp (argv [i], "--version")) {
88                         log_info ("isc-dhclient-%s", DHCP_VERSION);
89                         exit (0);
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;
94 +#endif
95                 } else if (argv [i][0] == '-') {
96                     usage ();
97                 } else {
98 @@ -572,7 +579,11 @@
99         log_info (arr);
100         log_info (url);
101  
102 +#ifdef EXTENDED_NEW_OPTION_INFO
103 +       log_error ("Usage: dhclient [-1dqrx] [-nwy] [-p <port>] %s",
104 +#else
105         log_error ("Usage: dhclient [-1dqrx] [-nw] [-p <port>] %s",
106 +#endif
107                    "[-s server]");
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;
113         const char *prefix;
114 +        struct universe *universe;
115  };
116  
117 +#ifdef EXTENDED_NEW_OPTION_INFO                        
118 +static 
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              
127 +)
128 +{
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 );
133 +}
134 +#endif
135 +
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)) {
141                 if (data.len) {
142                         char name [256];
143 +#ifdef EXTENDED_NEW_OPTION_INFO                        
144 +                       if (  extended_option_environment )
145 +                       {
146 +                               if(  ( oc->option->universe != &dhcp_universe )
147 +                                  &&( oc->option->universe->index > fqdn_universe.index )
148 +                                  &&( es->universe !=  oc->option->universe )
149 +                                 )
150 +                               {
151 +                                       es->universe = oc->option->universe;
152 +                                       (*(es->universe->foreach))
153 +                                            (  (struct packet *)0, (struct lease *)0, 
154 +                                               client_state, 
155 +                                               in_options, cfg_options, 
156 +                                               scope, es->universe, es, 
157 +                                               build_universe_info_envvar
158 +                                            );
159 +                               }else
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 
165 +                                             );
166 +                       }
167 +#endif
168                         if (dhcp_option_ev_name (name, sizeof name,
169                                                  oc -> option)) {
170                                 client_envadd (es -> client, es -> prefix,
171 @@ -2575,6 +2631,7 @@
172  
173         es.client = client;
174         es.prefix = prefix;
175 +       es.universe = 0L;
176  
177         client_envadd (client,
178                        prefix, "ip_address", "%s", piaddr (lease -> address));
179 @@ -2788,7 +2845,14 @@
180                         s = option -> name;
181                         if (j + 1 == buflen)
182                                 return 0;
183 +#ifdef EXTENDED_NEW_OPTION_INFO
184 +                       if ( ! extended_option_environment )
185 +                           buf [j++] = '_';
186 +                       else
187 +                           buf [j++] = '.';
188 +#else
189                         buf [j++] = '_';
190 +#endif
191                 }
192                 ++i;
193         } while (i != 2);
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
196 @@ -78,6 +78,9 @@
197  .B -w
198  ]
199  [
200 +.B -y
201 +]
202 +[
203  .I if0
204  [
205  .I ...ifN
206 @@ -252,6 +255,10 @@
207  supplying the
208  .B -nw
209  flag.
210 +.PP
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.
214  .SH CONFIGURATION
215  The syntax of the dhclient.conf(5) file is discussed separately.
216  .SH OMAPI
This page took 0.040166 seconds and 3 git commands to generate.