View Javadoc

1   /*
2    *  Licensed to the Apache Software Foundation (ASF) under one
3    *  or more contributor license agreements.  See the NOTICE file
4    *  distributed with this work for additional information
5    *  regarding copyright ownership.  The ASF licenses this file
6    *  to you under the Apache License, Version 2.0 (the
7    *  "License"); you may not use this file except in compliance
8    *  with the License.  You may obtain a copy of the License at
9    *  
10   *    http://www.apache.org/licenses/LICENSE-2.0
11   *  
12   *  Unless required by applicable law or agreed to in writing,
13   *  software distributed under the License is distributed on an
14   *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   *  KIND, either express or implied.  See the License for the
16   *  specific language governing permissions and limitations
17   *  under the License. 
18   *  
19   */
20  package org.apache.directory.server.dhcp.store;
21  
22  
23  import java.net.InetAddress;
24  
25  import org.apache.directory.server.dhcp.DhcpException;
26  import org.apache.directory.server.dhcp.messages.HardwareAddress;
27  import org.apache.directory.server.dhcp.options.OptionsField;
28  import org.apache.directory.server.dhcp.service.Lease;
29  
30  
31  /**
32   * 
33   * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
34   * @version $Rev: 545042 $, $Date: 2007-06-06 22:32:01 -0500 (Mi, 06 Jun 2007) $
35   */
36  public interface DhcpStore
37  {
38      /**
39       * Find a lease to offer in response to a DHCPDISCOVER request.
40       * <p>
41       * The lease to offer should be determined by an algorithme like the
42       * following:
43       * <ul>
44       * <li> Try to find an existing lease for the given hardware address. The
45       * lease may be either ACTIVE or EXPIRED.
46       * <li>Try to find a lease which has been explicitely dedicated to the
47       * given hardware address.
48       * <li>Try to get a lease from a pool of leases. If the client requested a
49       * specific address, the request should be honored, if possible. Otherwise
50       * the selection of an address should be based on the selection base address
51       * and may be refined using the supplied options.
52       * </ul>
53       * <p>
54       * If the requestedLeaseTime is >= 0, the validity duration of the returned
55       * lease must be updated, so that the lease is valid for at least the
56       * specified time. The duration may, however, be constrained by a configured
57       * maximum lease time.
58       * 
59       * @param hardwareAddress
60       *            hardwareAddress the hardware address of the client requesting
61       *            the lease.
62       * @param requestedAddress
63       *            the address requested by the client or <code>null</code> if
64       *            the client did not request a specific address.
65       * @param selectionBase
66       *            the address on which to base the selection of a lease from a
67       *            pool, i.e. either the address of the interface on which the
68       *            request was received or the address of a DHCP relay agent.
69       * @param requestedLeaseTime
70       *            the lease time in milliseconds as requested by the client, or
71       *            -1 if the client did not request a specific lease time.
72       * @param options
73       *            the supplied DHCP options. Lease selection may be refined by
74       *            using those options
75       * @return a lease or <code>null</code> if no matching lease was found.
76       * @throws DhcpException
77       */
78      Lease getLeaseOffer( HardwareAddress hardwareAddress, InetAddress requestedAddress, InetAddress selectionBase,
79          long requestedLeaseTime, OptionsField options ) throws DhcpException;
80  
81  
82      /**
83       * Retrieve an existing lease from the dhcp store.
84       * 
85       * @param hardwareAddress
86       * @param requestedAddress
87       * @param selectionBase
88       * @param requestedLeaseTime
89       * @param options
90       * @return Lease
91       * @throws DhcpException 
92       */
93      Lease getExistingLease( HardwareAddress hardwareAddress, InetAddress requestedAddress, InetAddress selectionBase,
94          long requestedLeaseTime, OptionsField options ) throws DhcpException;
95  
96  
97      /**
98       * Release the specified lease. 
99       * 
100      * @param lease
101      */
102     void releaseLease( Lease lease );
103 }