blob: bd2e16b313521005f03623abe1c1df283cf380a0 [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
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
danielcd9deed2015-10-30 17:16:16 +090055 * @param fromOpenStack true if the request is from Openstack
56 * @param addressList subnetMask, DHCP IP Address, Router IP Address, Domain Server IP Address if the request
57 * from OpenStack
samanwita palf28207b2015-09-04 10:41:56 -070058 * @return returns true if the assignment was successful, false otherwise
59 */
danielcd9deed2015-10-30 17:16:16 +090060 boolean assignIP(HostId hostId, Ip4Address ipAddr, int leaseTime, boolean fromOpenStack,
61 List<Ip4Address> addressList);
62
samanwita palf28207b2015-09-04 10:41:56 -070063
64 /**
65 * Sets the default time for which suggested IP mappings are valid.
66 *
67 * @param timeInSeconds default time for IP mappings to be valid
68 */
69 void setDefaultTimeoutForPurge(int timeInSeconds);
70
71 /**
samanwita palf28207b2015-09-04 10:41:56 -070072 * Releases the IP assigned to a Mac ID into the free pool.
73 *
samanwita pal2a313402015-09-14 16:03:22 -070074 * @param hostId the host ID for which the mapping needs to be changed
Brian O'Connor52515622015-10-09 17:03:44 -070075 * @return released ip
samanwita palf28207b2015-09-04 10:41:56 -070076 */
samanwita palc40e5ed2015-09-24 11:01:51 -070077 Ip4Address releaseIP(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -070078
79 /**
samanwita pal0bff4302015-09-15 13:37:00 -070080 * Returns a collection of all the MacAddress to IPAddress mapping assigned to the hosts.
81 *
82 * @return the collection of the mappings
83 */
84 Map<HostId, IpAssignment> listAssignedMapping();
85
86 /**
samanwita palf28207b2015-09-04 10:41:56 -070087 * Returns a collection of all the MacAddress to IPAddress mapping.
88 *
89 * @return the collection of the mappings
90 */
samanwita pal0bff4302015-09-15 13:37:00 -070091 Map<HostId, IpAssignment> listAllMapping();
samanwita palf28207b2015-09-04 10:41:56 -070092
93 /**
94 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
95 *
96 * @param macID macID of the client
97 * @param ipAddr IP Address requested for the client
danielcd9deed2015-10-30 17:16:16 +090098 * @param fromOpenStack true if the request is from Openstack
99 * @param addressList subnetMask, DHCP/Router/Domain Server IP Address if the request from OpenStack
samanwita palf28207b2015-09-04 10:41:56 -0700100 * @return true if the mapping was successfully registered, false otherwise
101 */
danielcd9deed2015-10-30 17:16:16 +0900102 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr, boolean fromOpenStack, List<Ip4Address> addressList);
samanwita palf28207b2015-09-04 10:41:56 -0700103
104 /**
105 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
106 *
107 * @param macID macID of the client
108 * @return true if the mapping was successfully registered, false otherwise
109 */
110 boolean removeStaticIP(MacAddress macID);
111
112 /**
113 * Returns the list of all the available IPs with the server.
114 *
115 * @return list of available IPs
116 */
117 Iterable<Ip4Address> getAvailableIPs();
118
danielcd9deed2015-10-30 17:16:16 +0900119 /**
120 *
121 *
122 * @param hostId
123 * @return
124 */
125 IpAssignment getIpAssignmentFromAllocationMap(HostId hostId);
samanwita palf28207b2015-09-04 10:41:56 -0700126}