Browse Source

[DHCP] Fix DHCP state confusion.

DHCP code was using an incorrect check for whether to construct a
DHCPDISCOVER or DHCPREQUEST packet.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
7234f91bf8
1 changed files with 5 additions and 2 deletions
  1. 5
    2
      src/net/udp/dhcp.c

+ 5
- 2
src/net/udp/dhcp.c View File

622
 		.netdev = dhcp->netdev,
622
 		.netdev = dhcp->netdev,
623
 	};
623
 	};
624
 	struct io_buffer *iobuf;
624
 	struct io_buffer *iobuf;
625
-	struct dhcp_packet *dhcpoffer;
625
+	struct dhcp_packet *dhcpoffer = NULL;
626
 	struct dhcp_packet dhcppkt;
626
 	struct dhcp_packet dhcppkt;
627
 	int rc;
627
 	int rc;
628
 	
628
 	
643
 		return -ENOMEM;
643
 		return -ENOMEM;
644
 
644
 
645
 	/* Create DHCP packet in temporary buffer */
645
 	/* Create DHCP packet in temporary buffer */
646
-	dhcpoffer = ( dhcp->response ? &dhcp->response->dhcppkt : NULL );
646
+	if ( dhcp->state == DHCPREQUEST ) {
647
+		assert ( dhcp->response );
648
+		dhcpoffer = &dhcp->response->dhcppkt;
649
+	}
647
 	if ( ( rc = create_dhcp_request ( &dhcppkt, dhcp->netdev,
650
 	if ( ( rc = create_dhcp_request ( &dhcppkt, dhcp->netdev,
648
 					  dhcpoffer, iobuf->data,
651
 					  dhcpoffer, iobuf->data,
649
 					  iob_tailroom ( iobuf ) ) ) != 0 ) {
652
 					  iob_tailroom ( iobuf ) ) ) != 0 ) {

Loading…
Cancel
Save