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 */ 35 public interface DhcpStore 36 { 37 /** 38 * Find a lease to offer in response to a DHCPDISCOVER request. 39 * <p> 40 * The lease to offer should be determined by an algorithme like the 41 * following: 42 * <ul> 43 * <li> Try to find an existing lease for the given hardware address. The 44 * lease may be either ACTIVE or EXPIRED. 45 * <li>Try to find a lease which has been explicitely dedicated to the 46 * given hardware address. 47 * <li>Try to get a lease from a pool of leases. If the client requested a 48 * specific address, the request should be honored, if possible. Otherwise 49 * the selection of an address should be based on the selection base address 50 * and may be refined using the supplied options. 51 * </ul> 52 * <p> 53 * If the requestedLeaseTime is >= 0, the validity duration of the returned 54 * lease must be updated, so that the lease is valid for at least the 55 * specified time. The duration may, however, be constrained by a configured 56 * maximum lease time. 57 * 58 * @param hardwareAddress 59 * hardwareAddress the hardware address of the client requesting 60 * the lease. 61 * @param requestedAddress 62 * the address requested by the client or <code>null</code> if 63 * the client did not request a specific address. 64 * @param selectionBase 65 * the address on which to base the selection of a lease from a 66 * pool, i.e. either the address of the interface on which the 67 * request was received or the address of a DHCP relay agent. 68 * @param requestedLeaseTime 69 * the lease time in milliseconds as requested by the client, or 70 * -1 if the client did not request a specific lease time. 71 * @param options 72 * the supplied DHCP options. Lease selection may be refined by 73 * using those options 74 * @return a lease or <code>null</code> if no matching lease was found. 75 * @throws DhcpException 76 */ 77 Lease getLeaseOffer( HardwareAddress hardwareAddress, InetAddress requestedAddress, InetAddress selectionBase, 78 long requestedLeaseTime, OptionsField options ) throws DhcpException; 79 80 81 /** 82 * Retrieve an existing lease from the dhcp store. 83 * 84 * @param hardwareAddress 85 * @param requestedAddress 86 * @param selectionBase 87 * @param requestedLeaseTime 88 * @param options 89 * @return Lease 90 * @throws DhcpException 91 */ 92 Lease getExistingLease( HardwareAddress hardwareAddress, InetAddress requestedAddress, InetAddress selectionBase, 93 long requestedLeaseTime, OptionsField options ) throws DhcpException; 94 95 96 /** 97 * Release the specified lease. 98 * 99 * @param lease 100 */ 101 void releaseLease( Lease lease ); 102 }