Переглянути джерело

Don't build option-overloaded packets; they just confuse people (ISC

DHCPD and Windows RIS in particular).
tags/v0.9.3
Michael Brown 17 роки тому
джерело
коміт
acd598b4f9
3 змінених файлів з 23 додано та 55 видалено
  1. 8
    0
      contrib/bochs/README.windows-ris
  2. 4
    24
      src/include/gpxe/dhcp.h
  3. 11
    31
      src/net/udp/dhcp.c

+ 8
- 0
contrib/bochs/README.windows-ris Переглянути файл

@@ -21,3 +21,11 @@ startrom.com in a hex editor, search for the hex string
21 21
 now accept the "F" key instead of "F12".
22 22
 
23 23
 
24
+
25
+DHCP filename
26
+=============
27
+
28
+Must use Windows backslash separator e.g. 'filename
29
+"OSChooser\\i386\\startrom.com";', otherwise startrom.com fails to
30
+correctly identify the path to NTLDR.
31
+

+ 4
- 24
src/include/gpxe/dhcp.h Переглянути файл

@@ -387,12 +387,12 @@ struct dhcphdr {
387 387
 	 *
388 388
 	 * This field may be overridden and contain DHCP options
389 389
 	 */
390
-	uint8_t sname[64];
390
+	char sname[64];
391 391
 	/** Boot file name (null terminated)
392 392
 	 *
393 393
 	 * This field may be overridden and contain DHCP options
394 394
 	 */
395
-	uint8_t file[128];
395
+	char file[128];
396 396
 	/** DHCP magic cookie
397 397
 	 *
398 398
 	 * Must have the value @c DHCP_MAGIC_COOKIE.
@@ -423,20 +423,6 @@ struct dhcphdr {
423 423
  */
424 424
 #define DHCP_MIN_LEN 552
425 425
 
426
-/** DHCP packet option block fill order
427
- *
428
- * This is the order in which option blocks are filled when
429
- * reassembling a DHCP packet.  We fill the smallest field ("sname")
430
- * first, to maximise the chances of being able to fit large options
431
- * within fields which are large enough to contain them.
432
- */
433
-enum dhcp_packet_option_block_fill_order {
434
-	OPTS_SNAME = 0,
435
-	OPTS_FILE,
436
-	OPTS_MAIN,
437
-	NUM_OPT_BLOCKS
438
-};
439
-
440 426
 /**
441 427
  * A DHCP packet
442 428
  *
@@ -448,14 +434,8 @@ struct dhcp_packet {
448 434
 	size_t max_len;
449 435
 	/** Used length of the DHCP packet buffer */
450 436
 	size_t len;
451
-	/** DHCP option blocks within a DHCP packet
452
-	 *
453
-	 * A DHCP packet contains three fields which can be used to
454
-	 * contain options: the actual "options" field plus the "file"
455
-	 * and "sname" fields (which can be overloaded to contain
456
-	 * options).
457
-	 */
458
-	struct dhcp_option_block options[NUM_OPT_BLOCKS];
437
+	/** DHCP options */
438
+	struct dhcp_option_block options;
459 439
 };
460 440
 
461 441
 /**

+ 11
- 31
src/net/udp/dhcp.c Переглянути файл

@@ -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,

Завантаження…
Відмінити
Зберегти