예제 #1
0
        protected void PopulatePrefixOptions(DhcpV6IaPrefixOption iaPrefixOption, DhcpLink dhcpLink, DhcpV6OptionConfigObject configObj)
        {
            Dictionary <int, DhcpOption> optionMap = dhcpServerConfig.EffectivePrefixOptions(this.requestMsg, dhcpLink, configObj);

            if (DhcpServerPolicies.EffectivePolicyAsBoolean(configObj, dhcpLink.GetLink(), Property.SEND_REQUESTED_OPTIONS_ONLY))
            {
                optionMap = this.RequestedOptions(optionMap, this.requestMsg);
            }

            iaPrefixOption.PutAllDhcpOptions(optionMap);
        }
예제 #2
0
        protected void PopulatePrefixOptions(DhcpV6IaPrefixOption iaPrefixOption)
        {
            Dictionary <int, DhcpOption> optionMap = dhcpServerConfig.EffectivePrefixOptions(this.requestMsg);

            if (DhcpServerPolicies.GlobalPolicyAsBoolean(Property.SEND_REQUESTED_OPTIONS_ONLY))
            {
                optionMap = this.RequestedOptions(optionMap, this.requestMsg);
            }

            iaPrefixOption.PutAllDhcpOptions(optionMap);
        }
예제 #3
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);
        }