Skip to content

Commit 786eba2

Browse files
committed
NoInterfaceFound error now prints the interface name
1 parent 2d31957 commit 786eba2

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

crates/lib-dhcp/src/client/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ pub enum ClientError {
1919
#[error("Failed to retrieve interfaces: {0}")]
2020
InterfaceError(#[from] InterfaceError),
2121

22-
#[error("Failed to select a network interface")]
23-
NoInterfaceFound,
22+
#[error("Failed to select a network interface: {0}")]
23+
NoInterfaceFound(String),
2424

2525
#[error("Parse hardware address error: {0}")]
2626
ParseHardwareAddrError(#[from] ParseHardwareAddrError),

crates/lib-dhcp/src/client/mod.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ impl ClientBuilder {
7070
let interface =
7171
match utils::select_network_interface(&self.interface, self.interface_fallback)? {
7272
Some(ifa) => ifa,
73-
None => return Err(ClientError::NoInterfaceFound),
73+
None => return Err(ClientError::NoInterfaceFound(self.interface)),
7474
};
7575

7676
let hardware_address = match &interface.mac_addr {
@@ -132,6 +132,8 @@ impl ClientBuilder {
132132
}
133133
}
134134

135+
// TODO (Techassi): The T1 and T2 timers a implemented slightly wrong. See 4.4.5
136+
135137
pub struct Client {
136138
/// Duration before the binding process of the socket times out.
137139
bind_timeout: time::Duration,
@@ -231,7 +233,7 @@ impl Client {
231233
println!("Sending DHCPDISCOVER message");
232234
let discover_message = self.builder.make_discover_message(
233235
self.get_xid(),
234-
Some(self.destination_addr()),
236+
self.destination_addr(),
235237
None,
236238
None,
237239
)?;
@@ -601,7 +603,7 @@ impl Client {
601603
&self.interface.name,
602604
)?;
603605

604-
Ok(())
606+
Ok(self.transition_to(DhcpState::Bound)?)
605607
}
606608

607609
/// Returns the current transaction ID.

0 commit comments

Comments
 (0)