blob: b6c60a2aa7a2bda05aff4c81d0593561d7cb981a [file] [log] [blame]
samanwita pal18696f62015-07-17 13:15:43 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.dhcpserver;
17
18import org.onlab.packet.Ip4Address;
19import org.onlab.packet.MacAddress;
20
samanwita palf66ed8a2015-07-21 15:45:33 -070021import java.util.Map;
22
samanwita pal18696f62015-07-17 13:15:43 -070023/**
24 * DHCPStore Interface.
25 */
26public interface DHCPStore {
27
28 /**
29 * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
30 *
31 * @param macID Mac ID of the client requesting an IP
32 * @return IP address assigned to the Mac ID
33 */
34 Ip4Address suggestIP(MacAddress macID);
35
36 /**
37 * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
38 *
39 * @param macID Mac Id of the client requesting an IP
40 * @param ipAddr IP Address being requested
41 * @param leaseTime Lease time offered by the server for this mapping
42 * @return returns true if the assignment was successful, false otherwise
43 */
samanwita palf66ed8a2015-07-21 15:45:33 -070044 boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime);
samanwita pal18696f62015-07-17 13:15:43 -070045
46 /**
47 * Sets the default time for which suggested IP mappings are valid.
48 *
49 * @param timeInSeconds default time for IP mappings to be valid
50 */
samanwita palf66ed8a2015-07-21 15:45:33 -070051 void setDefaultTimeoutForPurge(int timeInSeconds);
samanwita pal18696f62015-07-17 13:15:43 -070052
53 /**
54 * Releases the IP assigned to a Mac ID into the free pool.
55 *
56 * @param macID the macID for which the mapping needs to be changed
57 */
58 void releaseIP(MacAddress macID);
59
samanwita palf66ed8a2015-07-21 15:45:33 -070060 /**
61 * Returns a collection of all the MacAddress to IPAddress mapping.
62 *
63 * @return the collection of the mappings
64 */
65 Map<MacAddress, Ip4Address> listMapping();
66
67 /**
68 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
69 *
70 * @param macID macID of the client
71 * @param ipAddr IP Address requested for the client
72 * @return true if the mapping was successfully registered, false otherwise
73 */
74 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr);
75
76 /**
77 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
78 *
79 * @param macID macID of the client
80 * @return true if the mapping was successfully registered, false otherwise
81 */
82 boolean removeStaticIP(MacAddress macID);
83
84 /**
85 * Returns the list of all the available IPs with the server.
86 *
87 * @return list of available IPs
88 */
89 Iterable<Ip4Address> getAvailableIPs();
90
samanwita pal18696f62015-07-17 13:15:43 -070091}