Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: ffe2de73c18a
Choose a base ref
...
head repository: smoltcp-rs/smoltcp
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: c5aa37185f63
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Jul 24, 2017

  1. Copy the full SHA
    c6d4823 View commit details
  2. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    c5aa371 View commit details
Showing with 12 additions and 11 deletions.
  1. +12 −11 src/iface/ethernet.rs
23 changes: 12 additions & 11 deletions src/iface/ethernet.rs
Original file line number Diff line number Diff line change
@@ -210,8 +210,11 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
<Socket as AsSocket<RawSocket>>::try_as_socket) {
match raw_socket.process(timestamp, &IpRepr::Ipv4(ipv4_repr),
ipv4_packet.payload()) {
// The packet is valid and handled by socket.
Ok(()) => handled_by_raw_socket = true,
Err(Error::Rejected) => (),
// The packet isn't addressed to the socket, or cannot be accepted by it.
Err(Error::Rejected) | Err(Error::Exhausted) => (),
// Raw sockets either accept or reject packets, not parse them.
_ => unreachable!(),
}
}
@@ -232,7 +235,7 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
Ok(Response::Nop),
_ => {
let icmp_reply_repr = Icmpv4Repr::DstUnreachable {
reason: Icmpv4DstUnreachable::PortUnreachable,
reason: Icmpv4DstUnreachable::ProtoUnreachable,
header: ipv4_repr,
data: &ipv4_packet.payload()[0..8]
};
@@ -287,17 +290,16 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
for udp_socket in sockets.iter_mut().filter_map(
<Socket as AsSocket<UdpSocket>>::try_as_socket) {
match udp_socket.process(timestamp, &ip_repr, ip_payload) {
// The packet was valid and handled by socket.
// The packet is valid and handled by socket.
Ok(()) => return Ok(Response::Nop),
// The packet wasn't addressed to the socket.
// The packet isn't addressed to the socket.
Err(Error::Rejected) => continue,
// The packet was addressed to the socket but is malformed.
Err(Error::Malformed) => break,
// The packet is malformed, or addressed to the socket but cannot be accepted.
Err(e) => return Err(e)
}
}

//The packet wasn't handled by a socket, send an ICMP port unreachable packet.
// The packet wasn't handled by a socket, send an ICMP port unreachable packet.
let icmp_reply_repr = Icmpv4Repr::DstUnreachable {
reason: Icmpv4DstUnreachable::PortUnreachable,
header: ipv4_repr,
@@ -320,13 +322,12 @@ impl<'a, 'b, 'c, DeviceT: Device + 'a> Interface<'a, 'b, 'c, DeviceT> {
for tcp_socket in sockets.iter_mut().filter_map(
<Socket as AsSocket<TcpSocket>>::try_as_socket) {
match tcp_socket.process(timestamp, &ip_repr, ip_payload) {
// The packet was valid and handled by socket.
// The packet is valid and handled by socket.
Ok(()) => return Ok(Response::Nop),
// The packet wasn't addressed to the socket.
// The packet isn't addressed to the socket.
// Send RST only if no other socket accepts the packet.
Err(Error::Rejected) => continue,
// The packet was addressed to the socket but is malformed.
Err(Error::Malformed) => break,
// The packet is malformed, or addressed to the socket but cannot be accepted.
Err(e) => return Err(e)
}
}