001 /*
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements. See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership. The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License. You may obtain a copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing,
013 * software distributed under the License is distributed on an
014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015 * KIND, either express or implied. See the License for the
016 * specific language governing permissions and limitations
017 * under the License.
018 *
019 */
020 package org.apache.directory.server.dhcp.store;
021
022
023 import java.net.InetAddress;
024
025 import org.apache.directory.server.dhcp.DhcpException;
026 import org.apache.directory.server.dhcp.messages.HardwareAddress;
027 import org.apache.directory.server.dhcp.options.OptionsField;
028 import org.apache.directory.server.dhcp.service.Lease;
029
030
031 /**
032 *
033 * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
034 * @version $Rev: 545042 $, $Date: 2007-06-06 22:32:01 -0500 (Mi, 06 Jun 2007) $
035 */
036 public interface DhcpStore
037 {
038 /**
039 * Find a lease to offer in response to a DHCPDISCOVER request.
040 * <p>
041 * The lease to offer should be determined by an algorithme like the
042 * following:
043 * <ul>
044 * <li> Try to find an existing lease for the given hardware address. The
045 * lease may be either ACTIVE or EXPIRED.
046 * <li>Try to find a lease which has been explicitely dedicated to the
047 * given hardware address.
048 * <li>Try to get a lease from a pool of leases. If the client requested a
049 * specific address, the request should be honored, if possible. Otherwise
050 * the selection of an address should be based on the selection base address
051 * and may be refined using the supplied options.
052 * </ul>
053 * <p>
054 * If the requestedLeaseTime is >= 0, the validity duration of the returned
055 * lease must be updated, so that the lease is valid for at least the
056 * specified time. The duration may, however, be constrained by a configured
057 * maximum lease time.
058 *
059 * @param hardwareAddress
060 * hardwareAddress the hardware address of the client requesting
061 * the lease.
062 * @param requestedAddress
063 * the address requested by the client or <code>null</code> if
064 * the client did not request a specific address.
065 * @param selectionBase
066 * the address on which to base the selection of a lease from a
067 * pool, i.e. either the address of the interface on which the
068 * request was received or the address of a DHCP relay agent.
069 * @param requestedLeaseTime
070 * the lease time in milliseconds as requested by the client, or
071 * -1 if the client did not request a specific lease time.
072 * @param options
073 * the supplied DHCP options. Lease selection may be refined by
074 * using those options
075 * @return a lease or <code>null</code> if no matching lease was found.
076 * @throws DhcpException
077 */
078 Lease getLeaseOffer( HardwareAddress hardwareAddress, InetAddress requestedAddress, InetAddress selectionBase,
079 long requestedLeaseTime, OptionsField options ) throws DhcpException;
080
081
082 /**
083 * Retrieve an existing lease from the dhcp store.
084 *
085 * @param hardwareAddress
086 * @param requestedAddress
087 * @param selectionBase
088 * @param requestedLeaseTime
089 * @param options
090 * @return Lease
091 * @throws DhcpException
092 */
093 Lease getExistingLease( HardwareAddress hardwareAddress, InetAddress requestedAddress, InetAddress selectionBase,
094 long requestedLeaseTime, OptionsField options ) throws DhcpException;
095
096
097 /**
098 * Release the specified lease.
099 *
100 * @param lease
101 */
102 void releaseLease( Lease lease );
103 }