blob: 5615af1ae32bb5079455584d84308d694a5f6f73 [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 palc40e5ed2015-09-24 11:01:51 -070068 Ip4Address releaseIP(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -070069
70 /**
samanwita pal0bff4302015-09-15 13:37:00 -070071 * Returns a collection of all the MacAddress to IPAddress mapping assigned to the hosts.
72 *
73 * @return the collection of the mappings
74 */
75 Map<HostId, IpAssignment> listAssignedMapping();
76
77 /**
samanwita palf28207b2015-09-04 10:41:56 -070078 * Returns a collection of all the MacAddress to IPAddress mapping.
79 *
80 * @return the collection of the mappings
81 */
samanwita pal0bff4302015-09-15 13:37:00 -070082 Map<HostId, IpAssignment> listAllMapping();
samanwita palf28207b2015-09-04 10:41:56 -070083
84 /**
85 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
86 *
87 * @param macID macID of the client
88 * @param ipAddr IP Address requested for the client
89 * @return true if the mapping was successfully registered, false otherwise
90 */
91 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr);
92
93 /**
94 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
95 *
96 * @param macID macID of the client
97 * @return true if the mapping was successfully registered, false otherwise
98 */
99 boolean removeStaticIP(MacAddress macID);
100
101 /**
102 * Returns the list of all the available IPs with the server.
103 *
104 * @return list of available IPs
105 */
106 Iterable<Ip4Address> getAvailableIPs();
107
108}