Skip to content

Commit

Permalink
bump smoltcp
Browse files Browse the repository at this point in the history
  • Loading branch information
mhils committed May 16, 2024
1 parent c2c2ef5 commit dab3910
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 47 deletions.
63 changes: 31 additions & 32 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ futures-util = { version = "0.3.30", features = ["sink"] }
lru_time_cache = "0.11.11"
internet-packet = { version = "0.2.0", features = ["smoltcp"] }

# [patch.crates-io]
[patch.crates-io]
# tokio = { path = "../tokio/tokio" }
# smoltcp = { git = 'https://github.com/mhils/smoltcp', rev = 'f65351adfa92db5193f368368cb668bac721fe43' }
smoltcp = { git = 'https://github.com/smoltcp-rs/smoltcp', rev = 'ef67e7b46cabf49783053cbf68d8671ed97ff8d4' }

[target.'cfg(windows)'.dependencies.windows]
version = "0.56.0"
Expand Down
9 changes: 3 additions & 6 deletions src/network/icmp.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
use crate::messages::SmolPacket;
use smoltcp::phy::ChecksumCapabilities;
use smoltcp::wire::{
Icmpv4Message, Icmpv4Packet, Icmpv4Repr, Icmpv6Message, Icmpv6Packet, Icmpv6Repr, IpAddress,
IpProtocol, Ipv4Packet, Ipv4Repr, Ipv6Packet, Ipv6Repr,
};
use smoltcp::wire::{Icmpv4Message, Icmpv4Packet, Icmpv4Repr, Icmpv6Message, Icmpv6Packet, Icmpv6Repr, IpProtocol, Ipv4Packet, Ipv4Repr, Ipv6Packet, Ipv6Repr};

pub(super) fn handle_icmpv4_echo_request(
mut input_packet: Ipv4Packet<Vec<u8>>,
Expand Down Expand Up @@ -98,8 +95,8 @@ pub(super) fn handle_icmpv6_echo_request(
let mut output_ip_packet = SmolPacket::from(output_ipv6_packet);
icmp_repr.emit(
// Directing fake reply back to the original source address.
&IpAddress::from(dst_addr),
&IpAddress::from(src_addr),
&dst_addr,
&src_addr,
&mut Icmpv6Packet::new_unchecked(output_ip_packet.payload_mut()),
&ChecksumCapabilities::default(),
);
Expand Down
10 changes: 8 additions & 2 deletions src/network/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use anyhow::Result;
use pretty_hex::pretty_hex;
use smoltcp::iface::{Config, SocketSet};
use smoltcp::socket::{tcp, Socket};
use smoltcp::wire::HardwareAddress;
use smoltcp::wire::{HardwareAddress, Ipv6Address};
use smoltcp::{
iface::{Interface, SocketHandle},
time::Instant,
Expand Down Expand Up @@ -64,12 +64,18 @@ impl<'a> TcpHandler<'a> {
ip_address
.push(IpCidr::new(IpAddress::v4(0, 0, 0, 1), 0))
.unwrap();
ip_address
.push(IpCidr::new(IpAddress::v6(0, 0, 0, 0,0,0,0,1), 0))
.unwrap();
});
// TODO: IPv6
iface
.routes_mut()
.add_default_ipv4_route(Ipv4Address::new(0, 0, 0, 1))
.unwrap();
iface
.routes_mut()
.add_default_ipv6_route(Ipv6Address::new(0, 0, 0, 0,0,0,0,1))
.unwrap();

TcpHandler {
iface,
Expand Down
4 changes: 2 additions & 2 deletions src/network/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,8 @@ fn build_icmp6_echo_packet(
let mut output_ipv6_packet = Ipv6Packet::new_unchecked(buf);
ip_repr.emit(&mut output_ipv6_packet);
icmp_repr.emit(
&IpAddress::from(src_addr),
&IpAddress::from(dst_addr),
&src_addr,
&dst_addr,
&mut Icmpv6Packet::new_unchecked(output_ipv6_packet.payload_mut()),
&ChecksumCapabilities::default(),
);
Expand Down
4 changes: 1 addition & 3 deletions src/network/udp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ impl UdpHandler {
}

pub(crate) fn write_data(&mut self, id: ConnectionId, data: Vec<u8>) -> Option<UdpPacket> {
let Some((state, addrs)) = self.connections.get(&id) else {
return None;
};
let (state, addrs) = self.connections.get(&id)?;
// Refresh id lookup.
self.id_lookup.insert(*addrs, id);

Expand Down

0 comments on commit dab3910

Please sign in to comment.