private TimeSpan GetLeaseDuration()
        {
            var option = DhcpServerOptionValue.GetScopeDefaultOptionValue(this, 51);

            if (option == null)
            {
                return(default(TimeSpan));
            }
            else
            {
                return(TimeSpan.FromSeconds(((DhcpServerOptionElementDWord)option.Values[0]).RawValue));
            }
        }
 internal static DhcpServerDnsSettings GetScopeDnsSettings(DhcpServer server, DhcpServerIpAddress address)
 {
     // Flag is Option 81
     try
     {
         var option = DhcpServerOptionValue.GetScopeDefaultOptionValue(server, address, 81);
         if (option.Values.FirstOrDefault() is DhcpServerOptionElementDWord value)
         {
             return(new DhcpServerDnsSettings((uint)value.RawValue));
         }
         else
         {
             return(GetGlobalDnsSettings(server));
         }
     }
     catch (DhcpServerException e) when(e.ApiErrorId == (uint)DhcpErrors.ERROR_FILE_NOT_FOUND)
     {
         return(GetGlobalDnsSettings(server));
     }
 }
Exemple #3
0
 internal static DhcpServerDnsSettings GetScopeDnsSettings(DhcpServerScope Scope)
 {
     // Flag is Option 81
     try
     {
         var option = DhcpServerOptionValue.GetScopeDefaultOptionValue(Scope, 81);
         if (option.Values.Count != 1)
         {
             return(GetGlobalDnsSettings(Scope.Server));
         }
         else
         {
             return(null);
         }
     }
     catch (DhcpServerException e) when(e.ApiErrorId == (uint)DhcpErrors.ERROR_FILE_NOT_FOUND)
     {
         return(null);
     }
 }
 /// <summary>
 /// Retrieves the Option Value assoicated with the Option and Scope from the Default options
 /// </summary>
 /// <param name="OptionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public DhcpServerOptionValue GetOptionValue(int OptionId)
 {
     return(DhcpServerOptionValue.GetScopeDefaultOptionValue(this, OptionId));
 }
Exemple #5
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope from the Default options
 /// </summary>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetDefaultOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetScopeDefaultOptionValue(Scope, (int)optionId);