/** * Adds the v4 binding to reply. * * @param clientLink the client link * @param binding the binding */ protected void AddBindingToReply(DhcpLink clientLink, Binding binding) { HashSet <BindingObject> bindingObjs = binding.GetBindingObjects(); if ((bindingObjs != null) && bindingObjs.Count > 0) { if (bindingObjs.Count == 1) { BindingObject bindingObj = bindingObjs.First(); IPAddress inetAddr = bindingObj.GetIpAddress(); if (inetAddr != null) { _replyMsg.SetYiAddr(inetAddr); // must be an DhcpV4OptionConfigObject for v4 binding DhcpV4OptionConfigObject configObj = (DhcpV4OptionConfigObject)bindingObj.GetConfigObj(); if (configObj != null) { long preferred = configObj.GetPreferredLifetime(); DhcpV4LeaseTimeOption dhcpV4LeaseTimeOption = new DhcpV4LeaseTimeOption(); dhcpV4LeaseTimeOption.SetUnsignedInt(preferred); _replyMsg.PutDhcpOption(dhcpV4LeaseTimeOption); PopulateV4Reply(clientLink, configObj); //TODO when do actually start the timer? currently, two get // created - one during advertise, one during reply // policy to allow real-time expiration? // bp.startExpireTimerTask(bindingAddr, iaAddrOption.getValidLifetime()); } else { log.Error("Null binding pool in binding: " + binding.ToString()); } } else { log.Error("Null address in binding: " + binding.ToString()); } } else { log.Error("Expected only one bindingObject in v4 Binding, but found " + bindingObjs.Count + "bindingObjects"); } } else { log.Error("No V4 bindings in binding object!"); } }