aboutsummaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authordiogo464 <[email protected]>2025-10-11 11:40:17 +0100
committerdiogo464 <[email protected]>2025-10-11 11:40:17 +0100
commit15a5bb445c3f599a110bfda0756baf18247ec05a (patch)
tree85eaabf1817736de06087012dc1eb4850b0f06b4 /src/main.rs
parent521218ce06fbb7bd518eb6a069406936079e3ec2 (diff)
fixed clippy warnings
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs42
1 files changed, 19 insertions, 23 deletions
diff --git a/src/main.rs b/src/main.rs
index c179ac0..819d656 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -14,10 +14,10 @@ use ipnet::Ipv4Net;
14 14
15use crate::dhcp::{DhcpOption, DhcpPacket}; 15use crate::dhcp::{DhcpOption, DhcpPacket};
16 16
17const BOOT_FILE_X64_BIOS: &'static str = "netboot.xyz.kpxe"; 17const BOOT_FILE_X64_BIOS: &str = "netboot.xyz.kpxe";
18const BOOT_FILE_X64_EFI: &'static str = "netboot.xyz.efi"; 18const BOOT_FILE_X64_EFI: &str = "netboot.xyz.efi";
19const BOOT_FILE_A64_EFI: &'static str = "netboot.xyz-arm64.efi"; 19const BOOT_FILE_A64_EFI: &str = "netboot.xyz-arm64.efi";
20const MENU_FILE: &'static str = "menu.ipxe"; 20const MENU_FILE: &str = "menu.ipxe";
21 21
22#[derive(Debug, Parser)] 22#[derive(Debug, Parser)]
23struct Cli { 23struct Cli {
@@ -235,14 +235,13 @@ fn handle_packet_4011(context: &Context, buf: &[u8], socket: &UdpSocket, sender_
235 235
236 let mut client_class = None; 236 let mut client_class = None;
237 for option in &packet.options { 237 for option in &packet.options {
238 if let DhcpOption::VendorClassIdentifier(vendor_class) = option { 238 if let DhcpOption::VendorClassIdentifier(vendor_class) = option
239 if let Ok(dhcp::PxeClassIdentifier::Client(class)) = 239 && let Ok(dhcp::PxeClassIdentifier::Client(class)) =
240 dhcp::PxeClassIdentifier::try_from(vendor_class.as_slice()) 240 dhcp::PxeClassIdentifier::try_from(vendor_class.as_slice())
241 { 241 {
242 println!("{class}"); 242 println!("{class}");
243 client_class = Some(class); 243 client_class = Some(class);
244 } 244 }
245 }
246 } 245 }
247 let client_class = match client_class { 246 let client_class = match client_class {
248 Some(class) => class, 247 Some(class) => class,
@@ -303,22 +302,19 @@ fn list_network_interfaces() -> Result<Vec<InterfaceAddr>> {
303 .to_string_lossy() 302 .to_string_lossy()
304 .into_owned(); 303 .into_owned();
305 304
306 match addr_family as i32 { 305 if addr_family as i32 == libc::AF_INET {
307 libc::AF_INET => { 306 let addr = ifa.ifa_addr as *const libc::sockaddr_in;
308 let addr = ifa.ifa_addr as *const libc::sockaddr_in; 307 let mask = ifa.ifa_netmask as *const libc::sockaddr_in;
309 let mask = ifa.ifa_netmask as *const libc::sockaddr_in; 308
310 309 let addr = Ipv4Addr::from((*addr).sin_addr.s_addr.to_ne_bytes());
311 let addr = Ipv4Addr::from((*addr).sin_addr.s_addr.to_ne_bytes()); 310 let mask = Ipv4Addr::from((*mask).sin_addr.s_addr.to_ne_bytes());
312 let mask = Ipv4Addr::from((*mask).sin_addr.s_addr.to_ne_bytes()); 311 let network = Ipv4Net::with_netmask(addr, mask).unwrap().trunc();
313 let network = Ipv4Net::with_netmask(addr, mask).unwrap().trunc(); 312
314 313 interfaces.push(InterfaceAddr {
315 interfaces.push(InterfaceAddr { 314 interface: name,
316 interface: name, 315 address: addr,
317 address: addr, 316 network,
318 network, 317 });
319 });
320 }
321 _ => {}
322 } 318 }
323 } 319 }
324 320