Skip to content

Commit 096519f

Browse files
committed
Update dependencies
1 parent df4d938 commit 096519f

File tree

9 files changed

+110
-107
lines changed

9 files changed

+110
-107
lines changed

pixie-shared/src/lib.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@ extern crate alloc;
44

55
use alloc::{collections::BTreeMap, string::String, vec::Vec};
66
use blake3::OUT_LEN;
7+
use core::net::Ipv4Addr;
78
use serde::{Deserialize, Serialize};
89

910
#[cfg(feature = "std")]
10-
use std::{
11-
collections::HashMap,
12-
net::{Ipv4Addr, SocketAddrV4},
13-
};
11+
use std::{collections::HashMap, net::SocketAddrV4};
1412

1513
pub mod bijection;
1614
pub use bijection::Bijection;
@@ -82,11 +80,9 @@ pub const PACKET_LEN: usize = 1436;
8280
pub const HEADER_LEN: usize = 34;
8381
pub const BODY_LEN: usize = PACKET_LEN - HEADER_LEN;
8482

85-
pub type Ip = [u8; 4];
86-
87-
#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)]
83+
#[derive(Debug, Clone, Copy, Serialize, Deserialize)]
8884
pub struct Address {
89-
pub ip: Ip,
85+
pub ip: Ipv4Addr,
9086
pub port: u16,
9187
}
9288

pixie-uefi/Cargo.lock

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pixie-uefi/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ managed = { version = "0.8.0", default-features = false, features = ["alloc"] }
1919
postcard = { version = "1.0.8", default-features = false, features = ["alloc"] }
2020
rand = { version = "0.8.5", default-features = false }
2121
rand_xoshiro = { version = "0.6.0", default-features = false }
22-
smoltcp = { version = "0.11.0", default-features = false, features = ["alloc", "proto-ipv4", "medium-ethernet", "socket-udp", "socket-tcp", "socket-dhcpv4", "async"] }
23-
uefi = { version = "0.32.0", features = ["alloc", "global_allocator", "panic_handler"] }
22+
smoltcp = { version = "0.12.0", default-features = false, features = ["alloc", "proto-ipv4", "medium-ethernet", "socket-udp", "socket-tcp", "socket-dhcpv4", "async", "socket-tcp-cubic"] }
23+
uefi = { version = "0.33.0", features = ["alloc", "global_allocator", "panic_handler"] }
2424

2525
[dependencies.pixie-shared]
2626
path = "../pixie-shared"

pixie-uefi/src/main.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#![deny(unused_must_use)]
66

77
use alloc::boxed::Box;
8+
use core::net::Ipv4Addr;
89
use futures::future::{self, Either};
910
use pixie_shared::{Action, Address, TcpRequest, UdpRequest, ACTION_PORT};
1011
use uefi::prelude::*;
@@ -37,7 +38,7 @@ async fn server_discover(os: UefiOS) -> Result<Address> {
3738

3839
let msg = postcard::to_allocvec(&UdpRequest::Discover).unwrap();
3940
loop {
40-
socket.send([255; 4], ACTION_PORT, &msg).await?;
41+
socket.send(Ipv4Addr::BROADCAST, ACTION_PORT, &msg).await?;
4142
os.sleep_us(1_000_000).await;
4243
}
4344
};

pixie-uefi/src/os/boot_options.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use alloc::{
44
};
55
use uefi::{
66
proto::device_path::DevicePath,
7-
table::runtime::{VariableAttributes, VariableVendor},
7+
runtime::{VariableAttributes, VariableVendor},
88
CString16,
99
};
1010

pixie-uefi/src/os/disk.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@ use gpt_disk_io::{
77
BlockIo,
88
};
99
use uefi::{
10-
boot::ScopedProtocol,
10+
boot::{OpenProtocolParams, ScopedProtocol},
1111
proto::media::{block::BlockIO, disk::DiskIo},
12-
table::boot::OpenProtocolParams,
1312
Handle,
1413
};
1514

@@ -30,7 +29,7 @@ fn open_disk(
3029
controller: None,
3130
handle,
3231
},
33-
uefi::table::boot::OpenProtocolAttributes::GetProtocol,
32+
uefi::boot::OpenProtocolAttributes::GetProtocol,
3433
)
3534
};
3635
Ok((os.open_handle(handle)?, bio?))

pixie-uefi/src/os/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use core::{
33
ffi::c_void,
44
fmt::{self, Display, Write},
55
future::{poll_fn, Future, PollFn},
6+
net::Ipv4Addr,
67
ptr::NonNull,
78
task::{Context, Poll},
89
};
@@ -15,7 +16,7 @@ use alloc::{
1516
vec::Vec,
1617
};
1718
use uefi::{
18-
boot::ScopedProtocol,
19+
boot::{EventType, ScopedProtocol, TimerTrigger, Tpl},
1920
proto::{
2021
console::text::{Color, Input, Key, Output},
2122
device_path::{
@@ -25,10 +26,7 @@ use uefi::{
2526
},
2627
Protocol,
2728
},
28-
table::{
29-
boot::{EventType, TimerTrigger, Tpl},
30-
runtime::{VariableAttributes, VariableVendor},
31-
},
29+
runtime::{VariableAttributes, VariableVendor},
3230
CStr16, Event, Handle, Status,
3331
};
3432

@@ -435,7 +433,7 @@ impl UefiOS {
435433
Disk::new(*self)
436434
}
437435

438-
pub async fn connect(&self, ip: [u8; 4], port: u16) -> Result<TcpStream> {
436+
pub async fn connect(&self, ip: Ipv4Addr, port: u16) -> Result<TcpStream> {
439437
TcpStream::new(*self, ip, port).await
440438
}
441439

@@ -570,7 +568,7 @@ impl UefiOS {
570568
}
571569

572570
pub fn reset(&self) -> ! {
573-
uefi::runtime::reset(uefi::table::runtime::ResetType::WARM, Status::SUCCESS, None)
571+
uefi::runtime::reset(uefi::runtime::ResetType::WARM, Status::SUCCESS, None)
574572
}
575573
}
576574

pixie-uefi/src/os/net.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
use core::{future::poll_fn, task::Poll};
1+
use core::{future::poll_fn, net::IpAddr, task::Poll};
22

33
use alloc::boxed::Box;
44
use futures::future::select;
55

66
use smoltcp::{
7-
iface::{Config, Interface, SocketHandle, SocketSet},
7+
iface::{Config, Interface, PollResult, SocketHandle, SocketSet},
88
phy::{Device, DeviceCapabilities, Medium, RxToken, TxToken},
99
socket::{
1010
dhcpv4::{Event, Socket as Dhcpv4Socket},
1111
tcp::{Socket as TcpSocket, State},
12-
udp,
13-
udp::Socket as UdpSocket,
12+
udp::{self, Socket as UdpSocket},
1413
},
1514
storage::RingBuffer,
1615
time::{Duration, Instant},
@@ -102,7 +101,7 @@ impl TxToken for SnpTxToken<'_> {
102101
impl RxToken for SnpRxToken<'_> {
103102
fn consume<R, F>(self, f: F) -> R
104103
where
105-
F: FnOnce(&mut [u8]) -> R,
104+
F: FnOnce(&[u8]) -> R,
106105
{
107106
f(self.packet)
108107
}
@@ -224,7 +223,7 @@ impl NetworkInterface {
224223
let status = self
225224
.interface
226225
.poll(now, &mut self.device, &mut self.socket_set);
227-
if !status {
226+
if status == PollResult::None {
228227
return false;
229228
}
230229

@@ -265,20 +264,21 @@ pub struct TcpStream {
265264
// create that many, but still it would be nice to fix eventually.
266265
// Also, trying to use a closed connection may result in panics.
267266
impl TcpStream {
268-
pub async fn new(os: UefiOS, ip: [u8; 4], port: u16) -> Result<TcpStream> {
267+
pub async fn new(os: UefiOS, ip: Ipv4Address, port: u16) -> Result<TcpStream> {
269268
os.wait_for_ip().await;
270269
const TCP_BUF_SIZE: usize = 1 << 22;
271270
let mut tcp_socket = TcpSocket::new(
272271
RingBuffer::new(vec![0; TCP_BUF_SIZE]),
273272
RingBuffer::new(vec![0; TCP_BUF_SIZE]),
274273
);
274+
tcp_socket.set_congestion_control(smoltcp::socket::tcp::CongestionControl::Cubic);
275275
tcp_socket.set_timeout(Some(Duration::from_secs(5)));
276276
tcp_socket.set_keep_alive(Some(Duration::from_secs(1)));
277277
let sport = os.net().get_ephemeral_port();
278278
tcp_socket.connect(
279279
os.net().interface.context(),
280280
IpEndpoint {
281-
addr: IpAddress::Ipv4(Ipv4Address(ip)),
281+
addr: IpAddress::Ipv4(ip),
282282
port,
283283
},
284284
sport,
@@ -467,9 +467,9 @@ impl UdpHandle {
467467
Ok(ret)
468468
}
469469

470-
pub async fn send(&self, ip: [u8; 4], port: u16, data: &[u8]) -> Result<()> {
470+
pub async fn send(&self, ip: Ipv4Address, port: u16, data: &[u8]) -> Result<()> {
471471
let endpoint = IpEndpoint {
472-
addr: IpAddress::Ipv4(Ipv4Address(ip)),
472+
addr: ip.into(),
473473
port,
474474
};
475475

@@ -499,7 +499,9 @@ impl UdpHandle {
499499
} else {
500500
// Cannot fail if can_recv() returned true.
501501
let recvd = socket.recv_slice(buf2).unwrap();
502-
let ip = (recvd.1).endpoint.addr.as_bytes().try_into().unwrap();
502+
let IpAddr::V4(ip) = (recvd.1).endpoint.addr.into() else {
503+
unreachable!();
504+
};
503505
let port = (recvd.1).endpoint.port;
504506
Poll::Ready((recvd.0, Address { ip, port }))
505507
}

0 commit comments

Comments
 (0)