Пример #1
0
        protected void AddTaBindingToReply(DhcpLink clientLink, Binding binding)
        {
            DhcpV6IaTaOption dhcpIaTaOption = new DhcpV6IaTaOption();

            dhcpIaTaOption.SetIaId(binding.GetIaid());
            HashSet <BindingObject> bindingObjs = binding.GetBindingObjects();

            if (((bindingObjs != null) &&
                 bindingObjs.Count > 0))
            {
                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_TA binding
                        DhcpV6OptionConfigObject configObj = ((DhcpV6OptionConfigObject)(bindingObj.GetConfigObj()));
                        if ((configObj != null))
                        {
                            dhcpIaAddrOption.SetPreferredLifetime(configObj.GetPreferredLifetime());
                            dhcpIaAddrOption.SetValidLifetime(configObj.GetValidLifetime());
                            this.PopulateTaAddrOptions(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()));
                    }
                }

                dhcpIaTaOption.SetIaAddrOptions(dhcpIaAddrOptions);
            }
            else
            {
                log.Error("No IA_TA bindings in binding object!");
            }

            this.PopulateIaTaOptions(dhcpIaTaOption, this.clientLink);
            this.replyMsg.AddIaTaOption(dhcpIaTaOption);
        }
Пример #2
0
        protected void AddPdBindingToReply(DhcpLink clientLink, Binding binding)
        {
            DhcpV6IaPdOption dhcpIaPdOption = new DhcpV6IaPdOption();

            dhcpIaPdOption.SetIaId(binding.GetIaid());
            long minPreferredLifetime           = 0;
            HashSet <BindingObject> bindingObjs = binding.GetBindingObjects();

            if (((bindingObjs != null) &&
                 bindingObjs.Count > 0))
            {
                minPreferredLifetime = 4294967295;
                List <DhcpV6IaPrefixOption> dhcpIaPrefixOptions = new List <DhcpV6IaPrefixOption>();
                foreach (BindingObject bindingObj in bindingObjs)
                {
                    //  must be a Binding Prefix for IaPd binding
                    V6BindingPrefix      bindingPrefix      = ((V6BindingPrefix)(bindingObj));
                    DhcpV6IaPrefixOption dhcpIaPrefixOption = new DhcpV6IaPrefixOption();
                    IPAddress            inetAddr           = bindingObj.GetIpAddress();
                    if ((inetAddr != null))
                    {
                        dhcpIaPrefixOption.SetIpAddress(inetAddr);
                        dhcpIaPrefixOption.SetPrefixLength(bindingPrefix.GetPrefixLength());
                        //  must be an DhcpOptionConfigObject for IA_PD binding
                        DhcpV6OptionConfigObject configObj = ((DhcpV6OptionConfigObject)(bindingObj.GetConfigObj()));
                        if ((configObj != null))
                        {
                            long preferred = configObj.GetPreferredLifetime();
                            if (((minPreferredLifetime == 4294967295) ||
                                 (preferred < minPreferredLifetime)))
                            {
                                minPreferredLifetime = preferred;
                            }

                            dhcpIaPrefixOption.SetPreferredLifetime(preferred);
                            dhcpIaPrefixOption.SetValidLifetime(configObj.GetValidLifetime());
                            this.PopulatePrefixOptions(dhcpIaPrefixOption, this.clientLink, configObj);
                            dhcpIaPrefixOptions.Add(dhcpIaPrefixOption);
                            // 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()));
                    }
                }

                dhcpIaPdOption.SetIaPrefixOptions(dhcpIaPrefixOptions);
            }
            else
            {
                log.Error("No IA_PD bindings in binding object!");
            }

            SetIaPdT1(this.clientLink, dhcpIaPdOption, minPreferredLifetime);
            SetIaPdT2(this.clientLink, dhcpIaPdOption, minPreferredLifetime);
            PopulateIaPdOptions(dhcpIaPdOption, this.clientLink);
            replyMsg.AddIaPdOption(dhcpIaPdOption);
        }