blob: 0b95e5a5a449b20dd0e73ee55adbc9de53a1419c [file] [log] [blame]
samanwita palf28207b2015-09-04 10:41:56 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present 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
danielcd9deed2015-10-30 17:16:16 +090024
samanwita palf28207b2015-09-04 10:41:56 -070025/**
26 * DHCPStore Interface.
27 */
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070028public interface DhcpStore {
samanwita palf28207b2015-09-04 10:41:56 -070029
30 /**
31 * Appends all the IPs in a given range to the free pool of IPs.
32 *
33 * @param startIP Start IP for the range
34 * @param endIP End IP for the range
35 */
36 void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP);
37
38 /**
39 * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
40 *
samanwita pal2a313402015-09-14 16:03:22 -070041 * @param hostId Host ID of the client requesting an IP
Ray Milkey9b36d812015-09-09 15:24:54 -070042 * @param requestedIP requested IP address
Hyunsun Moon04b1fe92016-05-18 21:28:06 -070043 * @return IP address assigned to the Mac address; null if no available IP
samanwita palf28207b2015-09-04 10:41:56 -070044 */
samanwita pal2a313402015-09-14 16:03:22 -070045 Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP);
samanwita palf28207b2015-09-04 10:41:56 -070046
danielcd9deed2015-10-30 17:16:16 +090047
samanwita palf28207b2015-09-04 10:41:56 -070048 /**
49 * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
50 *
samanwita pal2a313402015-09-14 16:03:22 -070051 * @param hostId Host Id of the client requesting an IP
Hyunsun Moon04b1fe92016-05-18 21:28:06 -070052 * @param ipAssignment ip assignment
samanwita palf28207b2015-09-04 10:41:56 -070053 * @return returns true if the assignment was successful, false otherwise
54 */
Hyunsun Moon04b1fe92016-05-18 21:28:06 -070055 boolean assignIP(HostId hostId, IpAssignment ipAssignment);
danielcd9deed2015-10-30 17:16:16 +090056
samanwita palf28207b2015-09-04 10:41:56 -070057
58 /**
59 * Sets the default time for which suggested IP mappings are valid.
60 *
61 * @param timeInSeconds default time for IP mappings to be valid
62 */
63 void setDefaultTimeoutForPurge(int timeInSeconds);
64
65 /**
samanwita palf28207b2015-09-04 10:41:56 -070066 * Releases the IP assigned to a Mac ID into the free pool.
67 *
samanwita pal2a313402015-09-14 16:03:22 -070068 * @param hostId the host ID for which the mapping needs to be changed
Brian O'Connor52515622015-10-09 17:03:44 -070069 * @return released ip
samanwita palf28207b2015-09-04 10:41:56 -070070 */
samanwita palc40e5ed2015-09-24 11:01:51 -070071 Ip4Address releaseIP(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -070072
73 /**
samanwita pal0bff4302015-09-15 13:37:00 -070074 * Returns a collection of all the MacAddress to IPAddress mapping assigned to the hosts.
75 *
76 * @return the collection of the mappings
77 */
78 Map<HostId, IpAssignment> listAssignedMapping();
79
80 /**
samanwita palf28207b2015-09-04 10:41:56 -070081 * Returns a collection of all the MacAddress to IPAddress mapping.
82 *
83 * @return the collection of the mappings
84 */
samanwita pal0bff4302015-09-15 13:37:00 -070085 Map<HostId, IpAssignment> listAllMapping();
samanwita palf28207b2015-09-04 10:41:56 -070086
87 /**
88 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
89 *
Hyunsun Moon04b1fe92016-05-18 21:28:06 -070090 * @param macAddress mac address of the client
91 * @param ipAssignment ip address and dhcp options requested for the client
samanwita palf28207b2015-09-04 10:41:56 -070092 * @return true if the mapping was successfully registered, false otherwise
93 */
Hyunsun Moon04b1fe92016-05-18 21:28:06 -070094 boolean assignStaticIP(MacAddress macAddress, IpAssignment ipAssignment);
samanwita palf28207b2015-09-04 10:41:56 -070095
96 /**
97 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
98 *
Hyunsun Moon04b1fe92016-05-18 21:28:06 -070099 * @param macAddress mac address of the client
samanwita palf28207b2015-09-04 10:41:56 -0700100 * @return true if the mapping was successfully registered, false otherwise
101 */
Hyunsun Moon04b1fe92016-05-18 21:28:06 -0700102 boolean removeStaticIP(MacAddress macAddress);
samanwita palf28207b2015-09-04 10:41:56 -0700103
104 /**
105 * Returns the list of all the available IPs with the server.
106 *
107 * @return list of available IPs
108 */
109 Iterable<Ip4Address> getAvailableIPs();
110
danielcd9deed2015-10-30 17:16:16 +0900111 /**
Jian Lidfba7392016-01-22 16:46:58 -0800112 * Returns IpAssignment from map.
danielcd9deed2015-10-30 17:16:16 +0900113 *
Jian Lidfba7392016-01-22 16:46:58 -0800114 * @param hostId host identification
115 * @return IpAssignment
danielcd9deed2015-10-30 17:16:16 +0900116 */
117 IpAssignment getIpAssignmentFromAllocationMap(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -0700118}