Esempio n. 1
0
        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));
     }
 }
Esempio n. 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);
     }
 }
Esempio n. 4
0
 internal static DhcpServerDnsSettings GetGlobalDnsSettings(DhcpServer Server)
 {
     // Flag is Global Option 81
     try
     {
         var option = DhcpServerOptionValue.GetGlobalDefaultOptionValue(Server, 81);
         if (option.Values.Count == 1 && option.Values[0] is DhcpServerOptionElementDWord)
         {
             var value = (DhcpServerOptionElementDWord)option.Values[0];
             return(new DhcpServerDnsSettings((uint)value.RawValue));
         }
         else
         {
             return(new DhcpServerDnsSettings(FlagDefaultSettings));
         }
     }
     catch (DhcpServerException e) when(e.ApiErrorId == (uint)DhcpErrors.ERROR_FILE_NOT_FOUND)
     {
         // Default Settings
         return(new DhcpServerDnsSettings(FlagDefaultSettings));
     }
 }
Esempio n. 5
0
 /// <summary>
 /// Retrieves the Option Value assoicated with the Option and Scope within a User Class
 /// </summary>
 /// <param name="ClassName">The name of the User Class to retrieve the Option from</param>
 /// <param name="OptionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public DhcpServerOptionValue GetUserOptionValue(string ClassName, int OptionId)
 {
     return(DhcpServerOptionValue.GetScopeUserOptionValue(this, OptionId, ClassName));
 }
Esempio n. 6
0
 /// <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));
 }
Esempio n. 7
0
 /// <summary>
 /// The Option Value associated with the Scope Configuration
 /// </summary>
 internal DhcpServerOptionValue GetScopeValue(DhcpServerScope scope)
 => DhcpServerOptionValue.GetScopeOptionValue(scope, OptionId, ClassName, VendorName);
Esempio n. 8
0
 /// <summary>
 /// Enumerates a list of all Global Option Values, including vendor/user class options, associated with the DHCP Server
 /// </summary>
 public IEnumerable <IDhcpServerOptionValue> GetOptionValues()
 => DhcpServerOptionValue.GetAllGlobalOptionValues(Server);
Esempio n. 9
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId Value within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetUserOptionValue(string className, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetGlobalUserOptionValue(Server, className, (int)optionId);
Esempio n. 10
0
 /// <summary>
 /// The Option Value associated with the Scope Configuration
 /// </summary>
 public DhcpServerOptionValue GetScopeValue(DhcpServerScope Scope)
 {
     return(DhcpServerOptionValue.GetScopeOptionValue(Scope, OptionId, ClassName, VendorName));
 }
Esempio n. 11
0
 public void RemoveOptionValue(IDhcpServerOptionValue value)
 => DhcpServerOptionValue.DeleteScopeOptionValue(Scope, (DhcpServerOptionValue)value);
Esempio n. 12
0
 public void RemoveOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeOptionValue(Scope, (int)optionId);
Esempio n. 13
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a Vendor Class
 /// </summary>
 /// <param name="vendorName">The name of the Vendor Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public void RemoveVendorOptionValue(string vendorName, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeVendorOptionValue(Scope, (int)optionId, vendorName);
Esempio n. 14
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public void RemoveUserOptionValue(string className, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeUserOptionValue(Scope, (int)optionId, className);
Esempio n. 15
0
 public void AddOrSetOptionValue(IDhcpServerOptionValue value)
 => DhcpServerOptionValue.SetScopeOptionValue(Scope, (DhcpServerOptionValue)value);
Esempio n. 16
0
 /// <summary>
 /// The Option Value associated with the Reservation Configuration
 /// </summary>
 public DhcpServerOptionValue GetScopeReservationValue(DhcpServerScopeReservation Reservation)
 {
     return(DhcpServerOptionValue.GetScopeReservationOptionValue(Reservation, OptionId, ClassName, VendorName));
 }
Esempio n. 17
0
 /// <summary>
 /// The Option Value associated with the Global Server Configuration
 /// </summary>
 public DhcpServerOptionValue GetGlobalValue()
 {
     return(DhcpServerOptionValue.GetGlobalOptionValue(Server, OptionId, ClassName, VendorName));
 }
Esempio n. 18
0
 /// <summary>
 /// Enumerates a list of All Option Values, including vendor/user class option values, associated with the DHCP Scope
 /// </summary>
 public IEnumerator <IDhcpServerOptionValue> GetEnumerator()
 => DhcpServerOptionValue.GetAllScopeOptionValues(Scope).GetEnumerator();
Esempio n. 19
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId Value from the Default options
 /// </summary>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetDefaultOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetGlobalDefaultOptionValue(Server, (int)optionId);
Esempio n. 20
0
 /// <summary>
 /// Enumerates a list of Default Option Values associated with the DHCP Scope
 /// </summary>
 public IEnumerable <IDhcpServerOptionValue> GetDefaultOptionValues()
 => DhcpServerOptionValue.EnumScopeDefaultOptionValues(Scope);
Esempio n. 21
0
 /// <summary>
 /// Queries the DHCP Server for the specified OptionId Value within a Vendor Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetVendorOptionValue(string vendorName, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetGlobalVendorOptionValue(Server, vendorName, (int)optionId);
Esempio n. 22
0
 public IEnumerable <IDhcpServerOptionValue> GetUserOptionValues(string className)
 => DhcpServerOptionValue.EnumScopeUserOptionValues(Scope, className);
Esempio n. 23
0
 /// <summary>
 /// Enumerates a list of Global Option Values associated with the DHCP Server
 /// </summary>
 public IEnumerable <IDhcpServerOptionValue> GetDefaultOptionValues()
 => DhcpServerOptionValue.EnumGlobalDefaultOptionValues(Server);
Esempio n. 24
0
 public IEnumerable <IDhcpServerOptionValue> GetVendorOptionValues(string vendorName)
 => DhcpServerOptionValue.EnumScopeVendorOptionValues(Scope, vendorName);
Esempio n. 25
0
 /// <summary>
 /// The Option Value associated with the Reservation Configuration
 /// </summary>
 internal DhcpServerOptionValue GetScopeReservationValue(DhcpServerScopeReservation reservation)
 => DhcpServerOptionValue.GetScopeReservationOptionValue(reservation, OptionId, ClassName, VendorName);
Esempio n. 26
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);
Esempio n. 27
0
 /// <summary>
 /// Retrieves the Option Value assoicated with the Option and Scope within a Vendor Class
 /// </summary>
 /// <param name="VendorName">The name of the Vendor Class to retrieve the Option from</param>
 /// <param name="OptionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public DhcpServerOptionValue GetVendorOptionValue(string VendorName, int OptionId)
 {
     return(DhcpServerOptionValue.GetScopeVendorOptionValue(this, OptionId, VendorName));
 }
Esempio n. 28
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetUserOptionValue(string className, DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.GetScopeUserOptionValue(Scope, (int)optionId, className);
Esempio n. 29
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope within a Vendor Class
 /// </summary>
 /// <param name="vendorName">The name of the Vendor Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="DhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetVendorOptionValue(string vendorName, int optionId)
 => DhcpServerOptionValue.GetScopeVendorOptionValue(Scope, optionId, vendorName);
Esempio n. 30
0
 /// <summary>
 /// Retrieves the Option Value associated with the Option and Scope Reservation within a User Class
 /// </summary>
 /// <param name="className">The name of the User Class to retrieve the Option from</param>
 /// <param name="optionId">The identifier for the option value to retrieve</param>
 /// <returns>A <see cref="IDhcpServerOptionValue"/>.</returns>
 public IDhcpServerOptionValue GetUserOptionValue(string className, int optionId)
 => DhcpServerOptionValue.GetScopeReservationUserOptionValue(Reservation, optionId, className);