Skip to content

Commit

Permalink
Merge pull request #1479 from hermit-os/dependabot/cargo/smoltcp-0.12.0
Browse files Browse the repository at this point in the history
build(deps): Bump smoltcp from 0.11.0 to 0.12.0
  • Loading branch information
mkroening authored Dec 3, 2024
2 parents d227297 + f92ada0 commit e5ea9ac
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 23 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ volatile = "0.6"
zerocopy = { version = "0.8", default-features = false }

[dependencies.smoltcp]
version = "0.11"
version = "0.12"
optional = true
default-features = false
features = [
Expand Down
30 changes: 15 additions & 15 deletions src/executor/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,25 +116,25 @@ impl<'a> NetworkInterface<'a> {
// calculate the netmask length
// => count the number of contiguous 1 bits,
// starting at the most significant bit in the first octet
let mut prefix_len = (!mymask.as_bytes()[0]).trailing_zeros();
let mut prefix_len = (!mymask.octets()[0]).trailing_zeros();
if prefix_len == 8 {
prefix_len += (!mymask.as_bytes()[1]).trailing_zeros();
prefix_len += (!mymask.octets()[1]).trailing_zeros();
}
if prefix_len == 16 {
prefix_len += (!mymask.as_bytes()[2]).trailing_zeros();
prefix_len += (!mymask.octets()[2]).trailing_zeros();
}
if prefix_len == 24 {
prefix_len += (!mymask.as_bytes()[3]).trailing_zeros();
prefix_len += (!mymask.octets()[3]).trailing_zeros();
}

let ethernet_addr = EthernetAddress([mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]]);
let hardware_addr = HardwareAddress::Ethernet(ethernet_addr);
let ip_addrs = [IpCidr::new(
IpAddress::v4(
myip.as_bytes()[0],
myip.as_bytes()[1],
myip.as_bytes()[2],
myip.as_bytes()[3],
myip.octets()[0],
myip.octets()[1],
myip.octets()[2],
myip.octets()[3],
),
prefix_len.try_into().unwrap(),
)];
Expand All @@ -157,10 +157,10 @@ impl<'a> NetworkInterface<'a> {
ip_addrs
.push(IpCidr::new(
IpAddress::v4(
myip.as_bytes()[0],
myip.as_bytes()[1],
myip.as_bytes()[2],
myip.as_bytes()[3],
myip.octets()[0],
myip.octets()[1],
myip.octets()[2],
myip.octets()[3],
),
prefix_len.try_into().unwrap(),
))
Expand Down Expand Up @@ -228,11 +228,11 @@ impl RxToken {
}

impl phy::RxToken for RxToken {
fn consume<R, F>(mut self, f: F) -> R
fn consume<R, F>(self, f: F) -> R
where
F: FnOnce(&mut [u8]) -> R,
F: FnOnce(&[u8]) -> R,
{
f(&mut self.buffer[..])
f(&self.buffer[..])
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/executor/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::sync::atomic::{AtomicU16, Ordering};
use core::task::Poll;

use hermit_sync::InterruptTicketMutex;
use smoltcp::iface::{SocketHandle, SocketSet};
use smoltcp::iface::{PollResult, SocketHandle, SocketSet};
#[cfg(feature = "dhcpv4")]
use smoltcp::socket::dhcpv4;
#[cfg(feature = "dns")]
Expand Down Expand Up @@ -263,7 +263,7 @@ impl<'a> NetworkInterface<'a> {
Ok(tcp_handle)
}

pub(crate) fn poll_common(&mut self, timestamp: Instant) -> bool {
pub(crate) fn poll_common(&mut self, timestamp: Instant) -> PollResult {
self.iface
.poll(timestamp, &mut self.device, &mut self.sockets)
}
Expand Down
10 changes: 7 additions & 3 deletions src/syscalls/socket.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ impl From<IpEndpoint> for sockaddr_in {
match endpoint.addr {
IpAddress::Ipv4(ip) => {
let sin_addr = in_addr {
s_addr: u32::from_ne_bytes(ip.as_bytes().try_into().unwrap()),
s_addr: u32::from_ne_bytes(ip.octets()),
};

Self {
Expand Down Expand Up @@ -267,7 +267,7 @@ impl From<IpEndpoint> for sockaddr_in6 {
match endpoint.addr {
IpAddress::Ipv6(ip) => {
let mut in6_addr = in6_addr::default();
in6_addr.s6_addr.copy_from_slice(ip.as_bytes());
in6_addr.s6_addr.copy_from_slice(&ip.octets());

Self {
sin6_len: core::mem::size_of::<sockaddr_in6>().try_into().unwrap(),
Expand Down Expand Up @@ -400,7 +400,11 @@ pub unsafe extern "C" fn sys_getaddrbyname(
match block_on(get_query_result(query), None) {
Ok(addr_vec) => {
let slice = unsafe { core::slice::from_raw_parts_mut(inaddr, len) };
slice.copy_from_slice(addr_vec[0].as_bytes());

match addr_vec[0] {
IpAddress::Ipv4(ipv4_addr) => slice.copy_from_slice(&ipv4_addr.octets()),
IpAddress::Ipv6(ipv6_addr) => slice.copy_from_slice(&ipv6_addr.octets()),
}

0
}
Expand Down

0 comments on commit e5ea9ac

Please sign in to comment.