/// <summary>
        /// Creates a DHCP scope reservation from a client
        /// </summary>
        /// <param name="client">A DHCP client to convert to a reservation</param>
        /// <returns>The scope reservation</returns>
        public IDhcpServerScopeReservation AddReservation(IDhcpServerClient client)
        {
            if (!Scope.IpRange.Contains(client.IpAddress))
            {
                throw new ArgumentOutOfRangeException(nameof(client), "The client address is not within the IP range of the scope");
            }

            return(DhcpServerScopeReservation.CreateReservation(Scope, client.IpAddress, client.HardwareAddress));
        }
        internal static DhcpServerOptionValue GetScopeReservationOptionValue(DhcpServerScopeReservation Reservation, int OptionId, string ClassName, string VendorName)
        {
            var scopeInfo = new DHCP_OPTION_SCOPE_INFO_RESERVED()
            {
                ScopeType               = DHCP_OPTION_SCOPE_TYPE.DhcpReservedOptions,
                ReservedIpAddress       = Reservation.ipAddress,
                ReservedIpSubnetAddress = Reservation.ipAddressMask
            };

            var scopeInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(scopeInfo));

            Marshal.StructureToPtr(scopeInfo, scopeInfoPtr, true);

            return(GetOptionValue(Reservation.Server, scopeInfoPtr, OptionId, ClassName, VendorName));
        }
 internal static DhcpServerOptionValue GetScopeReservationDefaultOptionValue(DhcpServerScopeReservation Reservation, int OptionId)
 {
     return(GetScopeReservationOptionValue(Reservation, OptionId, null, null));
 }
        private static IEnumerable <DhcpServerOptionValue> EnumScopeReservationOptionValues(DhcpServerScopeReservation Reservation, string ClassName, string VendorName)
        {
            var scopeInfo = new DHCP_OPTION_SCOPE_INFO_RESERVED()
            {
                ScopeType               = DHCP_OPTION_SCOPE_TYPE.DhcpReservedOptions,
                ReservedIpAddress       = Reservation.ipAddress,
                ReservedIpSubnetAddress = Reservation.ipAddressMask
            };

            var scopeInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(scopeInfo));

            Marshal.StructureToPtr(scopeInfo, scopeInfoPtr, true);

            return(EnumOptionValues(Reservation.Server, scopeInfoPtr, ClassName, VendorName));
        }
 internal static IEnumerable <DhcpServerOptionValue> EnumScopeReservationUserOptionValues(DhcpServerScopeReservation Reservation, string ClassName)
 {
     return(EnumScopeReservationOptionValues(Reservation, ClassName, null));
 }
 internal static IEnumerable <DhcpServerOptionValue> EnumScopeReservationVendorOptionValues(DhcpServerScopeReservation Reservation, string VendorName)
 {
     return(EnumScopeReservationOptionValues(Reservation, null, VendorName));
 }
 internal static IEnumerable <DhcpServerOptionValue> EnumScopeReservationDefaultOptionValues(DhcpServerScopeReservation Reservation)
 {
     return(EnumScopeReservationOptionValues(Reservation, null, null));
 }
        internal static IEnumerable <DhcpServerOptionValue> GetAllScopeReservationOptionValues(DhcpServerScopeReservation Reservation)
        {
            var scopeInfo = new DHCP_OPTION_SCOPE_INFO_RESERVED()
            {
                ScopeType               = DHCP_OPTION_SCOPE_TYPE.DhcpReservedOptions,
                ReservedIpAddress       = Reservation.ipAddress,
                ReservedIpSubnetAddress = Reservation.ipAddressMask
            };

            var scopeInfoPtr = Marshal.AllocHGlobal(Marshal.SizeOf(scopeInfo));

            Marshal.StructureToPtr(scopeInfo, scopeInfoPtr, true);

            return(GetAllOptionValues(Reservation.Server, scopeInfoPtr));
        }
 internal static DhcpServerOptionValue GetScopeReservationUserOptionValue(DhcpServerScopeReservation Reservation, int OptionId, string ClassName)
 {
     return(GetScopeReservationOptionValue(Reservation, OptionId, ClassName, null));
 }
 internal static DhcpServerOptionValue GetScopeReservationVendorOptionValue(DhcpServerScopeReservation Reservation, int OptionId, string VendorName)
 {
     return(GetScopeReservationOptionValue(Reservation, OptionId, null, VendorName));
 }
 /// <summary>
 /// The Option Value associated with the Reservation Configuration
 /// </summary>
 internal DhcpServerOptionValue GetScopeReservationValue(DhcpServerScopeReservation reservation)
 => DhcpServerOptionValue.GetScopeReservationOptionValue(reservation, OptionId, ClassName, VendorName);
Exemple #12
0
 /// <summary>
 /// The Option Value associated with the Reservation Configuration
 /// </summary>
 public DhcpServerOptionValue GetScopeReservationValue(DhcpServerScopeReservation Reservation)
 {
     return(DhcpServerOptionValue.GetScopeReservationOptionValue(Reservation, OptionId, ClassName, VendorName));
 }
 /// <summary>
 /// Creates a DHCP scope reservation
 /// </summary>
 /// <param name="address">IP Address to reserve</param>
 /// <param name="hardwareAddress">Hardware address (MAC address) of client associated with this reservation</param>
 /// <param name="allowedClientTypes">Protocols this reservation supports</param>
 /// <returns>The scope reservation</returns>
 public IDhcpServerScopeReservation AddReservation(DhcpServerIpAddress address, DhcpServerHardwareAddress hardwareAddress, DhcpServerClientTypes allowedClientTypes)
 => DhcpServerScopeReservation.CreateReservation(Scope, address, hardwareAddress, allowedClientTypes);
 /// <summary>
 /// Creates a DHCP scope reservation
 /// </summary>
 /// <param name="address">IP Address to reserve</param>
 /// <param name="hardwareAddress">Hardware address (MAC address) of client associated with this reservation</param>
 /// <returns>The scope reservation</returns>
 public IDhcpServerScopeReservation AddReservation(DhcpServerIpAddress address, DhcpServerHardwareAddress hardwareAddress)
 => DhcpServerScopeReservation.CreateReservation(Scope, address, hardwareAddress);
 /// <summary>
 /// Enumerates a list of reservations associated with the DHCP Scope
 /// </summary>
 public IEnumerator <IDhcpServerScopeReservation> GetEnumerator()
 => DhcpServerScopeReservation.GetReservations(Scope).GetEnumerator();
Exemple #16
0
 internal DhcpServerScopeReservationOptionValueCollection(DhcpServerScopeReservation reservation)
 {
     Server      = reservation.Scope.Server;
     Scope       = reservation.Scope;
     Reservation = reservation;
 }