Ejemplo 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));
            }
        }
Ejemplo n.º 2
0
 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));
     }
 }
Ejemplo 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);
     }
 }
Ejemplo 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));
     }
 }
Ejemplo 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));
 }
Ejemplo 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));
 }
Ejemplo n.º 7
0
 /// <summary>
 /// The Option Value associated with the Scope Configuration
 /// </summary>
 internal DhcpServerOptionValue GetScopeValue(DhcpServerScope scope)
 => DhcpServerOptionValue.GetScopeOptionValue(scope, OptionId, ClassName, VendorName);
Ejemplo 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);
Ejemplo 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);
Ejemplo 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));
 }
Ejemplo n.º 11
0
 public void RemoveOptionValue(IDhcpServerOptionValue value)
 => DhcpServerOptionValue.DeleteScopeOptionValue(Scope, (DhcpServerOptionValue)value);
Ejemplo n.º 12
0
 public void RemoveOptionValue(DhcpServerOptionIds optionId)
 => DhcpServerOptionValue.DeleteScopeOptionValue(Scope, (int)optionId);
Ejemplo 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);
Ejemplo 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);
Ejemplo n.º 15
0
 public void AddOrSetOptionValue(IDhcpServerOptionValue value)
 => DhcpServerOptionValue.SetScopeOptionValue(Scope, (DhcpServerOptionValue)value);
Ejemplo 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));
 }
Ejemplo n.º 17
0
 /// <summary>
 /// The Option Value associated with the Global Server Configuration
 /// </summary>
 public DhcpServerOptionValue GetGlobalValue()
 {
     return(DhcpServerOptionValue.GetGlobalOptionValue(Server, OptionId, ClassName, VendorName));
 }
Ejemplo 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();
Ejemplo 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);
Ejemplo n.º 20
0
 /// <summary>
 /// Enumerates a list of Default Option Values associated with the DHCP Scope
 /// </summary>
 public IEnumerable <IDhcpServerOptionValue> GetDefaultOptionValues()
 => DhcpServerOptionValue.EnumScopeDefaultOptionValues(Scope);
Ejemplo 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);
Ejemplo n.º 22
0
 public IEnumerable <IDhcpServerOptionValue> GetUserOptionValues(string className)
 => DhcpServerOptionValue.EnumScopeUserOptionValues(Scope, className);
Ejemplo n.º 23
0
 /// <summary>
 /// Enumerates a list of Global Option Values associated with the DHCP Server
 /// </summary>
 public IEnumerable <IDhcpServerOptionValue> GetDefaultOptionValues()
 => DhcpServerOptionValue.EnumGlobalDefaultOptionValues(Server);
Ejemplo n.º 24
0
 public IEnumerable <IDhcpServerOptionValue> GetVendorOptionValues(string vendorName)
 => DhcpServerOptionValue.EnumScopeVendorOptionValues(Scope, vendorName);
Ejemplo n.º 25
0
 /// <summary>
 /// The Option Value associated with the Reservation Configuration
 /// </summary>
 internal DhcpServerOptionValue GetScopeReservationValue(DhcpServerScopeReservation reservation)
 => DhcpServerOptionValue.GetScopeReservationOptionValue(reservation, OptionId, ClassName, VendorName);
Ejemplo 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);
Ejemplo 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));
 }
Ejemplo 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);
Ejemplo 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);
Ejemplo 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);