|
@@ -138,7 +138,7 @@ static int set_dhcp_packet_option ( struct dhcp_packet *dhcppkt,
|
138
|
138
|
unsigned int tag, const void *data,
|
139
|
139
|
size_t len ) {
|
140
|
140
|
struct dhcphdr *dhcphdr = dhcppkt->dhcphdr;
|
141
|
|
- struct dhcp_option_block *options = dhcppkt->options;
|
|
141
|
+ struct dhcp_option_block *options = &dhcppkt->options;
|
142
|
142
|
struct dhcp_option *option = NULL;
|
143
|
143
|
|
144
|
144
|
/* Special-case the magic options */
|
|
@@ -152,31 +152,23 @@ static int set_dhcp_packet_option ( struct dhcp_packet *dhcppkt,
|
152
|
152
|
case DHCP_EB_SIADDR:
|
153
|
153
|
memcpy ( &dhcphdr->siaddr, data, sizeof ( dhcphdr->siaddr ) );
|
154
|
154
|
return 0;
|
155
|
|
- case DHCP_MESSAGE_TYPE:
|
156
|
|
- case DHCP_REQUESTED_ADDRESS:
|
157
|
|
- case DHCP_PARAMETER_REQUEST_LIST:
|
158
|
|
- /* These options have to be within the main options
|
159
|
|
- * block. This doesn't seem to be required by the
|
160
|
|
- * RFCs, but at least ISC dhcpd refuses to recognise
|
161
|
|
- * them otherwise.
|
162
|
|
- */
|
163
|
|
- options = &dhcppkt->options[OPTS_MAIN];
|
164
|
|
- break;
|
|
155
|
+ case DHCP_TFTP_SERVER_NAME:
|
|
156
|
+ strncpy ( dhcphdr->sname, data, sizeof ( dhcphdr->sname ) );
|
|
157
|
+ return 0;
|
|
158
|
+ case DHCP_BOOTFILE_NAME:
|
|
159
|
+ strncpy ( dhcphdr->file, data, sizeof ( dhcphdr->file ) );
|
|
160
|
+ return 0;
|
165
|
161
|
default:
|
166
|
162
|
/* Continue processing as normal */
|
167
|
163
|
break;
|
168
|
164
|
}
|
169
|
165
|
|
170
|
|
- /* Set option in first available options block */
|
171
|
|
- for ( ; options < &dhcppkt->options[NUM_OPT_BLOCKS] ; options++ ) {
|
172
|
|
- option = set_dhcp_option ( options, tag, data, len );
|
173
|
|
- if ( option )
|
174
|
|
- break;
|
175
|
|
- }
|
|
166
|
+ /* Set option */
|
|
167
|
+ option = set_dhcp_option ( options, tag, data, len );
|
176
|
168
|
|
177
|
169
|
/* Update DHCP packet length */
|
178
|
170
|
dhcppkt->len = ( offsetof ( typeof ( *dhcppkt->dhcphdr ), options )
|
179
|
|
- + dhcppkt->options[OPTS_MAIN].len );
|
|
171
|
+ + dhcppkt->options.len );
|
180
|
172
|
|
181
|
173
|
return ( option ? 0 : -ENOSPC );
|
182
|
174
|
}
|
|
@@ -296,8 +288,6 @@ int create_dhcp_packet ( struct net_device *netdev, uint8_t msgtype,
|
296
|
288
|
void *data, size_t max_len,
|
297
|
289
|
struct dhcp_packet *dhcppkt ) {
|
298
|
290
|
struct dhcphdr *dhcphdr = data;
|
299
|
|
- static const uint8_t overloading = ( DHCP_OPTION_OVERLOAD_FILE |
|
300
|
|
- DHCP_OPTION_OVERLOAD_SNAME );
|
301
|
291
|
int rc;
|
302
|
292
|
|
303
|
293
|
/* Sanity check */
|
|
@@ -316,20 +306,10 @@ int create_dhcp_packet ( struct net_device *netdev, uint8_t msgtype,
|
316
|
306
|
/* Initialise DHCP packet structure */
|
317
|
307
|
dhcppkt->dhcphdr = dhcphdr;
|
318
|
308
|
dhcppkt->max_len = max_len;
|
319
|
|
- init_dhcp_options ( &dhcppkt->options[OPTS_MAIN], dhcphdr->options,
|
|
309
|
+ init_dhcp_options ( &dhcppkt->options, dhcphdr->options,
|
320
|
310
|
( max_len -
|
321
|
311
|
offsetof ( typeof ( *dhcphdr ), options ) ) );
|
322
|
|
- init_dhcp_options ( &dhcppkt->options[OPTS_FILE], dhcphdr->file,
|
323
|
|
- sizeof ( dhcphdr->file ) );
|
324
|
|
- init_dhcp_options ( &dhcppkt->options[OPTS_SNAME], dhcphdr->sname,
|
325
|
|
- sizeof ( dhcphdr->sname ) );
|
326
|
312
|
|
327
|
|
- /* Set DHCP_OPTION_OVERLOAD option within the main options block */
|
328
|
|
- if ( set_dhcp_option ( &dhcppkt->options[OPTS_MAIN],
|
329
|
|
- DHCP_OPTION_OVERLOAD, &overloading,
|
330
|
|
- sizeof ( overloading ) ) == NULL )
|
331
|
|
- return -ENOSPC;
|
332
|
|
-
|
333
|
313
|
/* Set DHCP_MESSAGE_TYPE option */
|
334
|
314
|
if ( ( rc = set_dhcp_packet_option ( dhcppkt, DHCP_MESSAGE_TYPE,
|
335
|
315
|
&msgtype,
|