Esempio n. 1
0
        protected bool AllIaAddrsOnLink(DhcpV6IaNaOption dhcpIaNaOption, DhcpLink clientLink)
        {
            bool onLink = true;

            //  assume all IPs are on link
            if ((dhcpIaNaOption != null))
            {
                List <DhcpV6IaAddrOption> iaAddrOpts = dhcpIaNaOption.GetIaAddrOptions();
                if ((iaAddrOpts != null))
                {
                    foreach (DhcpV6IaAddrOption iaAddrOpt in iaAddrOpts)
                    {
                        if (this.clientLink.GetSubnet().GetSubnetAddress().IsIPv6LinkLocal)
                        {
                            //  if the Link address is link-local, then check if the
                            //  address is within one of the pools configured for this
                            //  local Link, which automatically makes this server
                            //  "authoritative" (in ISC parlance) for this local net
                            v6AddressPool p = DhcpServerConfiguration.FindNaAddrPool(this.clientLink.GetLink(), iaAddrOpt.GetInetAddress());
                            if ((p == null))
                            {
                                log.Info(("No local address pool found for requested IA_NA: " + (iaAddrOpt.ToString() + " - considered to be off link")));
                                iaAddrOpt.SetPreferredLifetime(0);
                                iaAddrOpt.SetValidLifetime(0);
                                onLink = false;
                            }
                        }
                        else
                        {
                            //  it the Link address is remote, then check
                            //  if the address is valid for that link
                            if (!this.clientLink.GetSubnet().Contains(iaAddrOpt.GetInetAddress()))
                            {
                                log.Info("Setting zero(0) lifetimes for off link address: " + iaAddrOpt.GetIpAddress());
                                iaAddrOpt.SetPreferredLifetime(0);
                                iaAddrOpt.SetValidLifetime(0);
                                onLink = false;
                            }
                        }
                    }
                }
            }

            return(onLink);
        }