pub struct Leases { /* private fields */ }Expand description
Used to manage the dynamic collection of IP addresses that the server leases.
Implementations§
Source§impl Leases
impl Leases
Sourcepub const FILE_NAME: &'static str = "toe-beans-leases.toml"
pub const FILE_NAME: &'static str = "toe-beans-leases.toml"
The file name that the Leases is read from and written to.
Sourcepub fn new(config: &Config) -> Self
pub fn new(config: &Config) -> Self
Depending on whether the passed Config enables use_leases_file:
Restore and validate the leases file or create a new, empty Leases.
Sourcepub fn offer(
&mut self,
owner: MacAddress,
requested_ip: Option<Ipv4Addr>,
) -> Result<Ipv4Addr>
pub fn offer( &mut self, owner: MacAddress, requested_ip: Option<Ipv4Addr>, ) -> Result<Ipv4Addr>
Takes an available IP address, marks it as offered, and returns it.
Returns one of:
- The previously offered address, if one has been offered.
- The requested address:
- If one was requested,
- and it is available,
- and there is not a static lease
- Otherwise any available address (unless none are available).
Sourcepub fn ack(&mut self, owner: MacAddress) -> Result<Ipv4Addr>
pub fn ack(&mut self, owner: MacAddress) -> Result<Ipv4Addr>
Takes a chaddr’s offered ip address and marks it as reserved then commits it to persistent storage and returns the address.
Sourcepub fn extend(&mut self, owner: MacAddress) -> Result<()>
pub fn extend(&mut self, owner: MacAddress) -> Result<()>
Resets the time of an offered or acked lease. Used by the server in the lease renew/rebind process.
Sourcepub fn release(&mut self, owner: MacAddress) -> Result<()>
pub fn release(&mut self, owner: MacAddress) -> Result<()>
Makes an ip address that was offered or acked available again.
Sourcepub fn is_available(&self, ip: &Ipv4Addr) -> bool
pub fn is_available(&self, ip: &Ipv4Addr) -> bool
Checks whether the passed IP address is available in the pool.
Sourcepub fn verify_lease(&self, owner: MacAddress, ip: &Ipv4Addr) -> Result<()>
pub fn verify_lease(&self, owner: MacAddress, ip: &Ipv4Addr) -> Result<()>
Checks if the passed IP address matches the committed, leased IP address, and that the lease is not expired.