dhcp: convert port check to hard assert.

This commit is contained in:
Dario Nieuwenhuis 2021-05-28 18:43:52 +02:00
parent 07c3a402a3
commit a81f2fef56
1 changed files with 2 additions and 3 deletions

View File

@ -161,9 +161,8 @@ impl Dhcpv4Socket {
pub(crate) fn process(&mut self, now: Instant, ethernet_addr: EthernetAddress, ip_repr: &Ipv4Repr, repr: &UdpRepr, payload: &[u8]) -> Result<()> {
let src_ip = ip_repr.src_addr;
if repr.src_port != DHCP_SERVER_PORT || repr.dst_port != DHCP_CLIENT_PORT {
return Ok(())
}
// This is enforced in interface.rs.
assert!(repr.src_port == DHCP_SERVER_PORT && repr.dst_port == DHCP_CLIENT_PORT);
let dhcp_packet = match DhcpPacket::new_checked(payload) {
Ok(dhcp_packet) => dhcp_packet,