Added Network trait that keeps track of network settings and has DHCP/Manual options for setting up options

This commit is contained in:
Jonah Dahlquist 2019-08-09 17:24:51 -05:00 committed by Jonah Dahlquist
commit fd9e861dde
7 changed files with 145 additions and 21 deletions

29
src/network/dhcp.rs Normal file
View file

@ -0,0 +1,29 @@
use crate::bus::ActiveBus;
use crate::network::{Network,NetworkSettings};
use crate::MacAddress;
pub struct Dhcp {
settings: NetworkSettings,
current: NetworkSettings,
}
impl Dhcp {
pub fn new(mac: MacAddress) -> Self {
let settings = NetworkSettings {
mac,
..NetworkSettings::default()
};
Self {
settings,
current: NetworkSettings::default(),
}
}
}
impl Network for Dhcp {
/// Gets (if necessary) and sets the network settings on the chip
fn refresh<SpiBus: ActiveBus>(&mut self, _bus: &mut SpiBus) -> Result<(), SpiBus::Error> {
// TODO actually negotiate settings from DHCP
Ok(())
}
}