blob: 1637cf7dbbb6d6dff1de923174f610961f3f8678 [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;
samanwita pal2a313402015-09-14 16:03:22 -070020import org.onosproject.net.HostId;
samanwita palf28207b2015-09-04 10:41:56 -070021
22import java.util.Map;
23
24/**
25 * DHCPStore Interface.
26 */
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070027public interface DhcpStore {
samanwita palf28207b2015-09-04 10:41:56 -070028
29 /**
30 * Appends all the IPs in a given range to the free pool of IPs.
31 *
32 * @param startIP Start IP for the range
33 * @param endIP End IP for the range
34 */
35 void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP);
36
37 /**
38 * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
39 *
samanwita pal2a313402015-09-14 16:03:22 -070040 * @param hostId Host ID of the client requesting an IP
Ray Milkey9b36d812015-09-09 15:24:54 -070041 * @param requestedIP requested IP address
samanwita palf28207b2015-09-04 10:41:56 -070042 * @return IP address assigned to the Mac ID
43 */
samanwita pal2a313402015-09-14 16:03:22 -070044 Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP);
samanwita palf28207b2015-09-04 10:41:56 -070045
46 /**
47 * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
48 *
samanwita pal2a313402015-09-14 16:03:22 -070049 * @param hostId Host Id of the client requesting an IP
samanwita palf28207b2015-09-04 10:41:56 -070050 * @param ipAddr IP Address being requested
51 * @param leaseTime Lease time offered by the server for this mapping
52 * @return returns true if the assignment was successful, false otherwise
53 */
samanwita pal2a313402015-09-14 16:03:22 -070054 boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime);
samanwita palf28207b2015-09-04 10:41:56 -070055
56 /**
57 * Sets the default time for which suggested IP mappings are valid.
58 *
59 * @param timeInSeconds default time for IP mappings to be valid
60 */
61 void setDefaultTimeoutForPurge(int timeInSeconds);
62
63 /**
samanwita palf28207b2015-09-04 10:41:56 -070064 * Releases the IP assigned to a Mac ID into the free pool.
65 *
samanwita pal2a313402015-09-14 16:03:22 -070066 * @param hostId the host ID for which the mapping needs to be changed
samanwita palf28207b2015-09-04 10:41:56 -070067 */
samanwita pal2a313402015-09-14 16:03:22 -070068 void releaseIP(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -070069
70 /**
71 * Returns a collection of all the MacAddress to IPAddress mapping.
72 *
73 * @return the collection of the mappings
74 */
samanwita pal2a313402015-09-14 16:03:22 -070075 Map<HostId, IpAssignment> listMapping();
samanwita palf28207b2015-09-04 10:41:56 -070076
77 /**
78 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
79 *
80 * @param macID macID of the client
81 * @param ipAddr IP Address requested for the client
82 * @return true if the mapping was successfully registered, false otherwise
83 */
84 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr);
85
86 /**
87 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
88 *
89 * @param macID macID of the client
90 * @return true if the mapping was successfully registered, false otherwise
91 */
92 boolean removeStaticIP(MacAddress macID);
93
94 /**
95 * Returns the list of all the available IPs with the server.
96 *
97 * @return list of available IPs
98 */
99 Iterable<Ip4Address> getAvailableIPs();
100
101}