From 85487bf3bc318343ab2dc9028f69329522e7a15a Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 22 Dec 2017 13:07:11 +0000 Subject: [PATCH] EthernetInterface::set_ipv4_gateway should panic on non-unicast addrs. --- src/iface/ethernet.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/iface/ethernet.rs b/src/iface/ethernet.rs index a3c3552..1cb3410 100644 --- a/src/iface/ethernet.rs +++ b/src/iface/ethernet.rs @@ -250,9 +250,13 @@ impl<'b, 'c, DeviceT> Interface<'b, 'c, DeviceT> } /// Set the IPv4 gateway of the interface. + /// + /// # Panics + /// This function panics if the given address is not unicast. pub fn set_ipv4_gateway(&mut self, gateway: GatewayAddrT) where GatewayAddrT: Into> { self.inner.ipv4_gateway = gateway.into(); + self.inner.ipv4_gateway.map(|addr| InterfaceInner::check_gateway_addr(&addr)); } /// Transmit packets queued in the given sockets, and receive packets queued