public Binding FindCurrentBinding(DhcpLink clientLink, DhcpV6ClientIdOption clientIdOption,
                                          DhcpV6IaPdOption iaPdOption, DhcpMessage requestMsg)
        {
            byte[] duid = clientIdOption.GetDuid();
            long   iaid = iaPdOption.GetIaId();

            return(base.FindCurrentBinding(clientLink, duid, IdentityAssoc.PD_TYPE,
                                           iaid, requestMsg));
        }
        /**
         * Extract the list of IP addresses from within the given IA_PD option.
         *
         * @param iaNaOption the IA_PD option
         *
         * @return the list of InetAddresses for the IPs in the IA_PD option
         */
        private List <IPAddress> GetInetAddrs(DhcpV6IaPdOption iaPdOption)
        {
            List <IPAddress>            inetAddrs = null;
            List <DhcpV6IaPrefixOption> iaPrefs   = iaPdOption.GetIaPrefixOptions();

            if ((iaPrefs != null) && iaPrefs.Count > 0)
            {
                inetAddrs = new List <IPAddress>();
                foreach (DhcpV6IaPrefixOption iaPrefix in iaPrefs)
                {
                    IPAddress inetAddr = iaPrefix.GetInetAddress();
                    inetAddrs.Add(inetAddr);
                }
            }
            return(inetAddrs);
        }
        public Binding CreateSolicitBinding(DhcpLink clientLink, DhcpV6ClientIdOption clientIdOption,
                                            DhcpV6IaPdOption iaPdOption, DhcpMessage requestMsg, byte state, IPAddress clientV4IPAddress)
        {
            byte[] duid = clientIdOption.GetDuid();
            long   iaid = iaPdOption.GetIaId();

            StaticBinding staticBinding =
                FindStaticBinding(clientLink.GetLink(), duid, IdentityAssoc.PD_TYPE, iaid, requestMsg);

            if (staticBinding != null)
            {
                return(base.CreateStaticBinding(clientLink, duid, IdentityAssoc.PD_TYPE,
                                                iaid, staticBinding, requestMsg));
            }
            else
            {
                return(base.CreateBinding(clientLink, duid, IdentityAssoc.PD_TYPE,
                                          iaid, GetInetAddrs(iaPdOption), requestMsg, state, clientV4IPAddress));
            }
        }
Esempio n. 4
0
        protected bool AllIaPrefixesOnLink(DhcpV6IaPdOption dhcpIaPdOption, DhcpLink clientLink)
        {
            bool onLink = true;

            //  assume all IPs are on link
            if ((dhcpIaPdOption != null))
            {
                List <DhcpV6IaPrefixOption> iaPrefixOpts = dhcpIaPdOption.GetIaPrefixOptions();
                if ((iaPrefixOpts != null))
                {
                    foreach (DhcpV6IaPrefixOption iaPrefixOpt in iaPrefixOpts)
                    {
                        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
                            v6PrefixPool p = DhcpServerConfiguration.FindPrefixPool(this.clientLink.GetLink(), iaPrefixOpt.GetInetAddress());
                            if ((p == null))
                            {
                                log.Info(("No local prefix pool found for requested IA_PD: "
                                          + (iaPrefixOpt.GetInetAddress().ToString() + " - considered to be off link")));
                                iaPrefixOpt.SetPreferredLifetime(0);
                                iaPrefixOpt.SetValidLifetime(0);
                                onLink = false;
                            }
                        }
                        else if (!this.clientLink.GetSubnet().Contains(iaPrefixOpt.GetInetAddress()))
                        {
                            log.Info(("Setting zero(0) lifetimes for off link prefix: " + iaPrefixOpt.GetInetAddress().ToString()));
                            iaPrefixOpt.SetPreferredLifetime(0);
                            iaPrefixOpt.SetValidLifetime(0);
                            onLink = false;
                        }
                    }
                }
            }

            return(onLink);
        }