Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,17 @@ defmt = ["dep:defmt", "heapless/defmt"]

"async" = []

# Automatically reply on an ICMP echo request
"auto-icmp-echo-reply" = []

default = [
"std", "log", # needed for `cargo test --no-default-features --features default` :/
"medium-ethernet", "medium-ip", "medium-ieee802154",
"phy-raw_socket", "phy-tuntap_interface",
"proto-ipv4", "proto-dhcpv4", "proto-ipv6", "proto-dns",
"proto-ipv4-fragmentation", "proto-sixlowpan-fragmentation",
"socket-raw", "socket-icmp", "socket-udp", "socket-tcp", "socket-dhcpv4", "socket-dns", "socket-mdns",
"packetmeta-id", "async", "multicast"
"packetmeta-id", "async", "multicast", "auto-icmp-echo-reply"
]

# Private features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ The IGMPv1 and IGMPv2 protocols are supported, and IPv4 multicast is available.
The ICMPv4 protocol is supported, and ICMP sockets are available.

* ICMPv4 header checksum is supported.
* ICMPv4 echo replies are generated in response to echo requests.
* ICMPv4 echo replies are generated in response to echo requests by default.
* ICMP sockets can listen to ICMPv4 Port Unreachable messages, or any ICMPv4 messages with
a given IPv4 identifier field.
* ICMPv4 protocol unreachable messages are **not** passed to higher layers when received.
Expand All @@ -97,7 +97,7 @@ The ICMPv4 protocol is supported, and ICMP sockets are available.
The ICMPv6 protocol is supported, and ICMP sockets are available.

* ICMPv6 header checksum is supported.
* ICMPv6 echo replies are generated in response to echo requests.
* ICMPv6 echo replies are generated in response to echo requests by default.
* ICMPv6 protocol unreachable messages are **not** passed to higher layers when received.

#### NDISC
Expand Down
14 changes: 7 additions & 7 deletions ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@ FEATURES_TEST=(
"std,medium-ethernet,proto-ipv4,multicast,socket-raw,socket-dns"
"std,medium-ethernet,proto-ipv4,socket-udp,socket-tcp,socket-dns"
"std,medium-ethernet,proto-ipv4,proto-dhcpv4,socket-udp"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv6,multicast,proto-rpl,socket-udp,socket-dns"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv6,multicast,proto-rpl,socket-udp,socket-dns,auto-icmp-echo-reply"
"std,medium-ethernet,proto-ipv6,socket-tcp"
"std,medium-ethernet,medium-ip,proto-ipv4,socket-icmp,socket-tcp"
"std,medium-ip,proto-ipv6,socket-icmp,socket-tcp"
"std,medium-ieee802154,proto-sixlowpan,socket-udp"
"std,medium-ieee802154,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp"
"std,medium-ieee802154,proto-rpl,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp"
"std,medium-ieee802154,proto-sixlowpan,socket-udp,auto-icmp-echo-reply"
"std,medium-ieee802154,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp,auto-icmp-echo-reply"
"std,medium-ieee802154,proto-rpl,proto-sixlowpan,proto-sixlowpan-fragmentation,socket-udp,auto-icmp-echo-reply"
"std,medium-ip,proto-ipv4,proto-ipv6,socket-tcp,socket-udp"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv4,proto-ipv6,multicast,proto-rpl,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"std,medium-ethernet,medium-ip,medium-ieee802154,proto-ipv4,proto-ipv6,multicast,proto-rpl,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async,auto-icmp-echo-reply"
"std,medium-ip,proto-ipv4,proto-ipv6,multicast,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"std,medium-ieee802154,medium-ip,proto-ipv4,socket-raw"
"std,medium-ieee802154,medium-ip,proto-ipv4,socket-raw,auto-icmp-echo-reply"
"std,medium-ethernet,proto-ipv4,proto-ipsec,socket-raw"
)

Expand All @@ -43,7 +43,7 @@ FEATURES_CHECK=(
"medium-ip,medium-ethernet,medium-ieee802154,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,proto-ipsec,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"defmt,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"defmt,alloc,medium-ip,medium-ethernet,proto-ipv6,proto-ipv6,multicast,proto-dhcpv4,socket-raw,socket-udp,socket-tcp,socket-icmp,socket-dns,async"
"medium-ieee802154,proto-sixlowpan,socket-dns"
"medium-ieee802154,proto-sixlowpan,socket-dns,auto-icmp-echo-reply"
)

test() {
Expand Down
3 changes: 2 additions & 1 deletion src/iface/interface/ipv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl InterfaceInner {

match icmp_repr {
// Respond to echo requests.
#[cfg(feature = "proto-ipv4")]
#[cfg(all(feature = "proto-ipv4", feature = "auto-icmp-echo-reply"))]
Icmpv4Repr::EchoRequest {
ident,
seq_no,
Expand All @@ -368,6 +368,7 @@ impl InterfaceInner {
_ if handled_by_icmp_socket => None,

// FIXME: do something correct here?
// By doing nothing, this arm handles the case when auto echo replies are disabled.
_ => None,
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/iface/interface/ipv6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ impl InterfaceInner {

match icmp_repr {
// Respond to echo requests.
#[cfg(feature = "auto-icmp-echo-reply")]
Icmpv6Repr::EchoRequest {
ident,
seq_no,
Expand Down Expand Up @@ -441,6 +442,7 @@ impl InterfaceInner {
_ if handled_by_icmp_socket => None,

// FIXME: do something correct here?
// By doing nothing, this arm handles the case when auto echo replies are disabled.
_ => None,
}
}
Expand Down
16 changes: 12 additions & 4 deletions src/iface/interface/tests/ipv4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,9 @@ fn test_icmp_error_port_unreachable(#[case] medium: Medium) {

#[rstest]
#[case(Medium::Ip)]
#[cfg(feature = "medium-ip")]
#[cfg(all(feature = "medium-ip", feature = "auto-icmp-echo-reply"))]
#[case(Medium::Ethernet)]
#[cfg(feature = "medium-ethernet")]
#[cfg(all(feature = "medium-ethernet", feature = "auto-icmp-echo-reply"))]
fn test_handle_ipv4_broadcast(#[case] medium: Medium) {
use crate::wire::{Icmpv4Packet, Icmpv4Repr};

Expand Down Expand Up @@ -626,9 +626,17 @@ fn test_arp_flush_after_update_ip(#[case] medium: Medium) {

#[rstest]
#[case(Medium::Ip)]
#[cfg(all(feature = "socket-icmp", feature = "medium-ip"))]
#[cfg(all(
feature = "socket-icmp",
feature = "medium-ip",
feature = "auto-icmp-echo-reply",
))]
#[case(Medium::Ethernet)]
#[cfg(all(feature = "socket-icmp", feature = "medium-ethernet"))]
#[cfg(all(
feature = "socket-icmp",
feature = "medium-ethernet",
feature = "auto-icmp-echo-reply",
))]
fn test_icmpv4_socket(#[case] medium: Medium) {
use crate::wire::Icmpv4Packet;

Expand Down