Browse Source

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 years ago
parent
commit
6c01d3bb95
2 changed files with 12 additions and 7 deletions
  1. 11
    1
      src/include/gpxe/dhcp.h
  2. 1
    6
      src/net/udp/dhcp.c

+ 11
- 1
src/include/gpxe/dhcp.h View File

23
 	uint8_t op;
23
 	uint8_t op;
24
 	/** Hardware address type
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
 	uint8_t htype;
30
 	uint8_t htype;
29
 	/** Hardware address length */
31
 	/** Hardware address length */
274
 	signed int priority;
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
 extern unsigned long dhcp_num_option ( struct dhcp_option *option );
287
 extern unsigned long dhcp_num_option ( struct dhcp_option *option );
278
 extern struct dhcp_option *
288
 extern struct dhcp_option *
279
 find_dhcp_option ( struct dhcp_option_block *options, unsigned int tag );
289
 find_dhcp_option ( struct dhcp_option_block *options, unsigned int tag );

+ 1
- 6
src/net/udp/dhcp.c View File

29
  *
29
  *
30
  */
30
  */
31
 
31
 
32
-struct dhcp_session {
33
-	struct net_device *netdev;
34
-	uint32_t xid;
35
-};
36
-
37
 /** DHCP operation types
32
 /** DHCP operation types
38
  *
33
  *
39
  * This table maps from DHCP message types (i.e. values of the @c
34
  * This table maps from DHCP message types (i.e. values of the @c
186
 	dhcppkt->op = dhcp_op[dhcp_message_type];
181
 	dhcppkt->op = dhcp_op[dhcp_message_type];
187
 
182
 
188
 	/* Fill in NIC details */
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
 	dhcppkt->hlen = dhcp->netdev->ll_protocol->ll_addr_len;
185
 	dhcppkt->hlen = dhcp->netdev->ll_protocol->ll_addr_len;
191
 	memcpy ( dhcppkt->chaddr, dhcp->netdev->ll_addr, dhcppkt->hlen );
186
 	memcpy ( dhcppkt->chaddr, dhcp->netdev->ll_addr, dhcppkt->hlen );
192
 
187
 

Loading…
Cancel
Save