Exemplo n.º 1
0
 /**
  * Adds an IP address to the DHCPPool if the address is not already present. If present, nothing
  * is added to the DHCPPool.
  *
  * @param {@code byte[]} ip: The IP address to attempt to add to the DHCPPool
  * @return {@code DHCPBinding}: Reference to the DHCPBinding object if successful, null if
  *     unsuccessful
  */
 public DHCPBinding addIPv4ToDHCPPool(IPv4Address ip) {
   DHCPBinding binding = null;
   if (this.getDHCPbindingFromIPv4(ip) == null) {
     if (ip.getInt() < STARTING_ADDRESS.getInt()) {
       STARTING_ADDRESS = ip;
     }
     binding = new DHCPBinding(ip, null);
     DHCP_POOL.add(binding);
     this.setPoolSize(this.getPoolSize() + 1);
     this.setPoolFull(false);
   }
   return binding;
 }
Exemplo n.º 2
0
 /**
  * Constructor for a DHCPPool of DHCPBinding's. Each DHCPBinding object is initialized with a null
  * MAC address and the lease is set to inactive (i.e. false).
  *
  * @param {@code byte[]} startingIPv4Address: The lowest IP address to lease.
  * @param {@code integer} size: (startingIPv4Address + size) is the highest IP address to lease.
  * @return none
  */
 public DHCPPool(IPv4Address startingIPv4Address, int size, Logger log) {
   this.log = log;
   int IPv4AsInt = startingIPv4Address.getInt();
   this.setPoolSize(size);
   this.setPoolAvailability(size);
   STARTING_ADDRESS = startingIPv4Address;
   for (int i = 0; i < size; i++) {
     DHCP_POOL.add(new DHCPBinding(IPv4Address.of(IPv4AsInt + i), UNASSIGNED_MAC));
   }
 }