blob: 0ecd1cb2e1b2be2af4bf05abf0d449a5399acb93 [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 /**
samanwita pal775f6192015-07-28 10:10:13 -070029 * Appends all the IPs in a given range to the free pool of IPs.
30 *
31 * @param startIP Start IP for the range
32 * @param endIP End IP for the range
33 */
34 void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP);
35
36 /**
samanwita pal18696f62015-07-17 13:15:43 -070037 * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
38 *
39 * @param macID Mac ID of the client requesting an IP
40 * @return IP address assigned to the Mac ID
41 */
samanwita palf09c09e2015-07-22 16:06:42 -070042 Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP);
samanwita pal18696f62015-07-17 13:15:43 -070043
44 /**
45 * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
46 *
47 * @param macID Mac Id of the client requesting an IP
48 * @param ipAddr IP Address being requested
49 * @param leaseTime Lease time offered by the server for this mapping
50 * @return returns true if the assignment was successful, false otherwise
51 */
samanwita palf66ed8a2015-07-21 15:45:33 -070052 boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime);
samanwita pal18696f62015-07-17 13:15:43 -070053
54 /**
55 * Sets the default time for which suggested IP mappings are valid.
56 *
57 * @param timeInSeconds default time for IP mappings to be valid
58 */
samanwita palf66ed8a2015-07-21 15:45:33 -070059 void setDefaultTimeoutForPurge(int timeInSeconds);
samanwita pal18696f62015-07-17 13:15:43 -070060
61 /**
samanwita pal775f6192015-07-28 10:10:13 -070062 * Sets the delay after which the dhcp server will purge expired entries.
63 *
64 * @param timeInSeconds default time
65 */
66 void setTimerDelay(int timeInSeconds);
67
68 /**
samanwita pal18696f62015-07-17 13:15:43 -070069 * Releases the IP assigned to a Mac ID into the free pool.
70 *
71 * @param macID the macID for which the mapping needs to be changed
72 */
73 void releaseIP(MacAddress macID);
74
samanwita palf66ed8a2015-07-21 15:45:33 -070075 /**
76 * Returns a collection of all the MacAddress to IPAddress mapping.
77 *
78 * @return the collection of the mappings
79 */
samanwita pal67eb43a2015-09-03 15:49:51 -070080 Map<MacAddress, IPAssignment> listMapping();
samanwita palf66ed8a2015-07-21 15:45:33 -070081
82 /**
83 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
84 *
85 * @param macID macID of the client
86 * @param ipAddr IP Address requested for the client
87 * @return true if the mapping was successfully registered, false otherwise
88 */
89 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr);
90
91 /**
92 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
93 *
94 * @param macID macID of the client
95 * @return true if the mapping was successfully registered, false otherwise
96 */
97 boolean removeStaticIP(MacAddress macID);
98
99 /**
100 * Returns the list of all the available IPs with the server.
101 *
102 * @return list of available IPs
103 */
104 Iterable<Ip4Address> getAvailableIPs();
105
samanwita pal18696f62015-07-17 13:15:43 -0700106}