blob: c4be7ed1b3bdffd1751b8090068c3c9c4d256484 [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
danielcd9deed2015-10-30 17:16:16 +090022import java.util.List;
samanwita palf28207b2015-09-04 10:41:56 -070023import java.util.Map;
24
danielcd9deed2015-10-30 17:16:16 +090025
samanwita palf28207b2015-09-04 10:41:56 -070026/**
27 * DHCPStore Interface.
28 */
Thomas Vachuskaa1da42e2015-09-09 00:45:22 -070029public interface DhcpStore {
samanwita palf28207b2015-09-04 10:41:56 -070030
31 /**
32 * Appends all the IPs in a given range to the free pool of IPs.
33 *
34 * @param startIP Start IP for the range
35 * @param endIP End IP for the range
36 */
37 void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP);
38
39 /**
40 * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
41 *
samanwita pal2a313402015-09-14 16:03:22 -070042 * @param hostId Host ID of the client requesting an IP
Ray Milkey9b36d812015-09-09 15:24:54 -070043 * @param requestedIP requested IP address
samanwita palf28207b2015-09-04 10:41:56 -070044 * @return IP address assigned to the Mac ID
45 */
samanwita pal2a313402015-09-14 16:03:22 -070046 Ip4Address suggestIP(HostId hostId, Ip4Address requestedIP);
samanwita palf28207b2015-09-04 10:41:56 -070047
danielcd9deed2015-10-30 17:16:16 +090048
samanwita palf28207b2015-09-04 10:41:56 -070049 /**
50 * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
51 *
samanwita pal2a313402015-09-14 16:03:22 -070052 * @param hostId Host Id of the client requesting an IP
samanwita palf28207b2015-09-04 10:41:56 -070053 * @param ipAddr IP Address being requested
54 * @param leaseTime Lease time offered by the server for this mapping
daniel877bb2f2015-11-12 21:33:05 +090055 * @param rangeNotEnforced true if rangeNotEnforced was set
56 * @param addressList subnetMask, DHCP/Router/DNS IP Addresses if rangeNotEnforced was set
samanwita palf28207b2015-09-04 10:41:56 -070057 * @return returns true if the assignment was successful, false otherwise
58 */
daniel877bb2f2015-11-12 21:33:05 +090059 boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime, boolean rangeNotEnforced,
danielcd9deed2015-10-30 17:16:16 +090060 List<Ip4Address> addressList);
61
samanwita palf28207b2015-09-04 10:41:56 -070062
63 /**
64 * Sets the default time for which suggested IP mappings are valid.
65 *
66 * @param timeInSeconds default time for IP mappings to be valid
67 */
68 void setDefaultTimeoutForPurge(int timeInSeconds);
69
70 /**
samanwita palf28207b2015-09-04 10:41:56 -070071 * Releases the IP assigned to a Mac ID into the free pool.
72 *
samanwita pal2a313402015-09-14 16:03:22 -070073 * @param hostId the host ID for which the mapping needs to be changed
Brian O'Connor52515622015-10-09 17:03:44 -070074 * @return released ip
samanwita palf28207b2015-09-04 10:41:56 -070075 */
samanwita palc40e5ed2015-09-24 11:01:51 -070076 Ip4Address releaseIP(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -070077
78 /**
samanwita pal0bff4302015-09-15 13:37:00 -070079 * Returns a collection of all the MacAddress to IPAddress mapping assigned to the hosts.
80 *
81 * @return the collection of the mappings
82 */
83 Map<HostId, IpAssignment> listAssignedMapping();
84
85 /**
samanwita palf28207b2015-09-04 10:41:56 -070086 * Returns a collection of all the MacAddress to IPAddress mapping.
87 *
88 * @return the collection of the mappings
89 */
samanwita pal0bff4302015-09-15 13:37:00 -070090 Map<HostId, IpAssignment> listAllMapping();
samanwita palf28207b2015-09-04 10:41:56 -070091
92 /**
93 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
94 *
95 * @param macID macID of the client
96 * @param ipAddr IP Address requested for the client
daniel877bb2f2015-11-12 21:33:05 +090097 * @param rangeNotEnforced true if rangeNotEnforced was set
98 * @param addressList subnetMask, DHCP/Router/DNS IP Addresses rangeNotEnforced was set
samanwita palf28207b2015-09-04 10:41:56 -070099 * @return true if the mapping was successfully registered, false otherwise
100 */
daniel877bb2f2015-11-12 21:33:05 +0900101 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr, boolean rangeNotEnforced, List<Ip4Address> addressList);
samanwita palf28207b2015-09-04 10:41:56 -0700102
103 /**
104 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
105 *
106 * @param macID macID of the client
107 * @return true if the mapping was successfully registered, false otherwise
108 */
109 boolean removeStaticIP(MacAddress macID);
110
111 /**
112 * Returns the list of all the available IPs with the server.
113 *
114 * @return list of available IPs
115 */
116 Iterable<Ip4Address> getAvailableIPs();
117
danielcd9deed2015-10-30 17:16:16 +0900118 /**
Jian Lidfba7392016-01-22 16:46:58 -0800119 * Returns IpAssignment from map.
danielcd9deed2015-10-30 17:16:16 +0900120 *
Jian Lidfba7392016-01-22 16:46:58 -0800121 * @param hostId host identification
122 * @return IpAssignment
danielcd9deed2015-10-30 17:16:16 +0900123 */
124 IpAssignment getIpAssignmentFromAllocationMap(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -0700125}