Esempio n. 1
0
        public void CheckScopeCreationInstruction(ScopeCreateInstruction <TAddressProperties, TAddress, TScopeProperties, TScopeProperty, TOption, TValueType> instructions)
        {
            if (instructions == null || instructions.IsValid() == false || instructions.ScopeProperties == null)
            {
                throw new ScopeException(DHCPv4ScopeExceptionReasons.NoInput);
            }

            if (_scopes.ContainsKey(instructions.Id) == true)
            {
                throw new ScopeException(DHCPv4ScopeExceptionReasons.IdExists);
            }

            TScope parent = _notFoundScope;

            if (instructions.ParentId.HasValue == true)
            {
                if (_scopes.ContainsKey(instructions.ParentId.Value) == false)
                {
                    throw new ScopeException(DHCPv4ScopeExceptionReasons.ScopeParentNotFound);
                }

                parent = _scopes[instructions.ParentId.Value];
            }

            CheckAddressProperties(parent, instructions.AddressProperties);

            if (_resolverManager.IsResolverInformationValid(instructions.ResolverInformation) == false)
            {
                throw new ScopeException(DHCPv4ScopeExceptionReasons.InvalidResolver);
            }
        }
Esempio n. 2
0
        protected void HandleScopeAdded(TScope scope, ScopeCreateInstruction <TAddressProperties, TAddress, TScopeProperties, TScopeProperty, TOption, TValueType> instruction)
        {
            if (instruction.ParentId.HasValue == true)
            {
                TScope parent = _scopes[instruction.ParentId.Value];
                scope.SetParent(parent);
            }
            else
            {
                _firstLevelScopes.Add(scope);
            }

            IScopeResolver <TPacket, TAddress> resolver = _resolverManager.InitializeResolver(instruction.ResolverInformation);

            scope.SetResolver(resolver);

            _scopes.Add(scope.Id, scope);
        }