protected void AddIaNaOptionStatusToReply(DhcpV6IaNaOption iaNaOption, int statusCode) { DhcpV6IaNaOption replyIaNaOption = new DhcpV6IaNaOption(); replyIaNaOption.SetIaId(iaNaOption.GetIaId()); DhcpV6StatusCodeOption status = new DhcpV6StatusCodeOption(); status.SetStatusCode(statusCode); replyIaNaOption.PutDhcpOption(status); this.replyMsg.AddIaNaOption(replyIaNaOption); }
protected void AddNaBindingToReply(DhcpLink clientLink, Binding binding) { DhcpV6IaNaOption dhcpIaNaOption = new DhcpV6IaNaOption(); dhcpIaNaOption.SetIaId(binding.GetIaid()); long minPreferredLifetime = 0; HashSet <BindingObject> bindingObjs = binding.GetBindingObjects(); if (bindingObjs != null && bindingObjs.Count > 0) { minPreferredLifetime = 4294967295; List <DhcpV6IaAddrOption> dhcpIaAddrOptions = new List <DhcpV6IaAddrOption>(); foreach (BindingObject bindingObj in bindingObjs) { DhcpV6IaAddrOption dhcpIaAddrOption = new DhcpV6IaAddrOption(); IPAddress inetAddr = bindingObj.GetIpAddress(); if ((inetAddr != null)) { dhcpIaAddrOption.SetIpAddress(inetAddr); // must be an DhcpOptionConfigObject for IA_NA binding DhcpV6OptionConfigObject configObj = ((DhcpV6OptionConfigObject)(bindingObj.GetConfigObj())); if ((configObj != null)) { long preferred = configObj.GetPreferredLifetime(); if (minPreferredLifetime == 4294967295 || preferred < minPreferredLifetime) { minPreferredLifetime = preferred; } dhcpIaAddrOption.SetPreferredLifetime(preferred); dhcpIaAddrOption.SetValidLifetime(configObj.GetValidLifetime()); this.PopulateNaAddrOptions(dhcpIaAddrOption, this.clientLink, configObj); dhcpIaAddrOptions.Add(dhcpIaAddrOption); // 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())); } } dhcpIaNaOption.SetIaAddrOptions(dhcpIaAddrOptions); } else { log.Error("No IA_NA bindings in binding object!"); } this.SetIaNaT1(this.clientLink, dhcpIaNaOption, minPreferredLifetime); this.SetIaNaT2(this.clientLink, dhcpIaNaOption, minPreferredLifetime); this.PopulateIaNaOptions(dhcpIaNaOption, this.clientLink); this.replyMsg.AddIaNaOption(dhcpIaNaOption); }