Bläddra i källkod

Fix creation of the htype field; the ll_proto field from which it is

derived is a 16-bit big-endian field, but htype is only 8 bits wide.
tags/v0.9.3
Michael Brown 18 år sedan
förälder
incheckning
6c01d3bb95
2 ändrade filer med 12 tillägg och 7 borttagningar
  1. 11
    1
      src/include/gpxe/dhcp.h
  2. 1
    6
      src/net/udp/dhcp.c

+ 11
- 1
src/include/gpxe/dhcp.h Visa fil

@@ -23,7 +23,9 @@ struct dhcp_packet {
23 23
 	uint8_t op;
24 24
 	/** Hardware address type
25 25
 	 *
26
-	 * This is an ARPHRD_XXX constant.
26
+	 * This is an ARPHRD_XXX constant.  Note that ARPHRD_XXX
27
+	 * constants are nominally 16 bits wide; this could be
28
+	 * considered to be a bug in the BOOTP/DHCP specification.
27 29
 	 */
28 30
 	uint8_t htype;
29 31
 	/** Hardware address length */
@@ -274,6 +276,14 @@ struct dhcp_option_block {
274 276
 	signed int priority;
275 277
 };
276 278
 
279
+/** A DHCP session */
280
+struct dhcp_session {
281
+	/** Network device being configured */
282
+	struct net_device *netdev;
283
+	/** Transaction ID, in network-endian order */
284
+	uint32_t xid;
285
+};
286
+
277 287
 extern unsigned long dhcp_num_option ( struct dhcp_option *option );
278 288
 extern struct dhcp_option *
279 289
 find_dhcp_option ( struct dhcp_option_block *options, unsigned int tag );

+ 1
- 6
src/net/udp/dhcp.c Visa fil

@@ -29,11 +29,6 @@
29 29
  *
30 30
  */
31 31
 
32
-struct dhcp_session {
33
-	struct net_device *netdev;
34
-	uint32_t xid;
35
-};
36
-
37 32
 /** DHCP operation types
38 33
  *
39 34
  * This table maps from DHCP message types (i.e. values of the @c
@@ -186,7 +181,7 @@ size_t dhcp_assemble ( struct dhcp_session *dhcp, void *data,
186 181
 	dhcppkt->op = dhcp_op[dhcp_message_type];
187 182
 
188 183
 	/* Fill in NIC details */
189
-	dhcppkt->htype = dhcp->netdev->ll_protocol->ll_proto;
184
+	dhcppkt->htype = ntohs ( dhcp->netdev->ll_protocol->ll_proto );
190 185
 	dhcppkt->hlen = dhcp->netdev->ll_protocol->ll_addr_len;
191 186
 	memcpy ( dhcppkt->chaddr, dhcp->netdev->ll_addr, dhcppkt->hlen );
192 187
 

Laddar…
Avbryt
Spara