@@ -574,13 +574,9 @@ impl<'a> Socket<'a> {
574
574
// 0x0f * 4 = 60 bytes.
575
575
const MAX_IPV4_HEADER_LEN : usize = 60 ;
576
576
577
- // We don't directly modify self.transaction_id because sending the packet
578
- // may fail. We only want to update state after successfully sending.
579
- let next_transaction_id = Self :: random_transaction_id ( cx) ;
580
-
581
577
let mut dhcp_repr = DhcpRepr {
582
578
message_type : DhcpMessageType :: Discover ,
583
- transaction_id : next_transaction_id ,
579
+ transaction_id : self . transaction_id ,
584
580
secs : 0 ,
585
581
client_hardware_address : ethernet_addr,
586
582
client_ip : Ipv4Address :: UNSPECIFIED ,
@@ -624,6 +620,9 @@ impl<'a> Socket<'a> {
624
620
return Ok ( ( ) ) ;
625
621
}
626
622
623
+ let next_transaction_id = Self :: random_transaction_id ( cx) ;
624
+ dhcp_repr. transaction_id = next_transaction_id;
625
+
627
626
// send packet
628
627
net_debug ! (
629
628
"DHCP send DISCOVER to {}: {:?}" ,
@@ -666,7 +665,6 @@ impl<'a> Socket<'a> {
666
665
+ ( self . retry_config . initial_request_timeout << ( state. retry as u32 / 2 ) ) ;
667
666
state. retry += 1 ;
668
667
669
- self . transaction_id = next_transaction_id;
670
668
Ok ( ( ) )
671
669
}
672
670
ClientState :: Renewing ( state) => {
@@ -692,6 +690,9 @@ impl<'a> Socket<'a> {
692
690
dhcp_repr. message_type = DhcpMessageType :: Request ;
693
691
dhcp_repr. client_ip = state. config . address . address ( ) ;
694
692
693
+ let next_transaction_id = Self :: random_transaction_id ( cx) ;
694
+ dhcp_repr. transaction_id = next_transaction_id;
695
+
695
696
net_debug ! ( "DHCP send renew to {}: {:?}" , ipv4_repr. dst_addr, dhcp_repr) ;
696
697
ipv4_repr. payload_len = udp_repr. header_len ( ) + dhcp_repr. buffer_len ( ) ;
697
698
emit ( cx, ( ipv4_repr, udp_repr, dhcp_repr) ) ?;
0 commit comments