blob: de864db120ae1d253914682bccbd11df52f9a6d9 [file] [log] [blame]
samanwita palf28207b2015-09-04 10:41:56 -07001/*
2 * Copyright 2014 Open Networking Laboratory
3 *
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;
20
21import java.util.Map;
22
23/**
24 * DHCPStore Interface.
25 */
26public interface DHCPStore {
27
28 /**
29 * Appends all the IPs in a given range to the free pool of IPs.
30 *
31 * @param startIP Start IP for the range
32 * @param endIP End IP for the range
33 */
34 void populateIPPoolfromRange(Ip4Address startIP, Ip4Address endIP);
35
36 /**
37 * Returns an IP Address for a Mac ID, in response to a DHCP DISCOVER message.
38 *
39 * @param macID Mac ID of the client requesting an IP
40 * @return IP address assigned to the Mac ID
41 */
42 Ip4Address suggestIP(MacAddress macID, Ip4Address requestedIP);
43
44 /**
45 * Assigns the requested IP to the Mac ID, in response to a DHCP REQUEST message.
46 *
47 * @param macID Mac Id of the client requesting an IP
48 * @param ipAddr IP Address being requested
49 * @param leaseTime Lease time offered by the server for this mapping
50 * @return returns true if the assignment was successful, false otherwise
51 */
52 boolean assignIP(MacAddress macID, Ip4Address ipAddr, int leaseTime);
53
54 /**
55 * Sets the default time for which suggested IP mappings are valid.
56 *
57 * @param timeInSeconds default time for IP mappings to be valid
58 */
59 void setDefaultTimeoutForPurge(int timeInSeconds);
60
61 /**
62 * Sets the delay after which the dhcp server will purge expired entries.
63 *
64 * @param timeInSeconds default time
65 */
66 void setTimerDelay(int timeInSeconds);
67
68 /**
69 * Releases the IP assigned to a Mac ID into the free pool.
70 *
71 * @param macID the macID for which the mapping needs to be changed
72 */
73 void releaseIP(MacAddress macID);
74
75 /**
76 * Returns a collection of all the MacAddress to IPAddress mapping.
77 *
78 * @return the collection of the mappings
79 */
80 Map<MacAddress, Ip4Address> listMapping();
81
82 /**
83 * Assigns the requested IP to the MAC ID (if available) for an indefinite period of time.
84 *
85 * @param macID macID of the client
86 * @param ipAddr IP Address requested for the client
87 * @return true if the mapping was successfully registered, false otherwise
88 */
89 boolean assignStaticIP(MacAddress macID, Ip4Address ipAddr);
90
91 /**
92 * Removes a static IP mapping associated with the given MAC ID from the DHCP Server.
93 *
94 * @param macID macID of the client
95 * @return true if the mapping was successfully registered, false otherwise
96 */
97 boolean removeStaticIP(MacAddress macID);
98
99 /**
100 * Returns the list of all the available IPs with the server.
101 *
102 * @return list of available IPs
103 */
104 Iterable<Ip4Address> getAvailableIPs();
105
106}