socket/dhcp: Use random transaction_id instead of sequential.

This is a minor security improvement against blind packet spoofing, since
it adds more entropy to the packets.
master
Dario Nieuwenhuis 2021-10-14 14:10:08 +02:00
parent d34f4f783b
commit af4db615f5
1 changed files with 2 additions and 2 deletions

View File

@ -340,9 +340,9 @@ impl Dhcpv4Socket {
// 0x0f * 4 = 60 bytes.
const MAX_IPV4_HEADER_LEN: usize = 60;
// We don't directly increment transaction_id because sending the packet
// We don't directly modify self.transaction_id because sending the packet
// may fail. We only want to update state after succesfully sending.
let next_transaction_id = self.transaction_id + 1;
let next_transaction_id = crate::rand::rand_u32();
let mut dhcp_repr = DhcpRepr {
message_type: DhcpMessageType::Discover,