Try fetching the mac address directly from the network driver
This commit is contained in:
@@ -12,11 +12,14 @@ use std::fs::File;
|
||||
use std::os::unix::io::{FromRawFd, RawFd};
|
||||
use std::process;
|
||||
use std::rc::Rc;
|
||||
use std::str::FromStr;
|
||||
|
||||
use event::EventQueue;
|
||||
use netutils::getcfg;
|
||||
use redox_netstack::error::{Error, Result};
|
||||
use redox_netstack::logger;
|
||||
use scheme::Smolnetd;
|
||||
use smoltcp::wire::EthernetAddress;
|
||||
|
||||
mod buffer_pool;
|
||||
mod link;
|
||||
@@ -32,6 +35,13 @@ fn run(daemon: redox_daemon::Daemon) -> Result<()> {
|
||||
.map_err(|e| Error::from_syscall_error(e, "failed to open network:"))?
|
||||
as RawFd;
|
||||
|
||||
let hardware_addr = std::fs::read("network:mac")
|
||||
.map(|mac_address| EthernetAddress::from_bytes(&mac_address))
|
||||
.unwrap_or_else(|_| {
|
||||
EthernetAddress::from_str(getcfg("mac").unwrap().trim())
|
||||
.expect("Can't parse the 'mac' cfg")
|
||||
});
|
||||
|
||||
trace!("opening :ip");
|
||||
let ip_fd = syscall::open(":ip", O_RDWR | O_CREAT | O_NONBLOCK)
|
||||
.map_err(|e| Error::from_syscall_error(e, "failed to open :ip"))? as RawFd;
|
||||
@@ -75,6 +85,7 @@ fn run(daemon: redox_daemon::Daemon) -> Result<()> {
|
||||
|
||||
let smolnetd = Rc::new(RefCell::new(Smolnetd::new(
|
||||
network_file,
|
||||
hardware_addr,
|
||||
ip_file,
|
||||
udp_file,
|
||||
tcp_file,
|
||||
|
||||
@@ -10,7 +10,7 @@ use smoltcp::iface::{Config, Interface as SmoltcpInterface};
|
||||
use smoltcp::phy::Tracer;
|
||||
use smoltcp::time::{Duration, Instant};
|
||||
use smoltcp::wire::{
|
||||
EthernetAddress, HardwareAddress, IpAddress, IpCidr, IpListenEndpoint, Ipv4Address,
|
||||
EthernetAddress, HardwareAddress, IpAddress, IpCidr, IpListenEndpoint, Ipv4Address,
|
||||
};
|
||||
use std::cell::RefCell;
|
||||
use std::fs::File;
|
||||
@@ -64,6 +64,7 @@ impl Smolnetd {
|
||||
|
||||
pub fn new(
|
||||
network_file: File,
|
||||
hardware_addr: EthernetAddress,
|
||||
ip_file: File,
|
||||
udp_file: File,
|
||||
tcp_file: File,
|
||||
@@ -71,8 +72,6 @@ impl Smolnetd {
|
||||
time_file: File,
|
||||
netcfg_file: File,
|
||||
) -> Smolnetd {
|
||||
let hardware_addr = EthernetAddress::from_str(getcfg("mac").unwrap().trim())
|
||||
.expect("Can't parse the 'mac' cfg");
|
||||
let protocol_addrs = vec![
|
||||
IpCidr::new(IpAddress::v4(127, 0, 0, 1), 8),
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user