示例#1
0
 /**
  * Tries to renew an IP lease.
  *
  * @param {@code byte[]}: The IP address on which to try and renew a lease
  * @param {@code long}: The time in seconds for which the lease will be valid
  * @return {@code DHCPBinding}: True on success, false if unknown IP address
  */
 public boolean renewLease(IPv4Address ip, int time) {
   DHCPBinding binding = this.getDHCPbindingFromIPv4(ip);
   if (binding != null) {
     binding.setLeaseStartTimeSeconds();
     binding.setLeaseDurationSeconds(time);
     binding.setLeaseStatus(true);
     return true;
   }
   return false;
 }
示例#2
0
 /**
  * Assigns a MAC address to the IP address of the DHCPBinding object in the DHCPPool object. This
  * method also sets the lease to active (i.e. true) when the assignment is made.
  *
  * @param {@code DHCPBinding} binding: The DHCPBinding object in which to set the MAC
  * @param {@code byte[]} mac: The MAC address to set in the DHCPBinding object
  * @param {@code long}: The time in seconds for which the lease will be valid
  * @return none
  */
 public void setDHCPbinding(DHCPBinding binding, MacAddress mac, int time) {
   int index = DHCP_POOL.indexOf(binding);
   binding.setMACAddress(mac);
   binding.setLeaseStatus(true);
   this.setPoolAvailability(this.getPoolAvailability() - 1);
   DHCP_POOL.set(index, binding);
   if (this.getPoolAvailability() == 0) setPoolFull(true);
   binding.setLeaseStartTimeSeconds();
   binding.setLeaseDurationSeconds(time);
 }