blob: 4e2d67d645f97f6353c52208c442a034665ac169 [file] [log] [blame]
samanwita palf28207b2015-09-04 10:41:56 -07001/*
Thomas Vachuska54dc3522015-09-09 00:11:45 -07002 * Copyright 2015 Open Networking Laboratory
samanwita palf28207b2015-09-04 10:41:56 -07003 *
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.dhcp;
17
18import org.onlab.packet.Ip4Address;
19import org.onlab.packet.MacAddress;
20
21import java.util.Map;
22
23/**
24 * DHCPStore Interface.
25 */
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070026public interface DhcpStore {
samanwita palf28207b2015-09-04 10:41:56 -070027
28 /**
29 * 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 /**
37 * 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
Ray Milkey9b36d812015-09-09 15:24:54 -070040 * @param requestedIP requested IP address
samanwita palf28207b2015-09-04 10:41:56 -070041 * @return IP address assigned to the Mac ID
42 */
43 Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP);
44
45 /**
46 * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
47 *
48 * @param macID Mac Id of the client requesting an IP
49 * @param ipAddr IP Address being requested
50 * @param leaseTime Lease time offered by the server for this mapping
51 * @return returns true if the assignment was successful, false otherwise
52 */
53 boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime);
54
55 /**
56 * Sets the default time for which suggested IP mappings are valid.
57 *
58 * @param timeInSeconds default time for IP mappings to be valid
59 */
60 void setDefaultTimeoutForPurge(int timeInSeconds);
61
62 /**
63 * Sets the delay after which the dhcp server will purge expired entries.
64 *
65 * @param timeInSeconds default time
66 */
67 void setTimerDelay(int timeInSeconds);
68
69 /**
70 * Releases the IP assigned to a Mac ID into the free pool.
71 *
72 * @param macID the macID for which the mapping needs to be changed
73 */
74 void releaseIP(MacAddress macID);
75
76 /**
77 * Returns a collection of all the MacAddress to IPAddress mapping.
78 *
79 * @return the collection of the mappings
80 */
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070081 Map<MacAddress, IpAssignment> listMapping();
samanwita palf28207b2015-09-04 10:41:56 -070082
83 /**
84 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
85 *
86 * @param macID macID of the client
87 * @param ipAddr IP Address requested for the client
88 * @return true if the mapping was successfully registered, false otherwise
89 */
90 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr);
91
92 /**
93 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
94 *
95 * @param macID macID of the client
96 * @return true if the mapping was successfully registered, false otherwise
97 */
98 boolean removeStaticIP(MacAddress macID);
99
100 /**
101 * Returns the list of all the available IPs with the server.
102 *
103 * @return list of available IPs
104 */
105 Iterable<Ip4Address> getAvailableIPs();
106
107}