Remove IpEndpoint::accepts.
Unclear purpose, one use, we don't need it.
This commit is contained in:
parent
8724157b54
commit
ffbb885586
|
@ -188,12 +188,14 @@ impl<'a, 'b> UdpSocket<'a, 'b> {
|
|||
let packet = UdpPacket::new_checked(&payload[..ip_repr.payload_len()])?;
|
||||
let repr = UdpRepr::parse(&packet, &ip_repr.src_addr(), &ip_repr.dst_addr())?;
|
||||
|
||||
let endpoint = IpEndpoint { addr: ip_repr.src_addr(), port: repr.src_port };
|
||||
if !self.endpoint.accepts(&endpoint) { return Err(Error::Rejected) }
|
||||
// Reject packets with a wrong destination.
|
||||
if self.endpoint.port != repr.dst_port { return Err(Error::Rejected) }
|
||||
if !self.endpoint.addr.is_unspecified() &&
|
||||
self.endpoint.addr != ip_repr.dst_addr() { return Err(Error::Rejected) }
|
||||
|
||||
let packet_buf = self.rx_buffer.try_enqueue(|buf| buf.resize(repr.payload.len()))?;
|
||||
packet_buf.as_mut().copy_from_slice(repr.payload);
|
||||
packet_buf.endpoint = endpoint;
|
||||
packet_buf.endpoint = IpEndpoint { addr: ip_repr.src_addr(), port: repr.src_port };
|
||||
net_trace!("[{}]{}:{}: receiving {} octets",
|
||||
self.debug_id, self.endpoint,
|
||||
packet_buf.endpoint, packet_buf.size);
|
||||
|
|
|
@ -139,14 +139,6 @@ impl Endpoint {
|
|||
pub fn is_specified(&self) -> bool {
|
||||
!self.addr.is_unspecified() && self.port != 0
|
||||
}
|
||||
|
||||
/// Query whether `self` should accept packets from `other`.
|
||||
///
|
||||
/// Returns `true` if `other` is a specified endpoint and `self` either
|
||||
/// has an unspecified address, or the addresses are equal.
|
||||
pub fn accepts(&self, other: &Endpoint) -> bool {
|
||||
other.is_specified() && (self.addr == other.addr || self.addr.is_unspecified())
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Endpoint {
|
||||
|
|
Loading…
Reference in New Issue