Exemple #1
0
 public DhcpOption getDhcpOption(int code) {
   DhcpOption result = null;
   if (dhcpOptions != null) {
     Iterator<DhcpOption> iterator = dhcpOptions.iterator();
     while (result == null && iterator.hasNext()) {
       DhcpOption dhcpOption = iterator.next();
       if (dhcpOption.getCode() == code) {
         result = dhcpOption;
       }
     }
   }
   return result;
 }
Exemple #2
0
 public void setDhcpOption(DhcpOption newOption) {
   if (dhcpOptions == null) {
     dhcpOptions = new ArrayList<>();
   }
   // first remove the option, if it exists
   boolean hasNotBeenRemoved = true;
   Iterator<DhcpOption> dhcpOptionsIterator = dhcpOptions.iterator();
   while (hasNotBeenRemoved && dhcpOptionsIterator.hasNext()) {
     DhcpOption dhcpOption = dhcpOptionsIterator.next();
     if (dhcpOption.getCode() == newOption.getCode()) {
       dhcpOptionsIterator.remove();
       hasNotBeenRemoved = false;
     }
   }
   dhcpOptions.add(newOption);
 }