コード例 #1
0
ファイル: DHCPPool.java プロジェクト: telestack/Floodlight
 /**
  * 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
ファイル: DHCPPool.java プロジェクト: telestack/Floodlight
 /**
  * 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);
 }
コード例 #3
0
ファイル: DHCPPool.java プロジェクト: telestack/Floodlight
 /**
  * Used to set a particular IP binding in the pool as a fixed/static IP lease. This method does
  * not set the lease as active, but instead reserves that IP for only the MAC provided. To set the
  * lease as active, the methods getAnyAvailableLease() or getSpecificAvailableLease() will return
  * the correct binding given the same MAC provided to this method is used to bind the lease later
  * on.
  *
  * @param {@code byte[]}: The IP address to set as static/fixed.
  * @param {@code byte[]}: The MAC address to match to the IP address ip when an address is
  *     requested from the MAC mac
  * @return {@code boolean}: True upon success; false upon failure (e.g. no IP found)
  */
 public boolean configureFixedIPLease(IPv4Address ip, MacAddress mac) {
   DHCPBinding binding = this.getDHCPbindingFromIPv4(ip);
   if (binding != null) {
     binding.setMACAddress(mac);
     binding.setStaticIPLease(true);
     binding.setLeaseStatus(false);
     return true;
   } else {
     return false;
   }
 }
コード例 #4
0
ファイル: DHCPPool.java プロジェクト: telestack/Floodlight
 /**
  * Cancel an IP lease.
  *
  * @param {@code byte[]}: The MAC address on which to try and cancel a lease
  * @return {@code boolean}: True on success, false if unknown IP address
  */
 public boolean cancelLeaseOfMAC(MacAddress mac) {
   DHCPBinding binding = getDHCPbindingFromMAC(mac);
   if (binding != null) {
     binding.clearLeaseTimes();
     binding.setLeaseStatus(false);
     this.setPoolAvailability(this.getPoolAvailability() + 1);
     this.setPoolFull(false);
     return true;
   }
   return false;
 }
コード例 #5
0
ファイル: DHCPPool.java プロジェクト: telestack/Floodlight
 /**
  * Cancel an IP lease.
  *
  * @param {@code byte[]}: The IP address on which to try and cancel a lease
  * @return {@code boolean}: True on success, false if unknown IP address
  */
 public boolean cancelLeaseOfIPv4(IPv4Address ip) {
   DHCPBinding binding = this.getDHCPbindingFromIPv4(ip);
   if (binding != null) {
     binding.clearLeaseTimes();
     binding.setLeaseStatus(false);
     this.setPoolAvailability(this.getPoolAvailability() + 1);
     this.setPoolFull(false);
     return true;
   }
   return false;
 }